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

Commit 4bd749a

Browse files
committed
Update core formal spec to the current (3rd) EH proposal
As described in `proposals/exceptions/Exceptions.md` and in `proposals/exceptions/Exceptions-formal-overview.md`. * Detailed changes from the previous (2nd proposal) formal spec: - Removed: + the reference type "exnref" is removed, + the administrative instruction "REFEXNADDR" is removed, + Release dependencies "bulk instructions" and "reference types" are removed. - Renamed: + "exn" and (most occurrences of) "exception" renamed to "tag", + "EITYPE" renamed to "TAGITYPE", + "ETYPE" renamed to "TAGTYPE", + variable names for tags changed from "et" to "tt" or "tagt" and "iet" to "itagt", + "CATCHN" is renamed to "CATCHadm". + "THROWADDR" is renamed to "THROWadm". - Adjusted: + syntax and rules for "TRY-CATCH", "RETHROW", and "CATCHadm", + folded text format for "TRY-CATCH", + validation example of control frame with opcode catch. - Added: + validation example of control frame with opcode catch_all, + administrative instructions "CAUGHTadm" and "DELEGATEadm" with rules, + syntax and rules for "TRY-DELEGATE". - Most prose that is changing in the 3rd spec is removed and a temporary "**TODO: add prose**" is added. + This will be updated in a followup PR to include the new prose instead. iIn several places added or adjusted prose or added TODO items to add prose in a followup PR. - Several similar **TODO**s are added for uncaught exceptions.
1 parent e9f4732 commit 4bd749a

24 files changed

+604
-635
lines changed

document/core/appendix/algorithm.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Types are representable as an enumeration.
2525

2626
.. code-block:: pseudo
2727
28-
type val_type = I32 | I64 | F32 | F64 | V128 | Funcref | Exnref | Externref
28+
type val_type = I32 | I64 | F32 | F64 | V128 | Funcref | Externref
2929
3030
func is_num(t : val_type | Unknown) : bool =
3131
return t = I32 || t = I64 || t = F32 || t = F64 || t = Unknown
@@ -34,7 +34,7 @@ Types are representable as an enumeration.
3434
return t = V128 || t = Unknown
3535
3636
func is_ref(t : val_type | Unknown) : bool =
37-
return t = Funcref || t = Exnref || t = Externref || t = Unknown
37+
return t = Funcref || t = Externref || t = Unknown
3838
3939
The algorithm uses two separate stacks: the *value stack* and the *control stack*.
4040
The former tracks the :ref:`types <syntax-valtype>` of operand values on the :ref:`stack <stack>`,
@@ -216,8 +216,14 @@ Other instructions are checked in a similar manner.
216216
217217
case (catch)
218218
let frame = pop_ctrl()
219-
error_if(frame.opcode =/= try)
220-
push_ctrl(catch, [exnref], frame.end_types)
219+
error_if(frame.opcode =/= try || frame.opcode =/= catch)
220+
let tagparams = tags.[x].type.params
221+
push_ctrl(catch, tagparams , frame.end_types)
222+
223+
case (catch_all)
224+
let frame = pop_ctrl()
225+
error_if(frame.opcode =/= try || frame.opcode =/= catch)
226+
push_ctrl(catch_all, [] , frame.end_types)
221227
222228
case (br n)
223229
error_if(ctrls.size() < n)

document/core/appendix/embedding.rst

+11-11
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Store
7676

7777
.. math::
7878
\begin{array}{lclll}
79-
\F{store\_init}() &=& \{ \SFUNCS~\epsilon,~ \SMEMS~\epsilon, ~\SEXNS~\epsilon,~ \STABLES~\epsilon,~ \SGLOBALS~\epsilon \} \\
79+
\F{store\_init}() &=& \{ \SFUNCS~\epsilon,~ \SMEMS~\epsilon, ~\STAGS~\epsilon,~ \STABLES~\epsilon,~ \SGLOBALS~\epsilon \} \\
8080
\end{array}
8181
8282
@@ -539,26 +539,26 @@ Memories
539539
\end{array}
540540
541541
542-
.. index:: exception, exception address, store, exception instance, exception type, function type
543-
.. _embed-exn:
542+
.. index:: tag, tag address, store, tag instance, tag type, function type
543+
.. _embed-tag:
544544

545-
Exceptions
546-
~~~~~~~~~~
545+
Tags
546+
~~~~
547547

548-
.. _embedd-exn-alloc:
548+
.. _embedd-tag-alloc:
549549

