Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0aa9dba
Syntax and validation for struct.new_desc
tlively Jul 7, 2026
47b07b7
const expr
tlively Jul 7, 2026
2ca8cdd
Exact func externtypes types
tlively Jul 8, 2026
ca049ee
cleanup old Instr_ok/ref.func-exact
tlively Jul 9, 2026
edfe5a2
Make allocation instructions exact
tlively Jul 9, 2026
ff4650a
Syntax and validation for ref.get_desc
tlively Jul 9, 2026
f174f3e
Syntax and validation for descriptor casts
tlively Jul 13, 2026
3b16166
Make exact and non-exact heap types the same case
tlively Jul 13, 2026
6a76272
Merge branch 'exact-heaptype-refactor' into struct-new-desc-syntax-va…
tlively Jul 13, 2026
e7acc8d
show EXACT
tlively Jul 13, 2026
8b09b7f
Merge branch 'exact-heaptype-refactor' into struct-new-desc-syntax-va…
tlively Jul 13, 2026
b9ebd33
Merge branch 'struct-new-desc-syntax-validation' into exact-extern-fu…
tlively Jul 13, 2026
34f1e65
update tests
tlively Jul 14, 2026
64a8276
Merge branch 'exact-heaptype-refactor' into struct-new-desc-syntax-va…
tlively Jul 14, 2026
c3b35c6
update tests
tlively Jul 14, 2026
c2bc74b
Merge branch 'struct-new-desc-syntax-validation' into exact-extern-fu…
tlively Jul 14, 2026
e4fd1bd
update tests
tlively Jul 14, 2026
153b685
update tests
tlively Jul 14, 2026
f1b94b8
fix parens
tlively Jul 14, 2026
de6816f
update tests
tlively Jul 14, 2026
f245509
Merge branch 'exact-heaptype-refactor' into struct-new-desc-syntax-va…
tlively Jul 14, 2026
abf31f3
Merge branch 'struct-new-desc-syntax-validation' into exact-extern-fu…
tlively Jul 14, 2026
75add5d
Merge branch 'exact-allocations' into ref-get-desc
tlively Jul 14, 2026
a889729
use exactness variable and update tests
tlively Jul 14, 2026
83977ac
Merge branch 'ref-get-desc' into cast-desc-eq-spec
tlively Jul 14, 2026
90248f3
use exactness vars and update tests
tlively Jul 14, 2026
952f3fb
Spectec for binary format of types and instructions
tlively Jul 16, 2026
290131a
Merge remote-tracking branch 'origin/main' into struct-new-desc-synta…
tlively Jul 24, 2026
29dcc39
Update prose and ExpandDesc => Expand_desc
tlively Jul 24, 2026
942e17c
Merge branch 'struct-new-desc-syntax-validation' into exact-extern-fu…
tlively Jul 24, 2026
e132360
Merge branch 'main' into struct-new-desc-syntax-validation
tlively Aug 17, 2026
655de1f
Merge branch 'struct-new-desc-syntax-validation' into exact-extern-fu…
tlively Aug 17, 2026
93c99a4
Merge branch 'main' into struct-new-desc-syntax-validation
tlively Sep 1, 2026
d4e6d66
Merge branch 'struct-new-desc-syntax-validation' into exact-extern-fu…
tlively Sep 1, 2026
c47c2df
Merge branch 'main' into struct-new-desc-syntax-validation
tlively Oct 5, 2026
606e534
Merge branch 'struct-new-desc-syntax-validation' into exact-extern-fu…
tlively Oct 5, 2026
a4b8421
Merge branch 'exact-extern-functype' into exact-allocations
tlively Oct 5, 2026
94ca608
Merge branch 'exact-allocations' into cast-desc-eq-spec
tlively Oct 5, 2026
7aeb249
Merge branch 'cast-desc-eq-spec' into spec-binary-format
tlively Oct 5, 2026
52229d7
Merge branch 'main' into exact-allocations
tlively Oct 23, 2026
262f245
Merge branch 'exact-allocations' into cast-desc-eq-spec
tlively Oct 23, 2026
c6d25c3
Merge branch 'cast-desc-eq-spec' into spec-binary-format
tlively Oct 23, 2026
d45ffc0
Merge branch 'main' into cast-desc-eq-spec
tlively Oct 23, 2026
9dd7bc4
Merge branch 'cast-desc-eq-spec' into spec-binary-format
tlively Oct 23, 2026
c2e4389
Merge branch 'main' into ref-get-desc
tlively Oct 23, 2026
6d4b2ad
Fix REFGETDESC macro and $free_instr
tlively Oct 23, 2026
68b3748
Merge branch 'ref-get-desc' into cast-desc-eq-spec
tlively Oct 23, 2026
d104a86
Fix descriptor cast validation rules and tests
tlively Oct 23, 2026
c61ac9b
Merge branch 'cast-desc-eq-spec' into spec-binary-format
tlively Oct 23, 2026
c83e603
Merge branch 'main' into cast-desc-eq-spec
tlively Oct 23, 2026
174ca0f
Merge branch 'cast-desc-eq-spec' into spec-binary-format
tlively Oct 23, 2026
caf78c7
Merge branch 'main' into spec-binary-format
tlively Oct 23, 2026
a3ef714
[spec] Binary format review fixes
tlively Oct 23, 2026
a82b087
[spec] Rename describestype/descriptortype to describes/descriptor
tlively Oct 23, 2026
98a8a19
Merge branch 'rename-describes-descriptor' into spec-binary-format
tlively Oct 24, 2026
8c2db5e
[spec] Update binary format for describes/descriptor rename
tlively Oct 24, 2026
356dfa2
Merge branch 'main' into spec-binary-format
tlively Oct 25, 2026
d1f8fce
simplify
tlively Oct 26, 2026
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
10 changes: 9 additions & 1 deletion document/core/appendix/index-instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,15 @@ def Instruction(version, name, opcode, type=None, validation=None, execution=Non
Instruction(3.0, r'\REFI31', r'\hex{FB}~\hex{1C}', r'[\I32] \to [(\REF~\I31)]', r'valid-ref.i31', r'exec-ref.i31'),
Instruction(3.0, r'\I31GETS', r'\hex{FB}~\hex{1D}', r'[\I31REF] \to [\I32]', r'valid-i31.get', r'exec-i31.get'),
Instruction(3.0, r'\I31GETU', r'\hex{FB}~\hex{1E}', r'[\I31REF] \to [\I32]', r'valid-i31.get', r'exec-i31.get'),
Instruction(0.0, None, r'\hex{FB}~\hex{1F} \dots'),
Instruction(0.0, None, r'\hex{FB}~\hex{1F}'),
Instruction(3.0, r'\STRUCTNEWDESC~x', r'\hex{FB}~\hex{20}', r'[t^\ast~(\REF~\NULL~(\EXACT~y))] \to [(\REF~(\EXACT~x))]', r'valid-struct.new_desc'),
Instruction(3.0, r'\STRUCTNEWDEFAULTDESC~x', r'\hex{FB}~\hex{21}', r'[(\REF~\NULL~(\EXACT~y))] \to [(\REF~(\EXACT~x))]', r'valid-struct.new_default_desc'),
Instruction(3.0, r'\REFGETDESC~x', r'\hex{FB}~\hex{22}', r'[(\REF~\NULL~\EXACT^?~x)] \to [(\REF~\EXACT^?~y)]', r'valid-ref.get_desc'),
Instruction(3.0, r'\REFCASTDESCEQ~(\REF~t)', r'\hex{FB}~\hex{23}', r"[(\REF~t')~(\REF~\NULL~(\EXACT~y))] \to [(\REF~t)]", r'valid-ref.cast_desc_eq'),
Instruction(3.0, r'\REFCASTDESCEQ~(\REF~\NULL~t)', r'\hex{FB}~\hex{24}', r"[(\REF~\NULL~t')~(\REF~\NULL~(\EXACT~y))] \to [(\REF~\NULL~t)]", r'valid-ref.cast_desc_eq'),
Instruction(3.0, r'\BRONCASTDESCEQ~t_1~t_2', r'\hex{FB}~\hex{25}', r'[t_1~(\REF~\NULL~(\EXACT~y))] \to [t_1\reftypediff t_2]', r'valid-br_on_cast_desc_eq'),
Instruction(3.0, r'\BRONCASTDESCEQFAIL~t_1~t_2', r'\hex{FB}~\hex{26}', r'[t_1~(\REF~\NULL~(\EXACT~y))] \to [t_2]', r'valid-br_on_cast_desc_eq_fail'),
Instruction(0.0, None, r'\hex{FB}~\hex{27} \dots'),
Instruction(2.0, r'\I32.\TRUNC\K{\_sat\_}\F32\K{\_s}', r'\hex{FC}~\hex{00}', r'[\F32] \to [\I32]', r'valid-cvtop', r'exec-cvtop', r'op-trunc_sat'),
Instruction(2.0, r'\I32.\TRUNC\K{\_sat\_}\F32\K{\_u}', r'\hex{FC}~\hex{01}', r'[\F32] \to [\I32]', r'valid-cvtop', r'exec-cvtop', r'op-trunc_sat'),
Instruction(2.0, r'\I32.\TRUNC\K{\_sat\_}\F64\K{\_s}', r'\hex{FC}~\hex{02}', r'[\F64] \to [\I32]', r'valid-cvtop', r'exec-cvtop', r'op-trunc_sat'),
Expand Down
11 changes: 7 additions & 4 deletions document/core/appendix/index-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ Category Constructor
(reserved) :math:`\hex{68}` .. :math:`\hex{65}`
:ref:`Reference type <syntax-reftype>` |REF| :math:`\hex{64}` (-28 as |Bs7|)
:ref:`Reference type <syntax-reftype>` |REF| |NULL| :math:`\hex{63}` (-29 as |Bs7|)
(reserved) :math:`\hex{62}` .. :math:`\hex{61}`
:ref:`Heap type <syntax-heaptype>` :math:`\EXACT~\typeidx` :math:`\hex{62}` (-30 as |Bs7|)
(reserved) :math:`\hex{61}`
:ref:`Composite type <syntax-comptype>` :math:`\TFUNC~[\valtype^\ast] \Tarrow[\valtype^\ast]` :math:`\hex{60}` (-32 as |Bs7|)
:ref:`Composite type <syntax-comptype>` :math:`\TSTRUCT~\fieldtype^\ast` :math:`\hex{5F}` (-33 as |Bs7|)
:ref:`Composite type <syntax-comptype>` :math:`\TARRAY~\fieldtype` :math:`\hex{5E}` (-34 as |Bs7|)
(reserved) :math:`\hex{5D}` .. :math:`\hex{51}`
:ref:`Sub type <syntax-subtype>` :math:`\TSUB~\typeidx^\ast~\comptype` :math:`\hex{50}` (-48 as |Bs7|)
:ref:`Sub type <syntax-subtype>` :math:`\TSUB~\TFINAL~\typeidx^\ast~\comptype` :math:`\hex{4F}` (-49 as |Bs7|)
:ref:`Sub type <syntax-subtype>` :math:`\TSUB~\typeidx^\ast~\desctype` :math:`\hex{50}` (-48 as |Bs7|)
:ref:`Sub type <syntax-subtype>` :math:`\TSUB~\TFINAL~\typeidx^\ast~\desctype` :math:`\hex{4F}` (-49 as |Bs7|)
:ref:`Recursive type <syntax-rectype>` :math:`\TREC~\subtype^\ast` :math:`\hex{4E}` (-50 as |Bs7|)
(reserved) :math:`\hex{4D}` .. :math:`\hex{41}`
:ref:`Descriptor type <syntax-desctype>` :math:`\TDESCRIPTOR~\typeidx` :math:`\hex{4D}` (-51 as |Bs7|)
:ref:`Descriptor type <syntax-desctype>` :math:`\TDESCRIBES~\typeidx` :math:`\hex{4C}` (-52 as |Bs7|)
(reserved) :math:`\hex{4B}` .. :math:`\hex{41}`
:ref:`Result type <syntax-resulttype>` :math:`[\epsilon]` :math:`\hex{40}` (-64 as |Bs7|)
:ref:`Tag type <syntax-tagtype>` :math:`\typeuse` (none)
:ref:`Global type <syntax-globaltype>` :math:`\mut~\valtype` (none)
Expand Down
6 changes: 6 additions & 0 deletions document/core/binary/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Control Instructions
.. _binary-br_on_non_null:
.. _binary-br_on_cast:
.. _binary-br_on_cast_fail:
.. _binary-br_on_cast_desc_eq:
.. _binary-br_on_cast_desc_eq_fail:
.. _binary-return:
.. _binary-call:
.. _binary-call_ref:
Expand Down Expand Up @@ -158,6 +160,8 @@ Generic :ref:`reference instructions <syntax-instr-ref>` are represented by sing
.. _binary-ref.as_non_null:
.. _binary-ref.test:
.. _binary-ref.cast:
.. _binary-ref.get_desc:
.. _binary-ref.cast_desc_eq:

$${grammar: {Binstr/ref}}

Expand All @@ -176,6 +180,8 @@ Aggregate Instructions
.. _binary-i31.get_u:
.. _binary-struct.new:
.. _binary-struct.new_default:
.. _binary-struct.new_desc:
.. _binary-struct.new_default_desc:
.. _binary-struct.get:
.. _binary-struct.get_s:
.. _binary-struct.get_u:
Expand Down
11 changes: 8 additions & 3 deletions document/core/binary/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $${grammar: Bvectype}
Heap Types
~~~~~~~~~~

:ref:`Heap types <syntax-reftype>` are encoded as either a single byte, or as a :ref:`type index <binary-typeidx>` encoded as a positive :ref:`signed integer <binary-sint>`.
:ref:`Heap types <syntax-heaptype>` are encoded as either a single byte, as the byte ${:0x62} followed by a :ref:`type index <binary-typeidx>`, or as a :ref:`type index <binary-typeidx>` encoded as a positive :ref:`signed integer <binary-sint>`.

$${grammar: Babsheaptype Bheaptype}

Expand Down Expand Up @@ -118,19 +118,24 @@ Composite Types
$${grammar: Bmut Bcomptype Bfieldtype Bstoragetype Bpacktype}


.. index:: recursive type, sub type, composite type
.. index:: recursive type, sub type, descriptor type, composite type
pair: binary format; recursive type
pair: binary format; sub type
pair: binary format; descriptor type
.. _binary-rectype:
.. _binary-subtype:
.. _binary-desctype:
.. _binary-describes:
.. _binary-descriptor:

Recursive Types
~~~~~~~~~~~~~~~

:ref:`Recursive types <syntax-rectype>` are encoded by the byte ${:0x4E} followed by a :ref:`list <binary-list>` of :ref:`sub types <syntax-subtype>`.
Additional shorthands are recognized for unary recursions and sub types without super types.
Each :ref:`composite type <binary-comptype>` may be preceded by a :ref:`describes <syntax-desctype>` clause encoded by the byte ${:0x4C} and a :ref:`type index <binary-typeidx>`, and a :ref:`descriptor <syntax-desctype>` clause encoded by the byte ${:0x4D} and a :ref:`type index <binary-typeidx>`.

$${grammar: Brectype Bsubtype}
$${grammar: Brectype Bsubtype Bdesctype Bdescribes Bdescriptor}


.. index:: limits
Expand Down
3 changes: 3 additions & 0 deletions document/core/util/macros.def
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,9 @@
.. |Bstoragetype| mathdef:: \xref{binary/types}{binary-storagetype}{\B{storagetype}}
.. |Bpacktype| mathdef:: \xref{binary/types}{binary-packtype}{\B{packtype}}
.. |Bcomptype| mathdef:: \xref{binary/types}{binary-comptype}{\B{comptype}}
.. |Bdescribes| mathdef:: \xref{binary/types}{binary-describes}{\B{describes}}
.. |Bdescriptor| mathdef:: \xref{binary/types}{binary-descriptor}{\B{descriptor}}
.. |Bdesctype| mathdef:: \xref{binary/types}{binary-desctype}{\B{desctype}}
.. |Bsubtype| mathdef:: \xref{binary/types}{binary-subtype}{\B{subtype}}
.. |Brectype| mathdef:: \xref{binary/types}{binary-rectype}{\B{rectype}}
.. |Bglobaltype| mathdef:: \xref{binary/types}{binary-globaltype}{\B{globaltype}}
Expand Down
16 changes: 13 additions & 3 deletions specification/wasm-latest/5.2-binary.types.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ grammar Babsheaptype : heaptype =

grammar Bheaptype : heaptype =
| ht:Babsheaptype => ht
| 0x62 x:Btypeidx => _HT EXACT (_IDX x)
| x33:Bs33 => _HT (_IDX $s33_to_u32(x33)) -- if x33 >= 0

grammar Breftype : reftype =
Expand Down Expand Up @@ -68,10 +69,19 @@ grammar Bcomptype : comptype =
| 0x5F ft*:Blist(Bfieldtype) => STRUCT ft*
| 0x60 t_1*:Bresulttype t_2*:Bresulttype => FUNC t_1* -> t_2*

grammar Bdescribes : describes =
| 0x4C x:Btypeidx => DESCRIBES (_IDX x)

grammar Bdescriptor : descriptor =
| 0x4D x:Btypeidx => DESCRIPTOR (_IDX x)

grammar Bdesctype : desctype =
| (dcs:Bdescribes)? (dcr:Bdescriptor)? ct:Bcomptype => dcs? dcr? ct

grammar Bsubtype : subtype =
| 0x4F x*:Blist(Btypeidx) ct:Bcomptype => SUB FINAL (_IDX x)* ct
| 0x50 x*:Blist(Btypeidx) ct:Bcomptype => SUB (_IDX x)* ct
| ct:Bcomptype => SUB FINAL eps ct
| 0x4F x*:Blist(Btypeidx) dct:Bdesctype => SUB FINAL (_IDX x)* dct
| 0x50 x*:Blist(Btypeidx) dct:Bdesctype => SUB (_IDX x)* dct
| dct:Bdesctype => SUB FINAL eps dct

grammar Brectype : rectype =
| 0x4E st*:Blist(Bsubtype) => REC st*
Expand Down
9 changes: 9 additions & 0 deletions specification/wasm-latest/5.3-binary.instructions.spectec
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ grammar Binstr/control : instr = ...
l:Blabelidx ht_1:Bheaptype ht_2:Bheaptype => BR_ON_CAST l (REF null_1? ht_1) (REF null_2? ht_2)
| 0xFB 25:Bu32 (null_1?, null_2?):Bcastop
l:Blabelidx ht_1:Bheaptype ht_2:Bheaptype => BR_ON_CAST_FAIL l (REF null_1? ht_1) (REF null_2? ht_2)
| 0xFB 37:Bu32 (null_1?, null_2?):Bcastop
l:Blabelidx ht_1:Bheaptype ht_2:Bheaptype => BR_ON_CAST_DESC_EQ l (REF null_1? ht_1) (REF null_2? ht_2)
| 0xFB 38:Bu32 (null_1?, null_2?):Bcastop
l:Blabelidx ht_1:Bheaptype ht_2:Bheaptype => BR_ON_CAST_DESC_EQ_FAIL l (REF null_1? ht_1) (REF null_2? ht_2)
| ...

grammar Bcatch : catch =
Expand Down Expand Up @@ -146,11 +150,16 @@ grammar Binstr/ref : instr = ...
| 0xFB 21:Bu32 ht:Bheaptype => REF.TEST (REF NULL ht)
| 0xFB 22:Bu32 ht:Bheaptype => REF.CAST (REF ht)
| 0xFB 23:Bu32 ht:Bheaptype => REF.CAST (REF NULL ht)
| 0xFB 34:Bu32 x:Btypeidx => REF.GET_DESC x
| 0xFB 35:Bu32 ht:Bheaptype => REF.CAST_DESC_EQ (REF ht)
| 0xFB 36:Bu32 ht:Bheaptype => REF.CAST_DESC_EQ (REF NULL ht)
| ...

grammar Binstr/struct : instr = ...
| 0xFB 0:Bu32 x:Btypeidx => STRUCT.NEW x
| 0xFB 1:Bu32 x:Btypeidx => STRUCT.NEW_DEFAULT x
| 0xFB 32:Bu32 x:Btypeidx => STRUCT.NEW_DESC x
| 0xFB 33:Bu32 x:Btypeidx => STRUCT.NEW_DEFAULT_DESC x
| 0xFB 2:Bu32 x:Btypeidx i:Bfieldidx => STRUCT.GET x i
| 0xFB 3:Bu32 x:Btypeidx i:Bfieldidx => STRUCT.GET S x i
| 0xFB 4:Bu32 x:Btypeidx i:Bfieldidx => STRUCT.GET U x i
Expand Down
Loading
Loading