-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Current core formal spec for WebAssembly Exception Handling #121
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
06d5b3f
Current core formal spec for WebAssembly Exception Handling
ioannad 231e0aa
Apply suggestions from code review
ioannad 91e5bd8
Addressed review comments without suggestions
ioannad 4929c85
Implemented latest comments and suggestions to PR#121
ioannad 3dac52e
Apply suggestions from code review
ioannad 1724804
Implemented the rest of the latest review comments for PR#121
ioannad 6d51a93
Apply suggestions from code review
ioannad 304d189
implemented latest review comments by Rossberg
ioannad 396777c
Apply suggestions from code review
ioannad b42015e
Implements the latest comments from Rossberg's review
ioannad 36f1c50
removed redundant explanation from exiting a handler
ioannad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1624,13 +1624,13 @@ Control Instructions | |
|
||
2. Let :math:`[t_1^n] \to [t_2^m]` be the :ref:`function type <syntax-functype>` :math:`\expand_F(\blocktype)`. | ||
|
||
3. Assert: due to :ref:`validation <valid-if>`, there are at least :math:`n` values on the top of the stack. | ||
3. Assert: due to :ref:`validation <valid-try>`, there are at least :math:`n` values on the top of the stack. | ||
|
||
4. Pop the values :math:`\val^n` from the stack. | ||
|
||
5. Let :math:`L` be the label whose arity is :math:`m` and whose continuation is the end of the |TRY| instruction. | ||
|
||
4. Execute the administrative instruction :math:`\CATCHN_m` by :ref:`entering <exec-instr-seq-enter>` the block :math:`\instr_1^\ast` with label :math:`L`, and reducing the resulting :ref:`throw context <syntax-ctxt-throw>`. | ||
4. :ref:`Execute <exec-catchn>` the administrative instruction :math:`\CATCHN_m` by :ref:`entering <exec-instr-seq-enter>` the block :math:`\instr_1^\ast` with label :math:`L`. | ||
|
||
.. math:: | ||
~\\[-1ex] | ||
|
@@ -1652,12 +1652,12 @@ Control Instructions | |
|
||
3. Let :math:`a` be the :ref:`event address <syntax-eventaddr>` :math:`F.\AMODULE.\MIEVENTS[x]`. | ||
|
||
4. :ref:`Throw <syntax-throwaddr>` the :ref:`event address <syntax-eventaddr>` :math:`a`. | ||
4. :ref:`Throw <exec-throwaddr>` the :ref:`event address <syntax-eventaddr>` :math:`a`. | ||
|
||
.. math:: | ||
~\\[-1ex] | ||
\begin{array}{lclr@{\qquad}l} | ||
\THROW~x &\stepto& \THROWADDR~a & (\iff F.\AMODULE.\MIEVENTS[x]=a) \\ | ||
\THROW~x &\stepto& \THROWADDR~a & (\iff F.\AMODULE.\MIEVENTS[x] = a) \\ | ||
\end{array} | ||
|
||
|
||
|
@@ -1674,17 +1674,17 @@ Control Instructions | |
|
||
a. Trap. | ||
|
||
4. Else the :math:`\EXNREF` value is of the form :math:`(\EXNREFADDR~a~\val^\ast)`. | ||
4. Assert: :math:`\EXNREF` is of the form :math:`(\REFEXNADDR~a~\val^\ast)`. | ||
|
||
5. Put the values :math:`\val^\ast` on the stack. | ||
|
||
6. :ref:`Throw <syntax-throwaddr>` the :ref:`event address <syntax-eventaddr>` :math:`a`. | ||
6. :ref:`Throw <exec-throwaddr>` the :ref:`event address <syntax-eventaddr>` :math:`a`. | ||
|
||
.. math:: | ||
~\\[-1ex] | ||
\begin{array}{lclr@{\qquad}} | ||
(\REFNULL~\EXNREF)~\RETHROW &\stepto& \TRAP \\ | ||
(\EXNREFADDR~a~\val^\ast)~\RETHROW &\stepto& \val^\ast~(\THROWADDR~a) \\ | ||
(\REFEXNADDR~a~\val^\ast)~\RETHROW &\stepto& \val^\ast~(\THROWADDR~a) \\ | ||
\end{array} | ||
|
||
|
||
|
@@ -1701,7 +1701,7 @@ Control Instructions | |
|
||
a. Trap. | ||
|
||
4. Else the :math:`\EXNREF` value is of the form :math:`(\EXNREFADDR~a~\val^\ast)`. | ||
4. Assert: :math:`\EXNREF` is of the form :math:`(\REFEXNADDR~a~\val^\ast)`. | ||
|
||
5. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`. | ||
|
||
|
@@ -1715,14 +1715,14 @@ Control Instructions | |
|
||
8. Else: | ||
|
||
a. Put the value :math:`(\EXNREFADDR~a~\val^\ast)` back on the stack. | ||
a. Put the value :math:`(\REFEXNADDR~a~\val^\ast)` back on the stack. | ||
|
||
.. math:: | ||
~\\[-1ex] | ||
\begin{array}{lclr@{\qquad}l} | ||
F; (\REFNULL~\EXNREF)~\BRONEXN~l~x &\stepto& F; \TRAP \\ | ||
F; (\EXNREFADDR~a~\val^\ast)~\BRONEXN~l~x &\stepto& F; \val^\ast~(\BR~l) & (\iff F.\AMODULE.\MIEVENTS[x] = a) \\ | ||
F; (\EXNREFADDR~a~\val^\ast)~\BRONEXN~l~x &\stepto& F; (\EXNREFADDR~a~\val^\ast) & (\iff F.\AMODULE.\MIEVENTS[x] \neq a) \\ | ||
F; (\REFEXNADDR~a~\val^\ast)~\BRONEXN~l~x &\stepto& F; \val^\ast~(\BR~l) & (\iff F.\AMODULE.\MIEVENTS[x] = a) \\ | ||
F; (\REFEXNADDR~a~\val^\ast)~\BRONEXN~l~x &\stepto& F; (\REFEXNADDR~a~\val^\ast) & (\iff F.\AMODULE.\MIEVENTS[x] \neq a) \\ | ||
\end{array} | ||
|
||
|
||
|
@@ -1996,6 +1996,28 @@ When the end of a block is reached without a jump or trap aborting it, then the | |
Therefore, execution of a loop falls off the end, unless a backwards branch is performed explicitly. | ||
|
||
|
||
.. index:: exception handling, throw context | ||
pair: handling; exception | ||
.. _exec-catchn: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
.. _exec-throwaddr: | ||
|
||
Exception Handling | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
The following auxiliary rules define the semantics of handling thrown exceptions | ||
inside :ref:`throw contexts <syntax-ctxt-throw>`. | ||
|
||
*TODO: Add rules prose, which may involve having defined return values for unresolved throws.* | ||
|
||
.. math:: | ||
\begin{array}{rcl} | ||
S;~F;~\CATCHN_m\{\instr^\ast\}~\val^m~\END &\stepto& S;~F;~\val^m \\ | ||
S;~F;~\CATCHN_m\{\instr^\ast\}~\XT[\val^n~[\_]~(\THROWADDR~a)]~\END &\stepto& | ||
S;~F;~\LABEL_m\{\}~(\REFEXNADDR~a~\val^n)~{\instr}^\ast~\END \\ | ||
&& \hspace{-12ex} (\iff S.\SEVENTS[a]=\{\EVATTR~\EXCEPTION, \EVTYPE~[t^n]\to[]\}) \\ | ||
\end{array} | ||
|
||
|
||
.. index:: ! call, function, function instance, label, frame | ||
|
||
Function Calls | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prose tries to avoid referring to administrative instructions, so I would express this a bit differently. I would phrase it as pushing and popping a handler on/off the stack, similar to how the prose describes function frames. That is, describe handlers as a new form of stack element in the Stack section (runtime.rst), and in the new auxiliary section Exception Handling have subsections for "installing" and exiting a handler, analogous to the ones for invoking functions.