550-
:math:`\F{exn\_alloc}(\store, \exntype) : (\store, \exnaddr)`
550+
:math:`\F{tag\_alloc}(\store, \tagtype) : (\store, \tagaddr)`
551551
.............................................................
552552

553-
1. Pre-condition: :math:`exntype` is :ref:`valid <valid-exntype>`.
553+
1. Pre-condition: :math:`tagtype` is :ref:`valid <valid-tagtype>`.
554554

555-
2. Let :math:`\exnaddr` be the result of :ref:`allocating an exception <alloc-exn>` in :math:`\store` with :ref:`exception type <syntax-exntype>` :math:`\exntype`.
555+
2. Let :math:`\tagaddr` be the result of :ref:`allocating a tag <alloc-tag>` in :math:`\store` with :ref:`tag type <syntax-tagtype>` :math:`\tagtype`.
556556

557-
3. Return the new store paired with :math:`\exnaddr`.
557+
3. Return the new store paired with :math:`\tagaddr`.
558558

559559
.. math::
560560
\begin{array}{lclll}
561-
\F{exn\_alloc}(S, \X{et}) &=& (S', \X{a}) && (\iff \allocexn(S, \X{et}) = S', \X{a}) \\
561+
\F{tag\_alloc}(S, \X{tt}) &=& (S', \X{a}) && (\iff \alloctag(S, \X{tt}) = S', \X{a}) \\
562562
\end{array}
563563
564564

document/core/appendix/implementation.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ However, it is expected that all implementations have "reasonably" large limits
2424
Syntactic Limits
2525
~~~~~~~~~~~~~~~~
2626

27-
.. index:: abstract syntax, module, type, function, table, memory, global, element, data, import, export, parameter, result, local, structured control instruction, instruction, name, Unicode, character
27+
.. index:: abstract syntax, module, type, function, table, memory, tag, global, element, data, import, export, parameter, result, local, structured control instruction, instruction, name, Unicode, character
2828
.. _impl-syntax:
2929

