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

Commit 7150909

Browse files
ioannadrossberg
andauthored
Modified the throw context example with concrete types but not concrete values. (#219)
* Simplified throw context example, with concrete types but not concrete values. Addresses @aheejin's request in a previous review comment: #180 (comment) Originally I wrote this using - `val_{i32} = (i32.const 1)`, - `val_{f32} = (f32.const 2.0)`, and - `val_{i64} = (i64.const 3)`, but the example seemed then really long. To keep the example relatively short I switched to the current version. * Typesetting fixes. * Addressed review comments. Co-authored-by: Andreas Rossberg <[email protected]>
1 parent 423f261 commit 7150909

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

document/core/exec/runtime.rst

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -729,41 +729,37 @@ If no exception :ref:`handler that catches the exception <syntax-handler>` is fo
729729
|CAUGHTadm| blocks do not represent active handlers. Instead, they delimit the continuation of a handler that has already been selected. Their sole purpose is to record the exception that has been caught, such that |RETHROW| can access it inside such a block.
730730

731731
.. note::
732-
For example, catching a simple :ref:`throw <exec-throw>` in a :ref:`try block <exec-try-catch>` would be as follows.
732+
For example, catching a simple :ref:`throw <syntax-throw>` in a :ref:`try block <syntax-try-catch>` would be as follows.
733733

734-
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`,
735-
and that the tag address `a` of :math:`x` corresponds to the tag type :math:`[t2^m] \to []`.
734+
Assume that :math:`\expand_F(bt) = [\I32~\F32~\I64] \to [\F32~\I64]`,
735+
and that the tag address `a` of :math:`x` has tag type :math:`[\F32~\I64] \to []`.
736+
Let :math:`\val_{i32}`, :math:`\val_{f32}`, and :math:`\val_{i64}` be values of type |I32|, |F32|, and |I64| respectively.
736737

737738
.. math::
738739
\begin{array}{ll}
739-
& \hspace{-5ex} S;~F;~\val^n~(\TRY~\X{bt}~(\THROW~x)~\CATCH~x~\RETURN~\END) \\
740-
\stepto & S;~F;~\LABEL_m\{\} (\CATCHadm\{a~\RETURN\}~\val^n~(\THROW~x)~\END)~\END \\
740+
& \hspace{-5ex} F;~\val_{i32}~\val_{f32}~\val_{i64}~(\TRY~\X{bt}~(\THROW~x)~\CATCH~x~\END) \\
741+
\stepto & F;~\LABEL_2\{\} (\CATCHadm\{a~\epsilon\}~\val_{i32}~\val_{f32}~\val_{i64}~(\THROW~x)~\END)~\END \\
741742
\end{array}
742743
743-
Let :math:`\val^n` be :math:`\val^{n-m} \val^m`.
744744
:ref:`Handling the thrown exception <exec-throwadm>` with tag address :math:`a` in the throw context
745-
:math:`T=[val^{n-m}\_]`, with the exception handler :math:`H=\CATCHadm\{a~\RETURN\}` gives:
745+
:math:`T=[\val_{i32}\_]`, with the exception handler :math:`H=\CATCHadm\{a~\epsilon\}` gives:
746746

747747
.. math::
748748
\begin{array}{lll}
749-
\stepto & S;~F;~\LABEL_m\{\}~(\CAUGHTadm\{a~\val^m\}~\val^m~\RETURN~\END)~\END & \hspace{9ex}\ \\
750-
\stepto & \val^m & \\
749+
\stepto & F;~\LABEL_2\{\}~(\CAUGHTadm\{a~\val_{f32}~\val_{i64}\}~\val_{f32}~\val_{i64}~\END)~\END & \hspace{9ex}\ \\
750+
\stepto & F;~\LABEL_2\{\}~\val_{f32}~\val_{i64}~\END & \hspace{9ex}\ \\
751+
\stepto & \val_{f32}~\val_{i64} & \\
751752
\end{array}
752753
753754
754-
When a throw of the form :math:`val^m (\THROWadm~a)` occurs, search for the maximal surrounding throw context :math:`T` is performed,
755-
which means any other values, labels, frames, and |CAUGHTadm| instructions surrounding the throw :math:`val^m (\THROWadm~a)` are popped,
755+
When a throw of the form :math:`\val^m (\THROWadm~a)` occurs, search for the maximal surrounding throw context :math:`T` is performed,
756+
which means any other values, labels, frames, and |CAUGHTadm| instructions surrounding the throw :math:`\val^m (\THROWadm~a)` are popped,
756757
until a :ref:`handler <syntax-handler>` for the exception is found.
757758
Then a new |CAUGHTadm| instruction, containing the tag address :math:`a` and the values :math:`\val^m`, is pushed onto the stack.
758759

759-
760-
In other words, when a throw occurs, normal execution halts and exceptional execution begins, until the throw
761-
is the continuation (i.e., in the place of a :math:`\_`) of a throw context in a catching try block.
762-
763760
In this particular case, the exception is caught by the exception handler :math:`H` and its values are returned.
764761

765762

766-
767763
.. index:: ! configuration, ! thread, store, frame, instruction, module instruction
768764
.. _syntax-thread:
769765
.. _syntax-config:

0 commit comments

Comments
 (0)