Skip to content

Commit

Permalink
Dependencies in proposal (#99)
Browse files Browse the repository at this point in the history
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](#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.
  • Loading branch information
aheejin committed Mar 5, 2020
1 parent 714d26e commit 4e8c37e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ holds a
[proposal](https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md) for
adding exception handling to WebAssembly.

The exception handling proposal depends on the [reference-types](https://github.com/WebAssembly/reference-types) proposal
and on the [multi-value](https://github.com/WebAssembly/multi-value) proposal.

The repository is a clone
of [WebAssembly/spec](https://github.com/WebAssembly/spec), and is rebased on the spec of its dependent proposal [WebAssembly/reference-types](https://github.com/WebAssembly/reference-types).
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).

The remainder of the document is contents of the [README.md](https://github.com/WebAssembly/reference-types/blob/master/README.md)
document of that repository.
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).

# Reference Types Proposal for WebAssembly

Expand All @@ -20,9 +22,20 @@ document of that repository.
This repository is a clone of [github.com/WebAssembly/spec/](https://github.com/WebAssembly/spec/).
It is meant for discussion, prototype specification and implementation of a proposal to add support for basic reference types to WebAssembly.

* See the [overview](proposals/reference-types/Overview.md) for a summary of the proposal.
* See the [overview](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md) for a summary of the proposal.

* See the [modified spec](https://webassembly.github.io/reference-types/) for details.

# Multi-value Proposal for WebAssembly

[![Build Status](https://travis-ci.org/WebAssembly/multi-value.svg?branch=master)](https://travis-ci.org/WebAssembly/multi-value)

This repository is a clone of [github.com/WebAssembly/spec/](https://github.com/WebAssembly/spec/).
It is meant for discussion, prototype specification and implementation of a proposal to add support for returning multiple values to WebAssembly.

* See the [overview](https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md) for a summary of the proposal.

* See the [modified spec](https://webassembly.github.io/reference-types/core/) for details.
* See the [modified spec](https://webassembly.github.io/multi-value/) for details.

Original `README` from upstream repository follows...

Expand Down
19 changes: 12 additions & 7 deletions proposals/Exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ on the second proposal, which uses first-class exception types, mainly based on
the reasoning that it is more expressive and also more extendible to other kinds
of events.

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

- The [reference types proposal](https://github.com/WebAssembly/reference-types/blob/master/proposals/reference-types/Overview.md),
since the [`exnref`](#the-exception-reference-data-type) type should be represented as a subtype of `anyref`.

- The [multi-value proposal](https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md),
since otherwise the [`br_on_exn`](#exception-data-extraction) instruction would only work with exceptions that contain one value.
Moreover, by using [multi-value](https://github.com/WebAssembly/multi-value/blob/master/proposals/multi-value/Overview.md),
the [`try` blocks](#try-and-catch-blocks) may use values already in the stack, and also push multiple values onto the stack.

---

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

```
try block_type
try blocktype
instruction*
catch
instruction*
Expand Down Expand Up @@ -316,7 +321,7 @@ document](https://github.com/WebAssembly/spec/blob/master/document/core/instruct
The following rules are added to *instructions*:

```
try resulttype instruction* catch instruction* end |
try blocktype instruction* catch instruction* end |
throw except_index |
rethrow |
br_on_exn label except_index
Expand Down Expand Up @@ -487,7 +492,7 @@ throws, and rethrows as follows:

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

0 comments on commit 4e8c37e

Please sign in to comment.