-
Notifications
You must be signed in to change notification settings - Fork 36
Modified the throw context example with concrete types but not concrete values. #219
Changes from 2 commits
5560091
0301d88
5989fde
48dd359
6df227f
8612f3e
9715e4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -732,31 +732,32 @@ Throw contexts allow matching the program context around a throw instruction up | |
.. note:: | ||
For example, catching a simple :ref:`throw <exec-throw>` in a :ref:`try block <exec-try-catch>` would be as follows. | ||
|
||
Assume that :math:`\expand_F(bt) = [t1^n] \to [t2^m]`, for some :math:`n > m` such that :math:`t1^n[(n-m):n] = t2^m`, | ||
and that the tag address `a` of :math:`x` corresponds to the tag type :math:`[t2^m] \to []`. | ||
Assume that :math:`\expand_F(bt) = [\I32~\F32~\I64] \to [\F32~\I64]`, | ||
and that the tag address `a` of :math:`x` corresponds to the tag type :math:`[\F32~\I64] \to []`. | ||
ioannad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Let :math:`val_{i32}`, :math:`val_{f32}`, and :math:`val_{i64}` be values of type |I32|, |F32|, and |I64| respectively. | ||
|
||
.. math:: | ||
\begin{array}{ll} | ||
& \hspace{-5ex} S;~F;~\val^n~(\TRY~\X{bt}~(\THROW~x)~\CATCH~x~\RETURN~\END) \\ | ||
\stepto & S;~F;~\LABEL_m\{\} (\CATCHadm\{a~\RETURN\}~\val^n~(\THROW~x)~\END)~\END \\ | ||
& \hspace{-5ex} F;~val_{i32}~val_{f32}~val_{i64}~(\TRY~\X{bt}~(\THROW~x)~\CATCH~x~\END) \\ | ||
\stepto & F;~\LABEL_2\{\} (\CATCHadm\{a~\epsilon\}~val_{i32}~val_{f32}~val_{i64}~(\THROW~x)~\END)~\END \\ | ||
\end{array} | ||
|
||
We denote :math:`\val^n = \val^{n-m} \val^m`. | ||
:ref:`Handling the thrown exception <exec-throwadm>` with tag address :math:`a` in the throw context | ||
:math:`T=[val^{n-m}\_]`, with the exception handler :math:`H=\CATCHadm\{a~\RETURN\}` gives: | ||
:math:`T=[val_{i32}\_]`, with the exception handler :math:`H=\CATCHadm\{a~\epsilon\}` gives: | ||
|
||
.. math:: | ||
\begin{array}{lll} | ||
\stepto & S;~F;~\LABEL_m\{\}~(\CAUGHTadm\{a~\val^m\}~\val^m~\RETURN~\END)~\END & \hspace{9ex}\ \\ | ||
\stepto & \val^m & \\ | ||
\stepto & F;~\LABEL_2\{\}~(\CAUGHTadm\{a~val_{f32}~val_{i64}\}~val_{f32}~val_{i64}~\END)~\END & \hspace{9ex}\ \\ | ||
\stepto & F;~\LABEL_2\{\}~val_{f32}~val_{i64}~\END & \hspace{9ex}\ \\ | ||
\stepto & val_{f32}~val_{i64} & \\ | ||
\end{array} | ||
|
||
|
||
|
||
ioannad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
When a throw of the form :math:`val^m (\THROWadm~a)` occurs, we search for the maximal surrounding throw context :math:`T`, | ||
which means we pop any other values, labels, frames, and |CAUGHTadm| instructions surrounding the throw :math:`val^m (\THROWadm~a)`, | ||
When a throw of the form :math:`\val^m (\THROWadm~a)` occurs, we search for the maximal surrounding throw context :math:`T`, | ||
ioannad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
which means we pop any other values, labels, frames, and |CAUGHTadm| instructions surrounding the throw :math:`\val^m (\THROWadm~a)`, | ||
until we find an exception handler (corresponding to a try block) that :ref:`handles the exception <syntax-handler>`. | ||
We then append the values :math:`val^m:[t^m]` to the tag address :math:`a` into a new |CAUGHTadm| instruction which we push on the stack. | ||
We then append the values :math:`\val^m:[t^m]` to the tag address :math:`a` into a new |CAUGHTadm| instruction which we push on the stack. | ||
|
||
In other words, when a throw occurs, normal execution halts and exceptional execution begins, until the throw | ||
is the continuation (i.e., in the place of a :math:`\_`) of a throw context in a catching try block. | ||
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. Not strictly related to this PR, but I'm not sure if I understand this sentence.
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. By the way this is a general question, so please don't consider this question as a blocker for landing this PR. 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.
@aheejin this is exactly what I meant, so by "exceptional execution" I meant the execution of the throw, so the popping of values and labels until the first catching try block is reached. I was only trying to describe the execution of a throw instruction, but I see now I overcomplicated it, making it seem as if there are more than one execution steps during "exceptional execution". About the hole, I think of the hole as the position of the stack pointer of the Wasm stack machine, but I see how mentioning the hole here can be confusing as well. Thank you for pointing this out! Rephrasing these two lines to:
Is it clearer like this? 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.
What's 'it' here? It looks to be "a thrown exception" looking at the first part of the sentence, but I'm not sure what it means that an exception is a continuation of a throw context. 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. By "the thrown exception" I meant the instruction that throws the exception, i.e., I guess it's better to call it "the exception throw" instead, reformulating. 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. (done) 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. This is now entirely removed, after this discussion. |
||
|
@@ -804,7 +805,7 @@ Finally, the following definition of *evaluation context* and associated structu | |
\begin{array}{llll} | ||
\production{(evaluation contexts)} & E &::=& | ||
[\_] ~|~ | ||
\val^\ast~E~\instr^\ast ~|~ | ||
val^\ast~E~\instr^\ast ~|~ | ||
ioannad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
\LABEL_n\{\instr^\ast\}~E~\END \\ | ||
\end{array} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.