Skip to content

Commit 5560091

Browse files
committed
Simplified throw context example, with concrete types but not concrete values.
Addresses @aheejin's request in a previous review comment: WebAssembly#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.
1 parent 76732ae commit 5560091

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

document/core/exec/runtime.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,23 +732,24 @@ Throw contexts allow matching the program context around a throw instruction up
732732
.. note::
733733
For example, catching a simple :ref:`throw <exec-throw>` in a :ref:`try block <exec-try-catch>` would be as follows.
734734

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

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

748748
.. math::
749749
\begin{array}{lll}
750-
\stepto & S;~F;~\LABEL_m\{\}~(\CAUGHTadm\{a~\val^m\}~\val^m~\RETURN~\END)~\END & \hspace{9ex}\ \\
751-
\stepto & \val^m & \\
750+
\stepto & F;~\LABEL_2\{\}~(\CAUGHTadm\{a~\val_{f32}~\val_{i64}\}~\val_{f32}~\val_{i64}~\END)~\END & \hspace{9ex}\ \\
751+
\stepto & F;~\LABEL_2\{\}~\val_{f32}~\val_{i64}~\END & \hspace{9ex}\ \\
752+
\stepto & \val_{f32}~\val_{i64} & \\
752753
\end{array}
753754
754755

0 commit comments

Comments
 (0)