Skip to content

Commit 820813a

Browse files
committed
Merge remote-tracking branch 'exn/main' into wasm-3.0+exn
2 parents adc65a5 + 25632dd commit 820813a

File tree

104 files changed

+10297
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+10297
-280
lines changed

.github/workflows/ci-spec.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ jobs:
4040
name: core-rendered
4141
path: document/core/_build/html
4242

43+
build-legacy-exceptions-spec:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout repo
47+
uses: actions/checkout@v2
48+
with:
49+
submodules: "recursive"
50+
- name: Setup TexLive
51+
run: sudo apt-get update -y && sudo apt-get install -y latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
52+
- name: Setup Sphinx
53+
run: pip install six && pip install sphinx==5.1.0
54+
- name: Build main spec
55+
run: cd document/legacy/exceptions && make main
56+
- name: Upload artifact
57+
uses: actions/upload-artifact@v2
58+
with:
59+
name: legacy-exceptions-rendered
60+
path: document/legacy/exceptions/_build/html
61+
4362
build-js-api-spec:
4463
runs-on: ubuntu-latest
4564
steps:
@@ -72,7 +91,7 @@ jobs:
7291

7392
publish-spec:
7493
runs-on: ubuntu-latest
75-
needs: [build-core-spec, build-js-api-spec, build-web-api-spec]
94+
needs: [build-core-spec, build-legacy-exceptions-spec, build-js-api-spec, build-web-api-spec]
7695
steps:
7796
- name: Checkout repo
7897
uses: actions/checkout@v2
@@ -83,6 +102,11 @@ jobs:
83102
with:
84103
name: core-rendered
85104
path: _output/core
105+
- name: Download legacy exceptions spec artifact
106+
uses: actions/download-artifact@v2
107+
with:
108+
name: legacy-exceptions-rendered
109+
path: _output/legacy/exceptions
86110
- name: Download JS API spec artifact
87111
uses: actions/download-artifact@v2
88112
with:

document/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DIRS = core js-api web-api
1+
DIRS = core js-api web-api legacy/exceptions
22
FILES = index.html
33
BUILDDIR = _build
44

document/core/appendix/algorithm.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Value types are representable as sets of enumerations:
3232
type vec_type = V128
3333
type heap_type =
3434
Any | Eq | I31 | Struct | Array | None |
35-
Func | Nofunc | Extern | Noextern | Bot |
35+
Func | Nofunc | Exn | Noexn | Extern | Noextern | Bot |
3636
Def(def : def_type)
3737
type ref_type = Ref(heap : heap_type, null : bool)
3838
type val_type = num_type | vec_type | ref_type | Bot
@@ -445,6 +445,28 @@ Other instructions are checked in a similar manner.
445445
pop_val(Ref(Def(types[x])))
446446
pop_val(unpack_field(st.fields[n]))
447447
448+
case (throw x)
449+
pop_vals(tags[x].type.params)
450+
unreachable()
451+
452+
case (try_table t1*->t2* handler*)
453+
pop_vals([t1*])
454+
foreach (handler in handler*)
455+
error_if(ctrls.size() < handler.label)
456+
push_ctrl(catch, [], label_types(ctrls[handler.label]))
457+
switch (handler.clause)
458+
case (catch x)
459+
push_vals(tags[x].type.params)
460+
case (catch_ref x)
461+
push_vals(tags[x].type.params)
462+
push_val(Exnref)
463+
case (catch_all)
464+
skip
465+
case (catch_all_ref)
466+
push_val(Exnref)
467+
pop_ctrl()
468+
push_ctrl(try_table, [t1*], [t2*])
469+
448470
.. note::
449471
It is an invariant under the current WebAssembly instruction set that an operand of :code:`Bot` type is never duplicated on the stack.
450472
This would change if the language were extended with stack instructions like :code:`dup`.

document/core/appendix/changes.rst

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,38 @@ Added vector type and instructions that manipulate multiple numeric values in pa
138138
* New injection/projection :ref:`vector instructions <syntax-instr-vec>`: :math:`\K{i}\!N\!\K{x}\!M\!\K{.splat}`, :math:`\K{f}\!N\!\K{x}\!M\!\K{.splat}`, :math:`\K{i}\!N\!\K{x}\!M\!\K{.bitmask}`
139139

