Skip to content

Commit b763423

Browse files
aheejinioannad
authored andcommitted
Dependencies in proposal (WebAssembly#99)
This PR adds the dependency to multi-value to the exception handling proposal text and to the README. I wrote an explanation of this dependency on the proposal text, but it's easier to see this once the verification and execution steps of `br_on_exn` and of `try` blocks are written out, as done [here](WebAssembly#87 (comment)) by @rossberg : Validation: ``` ft = t1* -> t2* C, label t2* |- e1* : t1* -> t2* C, label t2* |- e2* : exnref -> t2* ----------------------------------- C |- try ft e1* catch e2* end : ft C_label(l) = C_exn(x) = t* ------------------------------------- C |- br_on_exn l x : exnref -> exnref ``` Execution: ``` v^n (try ft e1* catch e2* end) --> catch_m{e2*} (label_m{} v^n e1* end) end) (iff ft = t1^n -> t2^m) S; F; catch_m{e*} T[v^n (throw a)] end --> S; F; label_m{} (exn a v^n) e* end (iff S_exn(a) = {typ t^n}) F; (exn a v*) (br_on_exn l x) --> F; v* (br l) (iff F_exn(x) = a) ``` Concerning the functionality of `try`-`catch` blocks, note especially the passing of `v^n` values into a `label_m{}`. Concerning the functionality of `br_on_exn`, note especially the execution step resulting in a `br` instruction.
1 parent e7eaba9 commit b763423

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

README.md

+31-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,39 @@ holds a
77
[proposal](https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md) for
88
adding exception handling to WebAssembly.
99

10-
The repository is a copy
11-
of [WebAssembly/spec](https://github.com/WebAssembly/spec).
10+
The exception handling proposal depends on the [reference-types](https://github.com/WebAssembly/reference-types) proposal
11+
and on the [multi-value](https://github.com/WebAssembly/multi-value) proposal.
1212

13-
The remainder of the document is contents of the
14-
original [README.md](https://github.com/WebAssembly/spec/blob/master/README.md)
15-
document of that repository.
13+
The repository is a clone
14+
of [WebAssembly/spec](https://github.com/WebAssembly/spec), first rebased on the spec of its dependency [reference-types](https://github.com/WebAssembly/reference-types), and then merged with the other dependency [multi-value](https://github.com/WebAssembly/multi-value).
1615

17-
## spec
16+
The remainder of the document has contents of the two README files of the dependencies: [reference-types/README.md](https://github.com/WebAssembly/reference-types/blob/master/README.md) and [multi-value/README.md](https://github.com/WebAssembly/multi-value/blob/master/README.md).
17+
18+
# Reference Types Proposal for WebAssembly
19+
20+
[![Build Status](https://travis-ci.org/WebAssembly/reference-types.svg?branch=master)](https://travis-ci.org/WebAssembly/reference-types)
21+
22+
This repository is a clone of [github.com/WebAssembly/spec/](https://github.com/WebAssembly/spec/).
23+
It is meant for discussion, prototype specification and implementation of a proposal to add support for basic reference types to WebAssembly.
24+
25+
* See the [overview](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md) for a summary of the proposal.
26+
27+
* See the [modified spec](https://webassembly.github.io/reference-types/) for details.
28+
29+
# Multi-value Proposal for WebAssembly
30+
31+
[![Build Status](https://travis-ci.org/WebAssembly/multi-value.svg?branch=master)](https://travis-ci.org/WebAssembly/multi-value)
32+
33+
This repository is a clone of [github.com/WebAssembly/spec/](https://github.com/WebAssembly/spec/).
34+
It is meant for discussion, prototype specification and implementation of a proposal to add support for returning multiple values to WebAssembly.
35+
36+
* See the [overview](https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md) for a summary of the proposal.
37+
38+
* See the [modified spec](https://webassembly.github.io/multi-value/) for details.
39+
40+
Original `README` from upstream repository follows...
41+
42+
# spec
1843

1944
This repository holds a prototypical reference implementation for WebAssembly,
2045
which is currently serving as the official specification. Eventually, we expect

proposals/Exceptions.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ on the second proposal, which uses first-class exception types, mainly based on
1010
the reasoning that it is more expressive and also more extendible to other kinds
1111
of events.
1212

13-
This proposal requires the [reference types
14-
proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md)
15-
as a prerequisite, since the [`exnref`](#the-exception-reference-data-type) type
16-
should be represented as a subtype of `anyref`.
13+
This proposal requires the following proposals as prerequisites.
14+
15+
- The [reference types proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md),
16+
since the [`exnref`](#the-exception-reference-data-type) type should be represented as a subtype of `anyref`.
17+
18+
- The [multi-value proposal](https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md),
19+
since otherwise the [`br_on_exn`](#exception-data-extraction) instruction would only work with exceptions that contain one value.
20+
Moreover, by using [multi-value](https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md),
21+
the [`try` blocks](#try-and-catch-blocks) may use values already in the stack, and also push multiple values onto the stack.
1722

1823
---
1924

@@ -152,7 +157,7 @@ instruction. That is, a try block is sequence of instructions having the
152157
following form:
153158

154159
```
155-
try block_type
160+
try blocktype
156161
instruction*
157162
catch
158163
instruction*
@@ -316,7 +321,7 @@ document](https://github.com/WebAssembly/spec/blob/master/document/core/instruct
316321
The following rules are added to *instructions*:
317322

318323
```
319-
try resulttype instruction* catch instruction* end |
324+
try blocktype instruction* catch instruction* end |
320325
throw except_index |
321326
rethrow |
322327
br_on_exn label except_index
@@ -487,7 +492,7 @@ throws, and rethrows as follows:
487492

488493
| Name | Opcode | Immediates | Description |
489494
| ---- | ---- | ---- | ---- |
490-
| `try` | `0x06` | sig : `block_type` | begins a block which can handle thrown exceptions |
495+
| `try` | `0x06` | sig : `blocktype` | begins a block which can handle thrown exceptions |
491496
| `catch` | `0x07` | | begins the catch block of the try block |
492497
| `throw` | `0x08` | index : `varint32` | Creates an exception defined by the exception `index`and then throws it |
493498
| `rethrow` | `0x09` | | Pops the `exnref` on top of the stack and throws it |

0 commit comments

Comments
 (0)