Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 7779599

Browse files
authored
Rename except_ref type to exnref (#84)
In #79 we agreed to change `except_ref` to `exnref`.
1 parent c2d35d3 commit 7779599

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

proposals/Exceptions.md

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ of events.
1212

1313
This proposal requires the [reference types
1414
proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md)
15-
as a prerequisite, since the [`except_ref`](#the-exception-reference-data-type)
16-
type should be represented as a subtype of `anyref`.
15+
as a prerequisite, since the [`exnref`](#the-exception-reference-data-type) type
16+
should be represented as a subtype of `anyref`.
1717

1818
---
1919

@@ -140,7 +140,7 @@ Exception indices are used by:
140140

141141
### The exception reference data type
142142

143-
Data types are extended to have a new `except_ref` type, that refers to an
143+
Data types are extended to have a new `exnref` type, that refers to an
144144
exception. The representation of an exception is left to the implementation.
145145

146146
### Try and catch blocks
@@ -200,7 +200,7 @@ are not in the body of the try block.
200200

201201
Once a catching try block is found for the thrown exception, the operand stack
202202
is popped back to the size the operand stack had when the try block was entered,
203-
and then an except_ref referring to the caught exception is pushed back onto the
203+
and then an `exnref` referring to the caught exception is pushed back onto the
204204
operand stack.
205205

206206
If control is transferred to the body of a catch block, and the last instruction
@@ -214,10 +214,10 @@ Note that a caught exception can be rethrown using the `rethrow` instruction.
214214

215215
### Rethrowing an exception
216216

217-
The `rethrow` instruction takes the exception associated with the `except_ref`
218-
on top of the stack, and rethrows the exception. A rethrow has the same effect
219-
as a throw, other than an exception is not created. Rather, the referenced
220-
exception on top of the stack is popped and then thrown.
217+
The `rethrow` instruction takes the exception associated with the `exnref` on
218+
top of the stack, and rethrows the exception. A rethrow has the same effect as a
219+
throw, other than an exception is not created. Rather, the referenced exception
220+
on top of the stack is popped and then thrown.
221221

222222
### Exception data extraction
223223

@@ -228,23 +228,22 @@ tag of an exception on top of the stack, in the form of:
228228
br_on_exn label except_index
229229
```
230230

231-
The `br_on_exn` instruction checks the exception tag of an `except_ref` on top
232-
of the stack if it matches the given exception index. If it does, it branches
233-
out to the label referenced by the instruction (In the binary form, the label
234-
will be converted to a relative depth immediate, like other branch
235-
instructions), and while doing that, pops the `except_ref` value from the stack
236-
and instead pushes the exception's argument values on top of the stack. In order
237-
to use these popped values, the block signature of the branch target has to
238-
match the exception types - because it receives the exception arguments as
239-
branch operands. If the exception tag does not match, the `except_ref` value
240-
remains on the stack. For example, when an `except_ref` contains an exception of
241-
type (i32 i64), the target block signature should be (i32 i64) as well, as in
242-
the following example:
231+
The `br_on_exn` instruction checks the exception tag of an `exnref` on top of
232+
the stack if it matches the given exception index. If it does, it branches out
233+
to the label referenced by the instruction (In the binary form, the label will
234+
be converted to a relative depth immediate, like other branch instructions), and
235+
while doing that, pops the `exnref` value from the stack and instead pushes the
236+
exception's argument values on top of the stack. In order to use these popped
237+
values, the block signature of the branch target has to match the exception
238+
types - because it receives the exception arguments as branch operands. If the
239+
exception tag does not match, the `exnref` value remains on the stack. For
240+
example, when an `exnref` contains an exception of type (i32 i64), the target
241+
block signature should be (i32 i64) as well, as in the following example:
243242

244243
```
245244
block $l (result i32 i64)
246245
...
247-
;; except_ref $e is on the stack at this point
246+
;; exnref $e is on the stack at this point
248247
br_on_exn $l ;; branch to $l with $e's arguments
249248
...
250249
end
@@ -331,20 +330,20 @@ document](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md).
331330

332331
### Data Types
333332

334-
#### except_ref
333+
#### exnref
335334

336335
An exception reference points to an exception.
337336

338337
### Language Types
339338

340339
| Opcode | Type constructor |
341340
|--------|------------------|
342-
| -0x18 | `except_ref` |
341+
| -0x18 | `exnref` |
343342

344343
#### value_type
345344

346-
A `varint7` indicating a `value_type` is extended to include `except_ref` as
347-
encoded above.
345+
A `varint7` indicating a `value_type` is extended to include `exnref` as encoded
346+
above.
348347

349348
#### Other Types
350349

@@ -465,8 +464,8 @@ throws, and rethrows as follows:
465464
| `try` | `0x06` | sig : `block_type` | begins a block which can handle thrown exceptions |
466465
| `catch` | `0x07` | | begins the catch block of the try block |
467466
| `throw` | `0x08` | index : `varint32` | Creates an exception defined by the exception `index`and then throws it |
468-
| `rethrow` | `0x09` | | Pops the `except_ref` on top of the stack and throws it |
469-
| `br_on_exn` | `0x0a` | relative_depth : `varuint32`, index : `varuint32` | Branches to the given label and extracts data within `except_ref` on top of stack if it was created using the corresponding exception `index` |
467+
| `rethrow` | `0x09` | | Pops the `exnref` on top of the stack and throws it |
468+
| `br_on_exn` | `0x0a` | relative_depth : `varuint32`, index : `varuint32` | Branches to the given label and extracts data within `exnref` on top of stack if it was created using the corresponding exception `index` |
470469

471470
The *sig* fields of `block`, `if`, and `try` operators are block signatures
472471
which describe their use of the operand stack.

0 commit comments

Comments
 (0)