140140

141-
Release 2.?
141+
.. [#proposal-signext]
142+
https://github.com/WebAssembly/spec/tree/main/proposals/sign-extension-ops/
143+
144+
.. [#proposal-cvtsat]
145+
https://github.com/WebAssembly/spec/tree/main/proposals/nontrapping-float-to-int-conversion/
146+
147+
.. [#proposal-multivalue]
148+
https://github.com/WebAssembly/spec/tree/main/proposals/multi-value/
149+
150+
.. [#proposal-reftype]
151+
https://github.com/WebAssembly/spec/tree/main/proposals/reference-types/
152+
153+
.. [#proposal-bulk]
154+
https://github.com/WebAssembly/spec/tree/main/proposals/bulk-memory-operations/
155+
156+
.. [#proposal-vectype]
157+
https://github.com/WebAssembly/spec/tree/main/proposals/simd/
158+
159+
160+
Release 3.0
142161
~~~~~~~~~~~
143162

163+
.. index: instruction, function, call
164+
165+
Tail Calls
166+
..........
167+
168+
Added instructions to perform tail calls [#proposal-tailcall]_.
169+
170+
* New :ref:`control instructions <syntax-instr-control>`: :math:`RETURNCALL` and :math:`RETURNCALLINDIRECT`
171+
172+
144173
.. index:: reference, reference type, heap type, value type, local, local type, instruction, instruction type, table, function, function type, matching, subtyping
145174

146175
Typeful References
@@ -193,60 +222,22 @@ Added managed reference types [#proposal-gc]_.
193222
* Extended set of :ref:`constant instructions <valid-const>` with |REFI31|, |STRUCTNEW|, |STRUCTNEWDEFAULT|, |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |ANYCONVERTEXTERN|, |EXTERNCONVERTANY|, and |GLOBALGET| for any previously declared immutable :ref:`global <syntax-global>`
194223

195224

196-
.. [#proposal-signext]
197-
https://github.com/WebAssembly/spec/tree/main/proposals/sign-extension-ops/
198-
199-
.. [#proposal-cvtsat]
200-
https://github.com/WebAssembly/spec/tree/main/proposals/nontrapping-float-to-int-conversion/
225+
.. index:: instruction, exception, reference type, tag type, tag, handler
201226

202-
.. [#proposal-multivalue]
203-
https://github.com/WebAssembly/spec/tree/main/proposals/multi-value/
204-
205-
.. [#proposal-reftype]
206-
https://github.com/WebAssembly/spec/tree/main/proposals/reference-types/
207-
208-
.. [#proposal-bulk]
209-
https://github.com/WebAssembly/spec/tree/main/proposals/bulk-memory-operations/
210-
211-
.. [#proposal-vectype]
212-
https://github.com/WebAssembly/spec/tree/main/proposals/simd/
213-
214-
215-
Release 3.0
216-
~~~~~~~~~~~
217-
218-
.. index: instruction, function, call
219-
220-
Tail calls
221-
..........
222-
223-
Added instructions to perform tail calls [#proposal-tailcall]_.
224-
225-
* New :ref:`control instructions <syntax-instr-control>`: :math:`RETURNCALL` and :math:`RETURNCALLINDIRECT`
226-
227-
228-
.. index:: reference, reference type, heap type, value type, local, local type, instruction, instruction type, table, function, function type, matching, subtyping
229-
230-
Typeful References
227+
Exception Handling
231228
..................
232229

233-
Added more precise types for references [#proposal-typedref]_.
234-
235-
* New generalised form of :ref:`reference types <syntax-reftype>`: :math:`(\REF~\NULL^?~\heaptype)`
236-
237-
* New class of :ref:`heap types <syntax-heaptype>`: |FUNC|, |EXTERN|, :math:`\typeidx`
230+
Added tag definitions, imports, and exports, and instructions to throw and catch exceptions [#proposal-exn]_
238231

239-
* Basic :ref:`subtyping <match>` on :ref:`reference <match-reftype>` and :ref:`value <match-valtype>` types
232+
* Modules may :ref:`define <syntax-tagtype>`, :ref:`import <syntax-import>`, and :ref:`export <syntax-export>` tags.
240233

241-
* New :ref:`reference instructions <syntax-instr-ref>`: |REFASNONNULL|, |BRONNULL|, |BRONNONNULL|
234+
* New :ref:`heap types <syntax-heaptype>`: |EXN|, |NOEXN|
242235

243-
* New :ref:`control instruction <syntax-instr-control>`: |CALLREF|
236+
* New :ref:`reference type <syntax-reftype>` short-hands: |EXNREF|, |NULLEXNREF|
244237

245-
* Refined typing of :ref:`reference instruction <syntax-instr-ref>` |REFFUNC| with more precise result type
238+
* New :ref:`control instructions <syntax-instr-control>`: |THROW|, |THROWREF|, and |TRYTABLE|.
246239

247-
* Refined typing of :ref:`local instructions <valid-instr-variable>` and :ref:`instruction sequences <valid-instr-seq>` to track the :ref:`initialization status <syntax-init>` of :ref:`locals <syntax-local>` with non-:ref:`defaultable <valid-defaultable>` type
248-
249-
* Extended :ref:`table definitions <syntax-table>` with optional initializer expression
240+
* New :ref:`tag section <binary-tagsec>` in binary format.
250241

251242

252243
.. [#proposal-tailcall]
@@ -257,3 +248,6 @@ Added more precise types for references [#proposal-typedref]_.
257248
258249
.. [#proposal-gc]
259250
https://github.com/WebAssembly/spec/tree/main/proposals/gc/
251+
252+
.. [#proposal-exn]
253+
https://github.com/WebAssembly/spec/tree/main/proposals/exception-handling/

document/core/appendix/custom.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ Each subsection consists of a
4646
n{:}\Bname & (\iff n = \text{name}) \\ &&&
4747
\Bmodulenamesubsec^? \\ &&&
4848
\Bfuncnamesubsec^? \\ &&&
49-
\Blocalnamesubsec^? \\
49+
\Blocalnamesubsec^? \\ &&&
50+
\Btagnamesubsec^? \\
5051
\production{name subsection} & \Bnamesubsection_N(\B{B}) &::=&
5152
N{:}\Bbyte~~\X{size}{:}\Bu32~~\B{B}
5253
& (\iff \X{size} = ||\B{B}||) \\
@@ -62,6 +63,7 @@ Id Subsection
6263
2 :ref:`local names <binary-localnamesec>`
6364
4 :ref:`type names <binary-typenamesec>`
6465
10 :ref:`field names <binary-fieldnamesec>`
66+
11 :ref:`tag names <binary-tagnamesec>`
6567
== ===========================================
6668

6769
Each subsection may occur at most once, and in order of increasing id.
@@ -177,3 +179,19 @@ It consists of an :ref:`indirect name map <binary-indirectnamemap>` assigning fi
177179
\production{field name subsection} & \Bfieldnamesubsec &::=&
178180
\Bnamesubsection_2(\Bindirectnamemap) \\
179181
\end{array}
182+
183+
184+
.. index:: tag, tag index
185+
.. _binary-tagnamesec:
186+
187+
Tag Names
188+
.........
189+
190+
The *tag name subsection* has the id 11.
191+
It consists of a :ref:`name map <binary-namemap>` assigning tag names to :ref:`tag indices <syntax-tagidx>`.
192+
193+
.. math::
194+
\begin{array}{llclll}
195+
\production{tag name subsection} & \Btagnamesubsec &::=&
196+
\Bnamesubsection_1(\Bnamemap) \\
197+
\end{array}

document/core/appendix/embedding.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Failure of an interface operation is indicated by an auxiliary syntactic class:
4949
\production{error} & \error &::=& \ERROR \\
5050
\end{array}
5151
52-
In addition to the error conditions specified explicitly in this section, implementations may also return errors when specific :ref:`implementation limitations <impl>` are reached.
52+
In addition to the error conditions specified explicitly in this section, such as invalid arguments or :ref:`exceptions <exception>` and :ref:`traps <trap>` resulting from :ref:`execution <exec>`, implementations may also return errors when specific :ref:`implementation limitations <impl>` are reached.
5353

5454
.. note::
5555
Errors are abstract and unspecific with this definition.
@@ -89,7 +89,7 @@ Store
8989

9090
.. math::
9191
\begin{array}{lclll}
92-
\F{store\_init}() &=& \{ \SFUNCS~\epsilon,~ \SMEMS~\epsilon,~ \STABLES~\epsilon,~ \SGLOBALS~\epsilon \} \\
92+
\F{store\_init}() &=& \{ \} \\
9393
\end{array}
9494
9595
@@ -167,7 +167,7 @@ Modules
167167
.. math::
168168
\begin{array}{lclll}
169169
\F{module\_instantiate}(S, m, \X{ev}^\ast) &=& (S', F.\AMODULE) && (\iff \instantiate(S, m, \X{ev}^\ast) \stepto^\ast S'; F; \epsilon) \\
170-
\F{module\_instantiate}(S, m, \X{ev}^\ast) &=& (S', \ERROR) && (\iff \instantiate(S, m, \X{ev}^\ast) \stepto^\ast S'; F; \TRAP) \\
170+
\F{module\_instantiate}(S, m, \X{ev}^\ast) &=& (S', \ERROR) && (\otherwise, \iff \instantiate(S, m, \X{ev}^\ast) \stepto^\ast S'; F; \result) \\
171171
\end{array}
172172
173173
.. note::
@@ -322,7 +322,7 @@ Functions
322322
~ \\
323323
\begin{array}{lclll}
324324
\F{func\_invoke}(S, a, v^\ast) &=& (S', {v'}^\ast) && (\iff \invoke(S, a, v^\ast) \stepto^\ast S'; F; {v'}^\ast) \\
325-
\F{func\_invoke}(S, a, v^\ast) &=& (S', \ERROR) && (\iff \invoke(S, a, v^\ast) \stepto^\ast S'; F; \TRAP) \\
325+
\F{func\_invoke}(S, a, v^\ast) &=& (S', \ERROR) && (\iff \invoke(S, a, v^\ast) \stepto^\ast S'; F; \result) \\
326326
\end{array}
327327
328328
.. note::
@@ -553,6 +553,28 @@ Memories
553553
\end{array}
554554
555555
556+
.. index:: tag, tag address, store, tag instance, tag type, function type
557+
.. _embed-tag:
558+
559+
Tags
560+
~~~~
561+
562+
.. _embedd-tag-alloc:
563+
564+
:math:`\F{tag\_alloc}(\store, \tagtype) : (\store, \tagaddr)`
565+
.............................................................
566+
567+
1. Pre-condition: :math:`tagtype` is :ref:`valid <valid-tagtype>`.
568+
569+
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`.
570+
571+
3. Return the new store paired with :math:`\tagaddr`.
572+
573+
.. math::
574+
\begin{array}{lclll}
575+
\F{tag\_alloc}(S, \X{tt}) &=& (S', \X{a}) && (\iff \alloctag(S, \X{tt}) = S', \X{a}) \\
576+
\end{array}
577+
556578
557579
.. index:: global, global address, store, global instance, global type, value
558580
.. _embed-global:

document/core/appendix/implementation.rst

Lines changed: 4 additions & 1 deletion
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, global, tag, element, data, import, export, parameter, result, local, structured control instruction, instruction, name, Unicode, character
2828
.. _impl-syntax:
2929

3030
Structure
@@ -37,6 +37,7 @@ An implementation may impose restrictions on the following dimensions of a modul
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
3939
* the number of :ref:`globals <syntax-global>` in a :ref:`module <syntax-module>`, including imports
40+
* the number of :ref:`tags <syntax-tag>` in a :ref:`module <syntax-module>`, including imports
4041
* the number of :ref:`element segments <syntax-elem>` in a :ref:`module <syntax-module>`
4142
* the number of :ref:`data segments <syntax-data>` in a :ref:`module <syntax-module>`
4243
* the number of :ref:`imports <syntax-import>` to a :ref:`module <syntax-module>`
@@ -131,8 +132,10 @@ Restrictions on the following dimensions may be imposed during :ref:`execution <
131132
* the number of allocated :ref:`table instances <syntax-tableinst>`
132133
* the number of allocated :ref:`memory instances <syntax-meminst>`
133134
* the number of allocated :ref:`global instances <syntax-globalinst>`
135+
* the number of allocated :ref:`tag instances <syntax-taginst>`
134136
* the number of allocated :ref:`structure instances <syntax-structinst>`
135137
* the number of allocated :ref:`array instances <syntax-arrayinst>`
138+
* the number of allocated :ref:`exception instances <syntax-exninst>`
136139
* the size of a :ref:`table instance <syntax-tableinst>`
137140
* the size of a :ref:`memory instance <syntax-meminst>`
138141
* the size of an :ref:`array instance <syntax-arrayinst>`

document/core/appendix/index-instructions.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,26 @@ def RefWrap(s, kind):
5252
return f':ref:`{kind} <{s}>`'
5353

5454

55-
def Instruction(name, opcode, type=None, validation=None, execution=None, operator=None):
55+
def Instruction(name, opcode, type=None, validation=None, execution=None, operator=None, validation2=None, execution2=None):
5656
if operator:
5757
execution_str = RefWrap(execution, 'execution') + ' (' + RefWrap(operator, 'operator') + ')'
58+
elif execution2:
59+
execution_str = ', '.join([RefWrap(execution, 'execution'),
60+
RefWrap(execution, 'execution')])
5861
else:
5962
execution_str = RefWrap(execution, 'execution')
6063

64+
if validation2:
65+
validation_str = ', '.join([RefWrap(validation, 'validation'),
66+
RefWrap(validation2, 'validation')])
67+
else:
68+
validation_str = RefWrap(validation, 'validation')
69+
6170
return (
6271
MathWrap(name, '(reserved)'),
6372
MathWrap(opcode),
6473
MathWrap(type),
65-
RefWrap(validation, 'validation'),
74+
validation_str,
6675
execution_str
6776
)
6877

@@ -76,9 +85,9 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
7685
Instruction(r'\ELSE', r'\hex{05}'),
7786
Instruction(None, r'\hex{06}'),
7887
Instruction(None, r'\hex{07}'),
79-
Instruction(None, r'\hex{08}'),
88+
Instruction(r'\THROW~x', r'\hex{08}', r'[t_1^\ast~t_x^\ast] \to [t_2^\ast]', r'valid-throw', r'exec-throw'),
8089
Instruction(None, r'\hex{09}'),
81-
Instruction(None, r'\hex{0A}'),
90+
Instruction(r'\THROWREF', r'\hex{0A}', r'[t_1^\ast~\EXNREF] \to [t_2^\ast]', r'valid-throw_ref', r'exec-throw_ref'),
8291
Instruction(r'\END', r'\hex{0B}'),
8392
Instruction(r'\BR~l', r'\hex{0C}', r'[t_1^\ast~t^\ast] \to [t_2^\ast]', r'valid-br', r'exec-br'),
8493
Instruction(r'\BRIF~l', r'\hex{0D}', r'[t^\ast~\I32] \to [t^\ast]', r'valid-br_if', r'exec-br_if'),
@@ -99,7 +108,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
99108
Instruction(r'\SELECT~t', r'\hex{1C}', r'[t~t~\I32] \to [t]', r'valid-select', r'exec-select'),
100109
Instruction(None, r'\hex{1D}'),
101110
Instruction(None, r'\hex{1E}'),
102-
Instruction(None, r'\hex{1F}'),
111+
Instruction(r'\TRYTABLE~\X{bt}', r'\hex{1F}', r'[t_1^\ast] \to [t_2^\ast]', r'valid-try_table', r'exec-try_table'),
103112
Instruction(r'\LOCALGET~x', r'\hex{20}', r'[] \to [t]', r'valid-local.get', r'exec-local.get'),
104113
Instruction(r'\LOCALSET~x', r'\hex{21}', r'[t] \to []', r'valid-local.set', r'exec-local.set'),
105114
Instruction(r'\LOCALTEE~x', r'\hex{22}', r'[t] \to [t]', r'valid-local.tee', r'exec-local.tee'),

0 commit comments

Comments
 (0)