From 9acb6e2c82edcc6873b8fdb7d36c7fdd8e8e403a Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Mon, 31 Jul 2023 17:59:02 +0200 Subject: [PATCH] Final opcodes (#372) Co-authored-by: Thomas Lively --- document/core/appendix/index-instructions.py | 85 ++++++++----- document/core/appendix/index-types.rst | 22 ++-- document/core/binary/instructions.rst | 60 ++++----- document/core/binary/types.rst | 22 ++-- interpreter/binary/decode.ml | 112 +++++++++-------- interpreter/binary/encode.ml | 101 ++++++++------- proposals/gc/MVP.md | 124 ++++++++++--------- 7 files changed, 282 insertions(+), 244 deletions(-) diff --git a/document/core/appendix/index-instructions.py b/document/core/appendix/index-instructions.py index 8d33768ab..f779a6b66 100755 --- a/document/core/appendix/index-instructions.py +++ b/document/core/appendix/index-instructions.py @@ -320,37 +320,38 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(None, r'\hex{F8}'), Instruction(None, r'\hex{F9}'), Instruction(None, r'\hex{FA}'), - Instruction(r'\STRUCTNEW~x', r'\hex{FB}~\hex{01}', r'[t^\ast] \to [(\REF~x)]', r'valid-struct.new', r'exec-struct.new'), - Instruction(r'\STRUCTNEWDEFAULT~x', r'\hex{FB}~\hex{02}', r'[] \to [(\REF~x)]', r'valid-struct.new_default', r'exec-struct.new_default'), - Instruction(r'\STRUCTGET~x~i', r'\hex{FB}~\hex{03}', r'[(\REF~\NULL~x)] \to [t]', r'valid-struct.get', r'exec-struct.get'), - Instruction(r'\STRUCTGETS~x~i', r'\hex{FB}~\hex{04}', r'[(\REF~\NULL~x)] \to [\I32]', r'valid-struct.get', r'exec-struct.get'), - Instruction(r'\STRUCTGETU~x~i', r'\hex{FB}~\hex{05}', r'[(\REF~\NULL~x)] \to [\I32]', r'valid-struct.get', r'exec-struct.get'), - Instruction(r'\STRUCTSET~x~i', r'\hex{FB}~\hex{06}', r'[(\REF~\NULL~x)~t] \to []', r'valid-struct.set', r'exec-struct.set'), - Instruction(r'\ARRAYFILL~x', r'\hex{FB}~\hex{0F}', r'[(\REF~\NULL~x)~\I32~t~\I32] \to []', r'valid-array.fill', r'exec-array.fill'), - Instruction(r'\ARRAYNEW~x', r'\hex{FB}~\hex{11}', r'[t] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'), - Instruction(r'\ARRAYNEWDEFAULT~x', r'\hex{FB}~\hex{12}', r'[] \to [(\REF~x)]', r'valid-array.new', r'exec-array.new'), - Instruction(r'\ARRAYGET~x', r'\hex{FB}~\hex{13}', r'[(\REF~\NULL~x)~\I32] \to [t]', r'valid-array.get', r'exec-array.get'), - Instruction(r'\ARRAYGETS~x', r'\hex{FB}~\hex{14}', r'[(\REF~\NULL~x)~\I32] \to [\I32]', r'valid-array.get', r'exec-array.get'), - Instruction(r'\ARRAYGETU~x', r'\hex{FB}~\hex{15}', r'[(\REF~\NULL~x)~\I32] \to [\I32]', r'valid-array.get', r'exec-array.get'), - Instruction(r'\ARRAYSET~x', r'\hex{FB}~\hex{16}', r'[(\REF~\NULL~x)~\I32~t] \to []', r'valid-array.set', r'exec-array.set'), - Instruction(r'\ARRAYLEN', r'\hex{FB}~\hex{17}', r'[\ARRAYREF] \to []', r'valid-array.len', r'exec-array.len'), - Instruction(r'\ARRAYCOPY~x~y', r'\hex{FB}~\hex{18}', r'[(\REF~\NULL~x)~\I32~(\REF~\NULL~y)~\I32~\I32] \to []', r'valid-array.copy', r'exec-array.copy'), - Instruction(r'\ARRAYNEWFIXED~x~n', r'\hex{FB}~\hex{19}', 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{1B}', 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{1C}', r'[\I32~\I32] \to [(\REF~x)]', r'valid-array.new_elem', r'exec-array.new_elem'), - Instruction(r'\I31NEW', r'\hex{FB}~\hex{20}', r'[\I32] \to [\I31REF]', r'valid-i31.new', r'exec-i31.new'), - Instruction(r'\I31GETS', r'\hex{FB}~\hex{21}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'), - Instruction(r'\I31GETU', r'\hex{FB}~\hex{22}', r'[\I31REF] \to [\I32]', r'valid-i31.get_sx', r'exec-i31.get_sx'), - Instruction(r'\REFTEST~(\REF~t)', r'\hex{FB}~\hex{40}', r"[(\REF~t')] \to [\I32]", r'valid-ref.test', r'exec-ref.test'), - Instruction(r'\REFCAST~(\REF~t)', r'\hex{FB}~\hex{41}', r"[(\REF~t')] \to [(\REF~t)]", r'valid-ref.test', r'exec-ref.test'), - Instruction(r'\REFTEST~(\REF~\NULL~t)', r'\hex{FB}~\hex{48}', r"[(REF~\NULL~t')] \to [\I32]", r'valid-ref.test', r'exec-ref.test'), - Instruction(r'\REFCAST~(\REF~\NULL~t)', r'\hex{FB}~\hex{49}', 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{4E}', 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{4F}', r'[t_1] \to [t_2]', r'valid-br_on_cast_fail', r'exec-br_on_cast_fail'), - Instruction(r'\ARRAYINITDATA~x~y', r'\hex{FB}~\hex{54}', r'[(\REF~\NULL~x)~\I32~\I32~\I32] \to []', r'valid-array.init_data', r'exec-array.init_data'), - Instruction(r'\ARRAYINITELEM~x~y', r'\hex{FB}~\hex{55}', r'[(\REF~\NULL~x)~\I32~\I32~\I32] \to []', r'valid-array.init_elem', r'exec-array.init_elem'), - Instruction(r'\EXTERNINTERNALIZE', r'\hex{FB}~\hex{70}', r'[\EXTERNREF] \to [\ANYREF]', r'valid-extern.internalize', r'exec-extern.internalize'), - Instruction(r'\EXTERNEXTERNALIZE', r'\hex{FB}~\hex{71}', r'[\ANYREF] \to [\EXTERNREF]', r'valid-extern.externalize', r'exec-extern.externalize'), + Instruction(r'\STRUCTNEW~x', r'\hex{FB}~\hex{00}', r'[t^\ast] \to [(\REF~x)]', r'valid-struct.new', r'exec-struct.new'), + Instruction(r'\STRUCTNEWDEFAULT~x', r'\hex{FB}~\hex{01}', r'[] \to [(\REF~x)]', r'valid-struct.new_default', r'exec-struct.new_default'), + Instruction(r'\STRUCTGET~x~i', r'\hex{FB}~\hex{02}', r'[(\REF~\NULL~x)] \to [t]', r'valid-struct.get', r'exec-struct.get'), + Instruction(r'\STRUCTGETS~x~i', r'\hex{FB}~\hex{03}', r'[(\REF~\NULL~x)] \to [\I32]', r'valid-struct.get', r'exec-struct.get'), + Instruction(r'\STRUCTGETU~x~i', r'\hex{FB}~\hex{04}', r'[(\REF~\NULL~x)] \to [\I32]', r'valid-struct.get', r'exec-struct.get'), + Instruction(r'\STRUCTSET~x~i', 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'\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'\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'), + Instruction(r'\ARRAYINITELEM~x~y', r'\hex{FB}~\hex{13}', r'[(\REF~\NULL~x)~\I32~\I32~\I32] \to []', r'valid-array.init_elem', r'exec-array.init_elem'), + Instruction(r'\REFTEST~(\REF~t)', r'\hex{FB}~\hex{14}', r"[(\REF~t')] \to [\I32]", r'valid-ref.test', r'exec-ref.test'), + Instruction(r'\REFTEST~(\REF~\NULL~t)', r'\hex{FB}~\hex{15}', r"[(REF~\NULL~t')] \to [\I32]", r'valid-ref.test', r'exec-ref.test'), + Instruction(r'\REFCAST~(\REF~t)', r'\hex{FB}~\hex{16}', r"[(\REF~t')] \to [(\REF~t)]", r'valid-ref.test', r'exec-ref.test'), + 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'\I31NEW', r'\hex{FB}~\hex{1C}', r'[\I32] \to [\I31REF]', r'valid-i31.new', r'exec-i31.new'), + 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'), + Instruction(None, r'\hex{FB}~\hex{1E} \dots'), Instruction(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_s'), Instruction(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_u'), Instruction(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_s'), @@ -369,6 +370,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\TABLEGROW~x', r'\hex{FC}~\hex{0F}', r'[t~\I32] \to [\I32]', r'valid-table.grow', r'exec-table.grow'), Instruction(r'\TABLESIZE~x', r'\hex{FC}~\hex{10}', r'[] \to [\I32]', r'valid-table.size', r'exec-table.size'), Instruction(r'\TABLEFILL~x', r'\hex{FC}~\hex{11}', r'[\I32~t~\I32] \to []', r'valid-table.fill', r'exec-table.fill'), + Instruction(None, r'\hex{FC}~\hex{1E} \dots'), Instruction(r'\V128.\LOAD~\memarg', r'\hex{FD}~~\hex{00}', r'[\I32] \to [\V128]', r'valid-load', r'exec-load'), Instruction(r'\V128.\LOAD\K{8x8\_s}~\memarg', r'\hex{FD}~~\hex{01}', r'[\I32] \to [\V128]', r'valid-load-extend', r'exec-load-extend'), Instruction(r'\V128.\LOAD\K{8x8\_u}~\memarg', r'\hex{FD}~~\hex{02}', r'[\I32] \to [\V128]', r'valid-load-extend', r'exec-load-extend'), @@ -523,6 +525,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\I16X8.\VMIN\K{\_u}', r'\hex{FD}~~\hex{97}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-imin_u'), Instruction(r'\I16X8.\VMAX\K{\_s}', r'\hex{FD}~~\hex{98}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-imax_s'), Instruction(r'\I16X8.\VMAX\K{\_u}', r'\hex{FD}~~\hex{99}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-imax_u'), + Instruction(None, r'\hex{FD}~\hex{9A}~\hex{01}'), Instruction(r'\I16X8.\AVGR\K{\_u}', r'\hex{FD}~~\hex{9B}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-iavgr_u'), Instruction(r'\I16X8.\EXTMUL\K{\_low\_i8x16\_s}', r'\hex{FD}~~\hex{9C}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vec-extmul', r'exec-vec-extmul'), Instruction(r'\I16X8.\EXTMUL\K{\_high\_i8x16\_s}', r'\hex{FD}~~\hex{9D}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vec-extmul', r'exec-vec-extmul'), @@ -530,8 +533,11 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\I16X8.\EXTMUL\K{\_high\_i8x16\_u}', r'\hex{FD}~~\hex{9F}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vec-extmul', r'exec-vec-extmul'), Instruction(r'\I32X4.\VABS', r'\hex{FD}~~\hex{A0}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-iabs'), Instruction(r'\I32X4.\VNEG', r'\hex{FD}~~\hex{A1}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-ineg'), + Instruction(None, r'\hex{FD}~\hex{A2}~\hex{01}'), Instruction(r'\I32X4.\ALLTRUE', r'\hex{FD}~~\hex{A3}~~\hex{01}', r'[\V128] \to [\I32]', r'valid-vtestop', r'exec-vtestop'), Instruction(r'\I32X4.\BITMASK', r'\hex{FD}~~\hex{A4}~~\hex{01}', r'[\V128] \to [\I32]', r'valid-vec-bitmask', r'exec-vec-bitmask'), + Instruction(None, r'\hex{FD}~\hex{A5}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{A6}~\hex{01}'), Instruction(r'\I32X4.\VEXTEND\K{\_low\_i16x8\_s}', r'\hex{FD}~~\hex{A7}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vcvtop'), Instruction(r'\I32X4.\VEXTEND\K{\_high\_i16x8\_s}', r'\hex{FD}~~\hex{A8}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vcvtop'), Instruction(r'\I32X4.\VEXTEND\K{\_low\_i16x8\_u}', r'\hex{FD}~~\hex{A9}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vcvtop'), @@ -540,7 +546,12 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\I32X4.\VSHR\K{\_s}', r'\hex{FD}~~\hex{AC}~~\hex{01}', r'[\V128~\I32] \to [\V128]', r'valid-vishiftop', r'exec-vishiftop', r'op-ishr_s'), Instruction(r'\I32X4.\VSHR\K{\_u}', r'\hex{FD}~~\hex{AD}~~\hex{01}', r'[\V128~\I32] \to [\V128]', r'valid-vishiftop', r'exec-vishiftop', r'op-ishr_u'), Instruction(r'\I32X4.\VADD', r'\hex{FD}~~\hex{AE}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-iadd'), + Instruction(None, r'\hex{FD}~\hex{AF}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{B0}~\hex{01}'), Instruction(r'\I32X4.\VSUB', r'\hex{FD}~~\hex{B1}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-isub'), + Instruction(None, r'\hex{FD}~\hex{B2}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{B3}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{B4}~\hex{01}'), Instruction(r'\I32X4.\VMUL', r'\hex{FD}~~\hex{B5}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-imul'), Instruction(r'\I32X4.\VMIN\K{\_s}', r'\hex{FD}~~\hex{B6}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-imin_s'), Instruction(r'\I32X4.\VMIN\K{\_u}', r'\hex{FD}~~\hex{B7}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-imin_u'), @@ -553,8 +564,11 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\I32X4.\EXTMUL\K{\_high\_i16x8\_u}', r'\hex{FD}~~\hex{BF}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vec-extmul', r'exec-vec-extmul'), Instruction(r'\I64X2.\VABS', r'\hex{FD}~~\hex{C0}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-iabs'), Instruction(r'\I64X2.\VNEG', r'\hex{FD}~~\hex{C1}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-ineg'), + Instruction(None, r'\hex{FD}~\hex{C2}~\hex{01}'), Instruction(r'\I64X2.\ALLTRUE', r'\hex{FD}~~\hex{C3}~~\hex{01}', r'[\V128] \to [\I32]', r'valid-vtestop', r'exec-vtestop'), Instruction(r'\I64X2.\BITMASK', r'\hex{FD}~~\hex{C4}~~\hex{01}', r'[\V128] \to [\I32]', r'valid-vec-bitmask', r'exec-vec-bitmask'), + Instruction(None, r'\hex{FD}~\hex{C5}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{C6}~\hex{01}'), Instruction(r'\I64X2.\VEXTEND\K{\_low\_i32x4\_s}', r'\hex{FD}~~\hex{C7}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vcvtop'), Instruction(r'\I64X2.\VEXTEND\K{\_high\_i32x4\_s}', r'\hex{FD}~~\hex{C8}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vcvtop'), Instruction(r'\I64X2.\VEXTEND\K{\_low\_i32x4\_u}', r'\hex{FD}~~\hex{C9}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vcvtop'), @@ -563,7 +577,12 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\I64X2.\VSHR\K{\_s}', r'\hex{FD}~~\hex{CC}~~\hex{01}', r'[\V128~\I32] \to [\V128]', r'valid-vishiftop', r'exec-vishiftop', r'op-ishr_s'), Instruction(r'\I64X2.\VSHR\K{\_u}', r'\hex{FD}~~\hex{CD}~~\hex{01}', r'[\V128~\I32] \to [\V128]', r'valid-vishiftop', r'exec-vishiftop', r'op-ishr_u'), Instruction(r'\I64X2.\VADD', r'\hex{FD}~~\hex{CE}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-iadd'), + Instruction(None, r'\hex{FD}~\hex{CF}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{D0}~\hex{01}'), Instruction(r'\I64X2.\VSUB', r'\hex{FD}~~\hex{D1}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-isub'), + Instruction(None, r'\hex{FD}~\hex{D2}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{D3}~\hex{01}'), + Instruction(None, r'\hex{FD}~\hex{D4}~\hex{01}'), Instruction(r'\I64X2.\VMUL', r'\hex{FD}~~\hex{D5}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-imul'), Instruction(r'\I64X2.\VEQ', r'\hex{FD}~~\hex{D6}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-ieq'), Instruction(r'\I64X2.\VNE', r'\hex{FD}~~\hex{D7}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-ine'), @@ -577,6 +596,7 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\I64X2.\EXTMUL\K{\_high\_i32x4\_u}', r'\hex{FD}~~\hex{DF}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vec-extmul', r'exec-vec-extmul'), Instruction(r'\F32X4.\VABS', r'\hex{FD}~~\hex{E0}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-fabs'), Instruction(r'\F32X4.\VNEG', r'\hex{FD}~~\hex{E1}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-fneg'), + Instruction(None, r'\hex{FD}~\hex{E2}~\hex{01}'), Instruction(r'\F32X4.\VSQRT', r'\hex{FD}~~\hex{E3}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vunop', r'exec-vunop', r'op-fsqrt'), Instruction(r'\F32X4.\VADD', r'\hex{FD}~~\hex{E4}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-fadd'), Instruction(r'\F32X4.\VSUB', r'\hex{FD}~~\hex{E5}~~\hex{01}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-fsub'), @@ -605,6 +625,9 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat Instruction(r'\I32X4.\VTRUNC\K{\_sat\_f64x2\_u\_zero}', r'\hex{FD}~~\hex{FD}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-trunc_sat_u'), Instruction(r'\F64X2.\VCONVERT\K{\_low\_i32x4\_s}', r'\hex{FD}~~\hex{FE}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-convert_s'), Instruction(r'\F64X2.\VCONVERT\K{\_low\_i32x4\_u}', r'\hex{FD}~~\hex{FF}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-convert_u'), + Instruction(None, r'\hex{FD}~\hex{00}~\hex{02} \dots'), + Instruction(None, r'\hex{FE}'), + Instruction(None, r'\hex{FF}'), ] diff --git a/document/core/appendix/index-types.rst b/document/core/appendix/index-types.rst index f2de63204..5d31e71c0 100644 --- a/document/core/appendix/index-types.rst +++ b/document/core/appendix/index-types.rst @@ -15,27 +15,27 @@ Category Constructor :ref:`Vector type ` |V128| :math:`\hex{7B}` (-5 as |Bs7|) :ref:`Packed type ` |I8| :math:`\hex{7A}` (-6 as |Bs7|) :ref:`Packed type ` |I16| :math:`\hex{79}` (-7 as |Bs7|) -(reserved) :math:`\hex{78}` .. :math:`\hex{71}` +(reserved) :math:`\hex{78}` .. :math:`\hex{74}` +:ref:`Heap type ` |NOFUNC| :math:`\hex{73}` (-13 as |Bs7|) +:ref:`Heap type ` |NOEXTERN| :math:`\hex{72}` (-14 as |Bs7|) +:ref:`Heap type ` |NONE| :math:`\hex{71}` (-15 as |Bs7|) :ref:`Heap type ` |FUNC| :math:`\hex{70}` (-16 as |Bs7|) :ref:`Heap type ` |EXTERN| :math:`\hex{6F}` (-17 as |Bs7|) :ref:`Heap type ` |ANY| :math:`\hex{6E}` (-18 as |Bs7|) :ref:`Heap type ` |EQT| :math:`\hex{6D}` (-19 as |Bs7|) -:ref:`Reference type ` |REF| |NULL| :math:`\hex{6C}` (-20 as |Bs7|) -:ref:`Reference type ` |REF| :math:`\hex{6B}` (-21 as |Bs7|) -:ref:`Heap type ` |I31| :math:`\hex{6A}` (-22 as |Bs7|) -:ref:`Heap type ` |NOFUNC| :math:`\hex{69}` (-23 as |Bs7|) -:ref:`Heap type ` |NOEXTERN| :math:`\hex{68}` (-24 as |Bs7|) -:ref:`Heap type ` |STRUCT| :math:`\hex{67}` (-25 as |Bs7|) -:ref:`Heap type ` |ARRAY| :math:`\hex{66}` (-26 as |Bs7|) -:ref:`Heap type ` |NONE| :math:`\hex{65}` (-27 as |Bs7|) +: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|) +: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}` :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|) (reserved) :math:`\hex{5D}` .. :math:`\hex{51}` :ref:`Sub type ` :math:`\TSUB~\typeidx^\ast~\comptype` :math:`\hex{50}` (-48 as |Bs7|) -:ref:`Recursive type ` :math:`\TREC~\subtype^\ast` :math:`\hex{4F}` (-49 as |Bs7|) -:ref:`Sub type ` :math:`\TSUB~\TFINAL~\typeidx^\ast~\comptype` :math:`\hex{4E}` (-50 as |Bs7|) +:ref:`Sub type ` :math:`\TSUB~\TFINAL~\typeidx^\ast~\comptype` :math:`\hex{4F}` (-49 as |Bs7|) +:ref:`Recursive type ` :math:`\TREC~\subtype^\ast` :math:`\hex{4E}` (-50 as |Bs7|) (reserved) :math:`\hex{4D}` .. :math:`\hex{41}` :ref:`Result type ` :math:`[\epsilon]` :math:`\hex{40}` (-64 as |Bs7|) :ref:`Table type ` :math:`\limits~\reftype` (none) diff --git a/document/core/binary/instructions.rst b/document/core/binary/instructions.rst index 4e69cdbcb..a23c02cf0 100644 --- a/document/core/binary/instructions.rst +++ b/document/core/binary/instructions.rst @@ -77,8 +77,8 @@ Control Instructions \hex{15}~~x{:}\Btypeidx &\Rightarrow& \RETURNCALLREF~x \\ &&|& \hex{D4}~~l{:}\Blabelidx &\Rightarrow& \BRONNULL~l \\ &&|& \hex{D6}~~l{:}\Blabelidx &\Rightarrow& \BRONNONNULL~l \\ &&|& - \hex{FB}~~78{:}\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}~~79{:}\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) \\ + \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) \\ \production{cast flags} & \Bcastflags &::=& 0{:}\Bu8 &\Rightarrow& (\epsilon, \epsilon) \\ &&|& 1{:}\Bu8 &\Rightarrow& (\NULL, \epsilon) \\ &&|& @@ -142,35 +142,35 @@ Generic :ref:`reference instructions ` are represented by sing \hex{D2}~~x{:}\Bfuncidx &\Rightarrow& \REFFUNC~x \\ &&|& \hex{D3} &\Rightarrow& \REFASNONNULL \\ &&|& \hex{D5} &\Rightarrow& \REFEQ \\ &&|& - \hex{FB}~~1{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \STRUCTNEW~x \\ &&|& - \hex{FB}~~2{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \STRUCTNEWDEFAULT~x \\ &&|& - \hex{FB}~~3{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTGET~x~i \\ &&|& - \hex{FB}~~4{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTGETS~x~i \\ &&|& - \hex{FB}~~5{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTGETU~x~i \\ &&|& - \hex{FB}~~6{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTSET~x~i \\ &&|& + \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 \\ &&|& + \hex{FB}~~3{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTGETS~x~i \\ &&|& + \hex{FB}~~4{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTGETU~x~i \\ &&|& + \hex{FB}~~5{:}\Bu32~~x{:}\Btypeidx~~i{:}\Bu32 &\Rightarrow& \STRUCTSET~x~i \\ &&|& + \hex{FB}~~6{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYNEW~x \\ &&|& + \hex{FB}~~7{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYNEWDEFAULT~x \\ &&|& + \hex{FB}~~8{:}\Bu32~~x{:}\Btypeidx~~n{:}\Bu32 &\Rightarrow& \ARRAYNEWFIXED~x~n \\ &&|& + \hex{FB}~~9{:}\Bu32~~x{:}\Btypeidx~~y{:}\Bdataidx &\Rightarrow& \ARRAYNEWDATA~x~y \\ &&|& + \hex{FB}~~10{:}\Bu32~~x{:}\Btypeidx~~y{:}\Belemidx &\Rightarrow& \ARRAYNEWELEM~x~y \\ &&|& + \hex{FB}~~11{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYGET~x \\ &&|& + \hex{FB}~~12{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYGETS~x \\ &&|& + \hex{FB}~~13{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYGETU~x \\ &&|& + \hex{FB}~~14{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYSET~x \\ &&|& + \hex{FB}~~15{:}\Bu32 &\Rightarrow& \ARRAYLEN \\ &&|& \hex{FB}~~16{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYFILL~x \\ &&|& - \hex{FB}~~17{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYNEW~x \\ &&|& - \hex{FB}~~18{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYNEWDEFAULT~x \\ &&|& - \hex{FB}~~19{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYGET~x \\ &&|& - \hex{FB}~~20{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYGETS~x \\ &&|& - \hex{FB}~~21{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYGETU~x \\ &&|& - \hex{FB}~~22{:}\Bu32~~x{:}\Btypeidx &\Rightarrow& \ARRAYSET~x \\ &&|& - \hex{FB}~~23{:}\Bu32 &\Rightarrow& \ARRAYLEN \\ &&|& - \hex{FB}~~24{:}\Bu32~~x{:}\Btypeidx~~y{:}\Btypeidx &\Rightarrow& \ARRAYCOPY~x~y \\ &&|& - \hex{FB}~~25{:}\Bu32~~x{:}\Btypeidx~~n{:}\Bu32 &\Rightarrow& \ARRAYNEWFIXED~x~n \\ &&|& - \hex{FB}~~27{:}\Bu32~~x{:}\Btypeidx~~y{:}\Bdataidx &\Rightarrow& \ARRAYNEWDATA~x~y \\ &&|& - \hex{FB}~~28{:}\Bu32~~x{:}\Btypeidx~~y{:}\Belemidx &\Rightarrow& \ARRAYNEWELEM~x~y \\ &&|& - \hex{FB}~~32{:}\Bu32 &\Rightarrow& \I31NEW \\ &&|& - \hex{FB}~~33{:}\Bu32 &\Rightarrow& \I31GETS \\ &&|& - \hex{FB}~~34{:}\Bu32 &\Rightarrow& \I31GETU \\ &&|& - \hex{FB}~~64{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFTEST~(\REF~\X{ht}) \\ &&|& - \hex{FB}~~65{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFCAST~(\REF~\X{ht}) \\ &&|& - \hex{FB}~~72{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFTEST~(\REF~\NULL~\X{ht}) \\ &&|& - \hex{FB}~~73{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFCAST~(\REF~\NULL~\X{ht}) \\ &&|& - \hex{FB}~~84{:}\Bu32~~x{:}\Btypeidx~~y{:}\Bdataidx &\Rightarrow& \ARRAYINITDATA~x~y \\ &&|& - \hex{FB}~~85{:}\Bu32~~x{:}\Btypeidx~~y{:}\Belemidx &\Rightarrow& \ARRAYINITELEM~x~y \\ &&|& - \hex{FB}~~112{:}\Bu32 &\Rightarrow& \EXTERNINTERNALIZE \\ &&|& - \hex{FB}~~113{:}\Bu32 &\Rightarrow& \EXTERNEXTERNALIZE \\ + \hex{FB}~~17{:}\Bu32~~x{:}\Btypeidx~~y{:}\Btypeidx &\Rightarrow& \ARRAYCOPY~x~y \\ &&|& + \hex{FB}~~18{:}\Bu32~~x{:}\Btypeidx~~y{:}\Bdataidx &\Rightarrow& \ARRAYINITDATA~x~y \\ &&|& + \hex{FB}~~19{:}\Bu32~~x{:}\Btypeidx~~y{:}\Belemidx &\Rightarrow& \ARRAYINITELEM~x~y \\ &&|& + \hex{FB}~~20{:}\Bu32~~\X{ht}{:}\Bheaptype &\Rightarrow& \REFTEST~(\REF~\X{ht}) \\ &&|& + \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}~~28{:}\Bu32 &\Rightarrow& \I31NEW \\ &&|& + \hex{FB}~~29{:}\Bu32 &\Rightarrow& \I31GETS \\ &&|& + \hex{FB}~~30{:}\Bu32 &\Rightarrow& \I31GETU \\ \end{array} diff --git a/document/core/binary/types.rst b/document/core/binary/types.rst index 64c98a268..39af72feb 100644 --- a/document/core/binary/types.rst +++ b/document/core/binary/types.rst @@ -58,16 +58,16 @@ Heap Types .. math:: \begin{array}{llclll@{\qquad\qquad}l} \production{abstract heap type} & \Babsheaptype &::=& - \hex{65} &\Rightarrow& \NONE \\ &&|& - \hex{66} &\Rightarrow& \ARRAY \\ &&|& - \hex{67} &\Rightarrow& \STRUCT \\ &&|& - \hex{68} &\Rightarrow& \NOEXTERN \\ &&|& - \hex{69} &\Rightarrow& \NOFUNC \\ &&|& - \hex{6A} &\Rightarrow& \I31 \\ &&|& - \hex{6D} &\Rightarrow& \EQT \\ &&|& - \hex{6E} &\Rightarrow& \ANY \\ &&|& + \hex{73} &\Rightarrow& \NOFUNC \\ &&|& + \hex{72} &\Rightarrow& \NOEXTERN \\ &&|& + \hex{71} &\Rightarrow& \NONE \\ &&|& + \hex{70} &\Rightarrow& \FUNC \\ &&|& \hex{6F} &\Rightarrow& \EXTERN \\ &&|& - \hex{70} &\Rightarrow& \FUNC \\ + \hex{6E} &\Rightarrow& \ANY \\ &&|& + \hex{6D} &\Rightarrow& \EQT \\ &&|& + \hex{6C} &\Rightarrow& \I31 \\ &&|& + \hex{6B} &\Rightarrow& \STRUCT \\ &&|& + \hex{6A} &\Rightarrow& \ARRAY \\ \production{heap type} & \Bheaptype &::=& \X{ht}{:}\Babsheaptype &\Rightarrow& \X{ht} \\ &&|& x{:}\Bs33 &\Rightarrow& x & (\iff x \geq 0) \\ @@ -86,8 +86,8 @@ Reference Types .. math:: \begin{array}{llclll@{\qquad\qquad}l} \production{reference type} & \Breftype &::=& - \hex{6B}~~\X{ht}{:}\Bheaptype &\Rightarrow& \REF~\X{ht} \\ &&|& - \hex{6C}~~\X{ht}{:}\Bheaptype &\Rightarrow& \REF~\NULL~\X{ht} \\ &&|& + \hex{64}~~\X{ht}{:}\Bheaptype &\Rightarrow& \REF~\X{ht} \\ &&|& + \hex{63}~~\X{ht}{:}\Bheaptype &\Rightarrow& \REF~\NULL~\X{ht} \\ &&|& \X{ht}{:}\Babsheaptype &\Rightarrow& \REF~\NULL~\X{ht} \\ \end{array} diff --git a/interpreter/binary/decode.ml b/interpreter/binary/decode.ml index af59368c2..cbff7fb2b 100644 --- a/interpreter/binary/decode.ml +++ b/interpreter/binary/decode.ml @@ -177,16 +177,16 @@ let heap_type s = (fun s -> VarHT (var_type s33 s)); (fun s -> match s7 s with + | -0x0d -> NoFuncHT + | -0x0e -> NoExternHT + | -0x0f -> NoneHT | -0x10 -> FuncHT | -0x11 -> ExternHT | -0x12 -> AnyHT | -0x13 -> EqHT - | -0x16 -> I31HT - | -0x17 -> NoFuncHT - | -0x18 -> NoExternHT - | -0x19 -> StructHT - | -0x1a -> ArrayHT - | -0x1b -> NoneHT + | -0x14 -> I31HT + | -0x15 -> StructHT + | -0x16 -> ArrayHT | _ -> error s pos "malformed heap type" ) ] s @@ -194,18 +194,18 @@ let heap_type s = let ref_type s = let pos = pos s in match s7 s with + | -0x0d -> (Null, NoFuncHT) + | -0x0e -> (Null, NoExternHT) + | -0x0f -> (Null, NoneHT) | -0x10 -> (Null, FuncHT) | -0x11 -> (Null, ExternHT) | -0x12 -> (Null, AnyHT) | -0x13 -> (Null, EqHT) - | -0x14 -> (Null, heap_type s) - | -0x15 -> (NoNull, heap_type s) - | -0x16 -> (Null, I31HT) - | -0x17 -> (Null, NoFuncHT) - | -0x18 -> (Null, NoExternHT) - | -0x19 -> (Null, StructHT) - | -0x1a -> (Null, ArrayHT) - | -0x1b -> (Null, NoneHT) + | -0x14 -> (Null, I31HT) + | -0x15 -> (Null, StructHT) + | -0x16 -> (Null, ArrayHT) + | -0x1c -> (NoNull, heap_type s) + | -0x1d -> (Null, heap_type s) | _ -> error s pos "malformed reference type" let val_type s = @@ -259,7 +259,7 @@ let sub_type s = skip 1 s; let xs = vec (var_type u32) s in SubT (NoFinal, List.map (fun x -> VarHT x) xs, str_type s) - | Some i when i = -0x32 land 0x7f -> + | Some i when i = -0x31 land 0x7f -> skip 1 s; let xs = vec (var_type u32) s in SubT (Final, List.map (fun x -> VarHT x) xs, str_type s) @@ -267,7 +267,7 @@ let sub_type s = let rec_type s = match peek s with - | Some i when i = -0x31 land 0x7f -> skip 1 s; RecT (vec sub_type s) + | Some i when i = -0x32 land 0x7f -> skip 1 s; RecT (vec sub_type s) | _ -> RecT [sub_type s] @@ -588,48 +588,46 @@ let rec instr s = | 0xfb as b -> (match u32 s with - | 0x01l -> struct_new (at var s) - | 0x02l -> struct_new_default (at var s) - | 0x03l -> let x = at var s in let y = at var s in struct_get x y - | 0x04l -> let x = at var s in let y = at var s in struct_get_s x y - | 0x05l -> let x = at var s in let y = at var s in struct_get_u x y - | 0x06l -> let x = at var s in let y = at var s in struct_set x y - - | 0x11l -> array_new (at var s) - | 0x12l -> array_new_default (at var s) - | 0x13l -> array_get (at var s) - | 0x14l -> array_get_s (at var s) - | 0x15l -> array_get_u (at var s) - | 0x16l -> array_set (at var s) - | 0x17l -> array_len - - | 0x18l -> let x = at var s in let y = at var s in array_copy x y - | 0x0fl -> array_fill (at var s) - | 0x54l -> let x = at var s in let y = at var s in array_init_data x y - | 0x55l -> let x = at var s in let y = at var s in array_init_elem x y - - | 0x19l -> let x = at var s in let n = u32 s in array_new_fixed x n - | 0x1bl -> let x = at var s in let y = at var s in array_new_data x y - | 0x1cl -> let x = at var s in let y = at var s in array_new_elem x y - - | 0x20l -> i31_new - | 0x21l -> i31_get_s - | 0x22l -> i31_get_u - - | 0x40l -> ref_test (NoNull, heap_type s) - | 0x41l -> ref_cast (NoNull, heap_type s) - | 0x48l -> ref_test (Null, heap_type s) - | 0x49l -> ref_cast (Null, heap_type s) - | 0x4el | 0x4fl as opcode -> + | 0x00l -> struct_new (at var s) + | 0x01l -> struct_new_default (at var s) + | 0x02l -> let x = at var s in let y = at var s in struct_get x y + | 0x03l -> let x = at var s in let y = at var s in struct_get_s x y + | 0x04l -> let x = at var s in let y = at var s in struct_get_u x y + | 0x05l -> let x = at var s in let y = at var s in struct_set x y + + | 0x06l -> array_new (at var s) + | 0x07l -> array_new_default (at var s) + | 0x08l -> let x = at var s in let n = u32 s in array_new_fixed x n + | 0x09l -> let x = at var s in let y = at var s in array_new_data x y + | 0x0al -> let x = at var s in let y = at var s in array_new_elem x y + | 0x0bl -> array_get (at var s) + | 0x0cl -> array_get_s (at var s) + | 0x0dl -> array_get_u (at var s) + | 0x0el -> array_set (at var s) + | 0x0fl -> array_len + | 0x10l -> array_fill (at var s) + | 0x11l -> let x = at var s in let y = at var s in array_copy x y + | 0x12l -> let x = at var s in let y = at var s in array_init_data x y + | 0x13l -> let x = at var s in let y = at var s in array_init_elem x y + + | 0x14l -> ref_test (NoNull, heap_type s) + | 0x15l -> ref_test (Null, heap_type s) + | 0x16l -> ref_cast (NoNull, heap_type s) + | 0x17l -> ref_cast (Null, heap_type s) + | 0x18l | 0x19l as opcode -> let flags = byte s in require (flags land 0xfc = 0) s (pos + 2) "malformed br_on_cast flags"; let x = at var s in let rt1 = ((if bit 0 flags then Null else NoNull), heap_type s) in let rt2 = ((if bit 1 flags then Null else NoNull), heap_type s) in - (if opcode = 0x4el then br_on_cast else br_on_cast_fail) x rt1 rt2 + (if opcode = 0x18l then br_on_cast else br_on_cast_fail) x rt1 rt2 - | 0x70l -> extern_internalize - | 0x71l -> extern_externalize + | 0x1al -> extern_internalize + | 0x1bl -> extern_externalize + + | 0x1cl -> i31_new + | 0x1dl -> i31_get_s + | 0x1el -> i31_get_u | n -> illegal2 s pos b n ) @@ -848,6 +846,7 @@ let rec instr s = | 0x97l -> i16x8_min_u | 0x98l -> i16x8_max_s | 0x99l -> i16x8_max_u + | 0x9al as n -> illegal s pos (I32.to_int_u n) | 0x9bl -> i16x8_avgr_u | 0x9cl -> i16x8_extmul_low_i8x16_s | 0x9dl -> i16x8_extmul_high_i8x16_s @@ -855,8 +854,10 @@ let rec instr s = | 0x9fl -> i16x8_extmul_high_i8x16_u | 0xa0l -> i32x4_abs | 0xa1l -> i32x4_neg + | 0xa2l as n -> illegal s pos (I32.to_int_u n) | 0xa3l -> i32x4_all_true | 0xa4l -> i32x4_bitmask + | 0xa5l | 0xa6l as n -> illegal s pos (I32.to_int_u n) | 0xa7l -> i32x4_extend_low_i16x8_s | 0xa8l -> i32x4_extend_high_i16x8_s | 0xa9l -> i32x4_extend_low_i16x8_u @@ -865,7 +866,9 @@ let rec instr s = | 0xacl -> i32x4_shr_s | 0xadl -> i32x4_shr_u | 0xael -> i32x4_add + | 0xafl | 0xb0l as n -> illegal s pos (I32.to_int_u n) | 0xb1l -> i32x4_sub + | 0xb2l | 0xb3l | 0xb4l as n -> illegal s pos (I32.to_int_u n) | 0xb5l -> i32x4_mul | 0xb6l -> i32x4_min_s | 0xb7l -> i32x4_min_u @@ -878,8 +881,10 @@ let rec instr s = | 0xbfl -> i32x4_extmul_high_i16x8_u | 0xc0l -> i64x2_abs | 0xc1l -> i64x2_neg + | 0xc2l as n -> illegal s pos (I32.to_int_u n) | 0xc3l -> i64x2_all_true | 0xc4l -> i64x2_bitmask + | 0xc5l | 0xc6l as n -> illegal s pos (I32.to_int_u n) | 0xc7l -> i64x2_extend_low_i32x4_s | 0xc8l -> i64x2_extend_high_i32x4_s | 0xc9l -> i64x2_extend_low_i32x4_u @@ -888,7 +893,9 @@ let rec instr s = | 0xccl -> i64x2_shr_s | 0xcdl -> i64x2_shr_u | 0xcel -> i64x2_add + | 0xcfl | 0xd0l as n -> illegal s pos (I32.to_int_u n) | 0xd1l -> i64x2_sub + | 0xd2l | 0xd3l | 0xd4l as n -> illegal s pos (I32.to_int_u n) | 0xd5l -> i64x2_mul | 0xd6l -> i64x2_eq | 0xd7l -> i64x2_ne @@ -902,6 +909,7 @@ let rec instr s = | 0xdfl -> i64x2_extmul_high_i32x4_u | 0xe0l -> f32x4_abs | 0xe1l -> f32x4_neg + | 0xe2l as n -> illegal s pos (I32.to_int_u n) | 0xe3l -> f32x4_sqrt | 0xe4l -> f32x4_add | 0xe5l -> f32x4_sub diff --git a/interpreter/binary/encode.ml b/interpreter/binary/encode.ml index 71615e415..fe7be0db6 100644 --- a/interpreter/binary/encode.ml +++ b/interpreter/binary/encode.ml @@ -116,15 +116,15 @@ struct let heap_type = function | AnyHT -> s7 (-0x12) - | NoneHT -> s7 (-0x1b) | EqHT -> s7 (-0x13) - | I31HT -> s7 (-0x16) - | StructHT -> s7 (-0x19) - | ArrayHT -> s7 (-0x1a) + | I31HT -> s7 (-0x14) + | StructHT -> s7 (-0x15) + | ArrayHT -> s7 (-0x16) + | NoneHT -> s7 (-0x0f) | FuncHT -> s7 (-0x10) - | NoFuncHT -> s7 (-0x17) + | NoFuncHT -> s7 (-0x0d) | ExternHT -> s7 (-0x11) - | NoExternHT -> s7 (-0x18) + | NoExternHT -> s7 (-0x0e) | VarHT x -> var_type s33 x | DefHT _ | BotHT -> assert false @@ -134,17 +134,17 @@ struct let ref_type = function | (Null, AnyHT) -> s7 (-0x12) - | (Null, NoneHT) -> s7 (-0x1b) | (Null, EqHT) -> s7 (-0x13) - | (Null, I31HT) -> s7 (-0x16) - | (Null, StructHT) -> s7 (-0x19) - | (Null, ArrayHT) -> s7 (-0x1a) + | (Null, I31HT) -> s7 (-0x14) + | (Null, StructHT) -> s7 (-0x15) + | (Null, ArrayHT) -> s7 (-0x16) + | (Null, NoneHT) -> s7 (-0x0f) | (Null, FuncHT) -> s7 (-0x10) - | (Null, NoFuncHT) -> s7 (-0x17) + | (Null, NoFuncHT) -> s7 (-0x0d) | (Null, ExternHT) -> s7 (-0x11) - | (Null, NoExternHT) -> s7 (-0x18) - | (Null, t) -> s7 (-0x14); heap_type t - | (NoNull, t) -> s7 (-0x15); heap_type t + | (Null, NoExternHT) -> s7 (-0x0e) + | (Null, t) -> s7 (-0x1d); heap_type t + | (NoNull, t) -> s7 (-0x1c); heap_type t let val_type = function | NumT t -> num_type t @@ -180,12 +180,12 @@ struct let sub_type = function | SubT (Final, [], st) -> str_type st - | SubT (Final, hts, st) -> s7 (-0x32); vec var_heap_type hts; str_type st + | SubT (Final, hts, st) -> s7 (-0x31); vec var_heap_type hts; str_type st | SubT (NoFinal, hts, st) -> s7 (-0x30); vec var_heap_type hts; str_type st let rec_type = function | RecT [st] -> sub_type st - | RecT sts -> s7 (-0x31); vec sub_type sts + | RecT sts -> s7 (-0x32); vec sub_type sts let limits uN {min; max} = bool (max <> None); uN min; opt uN max @@ -249,10 +249,10 @@ struct | BrOnNonNull x -> op 0xd6; var x | BrOnCast (x, (nul1, t1), (nul2, t2)) -> let flags = bit 0 (nul1 = Null) + bit 1 (nul2 = Null) in - op 0xfb; op 0x4e; byte flags; var x; heap_type t1; heap_type t2 + op 0xfb; op 0x18; byte flags; var x; heap_type t1; heap_type t2 | BrOnCastFail (x, (nul1, t1), (nul2, t2)) -> let flags = bit 0 (nul1 = Null) + bit 1 (nul2 = Null) in - op 0xfb; op 0x4f; byte flags; var x; heap_type t1; heap_type t2 + op 0xfb; op 0x19; byte flags; var x; heap_type t1; heap_type t2 | Return -> op 0x0f | Call x -> op 0x10; var x | CallRef x -> op 0x14; var x @@ -378,42 +378,41 @@ struct | RefIsNull -> op 0xd1 | RefAsNonNull -> op 0xd3 - | RefTest (NoNull, t) -> op 0xfb; op 0x40; heap_type t - | RefTest (Null, t) -> op 0xfb; op 0x48; heap_type t - | RefCast (NoNull, t) -> op 0xfb; op 0x41; heap_type t - | RefCast (Null, t) -> op 0xfb; op 0x49; heap_type t + | 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 0x20 - | I31Get SX -> op 0xfb; op 0x21 - | I31Get ZX -> op 0xfb; op 0x22 - - | StructNew (x, Explicit) -> op 0xfb; op 0x01; var x - | StructNew (x, Implicit) -> op 0xfb; op 0x02; var x - | StructGet (x, y, None) -> op 0xfb; op 0x03; var x; var y - | StructGet (x, y, Some SX) -> op 0xfb; op 0x04; var x; var y - | StructGet (x, y, Some ZX) -> op 0xfb; op 0x05; var x; var y - | StructSet (x, y) -> op 0xfb; op 0x06; var x; var y - - | ArrayNew (x, Explicit) -> op 0xfb; op 0x11; var x - | ArrayNew (x, Implicit) -> op 0xfb; op 0x12; var x - | ArrayNewFixed (x, n) -> op 0xfb; op 0x19; var x; u32 n - | ArrayNewElem (x, y) -> op 0xfb; op 0x1c; var x; var y - | ArrayNewData (x, y) -> op 0xfb; op 0x1b; var x; var y - | ArrayGet (x, None) -> op 0xfb; op 0x13; var x - | ArrayGet (x, Some SX) -> op 0xfb; op 0x14; var x - | ArrayGet (x, Some ZX) -> op 0xfb; op 0x15; var x - | ArraySet x -> op 0xfb; op 0x16; var x - | ArrayLen -> op 0xfb; op 0x17 - - | ArrayCopy (x, y) -> op 0xfb; op 0x18; var x; var y - | ArrayFill x -> op 0xfb; op 0x0f; var x - | ArrayInitData (x, y) -> op 0xfb; op 0x54; var x; var y - | ArrayInitElem (x, y) -> op 0xfb; op 0x55; var x; var y - - | ExternConvert Internalize -> op 0xfb; op 0x70 - | ExternConvert Externalize -> op 0xfb; op 0x71 + | I31New -> op 0xfb; op 0x1c + | I31Get SX -> op 0xfb; op 0x1d + | I31Get ZX -> op 0xfb; op 0x1e + + | StructNew (x, Explicit) -> op 0xfb; op 0x00; var x + | StructNew (x, Implicit) -> op 0xfb; op 0x01; var x + | StructGet (x, y, None) -> op 0xfb; op 0x02; var x; var y + | StructGet (x, y, Some SX) -> op 0xfb; op 0x03; var x; var y + | StructGet (x, y, Some ZX) -> op 0xfb; op 0x04; var x; var y + | StructSet (x, y) -> op 0xfb; op 0x05; var x; var y + + | ArrayNew (x, Explicit) -> op 0xfb; op 0x06; var x + | ArrayNew (x, Implicit) -> op 0xfb; op 0x07; var x + | ArrayNewFixed (x, n) -> op 0xfb; op 0x08; var x; u32 n + | ArrayNewElem (x, y) -> op 0xfb; op 0x0a; var x; var y + | ArrayNewData (x, y) -> op 0xfb; op 0x09; var x; var y + | ArrayGet (x, None) -> op 0xfb; op 0x0b; var x + | ArrayGet (x, Some SX) -> op 0xfb; op 0x0c; var x + | ArrayGet (x, Some ZX) -> op 0xfb; op 0x0d; var x + | ArraySet x -> op 0xfb; op 0x0e; var x + | ArrayLen -> op 0xfb; op 0x0f + | ArrayFill x -> op 0xfb; op 0x10; var x + | ArrayCopy (x, y) -> op 0xfb; op 0x11; var x; var y + | ArrayInitData (x, y) -> op 0xfb; op 0x12; var x; var y + | ArrayInitElem (x, y) -> op 0xfb; op 0x13; var x; var y + + | ExternConvert Internalize -> op 0xfb; op 0x1a + | ExternConvert Externalize -> op 0xfb; op 0x1b | Const {it = I32 c; _} -> op 0x41; s32 c | Const {it = I64 c; _} -> op 0x42; s64 c diff --git a/proposals/gc/MVP.md b/proposals/gc/MVP.md index efda212c7..6382005df 100644 --- a/proposals/gc/MVP.md +++ b/proposals/gc/MVP.md @@ -721,25 +721,25 @@ This extends the [encodings](https://github.com/WebAssembly/function-references/ | Opcode | Type | | ------ | --------------- | -| -0x06 | `i8` | -| -0x07 | `i16` | +| -0x08 | `i8` | +| -0x09 | `i16` | #### Reference Types | Opcode | Type | Parameters | Note | | ------ | --------------- | ---------- | ---- | +| -0x0d | `nullfuncref` | | shorthand | +| -0x0e | `nullexternref` | | shorthand | +| -0x0f | `nullref` | | shorthand | | -0x10 | `funcref` | | shorthand, from reftype proposal | | -0x11 | `externref` | | shorthand, from reftype proposal | | -0x12 | `anyref` | | shorthand | | -0x13 | `eqref` | | shorthand | -| -0x14 | `(ref null ht)` | `ht : heaptype (s33)` | from funcref proposal | -| -0x15 | `(ref ht)` | `ht : heaptype (s33)` | from funcref proposal | -| -0x16 | `i31ref` | | shorthand | -| -0x17 | `nullfuncref` | | shorthand | -| -0x18 | `nullexternref` | | shorthand | -| -0x19 | `structref` | | shorthand | -| -0x1a | `arrayref` | | shorthand | -| -0x1b | `nullref` | | shorthand | +| -0x14 | `i31ref` | | shorthand | +| -0x15 | `structref` | | shorthand | +| -0x16 | `arrayref` | | shorthand | +| -0x1c | `(ref ht)` | `ht : heaptype (s33)` | from funcref proposal | +| -0x1d | `(ref null ht)` | `ht : heaptype (s33)` | from funcref proposal | #### Heap Types @@ -748,42 +748,45 @@ The opcode for heap types is encoded as an `s33`. | Opcode | Type | Parameters | Note | | ------ | --------------- | ---------- | ---- | | i >= 0 | `(type i)` | | from funcref proposal | +| -0x0d | `nofunc` | | | +| -0x0e | `noextern` | | | +| -0x0f | `none` | | | | -0x10 | `func` | | from funcref proposal | | -0x11 | `extern` | | from funcref proposal | | -0x12 | `any` | | | | -0x13 | `eq` | | | -| -0x16 | `i31` | | | -| -0x17 | `nofunc` | | | -| -0x18 | `noextern` | | | -| -0x19 | `struct` | | | -| -0x1a | `array` | | | -| -0x1b | `none` | | | +| -0x14 | `i31` | | | +| -0x15 | `struct` | | | +| -0x16 | `array` | | | #### Composite Types -| Opcode | Type | Parameters | -| ------ | --------------- | ---------- | -| -0x21 | `struct ft*` | `ft* : vec(fieldtype)` | -| -0x22 | `array ft` | `ft : fieldtype` | +| Opcode | Type | Parameters | Note | +| ------ | --------------- | ---------- | ---- | +| -0x20 | `func t1* t2*` | `t1* : vec(valtype)`, `t2* : vec(valtype)` | from Wasm 1.0 | +| -0x21 | `struct ft*` | `ft* : vec(fieldtype)` | | +| -0x22 | `array ft` | `ft : fieldtype` | | #### Subtypes | Opcode | Type | Parameters | Note | | ------ | --------------- | ---------- | ---- | +| -0x20 | `func t1* t2*` | `t1* : vec(valtype)`, `t2* : vec(valtype)` | shorthand | | -0x21 | `struct ft*` | `ft* : vec(fieldtype)` | shorthand | | -0x22 | `array ft` | `ft : fieldtype` | shorthand | | -0x30 | `sub $t* st` | `$t* : vec(typeidx)`, `st : comptype` | | -| -0x32 | `sub final $t* st` | `$t* : vec(typeidx)`, `st : comptype` | | +| -0x31 | `sub final $t* st` | `$t* : vec(typeidx)`, `st : comptype` | | #### Defined Types | Opcode | Type | Parameters | Note | | ------ | --------------- | ---------- | ---- | +| -0x20 | `func t1* t2*` | `t1* : vec(valtype)`, `t2* : vec(valtype)` | shorthand | | -0x21 | `struct ft*` | `ft* : vec(fieldtype)` | shorthand | | -0x22 | `array ft` | `ft : fieldtype` | shorthand | | -0x30 | `sub $t* st` | `$t* : vec(typeidx)`, `st : comptype` | shorthand | -| -0x31 | `rec dt*` | `dt* : vec(subtype)` | | -| -0x32 | `sub final $t* st` | `$t* : vec(typeidx)`, `st : comptype` | shorthand | +| -0x31 | `sub final $t* st` | `$t* : vec(typeidx)`, `st : comptype` | shorthand | +| -0x32 | `rec dt*` | `dt* : vec(subtype)` | | #### Field Types @@ -794,41 +797,46 @@ The opcode for heap types is encoded as an `s33`. ### Instructions -| Opcode | Type | Parameters | -| ------ | --------------- | ---------- | -| 0xd5 | `ref.eq` | | -| 0xd6 | `br_on_non_null $l` | `$l : labelidx` | -| 0xfb01 | `struct.new $t` | `$t : typeidx` | -| 0xfb02 | `struct.new_default $t` | `$t : typeidx` | -| 0xfb03 | `struct.get $t i` | `$t : typeidx`, `i : fieldidx` | -| 0xfb04 | `struct.get_s $t i` | `$t : typeidx`, `i : fieldidx` | -| 0xfb05 | `struct.get_u $t i` | `$t : typeidx`, `i : fieldidx` | -| 0xfb06 | `struct.set $t i` | `$t : typeidx`, `i : fieldidx` | -| 0xfb0f | `array.fill $t` | `$t : typeidx` | -| 0xfb11 | `array.new $t` | `$t : typeidx` | -| 0xfb12 | `array.new_default $t` | `$t : typeidx` | -| 0xfb13 | `array.get $t` | `$t : typeidx` | -| 0xfb14 | `array.get_s $t` | `$t : typeidx` | -| 0xfb15 | `array.get_u $t` | `$t : typeidx` | -| 0xfb16 | `array.set $t` | `$t : typeidx` | -| 0xfb17 | `array.len` | | -| 0xfb18 | `array.copy $t1 $t2` | `$t1 : typeidx`, `$t2 : typeidx` | -| 0xfb19 | `array.new_fixed $t N` | `$t : typeidx`, `N : u32` | -| 0xfb1b | `array.new_data $t $d` | `$t : typeidx`, `$d : dataidx` | -| 0xfb1c | `array.new_elem $t $e` | `$t : typeidx`, `$e : elemidx` | -| 0xfb20 | `i31.new` | | -| 0xfb21 | `i31.get_s` | | -| 0xfb22 | `i31.get_u` | | -| 0xfb40 | `ref.test (ref ht)` | `ht : heaptype` | -| 0xfb41 | `ref.cast (ref ht)` | `ht : heaptype` | -| 0xfb48 | `ref.test (ref null ht)` | `ht : heaptype` | -| 0xfb49 | `ref.cast (ref null ht)` | `ht : heaptype` | -| 0xfb4e | `br_on_cast $l (ref null1? ht1) (ref null2? ht2)` | `flags : u8`, $l : labelidx`, `ht1 : heaptype`, `ht2 : heaptype` | -| 0xfb4f | `br_on_cast_fail $l (ref null1? ht1) (ref null2? ht2)` | `flags : u8`, $l : labelidx`, `ht1 : heaptype`, `ht2 : heaptype` | -| 0xfb54 | `array.init_data $t $d` | `$t : typeidx`, `$d: dataidx` | -| 0xfb55 | `array.init_elem $t $e` | `$t : typeidx`, `$d: elemidx` | -| 0xfb70 | `extern.internalize` | | -| 0xfb71 | `extern.externalize` | | +| Opcode | Type | Parameters | Note | +| ------ | --------------- | ---------- | ---- | +| 0xd0 | `ref.null ht` | `ht : heap_type` | from Wasm 2.0 | +| 0xd1 | `ref.is_null` | | from Wasm 2.0 | +| 0xd2 | `ref.func $f` | `$f : funcidx` | from Wasm 2.0 | +| 0xd3 | `ref.eq` | | +| 0xd4 | `ref.as_non_null` | | from funcref proposal | +| 0xd5 | `br_on_null $l` | `$l : u32` | from funcref proposal | +| 0xd6 | `br_on_non_null $l` | `$l : u32` | from funcref proposal | +| 0xfb00 | `struct.new $t` | `$t : typeidx` | +| 0xfb01 | `struct.new_default $t` | `$t : typeidx` | +| 0xfb02 | `struct.get $t i` | `$t : typeidx`, `i : fieldidx` | +| 0xfb03 | `struct.get_s $t i` | `$t : typeidx`, `i : fieldidx` | +| 0xfb04 | `struct.get_u $t i` | `$t : typeidx`, `i : fieldidx` | +| 0xfb05 | `struct.set $t i` | `$t : typeidx`, `i : fieldidx` | +| 0xfb06 | `array.new $t` | `$t : typeidx` | +| 0xfb07 | `array.new_default $t` | `$t : typeidx` | +| 0xfb08 | `array.new_fixed $t N` | `$t : typeidx`, `N : u32` | +| 0xfb09 | `array.new_data $t $d` | `$t : typeidx`, `$d : dataidx` | +| 0xfb0a | `array.new_elem $t $e` | `$t : typeidx`, `$e : elemidx` | +| 0xfb0b | `array.get $t` | `$t : typeidx` | +| 0xfb0c | `array.get_s $t` | `$t : typeidx` | +| 0xfb0d | `array.get_u $t` | `$t : typeidx` | +| 0xfb0e | `array.set $t` | `$t : typeidx` | +| 0xfb0f | `array.len` | +| 0xfb10 | `array.fill $t` | +| 0xfb11 | `array.copy $t1 $t2` | +| 0xfb12 | `array.init_data $t $d` | +| 0xfb13 | `array.init_elem $t $e` | +| 0xfb14 | `ref.test (ref ht)` | `ht : heaptype` | +| 0xfb15 | `ref.test (ref null ht)` | `ht : heaptype` | +| 0xfb16 | `ref.cast (ref ht)` | `ht : heaptype` | +| 0xfb17 | `ref.cast (ref null ht)` | `ht : heaptype` | +| 0xfb18 | `br_on_cast $l (ref null1? ht1) (ref null2? ht2)` | `flags : u8`, $l : labelidx`, `ht1 : heaptype`, `ht2 : heaptype` | +| 0xfb19 | `br_on_cast_fail $l (ref null1? ht1) (ref null2? ht2)` | `flags : u8`, $l : labelidx`, `ht1 : heaptype`, `ht2 : heaptype` | +| 0xfb1a | `extern.internalize` | +| 0xfb1b | `extern.externalize` | +| 0xfb1c | `i31.new` | +| 0xfb1d | `i31.get_s` | +| 0xfb1e | `i31.get_u` | Flag byte encoding for `br_on_cast(_fail)?`: