diff --git a/document/core/appendix/index-instructions.py b/document/core/appendix/index-instructions.py index f779a6b668..0169d91b67 100755 --- a/document/core/appendix/index-instructions.py +++ b/document/core/appendix/index-instructions.py @@ -280,9 +280,9 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat 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'\REFASNONNULL', r'\hex{D3}', 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{D4}', r'[t^\ast~(\REF~\NULL~\X{ht})] \to [t^\ast~(\REF~\X{ht})]', r'valid-br_on_null', r'exec-br_on_null'), - Instruction(r'\REFEQ', r'\hex{D5}', r'[\EQREF~\EQREF] \to [\I32]', r'valid-ref.eq', r'exec-ref.eq'), + 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'), Instruction(r'\BRONNONNULL~l', r'\hex{D6}', r'[t^\ast~(\REF~\NULL~\X{ht})] \to [t^\ast]', r'valid-br_on_non_null', r'exec-br_on_non_null'), Instruction(None, r'\hex{D7}'), Instruction(None, r'\hex{D8}'), diff --git a/document/core/appendix/index-types.rst b/document/core/appendix/index-types.rst index 5d31e71c01..854eb4e17a 100644 --- a/document/core/appendix/index-types.rst +++ b/document/core/appendix/index-types.rst @@ -26,9 +26,10 @@ Category Constructor :ref:`Heap type ` |I31| :math:`\hex{6C}` (-20 as |Bs7|) :ref:`Heap type ` |STRUCT| :math:`\hex{6B}` (-21 as |Bs7|) :ref:`Heap type ` |ARRAY| :math:`\hex{6A}` (-22 as |Bs7|) +(reserved) :math:`\hex{69}` .. :math:`\hex{65}` :ref:`Reference type ` |REF| :math:`\hex{64}` (-28 as |Bs7|) :ref:`Reference type ` |REF| |NULL| :math:`\hex{63}` (-29 as |Bs7|) -(reserved) :math:`\hex{64}` .. :math:`\hex{61}` +(reserved) :math:`\hex{62}` .. :math:`\hex{61}` :ref:`Composite type ` :math:`\TFUNC~[\valtype^\ast] \toF[\valtype^\ast]` :math:`\hex{60}` (-32 as |Bs7|) :ref:`Composite type ` :math:`\TSTRUCT~\fieldtype^\ast` :math:`\hex{5F}` (-33 as |Bs7|) :ref:`Composite type ` :math:`\TARRAY~\fieldtype` :math:`\hex{5E}` (-34 as |Bs7|) diff --git a/document/core/binary/instructions.rst b/document/core/binary/instructions.rst index a23c02cf0e..8e92770195 100644 --- a/document/core/binary/instructions.rst +++ b/document/core/binary/instructions.rst @@ -75,7 +75,7 @@ Control Instructions \hex{13}~~y{:}\Btypeidx~~x{:}\Btableidx &\Rightarrow& \RETURNCALLINDIRECT~x~y \\ &&|& \hex{14}~~x{:}\Btypeidx &\Rightarrow& \CALLREF~x \\ &&|& \hex{15}~~x{:}\Btypeidx &\Rightarrow& \RETURNCALLREF~x \\ &&|& - \hex{D4}~~l{:}\Blabelidx &\Rightarrow& \BRONNULL~l \\ &&|& + \hex{D5}~~l{:}\Blabelidx &\Rightarrow& \BRONNULL~l \\ &&|& \hex{D6}~~l{:}\Blabelidx &\Rightarrow& \BRONNONNULL~l \\ &&|& \hex{FB}~~24{:}\Bu32~~(\NULL_1^?,\NULL_2^?){:}\Bcastflags\\&&&~~~~l{:}\Blabelidx~~\X{ht}_1{:}\Bheaptype~~\X{ht}_2{:}\Bheaptype &\Rightarrow& \BRONCAST~l~(\REF~\NULL_1^?~\X{ht}_1)~(\REF~\NULL_2^?~\X{ht}_2) \\ &&|& \hex{FB}~~25{:}\Bu32~~(\NULL_1^?,\NULL_2^?){:}\Bcastflags\\&&&~~~~l{:}\Blabelidx~~\X{ht}_1{:}\Bheaptype~~\X{ht}_2{:}\Bheaptype &\Rightarrow& \BRONCASTFAIL~l~(\REF~\NULL_1^?~\X{ht}_1)~(\REF~\NULL_2^?~\X{ht}_2) \\ @@ -140,8 +140,8 @@ Generic :ref:`reference instructions ` are represented by sing \hex{D0}~~t{:}\Bheaptype &\Rightarrow& \REFNULL~t \\ &&|& \hex{D1} &\Rightarrow& \REFISNULL \\ &&|& \hex{D2}~~x{:}\Bfuncidx &\Rightarrow& \REFFUNC~x \\ &&|& - \hex{D3} &\Rightarrow& \REFASNONNULL \\ &&|& - \hex{D5} &\Rightarrow& \REFEQ \\ &&|& + \hex{D3} &\Rightarrow& \REFEQ \\ &&|& + \hex{D4} &\Rightarrow& \REFASNONNULL \\ &&|& \hex{FB}~~0{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \STRUCTNEW~x \\ &&|& \hex{FB}~~1{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \STRUCTNEWDEFAULT~x \\ &&|& \hex{FB}~~2{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTGET~x~i \\ &&|& diff --git a/interpreter/binary/decode.ml b/interpreter/binary/decode.ml index cbff7fb2b3..10dcceabc1 100644 --- a/interpreter/binary/decode.ml +++ b/interpreter/binary/decode.ml @@ -581,9 +581,9 @@ let rec instr s = | 0xd0 -> ref_null (heap_type s) | 0xd1 -> ref_is_null | 0xd2 -> ref_func (at var s) - | 0xd3 -> ref_as_non_null - | 0xd4 -> br_on_null (at var s) - | 0xd5 -> ref_eq + | 0xd3 -> ref_eq + | 0xd4 -> ref_as_non_null + | 0xd5 -> br_on_null (at var s) | 0xd6 -> br_on_non_null (at var s) | 0xfb as b -> diff --git a/interpreter/binary/encode.ml b/interpreter/binary/encode.ml index fe7be0db6e..de5047446e 100644 --- a/interpreter/binary/encode.ml +++ b/interpreter/binary/encode.ml @@ -245,7 +245,7 @@ struct | Br x -> op 0x0c; var x | BrIf x -> op 0x0d; var x | BrTable (xs, x) -> op 0x0e; vec var xs; var x - | BrOnNull x -> op 0xd4; var x + | BrOnNull x -> op 0xd5; var x | BrOnNonNull x -> op 0xd6; var x | BrOnCast (x, (nul1, t1), (nul2, t2)) -> let flags = bit 0 (nul1 = Null) + bit 1 (nul2 = Null) in @@ -376,15 +376,15 @@ struct | RefNull t -> op 0xd0; heap_type t | RefFunc x -> op 0xd2; var x + | RefEq -> op 0xd3 + | RefIsNull -> op 0xd1 - | RefAsNonNull -> op 0xd3 + | RefAsNonNull -> op 0xd4 | RefTest (NoNull, t) -> op 0xfb; op 0x14; heap_type t | RefTest (Null, t) -> op 0xfb; op 0x15; heap_type t | RefCast (NoNull, t) -> op 0xfb; op 0x16; heap_type t | RefCast (Null, t) -> op 0xfb; op 0x17; heap_type t - | RefEq -> op 0xd5 - | I31New -> op 0xfb; op 0x1c | I31Get SX -> op 0xfb; op 0x1d | I31Get ZX -> op 0xfb; op 0x1e