Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge with WebAssembly/spec and WebAssembly/gc #11

Merged
merged 63 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
fb69ac6
[test] Add JS API tests for Exported GC Objects
takikawa Feb 17, 2023
1779efb
Update getPrototypeOf test
takikawa Feb 20, 2023
15156e0
Address PR feedback
takikawa Apr 18, 2023
920e636
Rebase exported object test
takikawa Sep 8, 2023
25fb7d4
Fix wasm-module-builder for some missed updates
takikawa Sep 15, 2023
eee7a83
[spec] A few fixes
rossberg Sep 25, 2023
c70e2aa
[spec] Extend definition of constants
rossberg Oct 5, 2023
bdad982
Merge pull request #355 from takikawa/gc-object-wpt-test
rossberg Oct 5, 2023
5bca3f7
Rename extern.in/externalize
rossberg Oct 5, 2023
0102418
Merge pull request #447 from WebAssembly/extern-cvt-rename
rossberg Oct 5, 2023
2718b78
Merge branch 'main' into spec.fixes
rossberg Oct 5, 2023
e4e6ab6
Merge pull request #446 from WebAssembly/spec.const
rossberg Oct 5, 2023
2b058c0
Merge pull request #444 from WebAssembly/spec.fixes
rossberg Oct 5, 2023
83f9144
Fix cross-eyed merge
rossberg Oct 5, 2023
e19a159
Add missing init expression to table text format
rossberg Oct 6, 2023
ec57b2a
Merge pull request #449 from WebAssembly/spec.table-init
rossberg Oct 6, 2023
0ed695b
[ci] Don't install ocamlbuild (#1686)
foolip Oct 6, 2023
64070a8
[spec] Fix copypaste error for V128.Load*_Zero instructions in index …
rdunnington Jun 6, 2023
4a15066
[interpreter] Use explicit bounds checks instead Invalid_argument (#1…
zapashcanon Jun 13, 2023
e23c83b
[interpreter] Makefile tweak
rossberg Jun 14, 2023
05e4601
[spec] Tweak math layout
rossberg Jun 27, 2023
2e280f6
[spec] Some tweaks to layout and SIMD ops (#1667)
rossberg Jun 27, 2023
f113ac4
[spec] Add missing type to elem.drop and store soundness (#1668)
bvisness Jul 3, 2023
ef28217
[test] Add tests for out-of-range NaN payloads (#1670)
sunfishcode Jul 11, 2023
d1d1686
[spec] Fix typo (#1671)
pdubroy Jul 12, 2023
767f23a
[spec] Remark about the convention of using a pattern for attribute v…
rossberg Jul 24, 2023
423bf0b
[interpreter] Makefile support for opam releases
rossberg Jul 24, 2023
7b33c40
[interpreter] Makefile tweaks
rossberg Jul 24, 2023
38ea0a0
[interpreter] Makefile tweaks
rossberg Jul 24, 2023
98f35cb
[interpreter] Tune opam file to fix opam repo CI
rossberg Jul 24, 2023
bf6309f
[interpreter] Use dune instead of ocamlbuild (#1665)
zapashcanon Jul 26, 2023
fe6c68c
Fix and clean up Makefile
rossberg Sep 1, 2023
939b409
Make partest the default
rossberg Sep 1, 2023
9be2b36
[spec] Clarify that elements are given as expressions (#1676)
keithw Sep 6, 2023
cde89ca
[test] Fix typos (#1678)
yamt Sep 8, 2023
a994f2d
[test] text format: drop support for some pre-standard keywords (#1680)
keithw Sep 20, 2023
6d0ab8b
[test] Test that atypical folded if conditions are parsed correctly (…
tlively Sep 21, 2023
be6b12a
[interpreter] Run unittests with partest
rossberg Sep 21, 2023
da278f8
[interpreter] Update Makefile to ignore output of `cd` (#1683)
tlively Sep 22, 2023
af59a5c
[interpreter] Fix Makefile targets
rossberg Sep 25, 2023
7284293
[test] Merge token and tokens tests
rossberg Sep 25, 2023
e5435b2
[test] Make runner robust wrt parallel races
rossberg Sep 25, 2023
ef9c157
[interpreter] Update {memory,table}.copy to match spec text (#1666)
tlively Sep 25, 2023
245d382
[test] Fix typo in runner
rossberg Sep 25, 2023
9532002
[js-api] Editorial: fix some references to 'agent'
Ms2ger Jul 27, 2023
de85aff
[js-api] Editorial: replace reference to removed IterableToList abstr…
Ms2ger Jul 27, 2023
38885ff
[js-api] Editorial: drop unused algorithm
Ms2ger Jul 27, 2023
2eb52be
[ci] Don't install ocamlbuild (#1686)
foolip Oct 6, 2023
6becba4
Merge branch 'funcref'
rossberg Oct 6, 2023
e157117
[test] Add JS API tests for i31ref
takikawa Sep 19, 2023
10de3ad
Merge pull request #437 from takikawa/gc-js-api-i31-test
rossberg Oct 10, 2023
4e87dd2
[test] Add JS API tests for boundary casts
takikawa Sep 20, 2023
6370411
Merge pull request #439 from takikawa/gc-js-api-casts-test
rossberg Oct 13, 2023
0118f2d
[spec] Fix a few minor oversights
rossberg Oct 14, 2023
c36aa2f
Merge branch 'funcref'
rossberg Oct 14, 2023
2048b3d
[spec] Add missing shorthands
rossberg Oct 14, 2023
84158a7
[spec] Fix typo
rossberg Oct 14, 2023
86cda09
[spec] Fix the instruction types of `array.new_default` and `array.len`
q82419 Oct 16, 2023
ced37c7
Update index-instructions.py
rossberg Oct 16, 2023
e5d10ba
[spec] Fix array instruction types in index (#451)
rossberg Oct 16, 2023
be1f563
[spec] Pop dummy frame after Invocation (#1691)
r1ru Oct 16, 2023
4a46a40
Merge with WebAssembly/main
dhil Oct 20, 2023
5987142
Merge branch 'main' of github.com:WebAssembly/gc into wasmfx-merge
dhil Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-interpreter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
ocaml-compiler: 4.14.x
- name: Setup OCaml tools
run: opam install --yes ocamlbuild.0.14.0 ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0
run: opam install --yes ocamlfind.1.9.5 js_of_ocaml.4.0.0 js_of_ocaml-ppx.4.0.0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions document/core/appendix/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ Added managed reference types [#proposal-gc]_.

* New :ref:`reference instructions <syntax-instr-ref>` for :ref:`array types <syntax-structtype>`: |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |ARRAYNEWDATA|, |ARRAYNEWELEM|, :math:`\ARRAYGET\K{\_}\sx^?`, |ARRAYSET|, |ARRAYLEN|, |ARRAYFILL|, |ARRAYCOPY|, |ARRAYINITDATA|, |ARRAYINITELEM|

* New :ref:`reference instructions <syntax-instr-ref>` for converting :ref:`host types <syntax-externtype>`: |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|
* New :ref:`reference instructions <syntax-instr-ref>` for converting :ref:`host types <syntax-externtype>`: |ANYCONVERTEXTERN|, |EXTERNCONVERTANY|

* Extended set of :ref:`constant instructions <valid-const>` with |REFI31|, |STRUCTNEW|, |STRUCTNEWDEFAULT|, |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|, and |GLOBALGET| for any previously declared immutable :ref:`global <syntax-global>`
* 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>`


.. [#proposal-signext]
Expand Down
10 changes: 5 additions & 5 deletions document/core/appendix/index-instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
Instruction(None, r'\hex{CF}'),
Instruction(r'\REFNULL~\X{ht}', r'\hex{D0}', r'[] \to [(\REF~\NULL~\X{ht})]', r'valid-ref.null', r'exec-ref.null'),
Instruction(r'\REFISNULL', r'\hex{D1}', r'[(\REF~\NULL~\X{ht})] \to [\I32]', r'valid-ref.is_null', r'exec-ref.is_null'),
Instruction(r'\REFFUNC~x', r'\hex{D2}', r'[] \to [\FUNCREF]', r'valid-ref.func', r'exec-ref.func'),
Instruction(r'\REFFUNC~x', r'\hex{D2}', r'[] \to [\REF~\X{ht}]', r'valid-ref.func', r'exec-ref.func'),
Instruction(r'\REFEQ', r'\hex{D3}', r'[\EQREF~\EQREF] \to [\I32]', r'valid-ref.eq', r'exec-ref.eq'),
Instruction(r'\REFASNONNULL', r'\hex{D4}', r'[(\REF~\NULL~\X{ht})] \to [(\REF~\X{ht})]', r'valid-ref.as_non_null', r'exec-ref.as_non_null'),
Instruction(r'\BRONNULL~l', r'\hex{D5}', r'[t^\ast~(\REF~\NULL~\X{ht})] \to [t^\ast~(\REF~\X{ht})]', r'valid-br_on_null', r'exec-br_on_null'),
Expand Down Expand Up @@ -327,15 +327,15 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
Instruction(r'\STRUCTGETU~x~y', r'\hex{FB}~\hex{04}', r'[(\REF~\NULL~x)] \to [\I32]', r'valid-struct.get', r'exec-struct.get'),
Instruction(r'\STRUCTSET~x~y', r'\hex{FB}~\hex{05}', r'[(\REF~\NULL~x)~t] \to []', r'valid-struct.set', r'exec-struct.set'),
Instruction(r'\ARRAYNEW~x', r'\hex{FB}~\hex{06}', r'[t] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'),
Instruction(r'\ARRAYNEWDEFAULT~x', r'\hex{FB}~\hex{07}', r'[] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'),
Instruction(r'\ARRAYNEWDEFAULT~x', r'\hex{FB}~\hex{07}', r'[\I32] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'),
Instruction(r'\ARRAYNEWFIXED~x~n', r'\hex{FB}~\hex{08}', r'[t^n] \to [(\REF~x)]', r'valid-array.new_fixed', r'exec-array.new_fixed'),
Instruction(r'\ARRAYNEWDATA~x~y', r'\hex{FB}~\hex{09}', r'[\I32~\I32] \to [(\REF~x)]', r'valid-array.new_data', r'exec-array.new_data'),
Instruction(r'\ARRAYNEWELEM~x~y', r'\hex{FB}~\hex{0A}', r'[\I32~\I32] \to [(\REF~x)]', r'valid-array.new_elem', r'exec-array.new_elem'),
Instruction(r'\ARRAYGET~x', r'\hex{FB}~\hex{0B}', r'[(\REF~\NULL~x)~\I32] \to [t]', r'valid-array.get', r'exec-array.get'),
Instruction(r'\ARRAYGETS~x', r'\hex{FB}~\hex{0C}', r'[(\REF~\NULL~x)~\I32] \to [\I32]', r'valid-array.get', r'exec-array.get'),
Instruction(r'\ARRAYGETU~x', r'\hex{FB}~\hex{0D}', r'[(\REF~\NULL~x)~\I32] \to [\I32]', r'valid-array.get', r'exec-array.get'),
Instruction(r'\ARRAYSET~x', r'\hex{FB}~\hex{0E}', r'[(\REF~\NULL~x)~\I32~t] \to []', r'valid-array.set', r'exec-array.set'),
Instruction(r'\ARRAYLEN', r'\hex{FB}~\hex{0F}', r'[\ARRAYREF] \to []', r'valid-array.len', r'exec-array.len'),
Instruction(r'\ARRAYLEN', r'\hex{FB}~\hex{0F}', r'[(\REF~\NULL~\ARRAY)] \to [\I32]', r'valid-array.len', r'exec-array.len'),
Instruction(r'\ARRAYFILL~x', r'\hex{FB}~\hex{10}', r'[(\REF~\NULL~x)~\I32~t~\I32] \to []', r'valid-array.fill', r'exec-array.fill'),
Instruction(r'\ARRAYCOPY~x~y', r'\hex{FB}~\hex{11}', r'[(\REF~\NULL~x)~\I32~(\REF~\NULL~y)~\I32~\I32] \to []', r'valid-array.copy', r'exec-array.copy'),
Instruction(r'\ARRAYINITDATA~x~y', r'\hex{FB}~\hex{12}', r'[(\REF~\NULL~x)~\I32~\I32~\I32] \to []', r'valid-array.init_data', r'exec-array.init_data'),
Expand All @@ -346,8 +346,8 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
Instruction(r'\REFCAST~(\REF~\NULL~t)', r'\hex{FB}~\hex{17}', r"[(\REF~\NULL~t')] \to [(\REF~\NULL~t)]", r'valid-ref.cast', r'exec-ref.cast'),
Instruction(r'\BRONCAST~t_1~t_2', r'\hex{FB}~\hex{18}', r'[t_1] \to [t_1\reftypediff t_2]', r'valid-br_on_cast', r'exec-br_on_cast'),
Instruction(r'\BRONCASTFAIL~t_1~t_2', r'\hex{FB}~\hex{19}', r'[t_1] \to [t_2]', r'valid-br_on_cast_fail', r'exec-br_on_cast_fail'),
Instruction(r'\EXTERNINTERNALIZE', r'\hex{FB}~\hex{1A}', r'[\EXTERNREF] \to [\ANYREF]', r'valid-extern.internalize', r'exec-extern.internalize'),
Instruction(r'\EXTERNEXTERNALIZE', r'\hex{FB}~\hex{1B}', r'[\ANYREF] \to [\EXTERNREF]', r'valid-extern.externalize', r'exec-extern.externalize'),
Instruction(r'\ANYCONVERTEXTERN', r'\hex{FB}~\hex{1A}', r'[(\REF~\NULL~\EXTERN)] \to [(\REF~\NULL~\ANY)]', r'valid-any.convert_extern', r'exec-any.convert_extern'),
Instruction(r'\EXTERNCONVERTANY', r'\hex{FB}~\hex{1B}', r'[(\REF~\NULL~\ANY)] \to [(\REF~\NULL~\EXTERN)]', r'valid-extern.convert_any', r'exec-extern.convert_any'),
Instruction(r'\REFI31', r'\hex{FB}~\hex{1C}', r'[\I32] \to [\I31REF]', r'valid-ref.i31', r'exec-ref.i31'),
Instruction(r'\I31GETS', r'\hex{FB}~\hex{1D}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
Instruction(r'\I31GETU', r'\hex{FB}~\hex{1E}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'),
Expand Down
9 changes: 5 additions & 4 deletions document/core/binary/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Control Instructions
.. _binary-call_ref:
.. _binary-call_indirect:
.. _binary-return_call:
.. _binary-return_call_ref:
.. _binary-return_call_indirect:

.. math::
Expand Down Expand Up @@ -131,8 +132,8 @@ Generic :ref:`reference instructions <syntax-instr-ref>` are represented by sing
.. _binary-i31.get_u:
.. _binary-ref.test:
.. _binary-ref.cast:
.. _binary-extern.internalize:
.. _binary-extern.externalize:
.. _binary-any.convert_extern:
.. _binary-extern.convert_any:

.. math::
\begin{array}{llclll}
Expand Down Expand Up @@ -166,8 +167,8 @@ Generic :ref:`reference instructions <syntax-instr-ref>` are represented by sing
\hex{FB}~~21{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFTEST~(\REF~\NULL~\X{ht}) \\ &&|&
\hex{FB}~~22{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFCAST~(\REF~\X{ht}) \\ &&|&
\hex{FB}~~23{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFCAST~(\REF~\NULL~\X{ht}) \\ &&|&
\hex{FB}~~26{:}\Bu32 &\Rightarrow& \EXTERNINTERNALIZE \\ &&|&
\hex{FB}~~27{:}\Bu32 &\Rightarrow& \EXTERNEXTERNALIZE \\ &&|&
\hex{FB}~~26{:}\Bu32 &\Rightarrow& \ANYCONVERTEXTERN \\ &&|&
\hex{FB}~~27{:}\Bu32 &\Rightarrow& \EXTERNCONVERTANY \\ &&|&
\hex{FB}~~28{:}\Bu32 &\Rightarrow& \REFI31 \\ &&|&
\hex{FB}~~29{:}\Bu32 &\Rightarrow& \I31GETS \\ &&|&
\hex{FB}~~30{:}\Bu32 &\Rightarrow& \I31GETU \\
Expand Down
4 changes: 2 additions & 2 deletions document/core/binary/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ It decodes into a vector of :ref:`element segments <syntax-elem>` that represent
\production{element segment} & \Belem &::=&
0{:}\Bu32~~e{:}\Bexpr~~y^\ast{:}\Bvec(\Bfuncidx)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~\FUNCREF, \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
\{ \ETYPE~(\REF~\NULL~\FUNC), \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
1{:}\Bu32~~\X{et}:\Belemkind~~y^\ast{:}\Bvec(\Bfuncidx)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~\X{et}, \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EPASSIVE \} \\ &&|&
Expand All @@ -353,7 +353,7 @@ It decodes into a vector of :ref:`element segments <syntax-elem>` that represent
\{ \ETYPE~\X{et}, \EINIT~((\REFFUNC~y)~\END)^\ast, \EMODE~\EDECLARATIVE \} \\ &&|&
4{:}\Bu32~~e{:}\Bexpr~~\X{el}^\ast{:}\Bvec(\Bexpr)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~\FUNCREF, \EINIT~\X{el}^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
\{ \ETYPE~(\REF~\NULL~\FUNC), \EINIT~\X{el}^\ast, \EMODE~\EACTIVE~\{ \ETABLE~0, \EOFFSET~e \} \} \\ &&|&
5{:}\Bu32~~\X{et}:\Breftype~~\X{el}^\ast{:}\Bvec(\Bexpr)
&\Rightarrow& \\&&&\quad
\{ \ETYPE~et, \EINIT~\X{el}^\ast, \EMODE~\EPASSIVE \} \\ &&|&
Expand Down
48 changes: 31 additions & 17 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1475,43 +1475,57 @@ Where:
\end{array}


.. _exec-extern.externalize:
.. _exec-any.convert_extern:

:math:`\EXTERNEXTERNALIZE`
..........................
:math:`\ANYCONVERTEXTERN`
.........................

1. Assert: due to :ref:`validation <valid-extern.externalize>`, a :ref:`reference value <syntax-ref>` is on the top of the stack.
1. Assert: due to :ref:`validation <valid-any.convert_extern>`, a :ref:`reference value <syntax-ref>` is on the top of the stack.

2. Pop the value :math:`\reff` from the stack.

3. Let :math:`\reff'` be the reference value :math:`(\REFEXTERN~\reff)`.
3. If :math:`\reff` is :math:`\REFNULL~\X{ht}`, then:

a. Push the reference value :math:`(\REFNULL~\ANY)` to the stack.

4. Else:

a. Assert: due to :ref:`validation <valid-any.convert_extern>`, a :math:`\reff` is an :ref:`external reference <syntax-ref.extern>`.

5. Push the reference value :math:`\reff'` to the stack.
b. Let :math:`\REFEXTERN~\reff'` be the reference value :math:`\reff`.

c. Push the reference value :math:`\reff'` to the stack.

.. math::
\begin{array}{lcl@{\qquad}l}
\reff~\EXTERNEXTERNALIZE &\stepto& (\REFEXTERN~\reff)
(\REFNULL \X{ht})~\ANYCONVERTEXTERN &\stepto& (\REFNULL~\ANY) \\
(\REFEXTERN~\reff)~\ANYCONVERTEXTERN &\stepto& \reff \\
\end{array}


.. _exec-extern.internalize:
.. _exec-extern.convert_any:

:math:`\EXTERNINTERNALIZE`
..........................
:math:`\EXTERNCONVERTANY`
.........................

1. Assert: due to :ref:`validation <valid-extern.internalize>`, a :ref:`reference value <syntax-ref>` is on the top of the stack.
1. Assert: due to :ref:`validation <valid-extern.convert_any>`, a :ref:`reference value <syntax-ref>` is on the top of the stack.

2. Pop the value :math:`\reff` from the stack.

3. Assert: due to :ref:`validation <valid-extern.internalize>`, a :math:`\reff` is an :ref:`external reference <syntax-ref.extern>`.
3. If :math:`\reff` is :math:`\REFNULL~\X{ht}`, then:

a. Push the reference value :math:`(\REFNULL~\EXTERN)` to the stack.

4. Else:

4. Let :math:`\REFEXTERN~\reff'` be the reference value :math:`\reff`.
a. Let :math:`\reff'` be the reference value :math:`(\REFEXTERN~\reff)`.

5. Push the reference value :math:`\reff'` to the stack.
b. Push the reference value :math:`\reff'` to the stack.

.. math::
\begin{array}{lcl@{\qquad}l}
(\REFEXTERN~\reff)~\EXTERNINTERNALIZE &\stepto& \reff
(\REFNULL \X{ht})~\EXTERNCONVERTANY &\stepto& (\REFNULL~\EXTERN) \\
\reff~\EXTERNCONVERTANY &\stepto& (\REFEXTERN~\reff) & (\iff \reff \neq (\REFNULL \X{ht})) \\
\end{array}


Expand Down Expand Up @@ -4125,7 +4139,7 @@ Control Instructions

.. math::
\begin{array}{lcl@{\qquad}l}
S; \reff~(\BRONCAST~l~\X{rt}_1~X{rt}_2) &\stepto& (\BR~l)
S; \reff~(\BRONCAST~l~\X{rt}_1~X{rt}_2) &\stepto& \reff~(\BR~l)
& (\iff S \vdashval \reff : \X{rt}
\land \vdashreftypematch \X{rt} \matchesreftype \insttype_{F.\AMODULE}(\X{rt}_2)) \\
S; \reff~(\BRONCAST~l~\X{rt}_1~\X{rt}_2) &\stepto& \reff
Expand Down Expand Up @@ -4163,7 +4177,7 @@ Control Instructions
S; \reff~(\BRONCASTFAIL~l~\X{rt}_1~X{rt}_2) &\stepto& \reff
& (\iff S \vdashval \reff : \X{rt}
\land \vdashreftypematch \X{rt} \matchesreftype \insttype_{F.\AMODULE}(\X{rt}_2)) \\
S; \reff~(\BRONCASTFAIL~l~\X{rt}_1~\X{rt}_2) &\stepto& (\BR~l)
S; \reff~(\BRONCASTFAIL~l~\X{rt}_1~\X{rt}_2) &\stepto& \reff~(\BR~l)
& (\otherwise) \\
\end{array}

Expand Down
4 changes: 4 additions & 0 deletions document/core/exec/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ Once the function has returned, the following steps are executed:

2. Pop :math:`\val_{\F{res}}^m` from the stack.

3. Assert: due to :ref:`validation <valid-module>`, the frame :math:`F` is now on the top of the stack.

4. Pop the frame :math:`F` from the stack.

The values :math:`\val_{\F{res}}^m` are returned as the results of the invocation.

.. math::
Expand Down
10 changes: 5 additions & 5 deletions document/core/syntax/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ while the latter performs a downcast and :ref:`traps <trap>` if the operand's ty
.. _syntax-ref.i31:
.. _syntax-i31.get_s:
.. _syntax-i31.get_u:
.. _syntax-extern.internalize:
.. _syntax-extern.externalize:
.. _syntax-any.convert_extern:
.. _syntax-extern.convert_any:
.. _syntax-instr-struct:
.. _syntax-instr-array:
.. _syntax-instr-i31:
Expand Down Expand Up @@ -521,8 +521,8 @@ Instructions in this group are concerned with creating and accessing :ref:`refer
\ARRAYINITELEM~\typeidx~\elemidx \\&&|&
\REFI31 \\&&|&
\I31GET\K{\_}\sx \\&&|&
\EXTERNINTERNALIZE \\&&|&
\EXTERNEXTERNALIZE \\
\ANYCONVERTEXTERN \\&&|&
\EXTERNCONVERTANY \\
\end{array}

The instructions |STRUCTNEW| and |STRUCTNEWDEFAULT| allocate a new :ref:`structure <syntax-structtype>`, initializing them either with operands or with default values.
Expand All @@ -539,7 +539,7 @@ again allowing for different sign extension modes in the case of a :ref:`packed

The instructions |REFI31| and :math:`\I31GET\K{\_}\sx` convert between type |I31| and an unboxed :ref:`scalar <syntax-i31>`.

The instructions |EXTERNINTERNALIZE| and |EXTERNEXTERNALIZE| allow lossless conversion between references represented as type :math:`(\REF~\NULL~\EXTERN)`| and as :math:`(\REF~\NULL~\ANY)`.
The instructions |ANYCONVERTEXTERN| and |EXTERNCONVERTANY| allow lossless conversion between references represented as type :math:`(\REF~\NULL~\EXTERN)`| and as :math:`(\REF~\NULL~\ANY)`.

.. index:: ! parametric instruction, value type
pair: abstract syntax; instruction
Expand Down
25 changes: 24 additions & 1 deletion document/core/syntax/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ There are three disjoint hierarchies of heap types:
- *aggregate types* classify dynamically allocated *managed* data, such as *structures*, *arrays*, or *unboxed scalars*,
- *external types* classify *external* references possibly owned by the :ref:`embedder <embedder>`.

The values from the latter two hierarchies are interconvertible by ways of the |EXTERNINTERNALIZE| and |EXTERNEXTERNALIZE| instructions.
The values from the latter two hierarchies are interconvertible by ways of the |EXTERNCONVERTANY| and |ANYCONVERTEXTERN| instructions.
That is, both type hierarchies are inhabited by an isomorphic set of values, but may have different, incompatible representations in practice.

.. math::
Expand Down Expand Up @@ -168,6 +168,29 @@ Other references are *non-null*.
Reference types are *opaque*, meaning that neither their size nor their bit pattern can be observed.
Values of reference type can be stored in :ref:`tables <syntax-table>`.

Conventions
...........

* The reference type |ANYREF| is an abbreviation for :math:`\REF~\NULL~\ANY`.

* The reference type |EQREF| is an abbreviation for :math:`\REF~\NULL~\EQT`.

* The reference type |I31REF| is an abbreviation for :math:`\REF~\NULL~\I31`.

* The reference type |STRUCTREF| is an abbreviation for :math:`\REF~\NULL~\STRUCT`.

* The reference type |ARRAYREF| is an abbreviation for :math:`\REF~\NULL~\ARRAY`.

* The reference type |FUNCREF| is an abbreviation for :math:`\REF~\NULL~\FUNC`.

* The reference type |EXTERNREF| is an abbreviation for :math:`\REF~\NULL~\EXTERN`.

* The reference type |NULLREF| is an abbreviation for :math:`\REF~\NULL~\NONE`.

* The reference type |NULLFUNCREF| is an abbreviation for :math:`\REF~\NULL~\NOFUNC`.

* The reference type |NULLEXTERNREF| is an abbreviation for :math:`\REF~\NULL~\NOEXTERN`.


.. index:: ! value type, number type, vector type, reference type
pair: abstract syntax; value type
Expand Down
8 changes: 4 additions & 4 deletions document/core/text/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ Reference Instructions
.. _text-i31.get_u:
.. _text-ref.test:
.. _text-ref.cast:
.. _text-extern.internalize:
.. _text-extern.externalize:
.. _text-any.convert_extern:
.. _text-extern.convert_any:

.. math::
\begin{array}{llclll}
Expand Down Expand Up @@ -240,8 +240,8 @@ Reference Instructions
\text{ref.i31} &\Rightarrow& \REFI31 \\ &&|&
\text{i31.get\_u} &\Rightarrow& \I31GETU \\ &&|&
\text{i31.get\_s} &\Rightarrow& \I31GETS \\ &&|&
\text{extern.internalize} &\Rightarrow& \EXTERNINTERNALIZE \\ &&|&
\text{extern.externalize} &\Rightarrow& \EXTERNEXTERNALIZE \\
\text{any.convert_extern} &\Rightarrow& \ANYCONVERTEXTERN \\ &&|&
\text{extern.convert_any} &\Rightarrow& \EXTERNCONVERTANY \\
\end{array}


Expand Down
19 changes: 16 additions & 3 deletions document/core/text/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Functions can be defined as :ref:`imports <text-import>` or :ref:`exports <text-
Consequently, a function declaration can contain any number of exports, possibly followed by an import.


.. index:: table, table type, identifier
.. index:: table, table type, identifier, expression
pair: text format; table
.. _text-table:

Expand All @@ -258,11 +258,12 @@ Table definitions can bind a symbolic :ref:`table identifier <text-id>`.
.. math::
\begin{array}{llclll}
\production{table} & \Ttable_I &::=&
\text{(}~\text{table}~~\Tid^?~~\X{tt}{:}\Ttabletype_I~\text{)}
&\Rightarrow& \{ \TTYPE~\X{tt} \} \\
\text{(}~\text{table}~~\Tid^?~~\X{tt}{:}\Ttabletype_I~~e{:}\Texpr_I~\text{)}
&\Rightarrow& \{ \TTYPE~\X{tt}, \TINIT~e \} \\
\end{array}


.. index:: reference type, heap type
.. index:: import, name
pair: text format; import
.. index:: export, name, index, table index
Expand All @@ -276,6 +277,18 @@ Table definitions can bind a symbolic :ref:`table identifier <text-id>`.
Abbreviations
.............

A table's initialization :ref:`expression <text-expr>` can be omitted, in which case it defaults to :math:`\REFNULL`:

.. math::
\begin{array}{llclll}
\production{module field} &
\text{(}~\text{table}~~\Tid^?~~\Ttabletype~\text{)}
&\equiv&
\text{(}~\text{table}~~\Tid^?~~\Ttabletype~~\text{(}~\REFNULL~\X{ht}~\text{)}~\text{)}
\\ &&& \qquad\qquad
(\iff \Ttabletype = \Tlimits~\text{(}~\text{ref}~\text{null}^?~\X{ht}~\text{)}) \\
\end{array}

An :ref:`element segment <text-elem>` can be given inline with a table definition, in which case its offset is :math:`0` and the :ref:`limits <text-limits>` of the :ref:`table type <text-tabletype>` are inferred from the length of the given segment:

.. math::
Expand Down
4 changes: 2 additions & 2 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@
.. |I31GETS| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get\_s}}
.. |I31GETU| mathdef:: \xref{syntax/instructions}{syntax-instr-i31}{\K{i31.get\_u}}

.. |EXTERNINTERNALIZE| mathdef:: \xref{syntax/instructions}{syntax-instr-extern}{\K{extern.internalize}}
.. |EXTERNEXTERNALIZE| mathdef:: \xref{syntax/instructions}{syntax-instr-extern}{\K{extern.externalize}}
.. |ANYCONVERTEXTERN| mathdef:: \xref{syntax/instructions}{syntax-instr-extern}{\K{any.convert_extern}}
.. |EXTERNCONVERTANY| mathdef:: \xref{syntax/instructions}{syntax-instr-extern}{\K{extern.convert_any}}

.. |CONST| mathdef:: \xref{syntax/instructions}{syntax-instr-numeric}{\K{const}}
.. |EQZ| mathdef:: \xref{syntax/instructions}{syntax-instr-numeric}{\K{eqz}}
Expand Down
Loading
Loading