3030
Structure
@@ -36,7 +36,7 @@ An implementation may impose restrictions on the following dimensions of a modul
3636
* the number of :ref:`functions <syntax-func>` in a :ref:`module <syntax-module>`, including imports
3737
* the number of :ref:`tables <syntax-table>` in a :ref:`module <syntax-module>`, including imports
3838
* the number of :ref:`memories <syntax-mem>` in a :ref:`module <syntax-module>`, including imports
39-
* the number of :ref:`exceptions <syntax-exn>` in a :ref:`module <syntax-module>`, including imports
39+
* the number of :ref:`tags <syntax-tag>` in a :ref:`module <syntax-module>`, including imports
4040
* the number of :ref:`globals <syntax-global>` in a :ref:`module <syntax-module>`, including imports
4141
* the number of :ref:`element segments <syntax-elem>` in a :ref:`module <syntax-module>`
4242
* the number of :ref:`data segments <syntax-data>` in a :ref:`module <syntax-module>`
@@ -124,7 +124,7 @@ Restrictions on the following dimensions may be imposed during :ref:`execution <
124124
* the number of allocated :ref:`function instances <syntax-funcinst>`
125125
* the number of allocated :ref:`table instances <syntax-tableinst>`
126126
* the number of allocated :ref:`memory instances <syntax-meminst>`
127-
* the number of allocated :ref:`exception instances <syntax-exninst>`
127+
* the number of allocated :ref:`tag instances <syntax-taginst>`
128128
* the number of allocated :ref:`global instances <syntax-globalinst>`
129129
* the size of a :ref:`table instance <syntax-tableinst>`
130130
* the size of a :ref:`memory instance <syntax-meminst>`

document/core/appendix/index-rules.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Construct Judgement
1818
:ref:`Block type <valid-blocktype>` :math:`\vdashblocktype \blocktype \ok`
1919
:ref:`Table type <valid-tabletype>` :math:`\vdashtabletype \tabletype \ok`
2020
:ref:`Memory type <valid-memtype>` :math:`\vdashmemtype \memtype \ok`
21-
:ref:`Exception type <valid-exntype>` :math:`\vdashexntype \exntype \ok`
21+
:ref:`Tag type <valid-tagtype>` :math:`\vdashtagtype \tagtype \ok`
2222
:ref:`Global type <valid-globaltype>` :math:`\vdashglobaltype \globaltype \ok`
2323
:ref:`External type <valid-externtype>` :math:`\vdashexterntype \externtype \ok`
2424
:ref:`Instruction <valid-instr>` :math:`S;C \vdashinstr \instr : \stacktype`
@@ -27,7 +27,7 @@ Construct Judgement
2727
:ref:`Function <valid-func>` :math:`C \vdashfunc \func : \functype`
2828
:ref:`Table <valid-table>` :math:`C \vdashtable \table : \tabletype`
2929
:ref:`Memory <valid-mem>` :math:`C \vdashmem \mem : \memtype`
30-
:ref:`Exception <valid-exn>` :math:`C \vdashexn \exn : \exntype`
30+
:ref:`Tag <valid-tag>` :math:`C \vdashtag \tag : \tagtype`
3131
:ref:`Global <valid-global>` :math:`C \vdashglobal \global : \globaltype`
3232
:ref:`Element segment <valid-elem>` :math:`C \vdashelem \elem : \reftype`
3333
:ref:`Element mode <valid-elemmode>` :math:`C \vdashelemmode \elemmode : \reftype`
@@ -56,7 +56,7 @@ Construct Judgement
5656
:ref:`Function instance <valid-funcinst>` :math:`S \vdashfuncinst \funcinst : \functype`
5757
:ref:`Table instance <valid-tableinst>` :math:`S \vdashtableinst \tableinst : \tabletype`
5858
:ref:`Memory instance <valid-meminst>` :math:`S \vdashmeminst \meminst : \memtype`
59-
:ref:`Exception instance <valid-exninst>` :math:`S \vdashexninst \exninst : \exntype`
59+
:ref:`Tag instance <valid-taginst>` :math:`S \vdashtaginst \taginst : \tagtype`
6060
:ref:`Global instance <valid-globalinst>` :math:`S \vdashglobalinst \globalinst : \globaltype`
6161
:ref:`Element instance <valid-eleminst>` :math:`S \vdasheleminst \eleminst \ok`
6262
:ref:`Data instance <valid-datainst>` :math:`S \vdashdatainst \datainst \ok`
@@ -100,7 +100,7 @@ Construct Judgement
100100
:ref:`Function instance <extend-funcinst>` :math:`\vdashfuncinstextends \funcinst_1 \extendsto \funcinst_2`
101101
:ref:`Table instance <extend-tableinst>` :math:`\vdashtableinstextends \tableinst_1 \extendsto \tableinst_2`
102102
:ref:`Memory instance <extend-meminst>` :math:`\vdashmeminstextends \meminst_1 \extendsto \meminst_2`
103-
:ref:`Exception instance <extend-exninst>` :math:`\vdashexninstextends \exninst_1 \extendsto \exninst_2`
103+
:ref:`Tag instance <extend-taginst>` :math:`\vdashtaginstextends \taginst_1 \extendsto \taginst_2`
104104
:ref:`Global instance <extend-globalinst>` :math:`\vdashglobalinstextends \globalinst_1 \extendsto \globalinst_2`
105105
:ref:`Element instance <extend-eleminst>` :math:`\vdasheleminstextends \eleminst_1 \extendsto \eleminst_2`
106106
:ref:`Data instance <extend-datainst>` :math:`\vdashdatainstextends \datainst_1 \extendsto \datainst_2`

document/core/appendix/index-types.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ Category Constructor
1616
(reserved) :math:`\hex{7A}` .. :math:`\hex{71}`
1717
:ref:`Reference type <syntax-reftype>` |FUNCREF| :math:`\hex{70}` (-16 as |Bs7|)
1818
:ref:`Reference type <syntax-reftype>` |EXTERNREF| :math:`\hex{6F}` (-17 as |Bs7|)
19-
:ref:`Reference type <syntax-reftype>` |EXNREF| :math:`\hex{6E}` (-18 as |Bs7|)
2019
(reserved) :math:`\hex{6D}` .. :math:`\hex{61}`
2120
:ref:`Function type <syntax-functype>` :math:`[\valtype^\ast] \to [\valtype^\ast]` :math:`\hex{60}` (-32 as |Bs7|)
2221
(reserved) :math:`\hex{5F}` .. :math:`\hex{41}`
2322
:ref:`Result type <syntax-resulttype>` :math:`[\epsilon]` :math:`\hex{40}` (-64 as |Bs7|)
2423
:ref:`Table type <syntax-tabletype>` :math:`\limits~\reftype` (none)
2524
:ref:`Memory type <syntax-memtype>` :math:`\limits` (none)
26-
:ref:`Exception type <syntax-exntype>` :math:`\functype` (none)
25+
:ref:`Tag type <syntax-tagtype>` :math:`\functype` (none)
2726
:ref:`Global type <syntax-globaltype>` :math:`\mut~\valtype` (none)
2827
======================================== =========================================== ===============================================================================

0 commit comments

Comments
 (0)