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

Commit b72b682

Browse files
committed
Update formal spec to (partially) implement the current (3rd) EH proposal.
In particular: - exnref is removed from reference types - REFEXNADDR is removed from administrative instructions - exn and exception are renamed to tag (also when part of a word/macro) - renamed EITYPE to TAGITYPE, ETYPE to TAGTYPE, - changed variable names for tags from "et" to "tt" or "tagt", "iet" to "itagt" - adjusted indexing where needed - CATCHN is renamed to CATCHadm and its syntax and rules are adjusted - added CAUGHTadm and DELEGATEadm, both with syntax and rules - adjusted syntax and rules for TRY-CATCH, using \catchtype in binary and syntax, in order to describe TRY-CATCH compactly - added syntax and rules for TRY-DELEGATE - adjusted syntax and rules for RETHROW - removed dependencies "bulk instructions" and "reference types" from Release - adjusted/added validation example of control frame with opcode catch/catch_all resp. - adjusted "Folded Instructions" for TRY-CATCH (didn't add folded TRY-DELEGATE) - in several places added or adjusted prose, or added TODO items to add prose later In particular there are still the following items marked as TODO: [] to add prose for typing rule of DELEGATEadm [] to add prose for execution rules of TRY-CATCH, TRY-DELEGATE, and RETHROW [] to finish prose for "Throwing an exception" (exec/instructions.rst) [] to add EXCEPTION result value, signifying throwing an exception to the embedder [] to adjust block contexts by adding CATCHadm, DELEGATEadm, and CAUGHTadm [] to change labels to include the label type "catch" (in section "Contexts") [] to add prose for validation rules of TRY-DELEGATE and RETHROW
1 parent 7fcfe17 commit b72b682

25 files changed

+592
-595
lines changed

document/core/appendix/algorithm.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ Types are representable as an enumeration.
2525

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

document/core/appendix/embedding.rst

Lines changed: 11 additions & 11 deletions
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 an 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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

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

0 commit comments

Comments
 (0)