Repository navigation
Merge two proposals in a single doc - #61
Conversation
So far there have been two proposals, we have not decided on which to use for the instruction part. We have agreed to use the second proposal for the module and binary model (new event section and its format). This patch tries to update the spec to the status quo: this describes both proposals for the instruction part, and present the single agreed-on proposal for the module/binary part. I plan to add some more stuff to the proposal, such as some modifications to `rethrow` and the restriction on the order of the event section, but it will come after this patch. - Little bit of backstory: The initial motivation for the second proposal, which proposes a first-class exception ref type, was to ease some of toolchain implementation problems. The problems do not exist anymore for some other reason, but some people want to keep the second proposal on table because possible benefits it may bring, for example, better expressiveness. So we update this proposal to reflect the status quo and not to confuse people. We will eventually unify this to a single proposal.
|
@mstarzinger I don't seem to be able to add you as a reviewer. Maybe because your ID does not belong to WebAssembly team in github? |
rossberg
left a comment
There was a problem hiding this comment.
It seems like this change consists mostly of copy & pasting the previous proposal docs into one. It would be helpful to rework that and remove all the redundancy between the descriptions of the two variants, and thereby make the difference clearer.
My understanding is that the 2nd variant only differs as follows: (1) a reference type of first-class exception packages is added, (2) the monolithic try instruction is split into separate try and handle instructions, and (3) rethrow takes an exn operand instead of an index immediate. Everything else is (or could be) pretty much the same. Is that correct? It would help to have this spelled out more explicitly.
| exception. Similarly, the `except_index` of the `throw` instruction is the tag for | ||
| the constructed exception. See [exception index space](#exception-index-space) | ||
| for further clarification of exception tags. | ||
| The `except_index` of the `catch` instruction is the exception tag for the |
There was a problem hiding this comment.
Nit: "is the exception tag" -> "denotes the exception tag"
| the constructed exception. See [exception index space](#exception-index-space) | ||
| for further clarification of exception tags. | ||
| The `except_index` of the `catch` instruction is the exception tag for the | ||
| caught exception. Similarly, the `except_index` of the `throw` instruction is |
| such as reference counting, to perform the garbage collection in the embedder. | ||
|
|
||
| To do this, WebAssembly exceptions are immutable once created, to avoid cyclic | ||
| data structures that cannot be garbage collected. It also means that exceptions |
There was a problem hiding this comment.
Nit: "that cannot be garbage collected" -> "that cannot easily be reference-counted"
| * The embedder does not know the layout of data in linear memory, so it can't | ||
| find places where exception references are stored. | ||
|
|
||
| Hence, while an exception reference is a new first class type, this proposal |
There was a problem hiding this comment.
Perhaps include a link to the reference-types proposal here and clarify the intention that exceptions are added as an additional reference type.
|
The first proposal and the second one offer different instructions w/ different functionalities. The instructions are |
mstarzinger
left a comment
There was a problem hiding this comment.
Looks good from my side. Only some small nits.
| | `if` | `0x04` | sig : `block_type` | begin if expression | | ||
| | `else` | `0x05` | | begin else expression of if or try | | ||
| | `try` | `0x06` | sig : `block_type` | begins a block which can handle thrown exceptions | | ||
| | `catch` | `0x07` | tag : `varuint32` | begins a block when the exception `tag` is thrown | |
|
|
||
| ``` | ||
| try resulttype instruction* catch instruction* end | | ||
| except except_index | |
There was a problem hiding this comment.
The "except except_index" line confused me on my read-through the first time around. Is this still accurate or can we drop this line?
There was a problem hiding this comment.
I think we can drop this line. Thanks for the catch.
| #### High-level structure | ||
|
|
||
| A new `event` section is introduced and is named `event`. If included, it must | ||
| appear after immediately after the global section. |
There was a problem hiding this comment.
nit: One redundant "after" (the first one).
|
|
||
| The `exception` section is the named section 'exception'. The exception section | ||
| declares exception types using exception type signatures. | ||
| The `section` section is the named section 'event'. The event section declares a |
There was a problem hiding this comment.
nit: "section section" -> "event section"
Similar to the MVP, a 0-byte access at the end of the region is legal.
* Merge two proposals in a single doc So far there have been two proposals, we have not decided on which to use for the instruction part. We have agreed to use the second proposal for the module and binary model (new event section and its format). This patch tries to update the spec to the status quo: this describes both proposals for the instruction part, and present the single agreed-on proposal for the module/binary part. I plan to add some more stuff to the proposal, such as some modifications to `rethrow` and the restriction on the order of the event section, but it will come after this patch. - Little bit of backstory: The initial motivation for the second proposal, which proposes a first-class exception ref type, was to ease some of toolchain implementation problems. The problems do not exist anymore for some other reason, but some people want to keep the second proposal on table because possible benefits it may bring, for example, better expressiveness. So we update this proposal to reflect the status quo and not to confuse people. We will eventually unify this to a single proposal.
So far there have been two proposals, we have not decided on which to
use for the instruction part. We have agreed to use the second proposal
for the module and binary model (new event section and its format).
This patch tries to update the spec to the status quo: this describes
both proposals for the instruction part, and present the single
agreed-on proposal for the module/binary part.
I plan to add some more stuff to the proposal, such as some
modifications to
rethrowand the restriction on the order of the eventsection, but it will come after this patch.
The initial motivation for the second proposal, which proposes a
first-class exception ref type, was to ease some of toolchain
implementation problems. The problems do not exist anymore for some
other reason, but some people want to keep the second proposal on table
because possible benefits it may bring, for example, better
expressiveness. So we update this proposal to reflect the status quo and
not to confuse people. We will eventually unify this to a single
proposal.