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

Combine throw and create - #43

Merged
KarlSchimpf merged 3 commits into
WebAssembly:masterfrom
KarlSchimpf:rethrow
Feb 14, 2018
Merged

KarlSchimpf merged 3 commits into
WebAssembly:masterfrom
KarlSchimpf:rethrow

Conversation

@KarlSchimpf

Copy link
Copy Markdown
Contributor

Combine the throw and exception create instructions into a single 'throw' instruction. Add back from the original proposal the 'rethrow' instruction that can rethrow a caught exception.

Also cleans up cases some confusion of exception tags and exception indices. That is, the index is the static value used in the module, while the tag is the corresponding exception identifier for that index.

@KarlSchimpf
KarlSchimpf requested a review from eholk February 14, 2018 16:54
@KarlSchimpf KarlSchimpf self-assigned this Feb 14, 2018

@rossberg rossberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks! I have a couple of suggestions but they are all nitpicks on terminology.

Comment thread proposals/Level-1.md Outdated
[exception index space](#exception-index-space). This index is referred to as
the `exception tag`. The `tagged exception type` is the corresponding
[exception index space](#exception-index-space). This static index refers to the
corresponding runtime index that uniquely identifies the exception type, and is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Maybe it's even clearer if you avoid calling the runtime thing an "index" in the first place. How about changing wording to use "tag" right away?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound good. Changing.

Comment thread proposals/Level-1.md Outdated
the `exception tag`. The `tagged exception type` is the corresponding
[exception index space](#exception-index-space). This static index refers to the
corresponding runtime index that uniquely identifies the exception type, and is
called the `exception tag`. The `tagged exception type` is the corresponding

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terminology nitpick: Technically what's defined in the exception section is not a type. What an exception definition defines is a fresh tag, which is a runtime value that has the ascribed exception type (and multiple tags can have the same type yet be different tags). This may be nitpicking, but the difference is that it clarifies that (1) multiple tags can have the same type, and (2) dispatch is on values not types (types have no runtime representation in Wasm).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. reworking this text.

Comment thread proposals/Level-1.md Outdated
1. The `except` instruction which creates a WebAssembly instance of the
corresponding tagged exception type, and pushes a reference to it onto the
stack.
1. The `throw` instruction which creates a WebAssembly instance of the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I would say it creates an exception value with the corresponding tag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Reworking the code to match.

Comment thread proposals/Level-1.md Outdated
Data types are extended to have a new `except_ref` type. The representation of
an exception type is left to the host VM, but its size must be fixed. The actual
number of bytes it takes to represent any `except_ref` is left to the host VM.
an exception type is left to the host VM.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"exception type" -> "exception value"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread proposals/Level-1.md Outdated
The `throw` throws the exception on top of the stack. The exception is popped
off the top of the stack before throwing.
The `throw` instruction takes an exception index as an immediate argument. That
index is used to identify the tagged exception type to throw. The values to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: "tagged exception type" -> "exception tag"
"values to throw" -> "argument values"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewritten to match changes.

Comment thread proposals/Level-1.md Outdated
The `throw` instruction takes an exception index as an immediate argument. That
index is used to identify the tagged exception type to throw. The values to
throw (corresponding to the signature) are popped from the top of the stack, and
an exception is created. This includes attaching a stack track to the exception.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The stack trace isn't part of the core semantics and its presence may depend on the embedder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@rossberg rossberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo comments!

Comment thread proposals/Level-1.md Outdated
the caught exception.

Note that a caught exception can be rethrown using the `throw` instruction.
Note that a caught exception value can be rethrown using the `throw`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: rethrow instruction?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread proposals/Level-1.md Outdated
| `count` | `varuint32` | The number of types in the signature |
| `type` | `value_type*` | The type of each element in the signature |

Note: An `except_type` is not actually a type, just an exception definition that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the exception type in an exn def is indeed the type of the defined tag, so I believe this note isn't necessary (and probably misleading).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@KarlSchimpf
KarlSchimpf merged commit 7e760ce into WebAssembly:master Feb 14, 2018
@KarlSchimpf
KarlSchimpf deleted the rethrow branch February 26, 2018 21:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants