diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index ecf34f60bf..06dcf15520 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -687,19 +687,9 @@ Reference Instructions :math:`\REFNULL~x` ....................... -1. Let :math:`F` be the :ref:`current ` :ref:`frame `. - -2. Assert: due to :ref:`validation `, the :ref:`defined type ` :math:`F.\AMODULE.\MITYPES[x]` exists. - -3. Let :math:`\deftype` be the :ref:`defined type ` :math:`F.\AMODULE.\MITYPES[x]`. +$${rule-prose: Step_read/ref.null} -4. Push the value :math:`\REFNULL~\deftype` to the stack. - -$${rule: {Step_read/ref.null-*}} - -.. note:: - No formal reduction rule is required for the case |REFNULL| |ABSHEAPTYPE|, - since the instruction form is already a :ref:`value `. +$${rule: {Step_read/ref.null}} .. _exec-ref.func: diff --git a/document/core/exec/runtime.rst b/document/core/exec/runtime.rst index cfa74500cd..c1b5f7b27d 100644 --- a/document/core/exec/runtime.rst +++ b/document/core/exec/runtime.rst @@ -12,7 +12,6 @@ Runtime Structure .. _syntax-num: .. _syntax-vec: .. _syntax-ref: -.. _syntax-addrref: .. _syntax-ref.i31num: .. _syntax-ref.struct: .. _syntax-ref.array: @@ -34,6 +33,7 @@ It is convenient to reuse the same notation as for the ${:CONST} :ref:`instructi References other than null are represented with additional :ref:`administrative instructions `. They either are *scalar references*, containing a 31-bit :ref:`integer `, +*null references*, *structure references*, pointing to a specific :ref:`structure address `, *array references*, pointing to a specific :ref:`array address `, *function references*, pointing to a specific :ref:`function address `, @@ -41,7 +41,7 @@ They either are *scalar references*, containing a 31-bit :ref:`integer ` defined by the :ref:`embedder `. Any of the aformentioned references can furthermore be wrapped up as an *external reference*. -$${syntax: val num vec ref addrref} +$${syntax: val num vec ref} .. note:: Future versions of WebAssembly may add additional forms of values. @@ -590,7 +590,7 @@ In order to express the reduction of :ref:`traps `, :ref:`calls ` represents an allocated :ref:`reference ` value of respective form :ref:`"on the stack" `. +A :ref:`reference ` represents a :ref:`reference ` value of respective form :ref:`"on the stack" `. The ${:LABEL}, ${:FRAME}, and ${:HANDLER} instructions model :ref:`labels `, :ref:`frames `, and active :ref:`exception handlers `, respectively, :ref:`"on the stack" `. Moreover, the administrative syntax maintains the nesting structure of the original :ref:`structured control instruction ` or :ref:`function body ` and their :ref:`instruction sequences `. diff --git a/document/core/exec/values.rst b/document/core/exec/values.rst index ef2d01920c..a6ee02be65 100644 --- a/document/core/exec/values.rst +++ b/document/core/exec/values.rst @@ -46,11 +46,6 @@ $${rule-prose: Ref_ok/null} $${rule: Ref_ok/null} -.. note:: - A null reference can be typed with any smaller type. - In particular, that allows it to be typed with the least type in its respective hierarchy. - That ensures that the value is compatible with any nullable type in that hierarchy. - .. _valid-ref.i31num: diff --git a/document/core/util/macros.def b/document/core/util/macros.def index ef3b39299a..341ace26cf 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -1531,6 +1531,7 @@ .. Administrative Instructions, terminals .. |REFI31NUM| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}i\scriptstyle31}} +.. |REFNULLADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}null}} .. |REFFUNCADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}func}} .. |REFSTRUCTADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}struct}} .. |REFARRAYADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}array}} @@ -1545,7 +1546,6 @@ .. |num| mathdef:: \xref{exec/runtime}{syntax-num}{\X{num}} .. |vec| mathdef:: \xref{exec/runtime}{syntax-vec}{\X{vec}} .. |reff| mathdef:: \xref{exec/runtime}{syntax-ref}{\X{ref}} -.. |addrref| mathdef:: \xref{exec/runtime}{syntax-addrref}{\X{addrref}} .. |val| mathdef:: \xref{exec/runtime}{syntax-val}{\X{val}} .. |result| mathdef:: \xref{exec/runtime}{syntax-result}{\X{result}} diff --git a/interpreter/README.md b/interpreter/README.md index cade098659..0693b445f9 100644 --- a/interpreter/README.md +++ b/interpreter/README.md @@ -453,7 +453,7 @@ action: const: ( .const ) ;; number value ( + ) ;; vector value - ( ref.null ) ;; null reference + ( ref.null ? ) ;; null reference ( ref.host ) ;; host reference ( ref.extern ) ;; external host reference diff --git a/interpreter/exec/eval.ml b/interpreter/exec/eval.ml index b5ea0e9398..33ffa9a029 100644 --- a/interpreter/exec/eval.ml +++ b/interpreter/exec/eval.ml @@ -126,7 +126,7 @@ let any_ref (inst : moduleinst) x i at = let func_ref (inst : moduleinst) x i at = match any_ref inst x i at with | FuncRef f -> f - | NullRef _ -> Trap.error at ("uninitialized element " ^ Int64.to_string i) + | NullRef -> Trap.error at ("uninitialized element " ^ Int64.to_string i) | _ -> Crash.error at ("type mismatch for element " ^ Int64.to_string i) let blocktype (inst : moduleinst) bt at = @@ -231,13 +231,13 @@ let rec step (c : config) : config = else vs', [Plain (Br (Lib.List32.nth xs i)) @@ e.at] - | BrOnNull x, Ref (NullRef _) :: vs' -> + | BrOnNull x, Ref NullRef :: vs' -> vs', [Plain (Br x) @@ e.at] | BrOnNull x, Ref r :: vs' -> Ref r :: vs', [] - | BrOnNonNull x, Ref (NullRef _) :: vs' -> + | BrOnNonNull x, Ref NullRef :: vs' -> vs', [] | BrOnNonNull x, Ref r :: vs' -> @@ -263,7 +263,7 @@ let rec step (c : config) : config = | Call x, vs -> vs, [Invoke (func c.frame.inst x) @@ e.at] - | CallRef _x, Ref (NullRef _) :: vs -> + | CallRef _x, Ref NullRef :: vs -> vs, [Trapping "null function reference" @@ e.at] | CallRef _x, Ref (FuncRef f) :: vs -> @@ -285,7 +285,7 @@ let rec step (c : config) : config = | _ -> assert false ) - | ReturnCallRef _x, Ref (NullRef _) :: vs -> + | ReturnCallRef _x, Ref NullRef :: vs -> vs, [Trapping "null function reference" @@ e.at] | ReturnCallRef x, vs -> @@ -313,7 +313,7 @@ let rec step (c : config) : config = let args, vs' = split n vs e.at in vs', [Throwing (t, args) @@ e.at] - | ThrowRef, Ref (NullRef _) :: vs -> + | ThrowRef, Ref NullRef :: vs -> vs, [Trapping "null exception reference" @@ e.at] | ThrowRef, Ref (Exn.(ExnRef (Exn (t, args)))) :: vs -> @@ -627,19 +627,19 @@ let rec step (c : config) : config = vs, [] | RefNull t, vs' -> - Ref (NullRef (subst_heaptype (subst_of c.frame.inst) t)) :: vs', [] + Ref NullRef :: vs', [] | RefFunc x, vs' -> let f = func c.frame.inst x in Ref (FuncRef f) :: vs', [] - | RefIsNull, Ref (NullRef _) :: vs' -> + | RefIsNull, Ref NullRef :: vs' -> value_of_bool true :: vs', [] | RefIsNull, Ref _ :: vs' -> value_of_bool false :: vs', [] - | RefAsNonNull, Ref (NullRef _) :: vs' -> + | RefAsNonNull, Ref NullRef :: vs' -> vs', [Trapping "null reference" @@ e.at] | RefAsNonNull, Ref r :: vs' -> @@ -664,7 +664,7 @@ let rec step (c : config) : config = | RefI31, Num (I32 i) :: vs' -> Ref (I31.I31Ref (I31.of_i32 i)) :: vs', [] - | I31Get ext, Ref (NullRef _) :: vs' -> + | I31Get ext, Ref NullRef :: vs' -> vs', [Trapping "null i31 reference" @@ e.at] | I31Get ext, Ref (I31.I31Ref i) :: vs' -> @@ -687,7 +687,7 @@ let rec step (c : config) : config = with Failure _ -> Crash.error e.at "type mismatch packing value" in Ref (Aggr.StructRef struct_) :: vs'', [] - | StructGet (x, i, exto), Ref (NullRef _) :: vs' -> + | StructGet (x, i, exto), Ref NullRef :: vs' -> vs', [Trapping "null structure reference" @@ e.at] | StructGet (x, i, exto), Ref Aggr.(StructRef (Struct (_, fs))) :: vs' -> @@ -698,7 +698,7 @@ let rec step (c : config) : config = (try Aggr.read_field f exto :: vs', [] with Failure _ -> Crash.error e.at "type mismatch reading field") - | StructSet (x, i), v :: Ref (NullRef _) :: vs' -> + | StructSet (x, i), v :: Ref NullRef :: vs' -> vs', [Trapping "null structure reference" @@ e.at] | StructSet (x, i), v :: Ref Aggr.(StructRef (Struct (_, fs))) :: vs' -> @@ -765,7 +765,7 @@ let rec step (c : config) : config = with Failure _ -> Crash.error e.at "type mismatch packing value" in Ref (Aggr.ArrayRef array) :: vs', [] - | ArrayGet (x, exto), Num (I32 i) :: Ref (NullRef _) :: vs' -> + | ArrayGet (x, exto), Num (I32 i) :: Ref NullRef :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArrayGet (x, exto), Num (I32 i) :: Ref (Aggr.ArrayRef a) :: vs' @@ -776,7 +776,7 @@ let rec step (c : config) : config = (try Aggr.read_field (Lib.List32.nth fs i) exto :: vs', [] with Failure _ -> Crash.error e.at "type mismatch reading array") - | ArraySet x, v :: Num (I32 i) :: Ref (NullRef _) :: vs' -> + | ArraySet x, v :: Num (I32 i) :: Ref NullRef :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArraySet x, v :: Num (I32 i) :: Ref (Aggr.ArrayRef a) :: vs' @@ -787,18 +787,18 @@ let rec step (c : config) : config = (try Aggr.write_field (Lib.List32.nth fs i) v; vs', [] with Failure _ -> Crash.error e.at "type mismatch writing array") - | ArrayLen, Ref (NullRef _) :: vs' -> + | ArrayLen, Ref NullRef :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArrayLen, Ref Aggr.(ArrayRef (Array (_, fs))) :: vs' -> Num (I32 (Lib.List32.length fs)) :: vs', [] | ArrayCopy (x, y), - Num _ :: Num _ :: Ref (NullRef _) :: Num _ :: Ref _ :: vs' -> + Num _ :: Num _ :: Ref NullRef :: Num _ :: Ref _ :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArrayCopy (x, y), - Num _ :: Num _ :: Ref _ :: Num _ :: Ref (NullRef _) :: vs' -> + Num _ :: Num _ :: Ref _ :: Num _ :: Ref NullRef :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArrayCopy (x, y), @@ -846,7 +846,7 @@ let rec step (c : config) : config = Plain (ArraySet x); ] - | ArrayFill x, Num (I32 n) :: v :: Num (I32 i) :: Ref (NullRef _) :: vs' -> + | ArrayFill x, Num (I32 n) :: v :: Num (I32 i) :: Ref NullRef :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArrayFill x, Num (I32 n) :: v :: Num (I32 i) :: Ref (Aggr.ArrayRef a) :: vs' -> @@ -868,7 +868,7 @@ let rec step (c : config) : config = ] | ArrayInitData (x, y), - Num _ :: Num _ :: Num _ :: Ref (NullRef _) :: vs' -> + Num _ :: Num _ :: Num _ :: Ref NullRef :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArrayInitData (x, y), @@ -899,7 +899,7 @@ let rec step (c : config) : config = ] | ArrayInitElem (x, y), - Num _ :: Num _ :: Num _ :: Ref (NullRef _) :: vs' -> + Num _ :: Num _ :: Num _ :: Ref NullRef :: vs' -> vs', [Trapping "null array reference" @@ e.at] | ArrayInitElem (x, y), @@ -926,14 +926,14 @@ let rec step (c : config) : config = Plain (ArrayInitElem (x, y)); ] - | ExternConvert Internalize, Ref (NullRef _) :: vs' -> - Ref (NullRef NoneHT) :: vs', [] + | ExternConvert Internalize, Ref NullRef :: vs' -> + Ref NullRef :: vs', [] | ExternConvert Internalize, Ref (Extern.ExternRef r) :: vs' -> Ref r :: vs', [] - | ExternConvert Externalize, Ref (NullRef _) :: vs' -> - Ref (NullRef NoExternHT) :: vs', [] + | ExternConvert Externalize, Ref NullRef :: vs' -> + Ref NullRef :: vs', [] | ExternConvert Externalize, Ref r :: vs' -> Ref (Extern.ExternRef r) :: vs', [] diff --git a/interpreter/host/spectest.ml b/interpreter/host/spectest.ml index db3a44415c..ec29602cc3 100644 --- a/interpreter/host/spectest.ml +++ b/interpreter/host/spectest.ml @@ -15,17 +15,17 @@ let global (GlobalT (_, t) as gt) = | NumT F32T -> Num (F32 (F32.of_float 666.6)) | NumT F64T -> Num (F64 (F64.of_float 666.6)) | VecT V128T -> Vec (V128 (V128.I32x4.of_lanes [666l; 666l; 666l; 666l])) - | RefT (_, t) -> Ref (NullRef t) + | RefT _ -> Ref NullRef | BotT -> assert false in Some (ExternGlobal (Global.alloc gt v)) let table = let tt = TableT (I32AT, {min = 10L; max = Some 20L}, (Null, FuncHT)) in - Some (ExternTable (Table.alloc tt (NullRef FuncHT))) + Some (ExternTable (Table.alloc tt NullRef)) let table64 = let tt = TableT (I64AT, {min = 10L; max = Some 20L}, (Null, FuncHT)) in - Some (ExternTable (Table.alloc tt (NullRef FuncHT))) + Some (ExternTable (Table.alloc tt NullRef)) let memory = let mt = MemoryT (I32AT, {min = 1L; max = Some 2L}) in diff --git a/interpreter/runtime/value.ml b/interpreter/runtime/value.ml index b84468ae82..91d21c888f 100644 --- a/interpreter/runtime/value.ml +++ b/interpreter/runtime/value.ml @@ -17,7 +17,7 @@ type ref_ = .. type value = Num of num | Vec of vec | Ref of ref_ type t = value -type ref_ += NullRef of heaptype +type ref_ += NullRef type address = I64.t @@ -89,7 +89,7 @@ struct end let is_null_ref = function - | NullRef _ -> true + | NullRef -> true | _ -> false @@ -109,7 +109,7 @@ let type_of_vec = type_of_vecop let type_of_ref' = ref (function _ -> assert false) let type_of_ref = function - | NullRef t -> (Null, Match.bot_of_heaptype [] t) + | NullRef -> (Null, BotHT) | r -> (NoNull, !type_of_ref' r) let type_of_value = function @@ -124,11 +124,7 @@ let eq_num n1 n2 = n1 = n2 let eq_vec v1 v2 = v1 = v2 -let eq_ref' = ref (fun r1 r2 -> - match r1, r2 with - | NullRef _, NullRef _ -> true - | _, _ -> r1 == r2 -) +let eq_ref' = ref (==) let eq_ref r1 r2 = !eq_ref' r1 r2 @@ -152,7 +148,7 @@ let default_vec = function | V128T -> Some (Vec (V128 V128.zero)) let default_ref = function - | (Null, t) -> Some (Ref (NullRef t)) + | (Null, _) -> Some (Ref NullRef) | (NoNull, _) -> None let default_value = function @@ -323,7 +319,7 @@ let hex_string_of_vec = function let string_of_ref' = ref (function _ -> "ref") let string_of_ref = function - | NullRef _ -> "null" + | NullRef -> "null" | r -> !string_of_ref' r let string_of_value = function diff --git a/interpreter/script/js.ml b/interpreter/script/js.ml index ae4b5ac127..189cca9a62 100644 --- a/interpreter/script/js.ml +++ b/interpreter/script/js.ml @@ -390,29 +390,30 @@ let abs_mask_of = function | I32T | F32T -> I32 Int32.max_int | I64T | F64T -> I64 Int64.max_int -let value v = - match v.it with - | Num n -> [Const (n @@ v.at) @@ v.at] - | Vec s -> [VecConst (s @@ v.at) @@ v.at] - | Ref (NullRef ht) -> [RefNull (Match.bot_of_heaptype [] ht) @@ v.at] - | Ref (HostRef n) -> +let value v t = + match v.it, t with + | Num n, _ -> [Const (n @@ v.at) @@ v.at] + | Vec s, _ -> [VecConst (s @@ v.at) @@ v.at] + | Ref NullRef, (RefT (_, ht)) -> + [ RefNull (Match.bot_of_heaptype [] ht) @@ v.at ] + | Ref (HostRef n), _ -> [ Const (I32 n @@ v.at) @@ v.at; Call (hostref_idx @@ v.at) @@ v.at; ] - | Ref (Extern.ExternRef (HostRef n)) -> + | Ref (Extern.ExternRef (HostRef n)), _ -> [ Const (I32 n @@ v.at) @@ v.at; Call (hostref_idx @@ v.at) @@ v.at; ExternConvert Externalize @@ v.at; ] - | Ref _ -> assert false + | Ref _, _ -> assert false -let invoke dt vs at = +let invoke dt vs ts at = let dummy = RecT [SubT (Final, [], FuncT ([], []))] in let rts0 = Lib.List32.init subject_type_idx (fun i -> dummy, (dummy, i)) in let rts, i = statify_deftype rts0 dt in List.map (fun (_, (rt, _)) -> rt @@ at) (Lib.List32.drop subject_type_idx rts), ExternFuncT (Idx i), - List.concat (List.map value vs) @ [Call (subject_idx @@ at) @@ at] + List.concat (List.map2 value vs ts) @ [Call (subject_idx @@ at) @@ at] let get t at = [], ExternGlobalT t, [GlobalGet (subject_idx @@ at) @@ at] @@ -529,7 +530,7 @@ let assert_return ress ts at = VecTest (V128 (V128.I8x16 V128Op.AllTrue)) @@ at; Test (I32 I32Op.Eqz) @@ at; BrIf (0l @@ at) @@ at ] - | RefResult (RefPat {it = NullRef _; _}) -> + | RefResult (RefPat {it = NullRef; _}) -> [ RefIsNull @@ at; Test (Value.I32 I32Op.Eqz) @@ at; BrIf (0l @@ at) @@ at ] @@ -704,7 +705,7 @@ let of_vec v = let of_ref r = let open Value in match r with - | NullRef _ -> "null" + | NullRef -> "null" | HostRef n | Extern.ExternRef (HostRef n) -> "hostref(" ^ Int32.to_string n ^ ")" | _ -> assert false @@ -763,11 +764,11 @@ let of_action env act = "[" ^ String.concat ", " (List.map of_value vs) ^ "])", (match lookup_export env x_opt name act.at with | ExternFuncT (Def dt) -> - let (_, out) as ft = functype_of_comptype (expand_deftype dt) in + let (ins, out) as ft = functype_of_comptype (expand_deftype dt) in if is_js_functype ft then None else - Some (of_wrapper env x_opt name (invoke dt vs), out) + Some (of_wrapper env x_opt name (invoke dt vs ins), out) | _ -> None ) | Get (x_opt, name) -> diff --git a/interpreter/script/runner.ml b/interpreter/script/runner.ml index b5af67454b..bc9fdb0c51 100644 --- a/interpreter/script/runner.ml +++ b/interpreter/script/runner.ml @@ -463,7 +463,7 @@ let assert_ref_pat r p = | RefTypePat Types.FuncHT, Instance.FuncRef _ | RefTypePat Types.ExnHT, Exn.ExnRef _ | RefTypePat Types.ExternHT, _ -> true - | NullPat, Value.NullRef _ -> true + | NullPat, Value.NullRef -> true | _ -> false let rec assert_result v r = diff --git a/interpreter/text/arrange.ml b/interpreter/text/arrange.ml index 1ab2c222db..bcbb6979fc 100644 --- a/interpreter/text/arrange.ml +++ b/interpreter/text/arrange.ml @@ -771,7 +771,7 @@ let num mode = if mode = `Binary then hex_string_of_num else string_of_num let vec mode = if mode = `Binary then hex_string_of_vec else string_of_vec let ref_ = function - | NullRef t -> Node ("ref.null " ^ heaptype t, []) + | NullRef -> Node ("ref.null", []) | Script.HostRef n -> Node ("ref.host " ^ nat32 n, []) | Extern.ExternRef (Script.HostRef n) -> Node ("ref.extern " ^ nat32 n, []) | _ -> assert false diff --git a/interpreter/text/parser.mly b/interpreter/text/parser.mly index 194590270c..1bcc33393c 100644 --- a/interpreter/text/parser.mly +++ b/interpreter/text/parser.mly @@ -1500,7 +1500,7 @@ literal_vec : | LPAR VEC_CONST VECSHAPE list(num) RPAR { snd (vec $2 $3 $4 $sloc) } literal_ref : - | LPAR REF_NULL heaptype RPAR { Value.NullRef ($3 (empty_context ())) } + | LPAR REF_NULL heaptype? RPAR { Value.NullRef } | LPAR REF_HOST NAT RPAR { Script.HostRef (nat32 $3 $loc($3)) } | LPAR REF_EXTERN NAT RPAR { Extern.ExternRef (Script.HostRef (nat32 $3 $loc($3))) } @@ -1525,7 +1525,6 @@ result : | LPAR REF_FUNC RPAR { RefResult (RefTypePat FuncHT) @@ $sloc } | LPAR REF_EXN RPAR { RefResult (RefTypePat ExnHT) @@ $sloc } | LPAR REF_EXTERN RPAR { RefResult (RefTypePat ExternHT) @@ $sloc } - | LPAR REF_NULL RPAR { RefResult NullPat @@ $sloc } | LPAR VEC_CONST VECSHAPE list(numpat) RPAR { if V128.num_lanes $3 <> List.length $4 then error (at $sloc) "wrong number of lane literals"; diff --git a/specification/wasm-3.0/4.0-execution.configurations.spectec b/specification/wasm-3.0/4.0-execution.configurations.spectec index d7c2ce8f93..1a1a6b2246 100644 --- a/specification/wasm-3.0/4.0-execution.configurations.spectec +++ b/specification/wasm-3.0/4.0-execution.configurations.spectec @@ -32,18 +32,15 @@ syntax num hint(desc "number value") = syntax vec hint(desc "vector value") = | VCONST vectype vec_(vectype) hint(show %.CONST %%) hint(macro "VCONST") -syntax addrref hint(desc "address value") = +syntax ref hint(desc "reference value") hint(macro "reff") = | REF.I31_NUM u31 hint(show REF.I31 %%) hint(macro "%NUM") + | REF.NULL_ADDR hint(show REF.NULL) hint(macro "%ADDR") | REF.STRUCT_ADDR structaddr hint(show REF.STRUCT %%) hint(macro "%ADDR") | REF.ARRAY_ADDR arrayaddr hint(show REF.ARRAY %%) hint(macro "%ADDR") | REF.FUNC_ADDR funcaddr hint(show REF.FUNC %%) hint(macro "%ADDR") | REF.EXN_ADDR exnaddr hint(show REF.EXN %%) hint(macro "%ADDR") | REF.HOST_ADDR hostaddr hint(show REF.HOST %%) hint(macro "%ADDR") - | REF.EXTERN addrref - -syntax ref hint(desc "reference value") hint(macro "reff") = - | addrref - | REF.NULL heaptype + | REF.EXTERN ref syntax val hint(desc "value") = | num | vec | ref @@ -135,7 +132,7 @@ syntax frame hint(desc "frame") hint(macro "%" "A%") = syntax instr/admin hint(desc "administrative instruction") = | ... - | addrref + | ref | LABEL_ n `{instr*} instr* hint(show LABEL_%#% %%) | FRAME_ n `{frame} instr* hint(show FRAME_%#% %%) | HANDLER_ n `{catch*} instr* hint(show HANDLER_%#% %%) diff --git a/specification/wasm-3.0/4.1-execution.values.spectec b/specification/wasm-3.0/4.1-execution.values.spectec index 1b38a06234..b6951b99ee 100644 --- a/specification/wasm-3.0/4.1-execution.values.spectec +++ b/specification/wasm-3.0/4.1-execution.values.spectec @@ -8,7 +8,7 @@ def $default_(valtype) : val? def $default_(Inn) = (CONST Inn 0) def $default_(Fnn) = (CONST Fnn $fzero($size(Fnn))) def $default_(Vnn) = (VCONST Vnn 0) -def $default_(REF NULL ht) = (REF.NULL ht) +def $default_(REF NULL ht) = REF.NULL_ADDR def $default_(REF ht) = eps ;;relation Defaultable: |- valtype DEFAULTABLE ;; forward-declared in validation.instructions @@ -33,8 +33,7 @@ rule Vec_ok: rule Ref_ok/null: - s |- REF.NULL ht : (REF NULL ht') - -- Heaptype_sub: {} |- ht' <: ht + s |- REF.NULL_ADDR : (REF NULL BOT) rule Ref_ok/i31: s |- REF.I31_NUM i : (REF I31) @@ -59,8 +58,9 @@ rule Ref_ok/host: s |- REF.HOST_ADDR a : (REF ANY) rule Ref_ok/extern: - s |- REF.EXTERN addrref : (REF EXTERN) - -- Ref_ok: s |- addrref : (REF ANY) + s |- REF.EXTERN ref : (REF EXTERN) + -- Ref_ok: s |- ref : (REF ANY) + -- if ref =/= REF.NULL_ADDR rule Ref_ok/sub: s |- ref : rt diff --git a/specification/wasm-3.0/4.3-execution.instructions.spectec b/specification/wasm-3.0/4.3-execution.instructions.spectec index 8ed03426ac..9368923f30 100644 --- a/specification/wasm-3.0/4.3-execution.instructions.spectec +++ b/specification/wasm-3.0/4.3-execution.instructions.spectec @@ -130,7 +130,7 @@ rule Step_pure/br_table-ge: rule Step_pure/br_on_null-null: val (BR_ON_NULL l) ~> (BR l) - -- if val = REF.NULL ht + -- if val = REF.NULL_ADDR rule Step_pure/br_on_null-addr: val (BR_ON_NULL l) ~> val @@ -139,7 +139,7 @@ rule Step_pure/br_on_null-addr: rule Step_pure/br_on_non_null-null: val (BR_ON_NON_NULL l) ~> eps - -- if val = REF.NULL ht + -- if val = REF.NULL_ADDR rule Step_pure/br_on_non_null-addr: val (BR_ON_NON_NULL l) ~> val (BR l) @@ -175,7 +175,7 @@ rule Step_read/call: -- if $moduleinst(z).FUNCS[x] = a rule Step_read/call_ref-null: - z; (REF.NULL ht) (CALL_REF yy) ~> TRAP + z; (REF.NULL_ADDR) (CALL_REF yy) ~> TRAP rule Step_read/call_ref-func: z; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) @@ -198,7 +198,7 @@ rule Step_read/return_call_ref-handler: z; (HANDLER_ k `{catch*} val* (RETURN_CALL_REF yy) instr*) ~> val* (RETURN_CALL_REF yy) rule Step_read/return_call_ref-frame-null: - z; (FRAME_ k `{f} val* (REF.NULL ht) (RETURN_CALL_REF yy) instr*) ~> TRAP + z; (FRAME_ k `{f} val* (REF.NULL_ADDR) (RETURN_CALL_REF yy) instr*) ~> TRAP rule Step_read/return_call_ref-frame-addr: z; (FRAME_ k `{f} val'* val^n (REF.FUNC_ADDR a) (RETURN_CALL_REF yy) instr*) ~> val^n (REF.FUNC_ADDR a) (CALL_REF yy) @@ -235,7 +235,7 @@ rule Step/throw: -- if exn = {TAG $tagaddr(z)[x], FIELDS val^n} rule Step_read/throw_ref-null: - z; (REF.NULL ht) THROW_REF ~> TRAP + z; (REF.NULL_ADDR) THROW_REF ~> TRAP rule Step_read/throw_ref-instrs: z; val* (REF.EXN_ADDR a) THROW_REF instr* ~> (REF.EXN_ADDR a) THROW_REF @@ -622,8 +622,8 @@ rule Step/data.drop: ;; Reference instructions -rule Step_read/ref.null-idx: - z; (REF.NULL (_IDX x)) ~> (REF.NULL $type(z, x)) +rule Step_read/ref.null: + z; (REF.NULL ht) ~> REF.NULL_ADDR rule Step_read/ref.func: z; (REF.FUNC x) ~> (REF.FUNC_ADDR $moduleinst(z).FUNCS[x]) @@ -634,7 +634,7 @@ rule Step_pure/ref.i31: rule Step_pure/ref.is_null-true: ref REF.IS_NULL ~> (CONST I32 1) - -- if ref = (REF.NULL ht) + -- if ref = REF.NULL_ADDR rule Step_pure/ref.is_null-false: ref REF.IS_NULL ~> (CONST I32 0) @@ -643,7 +643,7 @@ rule Step_pure/ref.is_null-false: rule Step_pure/ref.as_non_null-null: ref REF.AS_NON_NULL ~> TRAP - -- if ref = (REF.NULL ht) + -- if ref = REF.NULL_ADDR rule Step_pure/ref.as_non_null-addr: ref REF.AS_NON_NULL ~> ref @@ -652,7 +652,7 @@ rule Step_pure/ref.as_non_null-addr: rule Step_pure/ref.eq-null: ref_1 ref_2 REF.EQ ~> (CONST I32 1) - -- if ref_1 = (REF.NULL ht_1) /\ ref_2 = (REF.NULL ht_2) + -- if ref_1 = REF.NULL_ADDR /\ ref_2 = REF.NULL_ADDR rule Step_pure/ref.eq-true: ref_1 ref_2 REF.EQ ~> (CONST I32 1) @@ -689,7 +689,7 @@ rule Step_read/ref.cast-fail: ;; Scalar reference instructions rule Step_pure/i31.get-null: - (REF.NULL ht) (I31.GET sx) ~> TRAP + (REF.NULL_ADDR) (I31.GET sx) ~> TRAP rule Step_pure/i31.get-num: (REF.I31_NUM i) (I31.GET sx) ~> (CONST I32 $extend__(31, 32, sx, i)) @@ -710,7 +710,7 @@ rule Step_read/struct.new_default: rule Step_read/struct.get-null: - z; (REF.NULL ht) (STRUCT.GET sx? x i) ~> TRAP + z; (REF.NULL_ADDR) (STRUCT.GET sx? x i) ~> TRAP rule Step_read/struct.get-struct: z; (REF.STRUCT_ADDR a) (STRUCT.GET sx? x i) ~> $unpackfield_(zt*[i], sx?, $structinst(z)[a].FIELDS[i]) @@ -719,7 +719,7 @@ rule Step_read/struct.get-struct: rule Step/struct.set-null: - z; (REF.NULL ht) val (STRUCT.SET x i) ~> z; TRAP + z; (REF.NULL_ADDR) val (STRUCT.SET x i) ~> z; TRAP rule Step/struct.set-struct: z; (REF.STRUCT_ADDR a) val (STRUCT.SET x i) ~> $with_struct(z, a, i, $packfield_(zt*[i], val)); eps @@ -770,7 +770,7 @@ rule Step_read/array.new_data-num: rule Step_read/array.get-null: - z; (REF.NULL ht) (CONST I32 i) (ARRAY.GET sx? x) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) (ARRAY.GET sx? x) ~> TRAP rule Step_read/array.get-oob: z; (REF.ARRAY_ADDR a) (CONST I32 i) (ARRAY.GET sx? x) ~> TRAP @@ -783,7 +783,7 @@ rule Step_read/array.get-array: rule Step/array.set-null: - z; (REF.NULL ht) (CONST I32 i) val (ARRAY.SET x) ~> z; TRAP + z; (REF.NULL_ADDR) (CONST I32 i) val (ARRAY.SET x) ~> z; TRAP rule Step/array.set-oob: z; (REF.ARRAY_ADDR a) (CONST I32 i) val (ARRAY.SET x) ~> z; TRAP @@ -796,14 +796,14 @@ rule Step/array.set-array: rule Step_read/array.len-null: - z; (REF.NULL ht) ARRAY.LEN ~> TRAP + z; (REF.NULL_ADDR) ARRAY.LEN ~> TRAP rule Step_read/array.len-array: z; (REF.ARRAY_ADDR a) ARRAY.LEN ~> (CONST I32 $(|$arrayinst(z)[a].FIELDS|)) rule Step_read/array.fill-null: - z; (REF.NULL ht) (CONST I32 i) val (CONST I32 n) (ARRAY.FILL x) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) val (CONST I32 n) (ARRAY.FILL x) ~> TRAP rule Step_read/array.fill-oob: z; (REF.ARRAY_ADDR a) (CONST I32 i) val (CONST I32 n) (ARRAY.FILL x) ~> TRAP @@ -821,10 +821,10 @@ rule Step_read/array.fill-succ: -- otherwise rule Step_read/array.copy-null1: - z; (REF.NULL ht_1) (CONST I32 i_1) ref (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i_1) ref (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP rule Step_read/array.copy-null2: - z; ref (CONST I32 i_1) (REF.NULL ht_2) (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP + z; ref (CONST I32 i_1) (REF.NULL_ADDR) (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP rule Step_read/array.copy-oob1: z; (REF.ARRAY_ADDR a_1) (CONST I32 i_1) (REF.ARRAY_ADDR a_2) (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP @@ -867,7 +867,7 @@ rule Step_read/array.copy-gt: rule Step_read/array.init_elem-null: - z; (REF.NULL ht) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_ELEM x y) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_ELEM x y) ~> TRAP rule Step_read/array.init_elem-oob1: z; (REF.ARRAY_ADDR a) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_ELEM x y) ~> TRAP @@ -895,7 +895,7 @@ rule Step_read/array.init_elem-succ: rule Step_read/array.init_data-null: - z; (REF.NULL ht) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_DATA x y) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_DATA x y) ~> TRAP rule Step_read/array.init_data-oob1: z; (REF.ARRAY_ADDR a) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_DATA x y) ~> TRAP @@ -928,17 +928,19 @@ rule Step_read/array.init_data-num: ;; External reference instructions rule Step_pure/extern.convert_any-null: - (REF.NULL ht) EXTERN.CONVERT_ANY ~> (REF.NULL EXTERN) + ref EXTERN.CONVERT_ANY ~> REF.NULL_ADDR + -- if ref = REF.NULL_ADDR rule Step_pure/extern.convert_any-addr: - addrref EXTERN.CONVERT_ANY ~> (REF.EXTERN addrref) + ref EXTERN.CONVERT_ANY ~> (REF.EXTERN ref) + -- otherwise rule Step_pure/any.convert_extern-null: - (REF.NULL ht) ANY.CONVERT_EXTERN ~> (REF.NULL ANY) + (REF.NULL_ADDR) ANY.CONVERT_EXTERN ~> REF.NULL_ADDR rule Step_pure/any.convert_extern-addr: - (REF.EXTERN addrref) ANY.CONVERT_EXTERN ~> addrref + (REF.EXTERN ref) ANY.CONVERT_EXTERN ~> ref ;; Numeric instructions diff --git a/specification/wasm-latest/4.0-execution.configurations.spectec b/specification/wasm-latest/4.0-execution.configurations.spectec index d7c2ce8f93..1a1a6b2246 100644 --- a/specification/wasm-latest/4.0-execution.configurations.spectec +++ b/specification/wasm-latest/4.0-execution.configurations.spectec @@ -32,18 +32,15 @@ syntax num hint(desc "number value") = syntax vec hint(desc "vector value") = | VCONST vectype vec_(vectype) hint(show %.CONST %%) hint(macro "VCONST") -syntax addrref hint(desc "address value") = +syntax ref hint(desc "reference value") hint(macro "reff") = | REF.I31_NUM u31 hint(show REF.I31 %%) hint(macro "%NUM") + | REF.NULL_ADDR hint(show REF.NULL) hint(macro "%ADDR") | REF.STRUCT_ADDR structaddr hint(show REF.STRUCT %%) hint(macro "%ADDR") | REF.ARRAY_ADDR arrayaddr hint(show REF.ARRAY %%) hint(macro "%ADDR") | REF.FUNC_ADDR funcaddr hint(show REF.FUNC %%) hint(macro "%ADDR") | REF.EXN_ADDR exnaddr hint(show REF.EXN %%) hint(macro "%ADDR") | REF.HOST_ADDR hostaddr hint(show REF.HOST %%) hint(macro "%ADDR") - | REF.EXTERN addrref - -syntax ref hint(desc "reference value") hint(macro "reff") = - | addrref - | REF.NULL heaptype + | REF.EXTERN ref syntax val hint(desc "value") = | num | vec | ref @@ -135,7 +132,7 @@ syntax frame hint(desc "frame") hint(macro "%" "A%") = syntax instr/admin hint(desc "administrative instruction") = | ... - | addrref + | ref | LABEL_ n `{instr*} instr* hint(show LABEL_%#% %%) | FRAME_ n `{frame} instr* hint(show FRAME_%#% %%) | HANDLER_ n `{catch*} instr* hint(show HANDLER_%#% %%) diff --git a/specification/wasm-latest/4.1-execution.values.spectec b/specification/wasm-latest/4.1-execution.values.spectec index 1b38a06234..b6951b99ee 100644 --- a/specification/wasm-latest/4.1-execution.values.spectec +++ b/specification/wasm-latest/4.1-execution.values.spectec @@ -8,7 +8,7 @@ def $default_(valtype) : val? def $default_(Inn) = (CONST Inn 0) def $default_(Fnn) = (CONST Fnn $fzero($size(Fnn))) def $default_(Vnn) = (VCONST Vnn 0) -def $default_(REF NULL ht) = (REF.NULL ht) +def $default_(REF NULL ht) = REF.NULL_ADDR def $default_(REF ht) = eps ;;relation Defaultable: |- valtype DEFAULTABLE ;; forward-declared in validation.instructions @@ -33,8 +33,7 @@ rule Vec_ok: rule Ref_ok/null: - s |- REF.NULL ht : (REF NULL ht') - -- Heaptype_sub: {} |- ht' <: ht + s |- REF.NULL_ADDR : (REF NULL BOT) rule Ref_ok/i31: s |- REF.I31_NUM i : (REF I31) @@ -59,8 +58,9 @@ rule Ref_ok/host: s |- REF.HOST_ADDR a : (REF ANY) rule Ref_ok/extern: - s |- REF.EXTERN addrref : (REF EXTERN) - -- Ref_ok: s |- addrref : (REF ANY) + s |- REF.EXTERN ref : (REF EXTERN) + -- Ref_ok: s |- ref : (REF ANY) + -- if ref =/= REF.NULL_ADDR rule Ref_ok/sub: s |- ref : rt diff --git a/specification/wasm-latest/4.3-execution.instructions.spectec b/specification/wasm-latest/4.3-execution.instructions.spectec index 8ed03426ac..9368923f30 100644 --- a/specification/wasm-latest/4.3-execution.instructions.spectec +++ b/specification/wasm-latest/4.3-execution.instructions.spectec @@ -130,7 +130,7 @@ rule Step_pure/br_table-ge: rule Step_pure/br_on_null-null: val (BR_ON_NULL l) ~> (BR l) - -- if val = REF.NULL ht + -- if val = REF.NULL_ADDR rule Step_pure/br_on_null-addr: val (BR_ON_NULL l) ~> val @@ -139,7 +139,7 @@ rule Step_pure/br_on_null-addr: rule Step_pure/br_on_non_null-null: val (BR_ON_NON_NULL l) ~> eps - -- if val = REF.NULL ht + -- if val = REF.NULL_ADDR rule Step_pure/br_on_non_null-addr: val (BR_ON_NON_NULL l) ~> val (BR l) @@ -175,7 +175,7 @@ rule Step_read/call: -- if $moduleinst(z).FUNCS[x] = a rule Step_read/call_ref-null: - z; (REF.NULL ht) (CALL_REF yy) ~> TRAP + z; (REF.NULL_ADDR) (CALL_REF yy) ~> TRAP rule Step_read/call_ref-func: z; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) @@ -198,7 +198,7 @@ rule Step_read/return_call_ref-handler: z; (HANDLER_ k `{catch*} val* (RETURN_CALL_REF yy) instr*) ~> val* (RETURN_CALL_REF yy) rule Step_read/return_call_ref-frame-null: - z; (FRAME_ k `{f} val* (REF.NULL ht) (RETURN_CALL_REF yy) instr*) ~> TRAP + z; (FRAME_ k `{f} val* (REF.NULL_ADDR) (RETURN_CALL_REF yy) instr*) ~> TRAP rule Step_read/return_call_ref-frame-addr: z; (FRAME_ k `{f} val'* val^n (REF.FUNC_ADDR a) (RETURN_CALL_REF yy) instr*) ~> val^n (REF.FUNC_ADDR a) (CALL_REF yy) @@ -235,7 +235,7 @@ rule Step/throw: -- if exn = {TAG $tagaddr(z)[x], FIELDS val^n} rule Step_read/throw_ref-null: - z; (REF.NULL ht) THROW_REF ~> TRAP + z; (REF.NULL_ADDR) THROW_REF ~> TRAP rule Step_read/throw_ref-instrs: z; val* (REF.EXN_ADDR a) THROW_REF instr* ~> (REF.EXN_ADDR a) THROW_REF @@ -622,8 +622,8 @@ rule Step/data.drop: ;; Reference instructions -rule Step_read/ref.null-idx: - z; (REF.NULL (_IDX x)) ~> (REF.NULL $type(z, x)) +rule Step_read/ref.null: + z; (REF.NULL ht) ~> REF.NULL_ADDR rule Step_read/ref.func: z; (REF.FUNC x) ~> (REF.FUNC_ADDR $moduleinst(z).FUNCS[x]) @@ -634,7 +634,7 @@ rule Step_pure/ref.i31: rule Step_pure/ref.is_null-true: ref REF.IS_NULL ~> (CONST I32 1) - -- if ref = (REF.NULL ht) + -- if ref = REF.NULL_ADDR rule Step_pure/ref.is_null-false: ref REF.IS_NULL ~> (CONST I32 0) @@ -643,7 +643,7 @@ rule Step_pure/ref.is_null-false: rule Step_pure/ref.as_non_null-null: ref REF.AS_NON_NULL ~> TRAP - -- if ref = (REF.NULL ht) + -- if ref = REF.NULL_ADDR rule Step_pure/ref.as_non_null-addr: ref REF.AS_NON_NULL ~> ref @@ -652,7 +652,7 @@ rule Step_pure/ref.as_non_null-addr: rule Step_pure/ref.eq-null: ref_1 ref_2 REF.EQ ~> (CONST I32 1) - -- if ref_1 = (REF.NULL ht_1) /\ ref_2 = (REF.NULL ht_2) + -- if ref_1 = REF.NULL_ADDR /\ ref_2 = REF.NULL_ADDR rule Step_pure/ref.eq-true: ref_1 ref_2 REF.EQ ~> (CONST I32 1) @@ -689,7 +689,7 @@ rule Step_read/ref.cast-fail: ;; Scalar reference instructions rule Step_pure/i31.get-null: - (REF.NULL ht) (I31.GET sx) ~> TRAP + (REF.NULL_ADDR) (I31.GET sx) ~> TRAP rule Step_pure/i31.get-num: (REF.I31_NUM i) (I31.GET sx) ~> (CONST I32 $extend__(31, 32, sx, i)) @@ -710,7 +710,7 @@ rule Step_read/struct.new_default: rule Step_read/struct.get-null: - z; (REF.NULL ht) (STRUCT.GET sx? x i) ~> TRAP + z; (REF.NULL_ADDR) (STRUCT.GET sx? x i) ~> TRAP rule Step_read/struct.get-struct: z; (REF.STRUCT_ADDR a) (STRUCT.GET sx? x i) ~> $unpackfield_(zt*[i], sx?, $structinst(z)[a].FIELDS[i]) @@ -719,7 +719,7 @@ rule Step_read/struct.get-struct: rule Step/struct.set-null: - z; (REF.NULL ht) val (STRUCT.SET x i) ~> z; TRAP + z; (REF.NULL_ADDR) val (STRUCT.SET x i) ~> z; TRAP rule Step/struct.set-struct: z; (REF.STRUCT_ADDR a) val (STRUCT.SET x i) ~> $with_struct(z, a, i, $packfield_(zt*[i], val)); eps @@ -770,7 +770,7 @@ rule Step_read/array.new_data-num: rule Step_read/array.get-null: - z; (REF.NULL ht) (CONST I32 i) (ARRAY.GET sx? x) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) (ARRAY.GET sx? x) ~> TRAP rule Step_read/array.get-oob: z; (REF.ARRAY_ADDR a) (CONST I32 i) (ARRAY.GET sx? x) ~> TRAP @@ -783,7 +783,7 @@ rule Step_read/array.get-array: rule Step/array.set-null: - z; (REF.NULL ht) (CONST I32 i) val (ARRAY.SET x) ~> z; TRAP + z; (REF.NULL_ADDR) (CONST I32 i) val (ARRAY.SET x) ~> z; TRAP rule Step/array.set-oob: z; (REF.ARRAY_ADDR a) (CONST I32 i) val (ARRAY.SET x) ~> z; TRAP @@ -796,14 +796,14 @@ rule Step/array.set-array: rule Step_read/array.len-null: - z; (REF.NULL ht) ARRAY.LEN ~> TRAP + z; (REF.NULL_ADDR) ARRAY.LEN ~> TRAP rule Step_read/array.len-array: z; (REF.ARRAY_ADDR a) ARRAY.LEN ~> (CONST I32 $(|$arrayinst(z)[a].FIELDS|)) rule Step_read/array.fill-null: - z; (REF.NULL ht) (CONST I32 i) val (CONST I32 n) (ARRAY.FILL x) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) val (CONST I32 n) (ARRAY.FILL x) ~> TRAP rule Step_read/array.fill-oob: z; (REF.ARRAY_ADDR a) (CONST I32 i) val (CONST I32 n) (ARRAY.FILL x) ~> TRAP @@ -821,10 +821,10 @@ rule Step_read/array.fill-succ: -- otherwise rule Step_read/array.copy-null1: - z; (REF.NULL ht_1) (CONST I32 i_1) ref (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i_1) ref (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP rule Step_read/array.copy-null2: - z; ref (CONST I32 i_1) (REF.NULL ht_2) (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP + z; ref (CONST I32 i_1) (REF.NULL_ADDR) (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP rule Step_read/array.copy-oob1: z; (REF.ARRAY_ADDR a_1) (CONST I32 i_1) (REF.ARRAY_ADDR a_2) (CONST I32 i_2) (CONST I32 n) (ARRAY.COPY x_1 x_2) ~> TRAP @@ -867,7 +867,7 @@ rule Step_read/array.copy-gt: rule Step_read/array.init_elem-null: - z; (REF.NULL ht) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_ELEM x y) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_ELEM x y) ~> TRAP rule Step_read/array.init_elem-oob1: z; (REF.ARRAY_ADDR a) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_ELEM x y) ~> TRAP @@ -895,7 +895,7 @@ rule Step_read/array.init_elem-succ: rule Step_read/array.init_data-null: - z; (REF.NULL ht) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_DATA x y) ~> TRAP + z; (REF.NULL_ADDR) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_DATA x y) ~> TRAP rule Step_read/array.init_data-oob1: z; (REF.ARRAY_ADDR a) (CONST I32 i) (CONST I32 j) (CONST I32 n) (ARRAY.INIT_DATA x y) ~> TRAP @@ -928,17 +928,19 @@ rule Step_read/array.init_data-num: ;; External reference instructions rule Step_pure/extern.convert_any-null: - (REF.NULL ht) EXTERN.CONVERT_ANY ~> (REF.NULL EXTERN) + ref EXTERN.CONVERT_ANY ~> REF.NULL_ADDR + -- if ref = REF.NULL_ADDR rule Step_pure/extern.convert_any-addr: - addrref EXTERN.CONVERT_ANY ~> (REF.EXTERN addrref) + ref EXTERN.CONVERT_ANY ~> (REF.EXTERN ref) + -- otherwise rule Step_pure/any.convert_extern-null: - (REF.NULL ht) ANY.CONVERT_EXTERN ~> (REF.NULL ANY) + (REF.NULL_ADDR) ANY.CONVERT_EXTERN ~> REF.NULL_ADDR rule Step_pure/any.convert_extern-addr: - (REF.EXTERN addrref) ANY.CONVERT_EXTERN ~> addrref + (REF.EXTERN ref) ANY.CONVERT_EXTERN ~> ref ;; Numeric instructions diff --git a/spectec/doc/example/output/NanoWasm.pdf b/spectec/doc/example/output/NanoWasm.pdf index 772ae3066b..102857f978 100644 Binary files a/spectec/doc/example/output/NanoWasm.pdf and b/spectec/doc/example/output/NanoWasm.pdf differ diff --git a/spectec/src/backend-interpreter/construct.ml b/spectec/src/backend-interpreter/construct.ml index fd5484d89c..b8ef93fc5b 100644 --- a/spectec/src/backend-interpreter/construct.ml +++ b/spectec/src/backend-interpreter/construct.ml @@ -1016,8 +1016,9 @@ and al_to_funcinst: value -> Instance.funcinst = function | v -> error_value "funcinst" v and al_to_ref: value -> ref_ = function - | CaseV ("REF.NULL", [ ht ]) -> NullRef (al_to_heaptype ht) | CaseV ("REF.I31_NUM", [ i ]) -> I31.I31Ref (al_to_nat i) + | CaseV ("REF.NULL_ADDR", []) -> NullRef + | CaseV ("REF.NULL", [ _ht ]) when !version <= 2 -> NullRef | CaseV ("REF.STRUCT_ADDR", [ addr ]) -> let struct_insts = Ds.Store.access "STRUCTS" in let struct_ = addr |> al_to_nat |> listv_nth struct_insts |> al_to_struct in @@ -1237,7 +1238,8 @@ let al_of_vec_shape shape (lanes: int64 list) = )) let rec al_of_ref = function - | NullRef ht -> CaseV ("REF.NULL", [ al_of_heaptype ht ]) + | NullRef when !version <= 2 -> CaseV ("REF.NULL", [ al_of_heaptype NoneHT ]) + | NullRef -> CaseV ("REF.NULL_ADDR", []) (* | I31.I31Ref i -> CaseV ("REF.I31_NUM", [ NumV (Int64.of_int i) ]) diff --git a/spectec/src/backend-interpreter/host.ml b/spectec/src/backend-interpreter/host.ml index 4d59c5d926..7fb04491c2 100644 --- a/spectec/src/backend-interpreter/host.ml +++ b/spectec/src/backend-interpreter/host.ml @@ -69,13 +69,13 @@ let spectest () = "global_f64", 666.6 |> F64.of_float |> f64_to_const |> create_globalinst (TupV [none "MUT"; nullary "F64"]); ] in (* Builtin tables *) - let nulls = CaseV ("REF.NULL", [ nullary "FUNC" ]) |> Array.make 10 in - let funcref = + let null, funcref = if !Construct.version <= 2 then - nullary "FUNCREF" + CaseV ("REF.NULL", [ nullary "FUNC" ]), nullary "FUNCREF" else - CaseV ("REF", [some "NULL"; nullary "FUNC"]) + nullary "REF.NULL_ADDR", CaseV ("REF", [some "NULL"; nullary "FUNC"]) in + let nulls = Array.make 10 null in let mk_ttype nt = let args = [ CaseV ("[", [ natV (Z.of_int 10); someV (natV (Z.of_int 20)) ]); funcref ] in if !Construct.version <= 2 then diff --git a/spectec/src/backend-interpreter/interpreter.ml b/spectec/src/backend-interpreter/interpreter.ml index 4cedf25b7e..945a05db00 100644 --- a/spectec/src/backend-interpreter/interpreter.ml +++ b/spectec/src/backend-interpreter/interpreter.ml @@ -165,10 +165,12 @@ and check_type ty v expr = ] in match v with (* addrref *) - | CaseV (ar, _) when List.mem ar addr_refs-> - boolV (ty = "addrref" ||ty = "ref" || ty = "val") + | CaseV (ar, _) when List.mem ar addr_refs -> + boolV (ty = "addrref" || ty = "ref" || ty = "val") (* nul *) - | CaseV ("REF.NULL", _) -> + | CaseV ("REF.NULL_ADDR", _) -> + boolV (ty = "nul" || ty = "ref" || ty = "val") + | CaseV ("REF.NULL", _) when !Construct.version <= 2 -> boolV (ty = "nul" || ty = "ref" || ty = "val") (* values *) | CaseV ("CONST", CaseV (nt, []) ::_) when List.mem nt inn_types -> @@ -707,9 +709,10 @@ and try_step_instr fname ctx env instr = try_with_error fname instr.at string_of_instr (step_instr fname ctx env) instr and step_wasm (ctx: AlContext.t) : value -> AlContext.t = function - | CaseV ("REF.NULL" as name, ([ CaseV ("_IDX", _) ] as args)) -> + | CaseV ("REF.NULL" as name, ([ CaseV ("_IDX", _) ] as args)) when !Construct.version <= 2 -> create_context name args :: ctx - | CaseV ("REF.NULL", _) + | CaseV ("REF.NULL", _) as v when !Construct.version <= 2 -> + WasmContext.push_value v; ctx | CaseV ("CONST", _) | CaseV ("VCONST", _) as v -> WasmContext.push_value v; ctx | CaseV (name, []) when Host.is_host name -> Host.call name; ctx diff --git a/spectec/src/backend-interpreter/relation.ml b/spectec/src/backend-interpreter/relation.ml index f5c25d7dde..9223ab89f0 100644 --- a/spectec/src/backend-interpreter/relation.ml +++ b/spectec/src/backend-interpreter/relation.ml @@ -10,30 +10,10 @@ let ref_ok = (* TODO: some / none *) let null = some "NULL" in let nonull = none "NULL" in - let none = nullary "NONE" in - let nofunc = nullary "NOFUNC" in - let noexn = nullary "NOEXN" in - let noextern = nullary "NOEXTERN" in - - let match_heaptype v1 v2 = - let ht1 = Construct.al_to_heaptype v1 in - let ht2 = Construct.al_to_heaptype v2 in - Match.match_reftype [] (Types.Null, ht1) (Types.Null, ht2) - in function (* null *) - | [CaseV ("REF.NULL", [ ht ]) as v] -> - if match_heaptype none ht then - CaseV ("REF", [ null; none]) - else if match_heaptype nofunc ht then - CaseV ("REF", [ null; nofunc]) - else if match_heaptype noexn ht then - CaseV ("REF", [ null; noexn]) - else if match_heaptype noextern ht then - CaseV ("REF", [ null; noextern]) - else - Numerics.error_typ_value "$Reftype" "null reference" v + | [CaseV ("REF.NULL_ADDR", [])] -> CaseV ("REF", [ null; nullary "BOT"]) (* i31 *) | [CaseV ("REF.I31_NUM", [ _ ])] -> CaseV ("REF", [ nonull; nullary "I31"]) (* host *) diff --git a/spectec/src/exe-spectec/main.ml b/spectec/src/exe-spectec/main.ml index 04b317f460..5b7847b146 100644 --- a/spectec/src/exe-spectec/main.ml +++ b/spectec/src/exe-spectec/main.ml @@ -157,7 +157,7 @@ let argspec = Arg.align ( ] @ List.map pass_argspec all_passes @ [ "--all-passes", Arg.Unit (fun () -> List.iter enable_pass all_passes)," Run all passes"; - "--test-version", Arg.Int (fun i -> Backend_interpreter.Construct.version := i), " Wasm version to assume for tests (default: 3)"; + "--test-version", Arg.Int (fun i -> Backend_interpreter.Construct.version := i; Il2al.Translate.version := i), " Wasm version to assume for tests (default: 3)"; "-help", Arg.Unit ignore, ""; "--help", Arg.Unit ignore, ""; diff --git a/spectec/src/il2al/translate.ml b/spectec/src/il2al/translate.ml index 333fdbe93a..4d56bea331 100644 --- a/spectec/src/il2al/translate.ml +++ b/spectec/src/il2al/translate.ml @@ -16,6 +16,9 @@ struct include Print end +let version = ref 3 + + (* Errors *) let error at msg = Error.error at "prose translation" msg @@ -151,14 +154,15 @@ let rec is_wasm_value e = "CONST"; "VCONST"; "REF.I31_NUM"; + "REF.NULL_ADDR"; "REF.STRUCT_ADDR"; "REF.ARRAY_ADDR"; "REF.EXN_ADDR"; "REF.FUNC_ADDR"; "REF.HOST_ADDR"; "REF.EXTERN"; - "REF.NULL" ] -> true + | Il.CaseE (op, _) when !version <= 2 && case_head op = "REF.NULL" -> true | Il.CallE (id, _) when id.it = "const" -> true | _ -> Valid.sub_typ e.note valT let is_wasm_instr e = diff --git a/spectec/src/il2al/translate.mli b/spectec/src/il2al/translate.mli index 7ccd92d955..6ed88d96fd 100644 --- a/spectec/src/il2al/translate.mli +++ b/spectec/src/il2al/translate.mli @@ -2,3 +2,5 @@ val translate_exp : Il.Ast.exp -> Al.Ast.expr val translate_argexp : Il.Ast.exp -> Al.Ast.expr list val translate_args : Il.Ast.arg list -> Al.Ast.arg list val translate : Il.Ast.script -> bool -> Al.Ast.algorithm list + +val version : int ref diff --git a/spectec/src/il2al/transpile.ml b/spectec/src/il2al/transpile.ml index 94a2ec01cf..14c5dca0d9 100644 --- a/spectec/src/il2al/transpile.ml +++ b/spectec/src/il2al/transpile.ml @@ -332,8 +332,22 @@ let extract_last_ifs il = in extract_first_ifs [] (List.rev il) -(* Unify more than 3 ifs at once, by extracting the common conditions *) -let unify_multi_if instrs = +(* Unify more than 3 ifs at once, by extracting the common conditions + if (... if A ...); if (... if A ...) + --> + if A (...; ...) +*) +let rec unify_multi_if instrs = + (* Apply recursively *) + let instrs = List.map (fun instr -> + let at = instr.at in + match instr.it with + | IfI (c, il1, il2) -> ifI (c, unify_multi_if il1, unify_multi_if il2) ~at + | OtherwiseI il -> otherwiseI (unify_multi_if il) ~at + | EitherI (il1, il2) -> eitherI (unify_multi_if il1, unify_multi_if il2) ~at + | _ -> instr + ) instrs in + let hd, ifs = extract_last_ifs instrs in hd @ merge_disjoint_ifs ifs @@ -665,6 +679,9 @@ let simplify_dot_access e = ) | _ -> e +(* If there is exactly one form of case check (i.e. fi.CODE is some FUNC) + regard it as an assertion *) + type count = One of string | Many module Counter = Map.Make (String) let infer_case_assert instrs = @@ -672,6 +689,7 @@ let infer_case_assert instrs = let rec handle_cond c mt_then mt_else = match c.it with + | BinE (`EqOp, e, {it = CaseE (Atom atom, _); _}) | IsCaseOfE (e, atom) -> let k = Print.string_of_expr e in let v = One (Print.string_of_atom atom) in diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index a09e800d23..2dcddd8853 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1967,32 +1967,6 @@ syntax addr = nat ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax arrayaddr = addr -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax exnaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax funcaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax hostaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax structaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -rec { - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-42.23 -syntax addrref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) -} - ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec syntax catch = | CATCH(tagidx : tagidx, labelidx : labelidx) @@ -2000,12 +1974,18 @@ syntax catch = | CATCH_ALL(labelidx : labelidx) | CATCH_ALL_REF(labelidx : labelidx) +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax exnaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax dataaddr = addr ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax elemaddr = addr +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax funcaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax globaladdr = addr @@ -2047,18 +2027,39 @@ syntax moduleinst = EXPORTS exportinst* } +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax hostaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax structaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +rec { + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-43.19 +syntax ref = + | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` + | `REF.STRUCT_ADDR`(structaddr : structaddr) + | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) + | `REF.FUNC_ADDR`(funcaddr : funcaddr) + | `REF.EXN_ADDR`(exnaddr : exnaddr) + | `REF.HOST_ADDR`(hostaddr : hostaddr) + | `REF.EXTERN`(ref : ref) +} + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax val = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -2070,7 +2071,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:136.1-142.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 syntax instr = | NOP | UNREACHABLE @@ -2180,12 +2181,13 @@ syntax instr = -- if ((sx?{sx <- `sx?`} = ?()) <=> ($lanetype(shape) <- [I32_lanetype I64_lanetype F32_lanetype F64_lanetype])) | VREPLACE_LANE(shape : shape, laneidx : laneidx) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) + | `REF.EXTERN`(ref : ref) | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) @@ -3347,7 +3349,7 @@ def $default_(valtype : valtype) : val? ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{Vnn : Vnn}((Vnn : Vnn <: valtype)) = ?(VCONST_val(Vnn, `%`_vec_(0))) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec - def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL`_val(ht)) + def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{ht : heaptype}(REF_valtype(?(), ht)) = ?() @@ -5410,17 +5412,6 @@ syntax num = syntax vec = | VCONST(vectype : vectype, vec_(vectype)) -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax ref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -5493,13 +5484,13 @@ syntax fieldval = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -5568,13 +5559,13 @@ def $unpackfield_(storagetype : storagetype, sx?, fieldval : fieldval) : val ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:190.1-190.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 def $tagsxa{a : addr, `xa*` : externaddr*}([TAG_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tagsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:198.1-198.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5582,13 +5573,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 def $globalsxa{a : addr, `xa*` : externaddr*}([GLOBAL_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $globalsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:202.1-202.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5596,13 +5587,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 def $memsxa{a : addr, `xa*` : externaddr*}([MEM_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $memsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:206.1-206.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5610,13 +5601,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 def $tablesxa{a : addr, `xa*` : externaddr*}([TABLE_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tablesxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:210.1-210.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5624,13 +5615,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 def $funcsxa{a : addr, `xa*` : externaddr*}([FUNC_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $funcsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:214.1-214.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5850,43 +5841,43 @@ rec { ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:25.1-25.60 relation Ref_ok: `%|-%:%`(store, ref, reftype) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-37.35 - rule null{s : store, ht : heaptype, ht' : heaptype}: - `%|-%:%`(s, `REF.NULL`_ref(ht), REF_reftype(?(NULL_null), ht')) - -- Heaptype_sub: `%|-%<:%`({TYPES [], RECS [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS []}, ht', ht) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-36.38 + rule null{s : store}: + `%|-%:%`(s, `REF.NULL_ADDR`_ref, REF_reftype(?(NULL_null), BOT_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:39.1-40.33 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:38.1-39.33 rule i31{s : store, i : u31}: `%|-%:%`(s, `REF.I31_NUM`_ref(i), REF_reftype(?(), I31_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:42.1-44.31 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:41.1-43.31 rule struct{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.STRUCT_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.STRUCTS_store[a].TYPE_structinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:46.1-48.30 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:45.1-47.30 rule array{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.ARRAY_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.ARRAYS_store[a].TYPE_arrayinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:50.1-52.29 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:49.1-51.29 rule func{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.FUNC_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.FUNCS_store[a].TYPE_funcinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:54.1-56.24 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:53.1-55.24 rule exn{s : store, a : addr, exn : exninst}: `%|-%:%`(s, `REF.EXN_ADDR`_ref(a), REF_reftype(?(), EXN_heaptype)) -- if (s.EXNS_store[a] = exn) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:58.1-59.35 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:57.1-58.35 rule host{s : store, a : addr}: `%|-%:%`(s, `REF.HOST_ADDR`_ref(a), REF_reftype(?(), ANY_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:61.1-63.38 - rule extern{s : store, addrref : addrref}: - `%|-%:%`(s, `REF.EXTERN`_ref(addrref), REF_reftype(?(), EXTERN_heaptype)) - -- Ref_ok: `%|-%:%`(s, (addrref : addrref <: ref), REF_reftype(?(), ANY_heaptype)) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:60.1-63.30 + rule extern{s : store, ref : ref}: + `%|-%:%`(s, `REF.EXTERN`_ref(ref), REF_reftype(?(), EXTERN_heaptype)) + -- Ref_ok: `%|-%:%`(s, ref, REF_reftype(?(), ANY_heaptype)) + -- if (ref =/= `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:65.1-68.34 rule sub{s : store, ref : ref, rt : reftype, rt' : reftype}: @@ -6052,9 +6043,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- if (i!`%`_num_.0 >= |l*{l <- `l*`}|) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NULL_instr(l)], [BR_instr(l)]) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_null-addr`{val : val, l : labelidx}: @@ -6062,9 +6053,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_non_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_non_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NON_NULL_instr(l)], []) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_non_null-addr`{val : val, l : labelidx}: @@ -6125,9 +6116,9 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([CONST_instr(I32_numtype, i) `REF.I31`_instr], [`REF.I31_NUM`_instr($wrap__(32, 31, i))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.is_null-true`{ref : ref, ht : heaptype}: + rule `ref.is_null-true`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.IS_NULL`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.is_null-false`{ref : ref}: @@ -6135,9 +6126,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.as_non_null-null`{ref : ref, ht : heaptype}: + rule `ref.as_non_null-null`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.AS_NON_NULL`_instr], [TRAP_instr]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.as_non_null-addr`{ref : ref}: @@ -6145,9 +6136,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.eq-null`{ref_1 : ref, ref_2 : ref, ht_1 : heaptype, ht_2 : heaptype}: + rule `ref.eq-null`{ref_1 : ref, ref_2 : ref}: `%~>%`([(ref_1 : ref <: instr) (ref_2 : ref <: instr) `REF.EQ`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if ((ref_1 = `REF.NULL`_ref(ht_1)) /\ (ref_2 = `REF.NULL`_ref(ht_2))) + -- if ((ref_1 = `REF.NULL_ADDR`_ref) /\ (ref_2 = `REF.NULL_ADDR`_ref)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.eq-true`{ref_1 : ref, ref_2 : ref}: @@ -6161,8 +6152,8 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `i31.get-null`{ht : heaptype, sx : sx}: - `%~>%`([`REF.NULL`_instr(ht) `I31.GET`_instr(sx)], [TRAP_instr]) + rule `i31.get-null`{sx : sx}: + `%~>%`([`REF.NULL_ADDR`_instr `I31.GET`_instr(sx)], [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `i31.get-num`{i : u31, sx : sx}: @@ -6173,20 +6164,22 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([(val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.NEW`_instr(x)], (val : val <: instr)^n{} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL`_instr(EXTERN_heaptype)]) + rule `extern.convert_any-null`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL_ADDR`_instr]) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-addr`{addrref : addrref}: - `%~>%`([(addrref : addrref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(addrref)]) + rule `extern.convert_any-addr`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(ref)]) + -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `ANY.CONVERT_EXTERN`_instr], [`REF.NULL`_instr(ANY_heaptype)]) + rule `any.convert_extern-null`: + `%~>%`([`REF.NULL_ADDR`_instr `ANY.CONVERT_EXTERN`_instr], [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-addr`{addrref : addrref}: - `%~>%`([`REF.EXTERN`_instr(addrref) `ANY.CONVERT_EXTERN`_instr], [(addrref : addrref <: instr)]) + rule `any.convert_extern-addr`{ref : ref}: + `%~>%`([`REF.EXTERN`_instr(ref) `ANY.CONVERT_EXTERN`_instr], [(ref : ref <: instr)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `unop-val`{nt : numtype, c_1 : num_(nt), unop : unop_(nt), c : num_(nt)}: @@ -6402,8 +6395,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, ht : heaptype, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, yy : typeuse}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `call_ref-func`{z : state, n : n, `val*` : val*, a : addr, yy : typeuse, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: @@ -6427,8 +6420,8 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, ht : heaptype, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL`_instr(ht)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) + rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, yy : typeuse, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL_ADDR`_instr] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `return_call_ref-frame-addr`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, yy : typeuse, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: @@ -6436,8 +6429,8 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($funcinst(z)[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`}), `%`_resulttype(t_2^m{t_2 <- `t_2*`}))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) THROW_REF_instr]), [TRAP_instr]) + rule `throw_ref-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr THROW_REF_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `throw_ref-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: @@ -6705,8 +6698,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) + rule `ref.null`{z : state, ht : heaptype}: + `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht)]), [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.func`{z : state, x : idx}: @@ -6741,8 +6734,8 @@ relation Step_read: `%~>%`(config, instr*) -- (if ($default_($unpack(zt)) = ?(val)))*{val <- `val*`, zt <- `zt*`} ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `struct.get-null`{z : state, ht : heaptype, `sx?` : sx?, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) + rule `struct.get-null`{z : state, `sx?` : sx?, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `struct.get-struct`{z : state, a : addr, `sx?` : sx?, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -6778,8 +6771,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($concatn_(syntax byte, $zbytes_(zt, c)^n{c <- `c*`}, ((($zsize(zt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) = $data(z, y).BYTES_datainst[i!`%`_num_.0 : ((((n * $zsize(zt)) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.get-null`{z : state, ht : heaptype, i : num_(I32_numtype), `sx?` : sx?, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) + rule `array.get-null`{z : state, i : num_(I32_numtype), `sx?` : sx?, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.get-oob`{z : state, a : addr, i : num_(I32_numtype), `sx?` : sx?, x : idx}: @@ -6792,16 +6785,16 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.len-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `ARRAY.LEN`_instr]), [TRAP_instr]) + rule `array.len-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `ARRAY.LEN`_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.len-array`{z : state, a : addr}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) `ARRAY.LEN`_instr]), [CONST_instr(I32_numtype, `%`_num_(|$arrayinst(z)[a].FIELDS_arrayinst|))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.fill-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, n : n, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) + rule `array.fill-null`{z : state, i : num_(I32_numtype), val : val, n : n, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.fill-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, n : n, x : idx}: @@ -6820,12 +6813,12 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null1`{z : state, ht_1 : heaptype, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht_1) CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null1`{z : state, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), ht_2 : heaptype, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL`_instr(ht_2) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.copy-oob1`{z : state, a_1 : addr, i_1 : num_(I32_numtype), a_2 : addr, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: @@ -6858,8 +6851,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (sx?{sx <- `sx?`} = $sx(zt_2)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_elem-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) + rule `array.init_elem-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_elem-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -6884,8 +6877,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (ref = $elem(z, y).REFS_eleminst[j!`%`_num_.0]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_data-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) + rule `array.init_data-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_data-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -7047,9 +7040,9 @@ relation Step: `%~>%`(config, config) -- if (a = |$structinst(z)|) -- if (si = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`, zt <- `zt*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.53 - rule `struct.set-null`{z : state, ht : heaptype, val : val, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 + rule `struct.set-null`{z : state, val : val, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:724.1-727.46 rule `struct.set-struct`{z : state, a : addr, val : val, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -7062,9 +7055,9 @@ relation Step: `%~>%`(config, config) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) -- if ((a = |$arrayinst(z)|) /\ (ai = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`}})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.64 - rule `array.set-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.66 + rule `array.set-null`{z : state, i : num_(I32_numtype), val : val, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:788.1-790.39 rule `array.set-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx}: diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index a4e05349c3..763ae1162f 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -8875,15 +8875,14 @@ $$ \begin{array}[t]{@{}lrrl@{}l@{}} \mbox{(number value)} & {\mathit{num}} & ::= & {\mathit{numtype}}{.}\mathsf{const}~{{\mathit{num}}}_{{\mathit{numtype}}} \\ \mbox{(vector value)} & {\mathit{vec}} & ::= & {\mathit{vectype}}{.}\mathsf{const}~{{\mathit{vec}}}_{{\mathit{vectype}}} \\ -\mbox{(address value)} & {\mathit{addrref}} & ::= & \mathsf{ref{.}i{\scriptstyle 31}}~{\mathit{u{\kern-0.1em\scriptstyle 31}}} \\ +\mbox{(reference value)} & {\mathit{ref}} & ::= & \mathsf{ref{.}i{\scriptstyle 31}}~{\mathit{u{\kern-0.1em\scriptstyle 31}}} \\ +& & | & \mathsf{ref{.}null} \\ & & | & \mathsf{ref{.}struct}~{\mathit{structaddr}} \\ & & | & \mathsf{ref{.}array}~{\mathit{arrayaddr}} \\ & & | & \mathsf{ref{.}func}~{\mathit{funcaddr}} \\ & & | & \mathsf{ref{.}exn}~{\mathit{exnaddr}} \\ & & | & \mathsf{ref{.}host}~{\mathit{hostaddr}} \\ -& & | & \mathsf{ref{.}extern}~{\mathit{addrref}} \\ -\mbox{(reference value)} & {\mathit{ref}} & ::= & {\mathit{addrref}} \\ -& & | & \mathsf{ref{.}null}~{\mathit{heaptype}} \\ +& & | & \mathsf{ref{.}extern}~{\mathit{ref}} \\ \mbox{(value)} & {\mathit{val}} & ::= & {\mathit{num}} ~~|~~ {\mathit{vec}} ~~|~~ {\mathit{ref}} \\ \mbox{(result)} & {\mathit{result}} & ::= & {{\mathit{val}}^\ast} ~~|~~ ( \mathsf{ref{.}exn\_addr}~{\mathit{exnaddr}} )~\mathsf{throw\_ref} ~~|~~ \mathsf{trap} \\ \end{array} @@ -8985,7 +8984,7 @@ $$ $$ \begin{array}[t]{@{}lrrl@{}l@{}} \mbox{(instruction)} & {\mathit{instr}} & ::= & \dots \\ -& & | & {\mathit{addrref}} \\ +& & | & {\mathit{ref}} \\ & & | & {{\mathsf{label}}_{n}}{\{ {{\mathit{instr}}^\ast} \}}~{{\mathit{instr}}^\ast} \\ & & | & {{\mathsf{frame}}_{n}}{\{ {\mathit{frame}} \}}~{{\mathit{instr}}^\ast} \\ & & | & {{\mathsf{handler}}_{n}}{\{ {{\mathit{catch}}^\ast} \}}~{{\mathit{instr}}^\ast} \\ @@ -9327,7 +9326,7 @@ $$ {{\mathrm{default}}}_{{\mathsf{i}}{N}} & = & ({\mathsf{i}}{N}{.}\mathsf{const}~0) \\ {{\mathrm{default}}}_{{\mathsf{f}}{N}} & = & ({\mathsf{f}}{N}{.}\mathsf{const}~{+0}) \\ {{\mathrm{default}}}_{{\mathsf{v}}{N}} & = & ({\mathsf{v}}{N}{.}\mathsf{const}~0) \\ -{{\mathrm{default}}}_{\mathsf{ref}~\mathsf{null}~{\mathit{ht}}} & = & (\mathsf{ref{.}null}~{\mathit{ht}}) \\ +{{\mathrm{default}}}_{\mathsf{ref}~\mathsf{null}~{\mathit{ht}}} & = & \mathsf{ref{.}null} \\ {{\mathrm{default}}}_{\mathsf{ref}~{\mathit{ht}}} & = & \epsilon \\ \end{array} $$ @@ -9389,9 +9388,8 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -\{ \} \vdash {\mathit{ht}'} \leq {\mathit{ht}} }{ -s \vdash \mathsf{ref{.}null}~{\mathit{ht}} : (\mathsf{ref}~\mathsf{null}~{\mathit{ht}'}) +s \vdash \mathsf{ref{.}null} : (\mathsf{ref}~\mathsf{null}~\mathsf{bot}) } \, {[\textsc{\scriptsize Ref\_ok{-}null}]} \qquad \end{array} @@ -9464,9 +9462,11 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -s \vdash {\mathit{addrref}} : (\mathsf{ref}~\mathsf{any}) +s \vdash {\mathit{ref}} : (\mathsf{ref}~\mathsf{any}) + \qquad +{\mathit{ref}} \neq \mathsf{ref{.}null} }{ -s \vdash \mathsf{ref{.}extern}~{\mathit{addrref}} : (\mathsf{ref}~\mathsf{extern}) +s \vdash \mathsf{ref{.}extern}~{\mathit{ref}} : (\mathsf{ref}~\mathsf{extern}) } \, {[\textsc{\scriptsize Ref\_ok{-}extern}]} \qquad \end{array} @@ -9747,7 +9747,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}br\_on\_null{-}null}]} \quad & {\mathit{val}}~(\mathsf{br\_on\_null}~l) & \hookrightarrow & (\mathsf{br}~l) & \quad \mbox{if}~ {\mathit{val}} = \mathsf{ref{.}null}~{\mathit{ht}} \\ +{[\textsc{\scriptsize E{-}br\_on\_null{-}null}]} \quad & {\mathit{val}}~(\mathsf{br\_on\_null}~l) & \hookrightarrow & (\mathsf{br}~l) & \quad \mbox{if}~ {\mathit{val}} = \mathsf{ref{.}null} \\ {[\textsc{\scriptsize E{-}br\_on\_null{-}addr}]} \quad & {\mathit{val}}~(\mathsf{br\_on\_null}~l) & \hookrightarrow & {\mathit{val}} & \quad \mbox{otherwise} \\ \end{array} $$ @@ -9756,7 +9756,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}br\_on\_non\_null{-}null}]} \quad & {\mathit{val}}~(\mathsf{br\_on\_non\_null}~l) & \hookrightarrow & \epsilon & \quad \mbox{if}~ {\mathit{val}} = \mathsf{ref{.}null}~{\mathit{ht}} \\ +{[\textsc{\scriptsize E{-}br\_on\_non\_null{-}null}]} \quad & {\mathit{val}}~(\mathsf{br\_on\_non\_null}~l) & \hookrightarrow & \epsilon & \quad \mbox{if}~ {\mathit{val}} = \mathsf{ref{.}null} \\ {[\textsc{\scriptsize E{-}br\_on\_non\_null{-}addr}]} \quad & {\mathit{val}}~(\mathsf{br\_on\_non\_null}~l) & \hookrightarrow & {\mathit{val}}~(\mathsf{br}~l) & \quad \mbox{otherwise} \\ \end{array} $$ @@ -9792,7 +9792,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} {[\textsc{\scriptsize E{-}call}]} \quad & z ; (\mathsf{call}~x) & \hookrightarrow & (\mathsf{ref{.}func}~a)~(\mathsf{call\_ref}~z{.}\mathsf{funcs}{}[a]{.}\mathsf{type}) & \quad \mbox{if}~ z{.}\mathsf{module}{.}\mathsf{funcs}{}[x] = a \\ -{[\textsc{\scriptsize E{-}call\_ref{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~(\mathsf{call\_ref}~y) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}call\_ref{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{call\_ref}~y) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}call\_ref{-}func}]} \quad & z ; {{\mathit{val}}^{n}}~(\mathsf{ref{.}func}~a)~(\mathsf{call\_ref}~y) & \hookrightarrow & ({{\mathsf{frame}}_{m}}{\{ f \}}~({{\mathsf{label}}_{m}}{\{ \epsilon \}}~{{\mathit{instr}}^\ast})) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad @@ -9820,7 +9820,7 @@ $$ \begin{array}[t]{@{}lrcl@{}l@{}} {[\textsc{\scriptsize E{-}return\_call\_ref{-}label}]} \quad & z ; ({{\mathsf{label}}_{k}}{\{ {{\mathit{instr}'}^\ast} \}}~{{\mathit{val}}^\ast}~(\mathsf{return\_call\_ref}~y)~{{\mathit{instr}}^\ast}) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{return\_call\_ref}~y) \\ {[\textsc{\scriptsize E{-}return\_call\_ref{-}handler}]} \quad & z ; ({{\mathsf{handler}}_{k}}{\{ {{\mathit{catch}}^\ast} \}}~{{\mathit{val}}^\ast}~(\mathsf{return\_call\_ref}~y)~{{\mathit{instr}}^\ast}) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{return\_call\_ref}~y) \\ -{[\textsc{\scriptsize E{-}return\_call\_ref{-}frame{-}null}]} \quad & z ; ({{\mathsf{frame}}_{k}}{\{ f \}}~{{\mathit{val}}^\ast}~(\mathsf{ref{.}null}~{\mathit{ht}})~(\mathsf{return\_call\_ref}~y)~{{\mathit{instr}}^\ast}) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}return\_call\_ref{-}frame{-}null}]} \quad & z ; ({{\mathsf{frame}}_{k}}{\{ f \}}~{{\mathit{val}}^\ast}~(\mathsf{ref{.}null})~(\mathsf{return\_call\_ref}~y)~{{\mathit{instr}}^\ast}) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}return\_call\_ref{-}frame{-}addr}]} \quad & z ; ({{\mathsf{frame}}_{k}}{\{ f \}}~{{\mathit{val}'}^\ast}~{{\mathit{val}}^{n}}~(\mathsf{ref{.}func}~a)~(\mathsf{return\_call\_ref}~y)~{{\mathit{instr}}^\ast}) & \hookrightarrow & {{\mathit{val}}^{n}}~(\mathsf{ref{.}func}~a)~(\mathsf{call\_ref}~y) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ z{.}\mathsf{funcs}{}[a]{.}\mathsf{type} \approx \mathsf{func}~{t_1^{n}} \rightarrow {t_2^{m}} @@ -9863,7 +9863,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}throw\_ref{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~\mathsf{throw\_ref} & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}throw\_ref{-}null}]} \quad & z ; (\mathsf{ref{.}null})~\mathsf{throw\_ref} & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}throw\_ref{-}instrs}]} \quad & z ; {{\mathit{val}}^\ast}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}~{{\mathit{instr}}^\ast} & \hookrightarrow & (\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {{\mathit{val}}^\ast} \neq \epsilon \lor {{\mathit{instr}}^\ast} \neq \epsilon @@ -10303,7 +10303,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}ref.null{-}idx}]} \quad & z ; (\mathsf{ref{.}null}~x) & \hookrightarrow & (\mathsf{ref{.}null}~z{.}\mathsf{types}{}[x]) \\ +{[\textsc{\scriptsize E{-}ref.null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}}) & \hookrightarrow & \mathsf{ref{.}null} \\ {[\textsc{\scriptsize E{-}ref.func}]} \quad & z ; (\mathsf{ref{.}func}~x) & \hookrightarrow & (\mathsf{ref{.}func}~z{.}\mathsf{module}{.}\mathsf{funcs}{}[x]) \\ \end{array} $$ @@ -10318,7 +10318,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}ref.is\_null{-}true}]} \quad & {\mathit{ref}}~\mathsf{ref{.}is\_null} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~1) & \quad \mbox{if}~ {\mathit{ref}} = (\mathsf{ref{.}null}~{\mathit{ht}}) \\ +{[\textsc{\scriptsize E{-}ref.is\_null{-}true}]} \quad & {\mathit{ref}}~\mathsf{ref{.}is\_null} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~1) & \quad \mbox{if}~ {\mathit{ref}} = \mathsf{ref{.}null} \\ {[\textsc{\scriptsize E{-}ref.is\_null{-}false}]} \quad & {\mathit{ref}}~\mathsf{ref{.}is\_null} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~0) & \quad \mbox{otherwise} \\ \end{array} $$ @@ -10327,7 +10327,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}ref.as\_non\_null{-}null}]} \quad & {\mathit{ref}}~\mathsf{ref{.}as\_non\_null} & \hookrightarrow & \mathsf{trap} & \quad \mbox{if}~ {\mathit{ref}} = (\mathsf{ref{.}null}~{\mathit{ht}}) \\ +{[\textsc{\scriptsize E{-}ref.as\_non\_null{-}null}]} \quad & {\mathit{ref}}~\mathsf{ref{.}as\_non\_null} & \hookrightarrow & \mathsf{trap} & \quad \mbox{if}~ {\mathit{ref}} = \mathsf{ref{.}null} \\ {[\textsc{\scriptsize E{-}ref.as\_non\_null{-}addr}]} \quad & {\mathit{ref}}~\mathsf{ref{.}as\_non\_null} & \hookrightarrow & {\mathit{ref}} & \quad \mbox{otherwise} \\ \end{array} $$ @@ -10336,7 +10336,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}ref.eq{-}null}]} \quad & {\mathit{ref}}_1~{\mathit{ref}}_2~\mathsf{ref{.}eq} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~1) & \quad \mbox{if}~ {\mathit{ref}}_1 = (\mathsf{ref{.}null}~{\mathit{ht}}_1) \land {\mathit{ref}}_2 = (\mathsf{ref{.}null}~{\mathit{ht}}_2) \\ +{[\textsc{\scriptsize E{-}ref.eq{-}null}]} \quad & {\mathit{ref}}_1~{\mathit{ref}}_2~\mathsf{ref{.}eq} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~1) & \quad \mbox{if}~ {\mathit{ref}}_1 = \mathsf{ref{.}null} \land {\mathit{ref}}_2 = \mathsf{ref{.}null} \\ {[\textsc{\scriptsize E{-}ref.eq{-}true}]} \quad & {\mathit{ref}}_1~{\mathit{ref}}_2~\mathsf{ref{.}eq} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~1) & \quad \mbox{otherwise, if}~ {\mathit{ref}}_1 = {\mathit{ref}}_2 \\ {[\textsc{\scriptsize E{-}ref.eq{-}false}]} \quad & {\mathit{ref}}_1~{\mathit{ref}}_2~\mathsf{ref{.}eq} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~0) & \quad \mbox{otherwise} \\ \end{array} @@ -10372,7 +10372,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}i31.get{-}null}]} \quad & (\mathsf{ref{.}null}~{\mathit{ht}})~({\mathsf{i{\scriptstyle 31}{.}get}}{\mathsf{\_}}{{\mathit{sx}}}) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}i31.get{-}null}]} \quad & (\mathsf{ref{.}null})~({\mathsf{i{\scriptstyle 31}{.}get}}{\mathsf{\_}}{{\mathit{sx}}}) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}i31.get{-}num}]} \quad & (\mathsf{ref{.}i{\scriptstyle 31}}~i)~({\mathsf{i{\scriptstyle 31}{.}get}}{\mathsf{\_}}{{\mathit{sx}}}) & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~{{{{\mathrm{extend}}}_{31, 32}^{{\mathit{sx}}}}}{(i)}) \\ \end{array} $$ @@ -10404,7 +10404,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}struct.get{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~({\mathsf{struct{.}get}}{\mathsf{\_}}{{{\mathit{sx}}^?}}~x~i) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}struct.get{-}null}]} \quad & z ; (\mathsf{ref{.}null})~({\mathsf{struct{.}get}}{\mathsf{\_}}{{{\mathit{sx}}^?}}~x~i) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}struct.get{-}struct}]} \quad & z ; (\mathsf{ref{.}struct}~a)~({\mathsf{struct{.}get}}{\mathsf{\_}}{{{\mathit{sx}}^?}}~x~i) & \hookrightarrow & {{{{\mathrm{unpack}}}_{{{\mathit{zt}}^\ast}{}[i]}^{{{\mathit{sx}}^?}}}}{(z{.}\mathsf{structs}{}[a]{.}\mathsf{fields}{}[i])} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ z{.}\mathsf{types}{}[x] \approx \mathsf{struct}~{({\mathsf{mut}^?}~{\mathit{zt}})^\ast} @@ -10416,7 +10416,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}struct.set{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~{\mathit{val}}~(\mathsf{struct{.}set}~x~i) & \hookrightarrow & z ; \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}struct.set{-}null}]} \quad & z ; (\mathsf{ref{.}null})~{\mathit{val}}~(\mathsf{struct{.}set}~x~i) & \hookrightarrow & z ; \mathsf{trap} \\ {[\textsc{\scriptsize E{-}struct.set{-}struct}]} \quad & z ; (\mathsf{ref{.}struct}~a)~{\mathit{val}}~(\mathsf{struct{.}set}~x~i) & \hookrightarrow & z{}[{.}\mathsf{structs}{}[a]{.}\mathsf{fields}{}[i] = {{\mathrm{pack}}}_{{{\mathit{zt}}^\ast}{}[i]}({\mathit{val}})] ; \epsilon & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ z{.}\mathsf{types}{}[x] \approx \mathsf{struct}~{({\mathsf{mut}^?}~{\mathit{zt}})^\ast} @@ -10494,7 +10494,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}array.get{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~({\mathsf{array{.}get}}{\mathsf{\_}}{{{\mathit{sx}}^?}}~x) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.get{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~({\mathsf{array{.}get}}{\mathsf{\_}}{{{\mathit{sx}}^?}}~x) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}array.get{-}oob}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~({\mathsf{array{.}get}}{\mathsf{\_}}{{{\mathit{sx}}^?}}~x) & \hookrightarrow & \mathsf{trap} & \quad \mbox{if}~ i \geq {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|} \\ {[\textsc{\scriptsize E{-}array.get{-}array}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~({\mathsf{array{.}get}}{\mathsf{\_}}{{{\mathit{sx}}^?}}~x) & \hookrightarrow & {{{{\mathrm{unpack}}}_{{\mathit{zt}}}^{{{\mathit{sx}}^?}}}}{(z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}{}[i])} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad @@ -10507,7 +10507,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}array.set{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{array{.}set}~x) & \hookrightarrow & z ; \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.set{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{array{.}set}~x) & \hookrightarrow & z ; \mathsf{trap} \\ {[\textsc{\scriptsize E{-}array.set{-}oob}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{array{.}set}~x) & \hookrightarrow & z ; \mathsf{trap} & \quad \mbox{if}~ i \geq {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|} \\ {[\textsc{\scriptsize E{-}array.set{-}array}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{array{.}set}~x) & \hookrightarrow & z{}[{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}{}[i] = {{\mathrm{pack}}}_{{\mathit{zt}}}({\mathit{val}})] ; \epsilon & \\ &&& \multicolumn{2}{@{}l@{}}{\quad @@ -10520,7 +10520,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}array.len{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~\mathsf{array{.}len} & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.len{-}null}]} \quad & z ; (\mathsf{ref{.}null})~\mathsf{array{.}len} & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}array.len{-}array}]} \quad & z ; (\mathsf{ref{.}array}~a)~\mathsf{array{.}len} & \hookrightarrow & (\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~{|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|}) \\ \end{array} $$ @@ -10529,7 +10529,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}array.fill{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}fill}~x) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.fill{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}fill}~x) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}array.fill{-}oob}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}fill}~x) & \hookrightarrow & \mathsf{trap} & \quad \mbox{if}~ i + n > {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|} \\ {[\textsc{\scriptsize E{-}array.fill{-}zero}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}fill}~x) & \hookrightarrow & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ {[\textsc{\scriptsize E{-}array.fill{-}succ}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~{\mathit{val}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}fill}~x) & \hookrightarrow & & \\ @@ -10539,8 +10539,8 @@ $$ (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i + 1)~{\mathit{val}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n - 1)~(\mathsf{array{.}fill}~x) \end{array} & \quad \mbox{otherwise} \\ \end{array} } \\ -{[\textsc{\scriptsize E{-}array.copy{-}null1}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}}_1)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_1)~{\mathit{ref}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_2)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}copy}~x_1~x_2) & \hookrightarrow & \mathsf{trap} \\ -{[\textsc{\scriptsize E{-}array.copy{-}null2}]} \quad & z ; {\mathit{ref}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_1)~(\mathsf{ref{.}null}~{\mathit{ht}}_2)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_2)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}copy}~x_1~x_2) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.copy{-}null1}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_1)~{\mathit{ref}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_2)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}copy}~x_1~x_2) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.copy{-}null2}]} \quad & z ; {\mathit{ref}}~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_1)~(\mathsf{ref{.}null})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_2)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}copy}~x_1~x_2) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}array.copy{-}oob1}]} \quad & z ; (\mathsf{ref{.}array}~a_1)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_1)~(\mathsf{ref{.}array}~a_2)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i_2)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}copy}~x_1~x_2) & \hookrightarrow & \mathsf{trap} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i_1 + n > {|z{.}\mathsf{arrays}{}[a_1]{.}\mathsf{fields}|} @@ -10596,7 +10596,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}array.init\_elem{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~j)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}init\_elem}~x~y) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.init\_elem{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~j)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}init\_elem}~x~y) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}array.init\_elem{-}oob1}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~j)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}init\_elem}~x~y) & \hookrightarrow & \mathsf{trap} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i + n > {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|} @@ -10628,7 +10628,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}array.init\_data{-}null}]} \quad & z ; (\mathsf{ref{.}null}~{\mathit{ht}})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~j)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}init\_data}~x~y) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}array.init\_data{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~j)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}init\_data}~x~y) & \hookrightarrow & \mathsf{trap} \\ {[\textsc{\scriptsize E{-}array.init\_data{-}oob1}]} \quad & z ; (\mathsf{ref{.}array}~a)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~i)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~j)~(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~n)~(\mathsf{array{.}init\_data}~x~y) & \hookrightarrow & \mathsf{trap} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i + n > {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|} @@ -10668,8 +10668,8 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}extern.convert\_any{-}null}]} \quad & (\mathsf{ref{.}null}~{\mathit{ht}})~\mathsf{extern{.}convert\_any} & \hookrightarrow & (\mathsf{ref{.}null}~\mathsf{extern}) \\ -{[\textsc{\scriptsize E{-}extern.convert\_any{-}addr}]} \quad & {\mathit{addrref}}~\mathsf{extern{.}convert\_any} & \hookrightarrow & (\mathsf{ref{.}extern}~{\mathit{addrref}}) \\ +{[\textsc{\scriptsize E{-}extern.convert\_any{-}null}]} \quad & {\mathit{ref}}~\mathsf{extern{.}convert\_any} & \hookrightarrow & \mathsf{ref{.}null} & \quad \mbox{if}~ {\mathit{ref}} = \mathsf{ref{.}null} \\ +{[\textsc{\scriptsize E{-}extern.convert\_any{-}addr}]} \quad & {\mathit{ref}}~\mathsf{extern{.}convert\_any} & \hookrightarrow & (\mathsf{ref{.}extern}~{\mathit{ref}}) & \quad \mbox{otherwise} \\ \end{array} $$ @@ -10677,8 +10677,8 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}any.convert\_extern{-}null}]} \quad & (\mathsf{ref{.}null}~{\mathit{ht}})~\mathsf{any{.}convert\_extern} & \hookrightarrow & (\mathsf{ref{.}null}~\mathsf{any}) \\ -{[\textsc{\scriptsize E{-}any.convert\_extern{-}addr}]} \quad & (\mathsf{ref{.}extern}~{\mathit{addrref}})~\mathsf{any{.}convert\_extern} & \hookrightarrow & {\mathit{addrref}} \\ +{[\textsc{\scriptsize E{-}any.convert\_extern{-}null}]} \quad & (\mathsf{ref{.}null})~\mathsf{any{.}convert\_extern} & \hookrightarrow & \mathsf{ref{.}null} \\ +{[\textsc{\scriptsize E{-}any.convert\_extern{-}addr}]} \quad & (\mathsf{ref{.}extern}~{\mathit{ref}})~\mathsf{any{.}convert\_extern} & \hookrightarrow & {\mathit{ref}} \\ \end{array} $$ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index 994343a023..261da39e2c 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1957,32 +1957,6 @@ syntax addr = nat ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax arrayaddr = addr -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax exnaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax funcaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax hostaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax structaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -rec { - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-42.23 -syntax addrref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) -} - ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec syntax catch = | CATCH(tagidx : tagidx, labelidx : labelidx) @@ -1990,12 +1964,18 @@ syntax catch = | CATCH_ALL(labelidx : labelidx) | CATCH_ALL_REF(labelidx : labelidx) +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax exnaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax dataaddr = addr ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax elemaddr = addr +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax funcaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax globaladdr = addr @@ -2037,18 +2017,39 @@ syntax moduleinst = EXPORTS exportinst* } +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax hostaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax structaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +rec { + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-43.19 +syntax ref = + | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` + | `REF.STRUCT_ADDR`(structaddr : structaddr) + | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) + | `REF.FUNC_ADDR`(funcaddr : funcaddr) + | `REF.EXN_ADDR`(exnaddr : exnaddr) + | `REF.HOST_ADDR`(hostaddr : hostaddr) + | `REF.EXTERN`(ref : ref) +} + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax val = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -2060,7 +2061,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:136.1-142.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 syntax instr = | NOP | UNREACHABLE @@ -2170,12 +2171,13 @@ syntax instr = -- if ((sx?{sx <- `sx?`} = ?()) <=> ($lanetype(shape) <- [I32_lanetype I64_lanetype F32_lanetype F64_lanetype])) | VREPLACE_LANE(shape : shape, laneidx : laneidx) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) + | `REF.EXTERN`(ref : ref) | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) @@ -3337,7 +3339,7 @@ def $default_(valtype : valtype) : val? ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{Vnn : Vnn}((Vnn : Vnn <: valtype)) = ?(VCONST_val(Vnn, `%`_vec_(0))) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec - def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL`_val(ht)) + def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{ht : heaptype}(REF_valtype(?(), ht)) = ?() @@ -5400,17 +5402,6 @@ syntax num = syntax vec = | VCONST(vectype : vectype, vec_(vectype)) -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax ref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -5483,13 +5474,13 @@ syntax fieldval = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -5558,13 +5549,13 @@ def $unpackfield_(storagetype : storagetype, sx?, fieldval : fieldval) : val ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:190.1-190.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 def $tagsxa{a : addr, `xa*` : externaddr*}([TAG_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tagsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:198.1-198.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5572,13 +5563,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 def $globalsxa{a : addr, `xa*` : externaddr*}([GLOBAL_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $globalsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:202.1-202.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5586,13 +5577,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 def $memsxa{a : addr, `xa*` : externaddr*}([MEM_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $memsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:206.1-206.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5600,13 +5591,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 def $tablesxa{a : addr, `xa*` : externaddr*}([TABLE_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tablesxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:210.1-210.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5614,13 +5605,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 def $funcsxa{a : addr, `xa*` : externaddr*}([FUNC_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $funcsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:214.1-214.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5840,43 +5831,43 @@ rec { ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:25.1-25.60 relation Ref_ok: `%|-%:%`(store, ref, reftype) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-37.35 - rule null{s : store, ht : heaptype, ht' : heaptype}: - `%|-%:%`(s, `REF.NULL`_ref(ht), REF_reftype(?(NULL_null), ht')) - -- Heaptype_sub: `%|-%<:%`({TYPES [], RECS [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS []}, ht', ht) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-36.38 + rule null{s : store}: + `%|-%:%`(s, `REF.NULL_ADDR`_ref, REF_reftype(?(NULL_null), BOT_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:39.1-40.33 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:38.1-39.33 rule i31{s : store, i : u31}: `%|-%:%`(s, `REF.I31_NUM`_ref(i), REF_reftype(?(), I31_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:42.1-44.31 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:41.1-43.31 rule struct{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.STRUCT_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.STRUCTS_store[a].TYPE_structinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:46.1-48.30 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:45.1-47.30 rule array{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.ARRAY_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.ARRAYS_store[a].TYPE_arrayinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:50.1-52.29 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:49.1-51.29 rule func{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.FUNC_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.FUNCS_store[a].TYPE_funcinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:54.1-56.24 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:53.1-55.24 rule exn{s : store, a : addr, exn : exninst}: `%|-%:%`(s, `REF.EXN_ADDR`_ref(a), REF_reftype(?(), EXN_heaptype)) -- if (s.EXNS_store[a] = exn) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:58.1-59.35 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:57.1-58.35 rule host{s : store, a : addr}: `%|-%:%`(s, `REF.HOST_ADDR`_ref(a), REF_reftype(?(), ANY_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:61.1-63.38 - rule extern{s : store, addrref : addrref}: - `%|-%:%`(s, `REF.EXTERN`_ref(addrref), REF_reftype(?(), EXTERN_heaptype)) - -- Ref_ok: `%|-%:%`(s, (addrref : addrref <: ref), REF_reftype(?(), ANY_heaptype)) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:60.1-63.30 + rule extern{s : store, ref : ref}: + `%|-%:%`(s, `REF.EXTERN`_ref(ref), REF_reftype(?(), EXTERN_heaptype)) + -- Ref_ok: `%|-%:%`(s, ref, REF_reftype(?(), ANY_heaptype)) + -- if (ref =/= `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:65.1-68.34 rule sub{s : store, ref : ref, rt : reftype, rt' : reftype}: @@ -6042,9 +6033,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- if (i!`%`_num_.0 >= |l*{l <- `l*`}|) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NULL_instr(l)], [BR_instr(l)]) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_null-addr`{val : val, l : labelidx}: @@ -6052,9 +6043,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_non_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_non_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NON_NULL_instr(l)], []) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_non_null-addr`{val : val, l : labelidx}: @@ -6115,9 +6106,9 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([CONST_instr(I32_numtype, i) `REF.I31`_instr], [`REF.I31_NUM`_instr($wrap__(32, 31, i))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.is_null-true`{ref : ref, ht : heaptype}: + rule `ref.is_null-true`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.IS_NULL`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.is_null-false`{ref : ref}: @@ -6125,9 +6116,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.as_non_null-null`{ref : ref, ht : heaptype}: + rule `ref.as_non_null-null`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.AS_NON_NULL`_instr], [TRAP_instr]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.as_non_null-addr`{ref : ref}: @@ -6135,9 +6126,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.eq-null`{ref_1 : ref, ref_2 : ref, ht_1 : heaptype, ht_2 : heaptype}: + rule `ref.eq-null`{ref_1 : ref, ref_2 : ref}: `%~>%`([(ref_1 : ref <: instr) (ref_2 : ref <: instr) `REF.EQ`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if ((ref_1 = `REF.NULL`_ref(ht_1)) /\ (ref_2 = `REF.NULL`_ref(ht_2))) + -- if ((ref_1 = `REF.NULL_ADDR`_ref) /\ (ref_2 = `REF.NULL_ADDR`_ref)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.eq-true`{ref_1 : ref, ref_2 : ref}: @@ -6151,8 +6142,8 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `i31.get-null`{ht : heaptype, sx : sx}: - `%~>%`([`REF.NULL`_instr(ht) `I31.GET`_instr(sx)], [TRAP_instr]) + rule `i31.get-null`{sx : sx}: + `%~>%`([`REF.NULL_ADDR`_instr `I31.GET`_instr(sx)], [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `i31.get-num`{i : u31, sx : sx}: @@ -6163,20 +6154,22 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([(val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.NEW`_instr(x)], (val : val <: instr)^n{} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL`_instr(EXTERN_heaptype)]) + rule `extern.convert_any-null`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL_ADDR`_instr]) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-addr`{addrref : addrref}: - `%~>%`([(addrref : addrref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(addrref)]) + rule `extern.convert_any-addr`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(ref)]) + -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `ANY.CONVERT_EXTERN`_instr], [`REF.NULL`_instr(ANY_heaptype)]) + rule `any.convert_extern-null`: + `%~>%`([`REF.NULL_ADDR`_instr `ANY.CONVERT_EXTERN`_instr], [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-addr`{addrref : addrref}: - `%~>%`([`REF.EXTERN`_instr(addrref) `ANY.CONVERT_EXTERN`_instr], [(addrref : addrref <: instr)]) + rule `any.convert_extern-addr`{ref : ref}: + `%~>%`([`REF.EXTERN`_instr(ref) `ANY.CONVERT_EXTERN`_instr], [(ref : ref <: instr)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `unop-val`{nt : numtype, c_1 : num_(nt), unop : unop_(nt), c : num_(nt)}: @@ -6392,8 +6385,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, ht : heaptype, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, yy : typeuse}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `call_ref-func`{z : state, n : n, `val*` : val*, a : addr, yy : typeuse, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: @@ -6417,8 +6410,8 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, ht : heaptype, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL`_instr(ht)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) + rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, yy : typeuse, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL_ADDR`_instr] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `return_call_ref-frame-addr`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, yy : typeuse, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: @@ -6426,8 +6419,8 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($funcinst(z)[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`}), `%`_resulttype(t_2^m{t_2 <- `t_2*`}))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) THROW_REF_instr]), [TRAP_instr]) + rule `throw_ref-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr THROW_REF_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `throw_ref-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: @@ -6695,8 +6688,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) + rule `ref.null`{z : state, ht : heaptype}: + `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht)]), [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.func`{z : state, x : idx}: @@ -6731,8 +6724,8 @@ relation Step_read: `%~>%`(config, instr*) -- (if ($default_($unpack(zt)) = ?(val)))*{val <- `val*`, zt <- `zt*`} ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `struct.get-null`{z : state, ht : heaptype, `sx?` : sx?, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) + rule `struct.get-null`{z : state, `sx?` : sx?, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `struct.get-struct`{z : state, a : addr, `sx?` : sx?, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -6768,8 +6761,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($concatn_(syntax byte, $zbytes_(zt, c)^n{c <- `c*`}, ((($zsize(zt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) = $data(z, y).BYTES_datainst[i!`%`_num_.0 : ((((n * $zsize(zt)) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.get-null`{z : state, ht : heaptype, i : num_(I32_numtype), `sx?` : sx?, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) + rule `array.get-null`{z : state, i : num_(I32_numtype), `sx?` : sx?, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.get-oob`{z : state, a : addr, i : num_(I32_numtype), `sx?` : sx?, x : idx}: @@ -6782,16 +6775,16 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.len-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `ARRAY.LEN`_instr]), [TRAP_instr]) + rule `array.len-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `ARRAY.LEN`_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.len-array`{z : state, a : addr}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) `ARRAY.LEN`_instr]), [CONST_instr(I32_numtype, `%`_num_(|$arrayinst(z)[a].FIELDS_arrayinst|))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.fill-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, n : n, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) + rule `array.fill-null`{z : state, i : num_(I32_numtype), val : val, n : n, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.fill-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, n : n, x : idx}: @@ -6810,12 +6803,12 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null1`{z : state, ht_1 : heaptype, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht_1) CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null1`{z : state, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), ht_2 : heaptype, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL`_instr(ht_2) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.copy-oob1`{z : state, a_1 : addr, i_1 : num_(I32_numtype), a_2 : addr, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: @@ -6848,8 +6841,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (sx?{sx <- `sx?`} = $sx(zt_2)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_elem-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) + rule `array.init_elem-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_elem-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -6874,8 +6867,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (ref = $elem(z, y).REFS_eleminst[j!`%`_num_.0]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_data-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) + rule `array.init_data-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_data-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -7037,9 +7030,9 @@ relation Step: `%~>%`(config, config) -- if (a = |$structinst(z)|) -- if (si = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`, zt <- `zt*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.53 - rule `struct.set-null`{z : state, ht : heaptype, val : val, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 + rule `struct.set-null`{z : state, val : val, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:724.1-727.46 rule `struct.set-struct`{z : state, a : addr, val : val, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -7052,9 +7045,9 @@ relation Step: `%~>%`(config, config) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) -- if ((a = |$arrayinst(z)|) /\ (ai = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`}})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.64 - rule `array.set-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.66 + rule `array.set-null`{z : state, i : num_(I32_numtype), val : val, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:788.1-790.39 rule `array.set-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx}: @@ -13376,32 +13369,6 @@ syntax addr = nat ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax arrayaddr = addr -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax exnaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax funcaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax hostaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax structaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -rec { - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-42.23 -syntax addrref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) -} - ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec syntax catch = | CATCH(tagidx : tagidx, labelidx : labelidx) @@ -13409,12 +13376,18 @@ syntax catch = | CATCH_ALL(labelidx : labelidx) | CATCH_ALL_REF(labelidx : labelidx) +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax exnaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax dataaddr = addr ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax elemaddr = addr +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax funcaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax globaladdr = addr @@ -13456,18 +13429,39 @@ syntax moduleinst = EXPORTS exportinst* } +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax hostaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax structaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +rec { + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-43.19 +syntax ref = + | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` + | `REF.STRUCT_ADDR`(structaddr : structaddr) + | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) + | `REF.FUNC_ADDR`(funcaddr : funcaddr) + | `REF.EXN_ADDR`(exnaddr : exnaddr) + | `REF.HOST_ADDR`(hostaddr : hostaddr) + | `REF.EXTERN`(ref : ref) +} + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax val = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -13479,7 +13473,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:136.1-142.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 syntax instr = | NOP | UNREACHABLE @@ -13589,12 +13583,13 @@ syntax instr = -- if ((sx?{sx <- `sx?`} = ?()) <=> ($lanetype(shape) <- [I32_lanetype I64_lanetype F32_lanetype F64_lanetype])) | VREPLACE_LANE(shape : shape, laneidx : laneidx) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) + | `REF.EXTERN`(ref : ref) | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) @@ -14756,7 +14751,7 @@ def $default_(valtype : valtype) : val? ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{Vnn : Vnn}((Vnn : Vnn <: valtype)) = ?(VCONST_val(Vnn, `%`_vec_(0))) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec - def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL`_val(ht)) + def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{ht : heaptype}(REF_valtype(?(), ht)) = ?() @@ -16819,17 +16814,6 @@ syntax num = syntax vec = | VCONST(vectype : vectype, vec_(vectype)) -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax ref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -16902,13 +16886,13 @@ syntax fieldval = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -16977,13 +16961,13 @@ def $unpackfield_(storagetype : storagetype, sx?, fieldval : fieldval) : val ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:190.1-190.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 def $tagsxa{a : addr, `xa*` : externaddr*}([TAG_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tagsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:198.1-198.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -16991,13 +16975,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 def $globalsxa{a : addr, `xa*` : externaddr*}([GLOBAL_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $globalsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:202.1-202.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17005,13 +16989,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 def $memsxa{a : addr, `xa*` : externaddr*}([MEM_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $memsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:206.1-206.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17019,13 +17003,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 def $tablesxa{a : addr, `xa*` : externaddr*}([TABLE_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tablesxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:210.1-210.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17033,13 +17017,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 def $funcsxa{a : addr, `xa*` : externaddr*}([FUNC_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $funcsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:214.1-214.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17261,43 +17245,43 @@ rec { ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:25.1-25.60 relation Ref_ok: `%|-%:%`(store, ref, reftype) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-37.35 - rule null{s : store, ht : heaptype, ht' : heaptype}: - `%|-%:%`(s, `REF.NULL`_ref(ht), REF_reftype(?(NULL_null), ht')) - -- Heaptype_sub: `%|-%<:%`({TYPES [], RECS [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS []}, ht', ht) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-36.38 + rule null{s : store}: + `%|-%:%`(s, `REF.NULL_ADDR`_ref, REF_reftype(?(NULL_null), BOT_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:39.1-40.33 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:38.1-39.33 rule i31{s : store, i : u31}: `%|-%:%`(s, `REF.I31_NUM`_ref(i), REF_reftype(?(), I31_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:42.1-44.31 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:41.1-43.31 rule struct{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.STRUCT_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.STRUCTS_store[a].TYPE_structinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:46.1-48.30 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:45.1-47.30 rule array{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.ARRAY_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.ARRAYS_store[a].TYPE_arrayinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:50.1-52.29 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:49.1-51.29 rule func{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.FUNC_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (s.FUNCS_store[a].TYPE_funcinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:54.1-56.24 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:53.1-55.24 rule exn{s : store, a : addr, exn : exninst}: `%|-%:%`(s, `REF.EXN_ADDR`_ref(a), REF_reftype(?(), EXN_heaptype)) -- if (s.EXNS_store[a] = exn) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:58.1-59.35 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:57.1-58.35 rule host{s : store, a : addr}: `%|-%:%`(s, `REF.HOST_ADDR`_ref(a), REF_reftype(?(), ANY_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:61.1-63.38 - rule extern{s : store, addrref : addrref}: - `%|-%:%`(s, `REF.EXTERN`_ref(addrref), REF_reftype(?(), EXTERN_heaptype)) - -- Ref_ok: `%|-%:%`(s, (addrref : addrref <: ref), REF_reftype(?(), ANY_heaptype)) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:60.1-63.30 + rule extern{s : store, ref : ref}: + `%|-%:%`(s, `REF.EXTERN`_ref(ref), REF_reftype(?(), EXTERN_heaptype)) + -- Ref_ok: `%|-%:%`(s, ref, REF_reftype(?(), ANY_heaptype)) + -- if (ref =/= `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:65.1-68.34 rule sub{s : store, ref : ref, rt : reftype, rt' : reftype}: @@ -17463,9 +17447,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- if (i!`%`_num_.0 >= |l*{l <- `l*`}|) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NULL_instr(l)], [BR_instr(l)]) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_null-addr`{val : val, l : labelidx}: @@ -17473,9 +17457,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_non_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_non_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NON_NULL_instr(l)], []) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_non_null-addr`{val : val, l : labelidx}: @@ -17536,9 +17520,9 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([CONST_instr(I32_numtype, i) `REF.I31`_instr], [`REF.I31_NUM`_instr($wrap__(32, 31, i))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.is_null-true`{ref : ref, ht : heaptype}: + rule `ref.is_null-true`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.IS_NULL`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.is_null-false`{ref : ref}: @@ -17546,9 +17530,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.as_non_null-null`{ref : ref, ht : heaptype}: + rule `ref.as_non_null-null`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.AS_NON_NULL`_instr], [TRAP_instr]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.as_non_null-addr`{ref : ref}: @@ -17556,9 +17540,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.eq-null`{ref_1 : ref, ref_2 : ref, ht_1 : heaptype, ht_2 : heaptype}: + rule `ref.eq-null`{ref_1 : ref, ref_2 : ref}: `%~>%`([(ref_1 : ref <: instr) (ref_2 : ref <: instr) `REF.EQ`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if ((ref_1 = `REF.NULL`_ref(ht_1)) /\ (ref_2 = `REF.NULL`_ref(ht_2))) + -- if ((ref_1 = `REF.NULL_ADDR`_ref) /\ (ref_2 = `REF.NULL_ADDR`_ref)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.eq-true`{ref_1 : ref, ref_2 : ref}: @@ -17572,8 +17556,8 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `i31.get-null`{ht : heaptype, sx : sx}: - `%~>%`([`REF.NULL`_instr(ht) `I31.GET`_instr(sx)], [TRAP_instr]) + rule `i31.get-null`{sx : sx}: + `%~>%`([`REF.NULL_ADDR`_instr `I31.GET`_instr(sx)], [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `i31.get-num`{i : u31, sx : sx}: @@ -17584,20 +17568,22 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([(val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.NEW`_instr(x)], (val : val <: instr)^n{} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL`_instr(EXTERN_heaptype)]) + rule `extern.convert_any-null`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL_ADDR`_instr]) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-addr`{addrref : addrref}: - `%~>%`([(addrref : addrref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(addrref)]) + rule `extern.convert_any-addr`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(ref)]) + -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `ANY.CONVERT_EXTERN`_instr], [`REF.NULL`_instr(ANY_heaptype)]) + rule `any.convert_extern-null`: + `%~>%`([`REF.NULL_ADDR`_instr `ANY.CONVERT_EXTERN`_instr], [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-addr`{addrref : addrref}: - `%~>%`([`REF.EXTERN`_instr(addrref) `ANY.CONVERT_EXTERN`_instr], [(addrref : addrref <: instr)]) + rule `any.convert_extern-addr`{ref : ref}: + `%~>%`([`REF.EXTERN`_instr(ref) `ANY.CONVERT_EXTERN`_instr], [(ref : ref <: instr)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `unop-val`{nt : numtype, c_1 : num_(nt), unop : unop_(nt), c : num_(nt)}: @@ -17813,8 +17799,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, ht : heaptype, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, yy : typeuse}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `call_ref-func`{z : state, n : n, `val*` : val*, a : addr, yy : typeuse, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: @@ -17838,8 +17824,8 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, ht : heaptype, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL`_instr(ht)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) + rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, yy : typeuse, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL_ADDR`_instr] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `return_call_ref-frame-addr`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, yy : typeuse, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: @@ -17847,8 +17833,8 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($funcinst(z)[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`}), `%`_resulttype(t_2^m{t_2 <- `t_2*`}))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) THROW_REF_instr]), [TRAP_instr]) + rule `throw_ref-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr THROW_REF_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `throw_ref-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: @@ -18116,8 +18102,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) + rule `ref.null`{z : state, ht : heaptype}: + `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht)]), [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.func`{z : state, x : idx}: @@ -18152,8 +18138,8 @@ relation Step_read: `%~>%`(config, instr*) -- (if ($default_($unpack(zt)) = ?(val)))*{val <- `val*`, zt <- `zt*`} ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `struct.get-null`{z : state, ht : heaptype, `sx?` : sx?, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) + rule `struct.get-null`{z : state, `sx?` : sx?, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `struct.get-struct`{z : state, a : addr, `sx?` : sx?, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -18189,8 +18175,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($concatn_(syntax byte, $zbytes_(zt, c)^n{c <- `c*`}, ((($zsize(zt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) = $data(z, y).BYTES_datainst[i!`%`_num_.0 : ((((n * $zsize(zt)) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.get-null`{z : state, ht : heaptype, i : num_(I32_numtype), `sx?` : sx?, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) + rule `array.get-null`{z : state, i : num_(I32_numtype), `sx?` : sx?, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.get-oob`{z : state, a : addr, i : num_(I32_numtype), `sx?` : sx?, x : idx}: @@ -18203,16 +18189,16 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.len-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `ARRAY.LEN`_instr]), [TRAP_instr]) + rule `array.len-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `ARRAY.LEN`_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.len-array`{z : state, a : addr}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) `ARRAY.LEN`_instr]), [CONST_instr(I32_numtype, `%`_num_(|$arrayinst(z)[a].FIELDS_arrayinst|))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.fill-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, n : n, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) + rule `array.fill-null`{z : state, i : num_(I32_numtype), val : val, n : n, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.fill-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, n : n, x : idx}: @@ -18231,12 +18217,12 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null1`{z : state, ht_1 : heaptype, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht_1) CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null1`{z : state, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), ht_2 : heaptype, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL`_instr(ht_2) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.copy-oob1`{z : state, a_1 : addr, i_1 : num_(I32_numtype), a_2 : addr, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: @@ -18269,8 +18255,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (sx?{sx <- `sx?`} = $sx(zt_2)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_elem-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) + rule `array.init_elem-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_elem-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -18295,8 +18281,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (ref = $elem(z, y).REFS_eleminst[j!`%`_num_.0]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_data-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) + rule `array.init_data-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_data-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -18458,9 +18444,9 @@ relation Step: `%~>%`(config, config) -- if (a = |$structinst(z)|) -- if (si = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`, zt <- `zt*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.53 - rule `struct.set-null`{z : state, ht : heaptype, val : val, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 + rule `struct.set-null`{z : state, val : val, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:724.1-727.46 rule `struct.set-struct`{z : state, a : addr, val : val, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -18473,9 +18459,9 @@ relation Step: `%~>%`(config, config) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) -- if ((a = |$arrayinst(z)|) /\ (ai = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`}})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.64 - rule `array.set-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.66 + rule `array.set-null`{z : state, i : num_(I32_numtype), val : val, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:788.1-790.39 rule `array.set-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx}: @@ -24797,32 +24783,6 @@ syntax addr = nat ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax arrayaddr = addr -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax exnaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax funcaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax hostaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax structaddr = addr - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -rec { - -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-42.23 -syntax addrref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) -} - ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec syntax catch = | CATCH(tagidx : tagidx, labelidx : labelidx) @@ -24830,12 +24790,18 @@ syntax catch = | CATCH_ALL(labelidx : labelidx) | CATCH_ALL_REF(labelidx : labelidx) +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax exnaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax dataaddr = addr ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax elemaddr = addr +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax funcaddr = addr + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax globaladdr = addr @@ -24877,18 +24843,39 @@ syntax moduleinst = EXPORTS exportinst* } +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax hostaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +syntax structaddr = addr + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec +rec { + +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:35.1-43.19 +syntax ref = + | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` + | `REF.STRUCT_ADDR`(structaddr : structaddr) + | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) + | `REF.FUNC_ADDR`(funcaddr : funcaddr) + | `REF.EXN_ADDR`(exnaddr : exnaddr) + | `REF.HOST_ADDR`(hostaddr : hostaddr) + | `REF.EXTERN`(ref : ref) +} + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax val = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -24900,7 +24887,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:136.1-142.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 syntax instr = | NOP | UNREACHABLE @@ -25010,12 +24997,13 @@ syntax instr = -- if ((sx?{sx <- `sx?`} = ?()) <=> ($lanetype(shape) <- [I32_lanetype I64_lanetype F32_lanetype F64_lanetype])) | VREPLACE_LANE(shape : shape, laneidx : laneidx) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) + | `REF.EXTERN`(ref : ref) | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) @@ -26203,7 +26191,7 @@ def $default_(valtype : valtype) : val? ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{Vnn : Vnn}((Vnn : Vnn <: valtype)) = ?(VCONST_val(Vnn, `%`_vec_(0))) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec - def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL`_val(ht)) + def $default_{ht : heaptype}(REF_valtype(?(NULL_null), ht)) = ?(`REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec def $default_{ht : heaptype}(REF_valtype(?(), ht)) = ?() @@ -28364,17 +28352,6 @@ syntax num = syntax vec = | VCONST(vectype : vectype, vec_(vectype)) -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec -syntax ref = - | `REF.I31_NUM`(u31 : u31) - | `REF.STRUCT_ADDR`(structaddr : structaddr) - | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) - | `REF.FUNC_ADDR`(funcaddr : funcaddr) - | `REF.EXN_ADDR`(exnaddr : exnaddr) - | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -28447,13 +28424,13 @@ syntax fieldval = | CONST(numtype : numtype, num_(numtype)) | VCONST(vectype : vectype, vec_(vectype)) | `REF.I31_NUM`(u31 : u31) + | `REF.NULL_ADDR` | `REF.STRUCT_ADDR`(structaddr : structaddr) | `REF.ARRAY_ADDR`(arrayaddr : arrayaddr) | `REF.FUNC_ADDR`(funcaddr : funcaddr) | `REF.EXN_ADDR`(exnaddr : exnaddr) | `REF.HOST_ADDR`(hostaddr : hostaddr) - | `REF.EXTERN`(addrref : addrref) - | `REF.NULL`(heaptype : heaptype) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -28522,13 +28499,13 @@ def $unpackfield_(storagetype : storagetype, sx?, fieldval : fieldval) : val ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:190.1-190.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 def $tagsxa{a : addr, `xa*` : externaddr*}([TAG_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tagsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:198.1-198.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -28536,13 +28513,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 def $globalsxa{a : addr, `xa*` : externaddr*}([GLOBAL_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $globalsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:202.1-202.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -28550,13 +28527,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 def $memsxa{a : addr, `xa*` : externaddr*}([MEM_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $memsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:206.1-206.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -28564,13 +28541,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 def $tablesxa{a : addr, `xa*` : externaddr*}([TABLE_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $tablesxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:210.1-210.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -28578,13 +28555,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 def $funcsxa{a : addr, `xa*` : externaddr*}([FUNC_externaddr(a)] ++ xa*{xa <- `xa*`}) = [a] ++ $funcsxa(xa*{xa <- `xa*`}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:214.1-214.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -28806,47 +28783,47 @@ rec { ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:25.1-25.60 relation Ref_ok: `%|-%:%`(store, ref, reftype) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-37.35 - rule null{s : store, ht : heaptype, ht' : heaptype}: - `%|-%:%`(s, `REF.NULL`_ref(ht), REF_reftype(?(NULL_null), ht')) - -- Heaptype_sub: `%|-%<:%`({TYPES [], RECS [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS []}, ht', ht) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:35.1-36.38 + rule null{s : store}: + `%|-%:%`(s, `REF.NULL_ADDR`_ref, REF_reftype(?(NULL_null), BOT_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:39.1-40.33 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:38.1-39.33 rule i31{s : store, i : u31}: `%|-%:%`(s, `REF.I31_NUM`_ref(i), REF_reftype(?(), I31_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:42.1-44.31 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:41.1-43.31 rule struct{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.STRUCT_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (a < |s.STRUCTS_store|) -- if (s.STRUCTS_store[a].TYPE_structinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:46.1-48.30 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:45.1-47.30 rule array{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.ARRAY_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (a < |s.ARRAYS_store|) -- if (s.ARRAYS_store[a].TYPE_arrayinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:50.1-52.29 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:49.1-51.29 rule func{s : store, a : addr, dt : deftype}: `%|-%:%`(s, `REF.FUNC_ADDR`_ref(a), REF_reftype(?(), (dt : deftype <: heaptype))) -- if (a < |s.FUNCS_store|) -- if (s.FUNCS_store[a].TYPE_funcinst = dt) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:54.1-56.24 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:53.1-55.24 rule exn{s : store, a : addr, exn : exninst}: `%|-%:%`(s, `REF.EXN_ADDR`_ref(a), REF_reftype(?(), EXN_heaptype)) -- if (a < |s.EXNS_store|) -- if (s.EXNS_store[a] = exn) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:58.1-59.35 + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:57.1-58.35 rule host{s : store, a : addr}: `%|-%:%`(s, `REF.HOST_ADDR`_ref(a), REF_reftype(?(), ANY_heaptype)) - ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:61.1-63.38 - rule extern{s : store, addrref : addrref}: - `%|-%:%`(s, `REF.EXTERN`_ref(addrref), REF_reftype(?(), EXTERN_heaptype)) - -- Ref_ok: `%|-%:%`(s, (addrref : addrref <: ref), REF_reftype(?(), ANY_heaptype)) + ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:60.1-63.30 + rule extern{s : store, ref : ref}: + `%|-%:%`(s, `REF.EXTERN`_ref(ref), REF_reftype(?(), EXTERN_heaptype)) + -- Ref_ok: `%|-%:%`(s, ref, REF_reftype(?(), ANY_heaptype)) + -- if (ref =/= `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.1-execution.values.spectec:65.1-68.34 rule sub{s : store, ref : ref, rt : reftype, rt' : reftype}: @@ -29017,9 +28994,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- if (i!`%`_num_.0 >= |l*{l <- `l*`}|) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NULL_instr(l)], [BR_instr(l)]) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_null-addr`{val : val, l : labelidx}: @@ -29027,9 +29004,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `br_on_non_null-null`{val : val, l : labelidx, ht : heaptype}: + rule `br_on_non_null-null`{val : val, l : labelidx}: `%~>%`([(val : val <: instr) BR_ON_NON_NULL_instr(l)], []) - -- if (val = `REF.NULL`_val(ht)) + -- if (val = `REF.NULL_ADDR`_val) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `br_on_non_null-addr`{val : val, l : labelidx}: @@ -29090,9 +29067,9 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([CONST_instr(I32_numtype, i) `REF.I31`_instr], [`REF.I31_NUM`_instr($wrap__(32, 31, i))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.is_null-true`{ref : ref, ht : heaptype}: + rule `ref.is_null-true`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.IS_NULL`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.is_null-false`{ref : ref}: @@ -29100,9 +29077,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.as_non_null-null`{ref : ref, ht : heaptype}: + rule `ref.as_non_null-null`{ref : ref}: `%~>%`([(ref : ref <: instr) `REF.AS_NON_NULL`_instr], [TRAP_instr]) - -- if (ref = `REF.NULL`_ref(ht)) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.as_non_null-addr`{ref : ref}: @@ -29110,9 +29087,9 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.eq-null`{ref_1 : ref, ref_2 : ref, ht_1 : heaptype, ht_2 : heaptype}: + rule `ref.eq-null`{ref_1 : ref, ref_2 : ref}: `%~>%`([(ref_1 : ref <: instr) (ref_2 : ref <: instr) `REF.EQ`_instr], [CONST_instr(I32_numtype, `%`_num_(1))]) - -- if ((ref_1 = `REF.NULL`_ref(ht_1)) /\ (ref_2 = `REF.NULL`_ref(ht_2))) + -- if ((ref_1 = `REF.NULL_ADDR`_ref) /\ (ref_2 = `REF.NULL_ADDR`_ref)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.eq-true`{ref_1 : ref, ref_2 : ref}: @@ -29126,8 +29103,8 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `i31.get-null`{ht : heaptype, sx : sx}: - `%~>%`([`REF.NULL`_instr(ht) `I31.GET`_instr(sx)], [TRAP_instr]) + rule `i31.get-null`{sx : sx}: + `%~>%`([`REF.NULL_ADDR`_instr `I31.GET`_instr(sx)], [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `i31.get-num`{i : u31, sx : sx}: @@ -29138,20 +29115,22 @@ relation Step_pure: `%~>%`(instr*, instr*) `%~>%`([(val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.NEW`_instr(x)], (val : val <: instr)^n{} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL`_instr(EXTERN_heaptype)]) + rule `extern.convert_any-null`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.NULL_ADDR`_instr]) + -- if (ref = `REF.NULL_ADDR`_ref) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `extern.convert_any-addr`{addrref : addrref}: - `%~>%`([(addrref : addrref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(addrref)]) + rule `extern.convert_any-addr`{ref : ref}: + `%~>%`([(ref : ref <: instr) `EXTERN.CONVERT_ANY`_instr], [`REF.EXTERN`_instr(ref)]) + -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-null`{ht : heaptype}: - `%~>%`([`REF.NULL`_instr(ht) `ANY.CONVERT_EXTERN`_instr], [`REF.NULL`_instr(ANY_heaptype)]) + rule `any.convert_extern-null`: + `%~>%`([`REF.NULL_ADDR`_instr `ANY.CONVERT_EXTERN`_instr], [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `any.convert_extern-addr`{addrref : addrref}: - `%~>%`([`REF.EXTERN`_instr(addrref) `ANY.CONVERT_EXTERN`_instr], [(addrref : addrref <: instr)]) + rule `any.convert_extern-addr`{ref : ref}: + `%~>%`([`REF.EXTERN`_instr(ref) `ANY.CONVERT_EXTERN`_instr], [(ref : ref <: instr)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `unop-val`{nt : numtype, c_1 : num_(nt), unop : unop_(nt), c : num_(nt)}: @@ -29380,8 +29359,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, ht : heaptype, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, yy : typeuse}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `call_ref-func`{z : state, n : n, `val*` : val*, a : addr, yy : typeuse, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: @@ -29408,8 +29387,8 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, ht : heaptype, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL`_instr(ht)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) + rule `return_call_ref-frame-null`{z : state, k : n, f : frame, `val*` : val*, yy : typeuse, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val : val <: instr)*{val <- `val*`} ++ [`REF.NULL_ADDR`_instr] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `return_call_ref-frame-addr`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, yy : typeuse, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: @@ -29418,8 +29397,8 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($funcinst(z)[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`}), `%`_resulttype(t_2^m{t_2 <- `t_2*`}))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) THROW_REF_instr]), [TRAP_instr]) + rule `throw_ref-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr THROW_REF_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `throw_ref-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: @@ -29693,8 +29672,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) + rule `ref.null`{z : state, ht : heaptype}: + `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht)]), [`REF.NULL_ADDR`_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `ref.func`{z : state, x : idx}: @@ -29731,8 +29710,8 @@ relation Step_read: `%~>%`(config, instr*) -- (if ($default_($unpack(zt)) = ?(val)))*{val <- `val*`, zt <- `zt*`} ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `struct.get-null`{z : state, ht : heaptype, `sx?` : sx?, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) + rule `struct.get-null`{z : state, `sx?` : sx?, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `STRUCT.GET`_instr(sx?{sx <- `sx?`}, x, i)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `struct.get-struct`{z : state, a : addr, `sx?` : sx?, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -29772,8 +29751,8 @@ relation Step_read: `%~>%`(config, instr*) -- if ($concatn_(syntax byte, $zbytes_(zt, c)^n{c <- `c*`}, ((($zsize(zt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) = $data(z, y).BYTES_datainst[i!`%`_num_.0 : ((((n * $zsize(zt)) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.get-null`{z : state, ht : heaptype, i : num_(I32_numtype), `sx?` : sx?, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) + rule `array.get-null`{z : state, i : num_(I32_numtype), `sx?` : sx?, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) `ARRAY.GET`_instr(sx?{sx <- `sx?`}, x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.get-oob`{z : state, a : addr, i : num_(I32_numtype), `sx?` : sx?, x : idx}: @@ -29789,8 +29768,8 @@ relation Step_read: `%~>%`(config, instr*) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.len-null`{z : state, ht : heaptype}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) `ARRAY.LEN`_instr]), [TRAP_instr]) + rule `array.len-null`{z : state}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr `ARRAY.LEN`_instr]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.len-array`{z : state, a : addr}: @@ -29798,8 +29777,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (a < |$arrayinst(z)|) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.fill-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, n : n, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) + rule `array.fill-null`{z : state, i : num_(I32_numtype), val : val, n : n, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.FILL`_instr(x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.fill-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, n : n, x : idx}: @@ -29819,12 +29798,12 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null1`{z : state, ht_1 : heaptype, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht_1) CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null1`{z : state, i_1 : num_(I32_numtype), ref : ref, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_1) (ref : ref <: instr) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), ht_2 : heaptype, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: - `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL`_instr(ht_2) CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) + rule `array.copy-null2`{z : state, ref : ref, i_1 : num_(I32_numtype), i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: + `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr(I32_numtype, i_1) `REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i_2) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.COPY`_instr(x_1, x_2)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.copy-oob1`{z : state, a_1 : addr, i_1 : num_(I32_numtype), a_2 : addr, i_2 : num_(I32_numtype), n : n, x_1 : idx, x_2 : idx}: @@ -29859,8 +29838,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (sx?{sx <- `sx?`} = $sx(zt_2)) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_elem-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) + rule `array.init_elem-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_ELEM`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_elem-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -29887,8 +29866,8 @@ relation Step_read: `%~>%`(config, instr*) -- if (ref = $elem(z, y).REFS_eleminst[j!`%`_num_.0]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `array.init_data-null`{z : state, ht : heaptype, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) + rule `array.init_data-null`{z : state, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) CONST_instr(I32_numtype, j) CONST_instr(I32_numtype, `%`_num_(n)) `ARRAY.INIT_DATA`_instr(x, y)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `array.init_data-oob1`{z : state, a : addr, i : num_(I32_numtype), j : num_(I32_numtype), n : n, x : idx, y : idx}: @@ -30056,9 +30035,9 @@ relation Step: `%~>%`(config, config) -- if (a = |$structinst(z)|) -- if (si = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`, zt <- `zt*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.53 - rule `struct.set-null`{z : state, ht : heaptype, val : val, x : idx, i : u32}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 + rule `struct.set-null`{z : state, val : val, x : idx, i : u32}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:724.1-727.46 rule `struct.set-struct`{z : state, a : addr, val : val, x : idx, i : u32, `zt*` : storagetype*, `mut?*` : mut?*}: @@ -30072,9 +30051,9 @@ relation Step: `%~>%`(config, config) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) -- if ((a = |$arrayinst(z)|) /\ (ai = {TYPE $type(z, x), FIELDS $packfield_(zt, val)^n{val <- `val*`}})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.64 - rule `array.set-null`{z : state, ht : heaptype, i : num_(I32_numtype), val : val, x : idx}: - `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(ht) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:785.1-786.66 + rule `array.set-null`{z : state, i : num_(I32_numtype), val : val, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:788.1-790.39 rule `array.set-oob`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx}: diff --git a/spectec/test-prose/TEST.md b/spectec/test-prose/TEST.md index 484fb7d67f..34fdf8a1df 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -8406,11 +8406,11 @@ The module :math:`(\mathsf{module}~{{\mathit{type}}^\ast}~{{\mathit{import}}^\as 1) Return :math:`{{\mathrm{ipopcnt}}}_{N}({\mathit{iN}})`. - #. Assert: Due to validation, :math:`{\mathit{unop}}` is some :math:`\mathsf{extend}~n`. + #. If :math:`{\mathit{unop}}` is some :math:`\mathsf{extend}~n`, then: - #. Let :math:`(\mathsf{extend}~M)` be the destructuring of :math:`{\mathit{unop}}`. + 1) Let :math:`(\mathsf{extend}~M)` be the destructuring of :math:`{\mathit{unop}}`. - #. Return :math:`{{{{\mathrm{extend}}}_{M, N}^{\mathsf{s}}}}{({{\mathrm{wrap}}}_{N, M}({\mathit{iN}}))}`. + #) Return :math:`{{{{\mathrm{extend}}}_{M, N}^{\mathsf{s}}}}{({{\mathrm{wrap}}}_{N, M}({\mathit{iN}}))}`. #. Assert: Due to validation, :math:`{\mathit{numtype}}` is :math:`{\mathsf{f}}{n}`. @@ -12633,9 +12633,9 @@ unop_ numtype unop_ iN 1) Return [$ictz_($sizenn(numtype), iN)]. c. If (unop_ = POPCNT), then: 1) Return [$ipopcnt_($sizenn(numtype), iN)]. - d. Assert: Due to validation, unop_ is some EXTEND. - e. Let (EXTEND M) be unop_. - f. Return [$extend__(M, $sizenn(numtype), S, $wrap__($sizenn(numtype), M, iN))]. + d. If unop_ is some EXTEND, then: + 1) Let (EXTEND M) be unop_. + 2) Return [$extend__(M, $sizenn(numtype), S, $wrap__($sizenn(numtype), M, iN))]. 2. Assert: Due to validation, numtype is Fnn. 3. If (unop_ = ABS), then: a. Return $fabs_($sizenn(numtype), iN). @@ -17278,11 +17278,9 @@ The reference value :math:`{\mathit{ref}}` is :ref:`valid ` with the * Either: - * The reference value :math:`{\mathit{ref}}` is of the form :math:`(\mathsf{ref{.}null}~{\mathit{ht}})`. + * The reference value :math:`{\mathit{ref}}` is of the form :math:`\mathsf{ref{.}null}`. - * The reference type :math:`{\mathit{rt}}` is of the form :math:`(\mathsf{ref}~\mathsf{null}~{\mathit{ht}'})`. - - * The heap type :math:`{\mathit{ht}'}` :ref:`matches ` the heap type :math:`{\mathit{ht}}`. + * The reference type :math:`{\mathit{rt}}` is of the form :math:`(\mathsf{ref}~\mathsf{null}~\mathsf{bot})`. * Or: @@ -17330,11 +17328,13 @@ The reference value :math:`{\mathit{ref}}` is :ref:`valid ` with the * The reference type :math:`{\mathit{rt}}` is of the form :math:`(\mathsf{ref}~\mathsf{any})`. * Or: - * The reference value :math:`{\mathit{ref}}` is of the form :math:`(\mathsf{ref{.}extern}~{\mathit{addrref}})`. + * The reference value :math:`{\mathit{ref}}` is of the form :math:`(\mathsf{ref{.}extern}~{\mathit{ref}'})`. * The reference type :math:`{\mathit{rt}}` is of the form :math:`(\mathsf{ref}~\mathsf{extern})`. - * The reference value :math:`{\mathit{addrref}}` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{any})`. + * The reference value :math:`{\mathit{ref}'}` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{any})`. + + * The reference value :math:`{\mathit{ref}'}` is not of the form :math:`\mathsf{ref{.}null}`. * Or: * The reference value :math:`{\mathit{ref}}` is :ref:`valid ` with the reference type :math:`{\mathit{rt}'}`. @@ -17344,10 +17344,7 @@ The reference value :math:`{\mathit{ref}}` is :ref:`valid ` with the -The reference value :math:`(\mathsf{ref{.}null}~{\mathit{ht}})` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{null}~{\mathit{ht}'})` if: - - - * The heap type :math:`{\mathit{ht}'}` :ref:`matches ` the heap type :math:`{\mathit{ht}}`. +The reference value :math:`\mathsf{ref{.}null}` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{null}~\mathsf{bot})`. @@ -17400,10 +17397,12 @@ The reference value :math:`(\mathsf{ref{.}host}~a)` is :ref:`valid ` -The reference value :math:`(\mathsf{ref{.}extern}~{\mathit{addrref}})` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{extern})` if: +The reference value :math:`(\mathsf{ref{.}extern}~{\mathit{ref}})` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{extern})` if: - * The reference value :math:`{\mathit{addrref}}` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{any})`. + * The reference value :math:`{\mathit{ref}}` is :ref:`valid ` with the reference type :math:`(\mathsf{ref}~\mathsf{any})`. + + * The reference value :math:`{\mathit{ref}}` is not of the form :math:`\mathsf{ref{.}null}`. @@ -17728,7 +17727,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Assert: Due to validation, the first non-value entry of the stack is a :math:`\mathsf{frame}`. -#. If :math:`{\mathit{val}''}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}''} = \mathsf{ref{.}null}`, then: a. Trap. @@ -18359,7 +18358,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Execute the instruction :math:`(\mathsf{br}~l)`. @@ -18376,7 +18375,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Do nothing. @@ -18520,7 +18519,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{ref}}` from the stack. -#. If :math:`{\mathit{ref}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{ref}} = \mathsf{ref{.}null}`, then: a. Push the value :math:`(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~1)` to the stack. @@ -18537,7 +18536,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{ref}}` from the stack. -#. If :math:`{\mathit{ref}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{ref}} = \mathsf{ref{.}null}`, then: a. Trap. @@ -18556,7 +18555,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{ref}}_1` from the stack. -#. If :math:`{\mathit{ref}}_1` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}` and :math:`{\mathit{ref}}_2` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{ref}}_1 = \mathsf{ref{.}null}` and :math:`{\mathit{ref}}_2 = \mathsf{ref{.}null}`, then: a. Push the value :math:`(\mathsf{i{\scriptstyle 32}}{.}\mathsf{const}~1)` to the stack. @@ -18577,7 +18576,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Trap. @@ -18609,17 +18608,17 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i ...................................... -1. Assert: Due to validation, a value is on the top of the stack. +1. Assert: Due to validation, a reference value is on the top of the stack. -#. Pop the value :math:`{\mathit{val}}` from the stack. +#. Pop the value :math:`{\mathit{ref}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{ref}} = \mathsf{ref{.}null}`, then: - a. Push the value :math:`(\mathsf{ref{.}null}~\mathsf{extern})` to the stack. + a. Push the value :math:`\mathsf{ref{.}null}` to the stack. -#. If :math:`{\mathit{val}}` is address value, then: +#. Else: - a. Push the value :math:`(\mathsf{ref{.}extern}~{\mathit{val}})` to the stack. + a. Push the value :math:`(\mathsf{ref{.}extern}~{\mathit{ref}})` to the stack. :math:`\mathsf{any{.}convert\_extern}` @@ -18630,15 +18629,15 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: - a. Push the value :math:`(\mathsf{ref{.}null}~\mathsf{any})` to the stack. + a. Push the value :math:`\mathsf{ref{.}null}` to the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}extern}~{\mathit{addrref}}`, then: +#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}extern}~{\mathit{ref}}`, then: - a. Let :math:`(\mathsf{ref{.}extern}~{\mathit{addrref}})` be the destructuring of :math:`{\mathit{val}}`. + a. Let :math:`(\mathsf{ref{.}extern}~{\mathit{ref}})` be the destructuring of :math:`{\mathit{val}}`. - #. Push the value :math:`{\mathit{addrref}}` to the stack. + #. Push the value :math:`{\mathit{ref}}` to the stack. :math:`{\mathit{nt}} {.} {\mathit{unop}}` @@ -19212,7 +19211,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}'}` from the stack. -#. If :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}`, then: a. Trap. @@ -19306,7 +19305,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}''}` from the stack. - #. If :math:`{\mathit{val}''}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: + #. If :math:`{\mathit{val}''} = \mathsf{ref{.}null}`, then: 1) Trap. @@ -19345,7 +19344,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}'}` from the stack. -#. If :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}`, then: a. Trap. @@ -20083,13 +20082,11 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Execute the instruction :math:`(\mathsf{memory{.}init}~x~y)`. -:math:`\mathsf{ref{.}null}~x` -............................. - +:math:`\mathsf{ref{.}null}~{\mathit{ht}}` +......................................... -1. Let :math:`z` be the current state. -#. Push the value :math:`(\mathsf{ref{.}null}~z{.}\mathsf{types}{}[x])` to the stack. +1. Push the value :math:`\mathsf{ref{.}null}` to the stack. :math:`\mathsf{ref{.}func}~x` @@ -20182,7 +20179,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Trap. @@ -20302,7 +20299,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Trap. @@ -20310,19 +20307,19 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Let :math:`(\mathsf{ref{.}array}~a)` be the destructuring of :math:`{\mathit{val}}`. -#. If :math:`a < {|z{.}\mathsf{arrays}|}` and :math:`i \geq {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|}`, then: +#. Assert: Due to validation, :math:`a < {|z{.}\mathsf{arrays}|}`. - a. Trap. +#. If :math:`i \geq {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|}`, then: -#. If :math:`i < {|z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}|}` and :math:`a < {|z{.}\mathsf{arrays}|}`, then: + a. Trap. - a. Assert: Due to validation, the :ref:`expansion ` of :math:`z{.}\mathsf{types}{}[x]` is some :math:`\mathsf{array}~{\mathit{fieldtype}}`. +#. Assert: Due to validation, the :ref:`expansion ` of :math:`z{.}\mathsf{types}{}[x]` is some :math:`\mathsf{array}~{\mathit{fieldtype}}`. - #. Let :math:`(\mathsf{array}~{\mathit{fieldtype}}_0)` be the destructuring of the :ref:`expansion ` of :math:`z{.}\mathsf{types}{}[x]`. +#. Let :math:`(\mathsf{array}~{\mathit{fieldtype}}_0)` be the destructuring of the :ref:`expansion ` of :math:`z{.}\mathsf{types}{}[x]`. - #. Let :math:`({\mathsf{mut}^?}~{\mathit{zt}})` be the destructuring of :math:`{\mathit{fieldtype}}_0`. +#. Let :math:`({\mathsf{mut}^?}~{\mathit{zt}})` be the destructuring of :math:`{\mathit{fieldtype}}_0`. - #. Push the value :math:`{{{{\mathrm{unpack}}}_{{\mathit{zt}}}^{{{\mathit{sx}}^?}}}}{(z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}{}[i])}` to the stack. +#. Push the value :math:`{{{{\mathrm{unpack}}}_{{\mathit{zt}}}^{{{\mathit{sx}}^?}}}}{(z{.}\mathsf{arrays}{}[a]{.}\mathsf{fields}{}[i])}` to the stack. :math:`\mathsf{array{.}len}` @@ -20335,7 +20332,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Trap. @@ -20370,7 +20367,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}'}` from the stack. -#. If :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}`, then: a. Trap. @@ -20437,11 +20434,11 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}'}` from the stack. -#. If :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}` and :math:`{\mathit{val}}` is reference value, then: +#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}` and :math:`{\mathit{val}}` is reference value, then: a. Trap. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}` and :math:`{\mathit{val}'}` is reference value, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}` and :math:`{\mathit{val}'}` is reference value, then: a. Trap. @@ -20548,7 +20545,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Trap. @@ -20613,7 +20610,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Trap. @@ -20942,7 +20939,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}'}` from the stack. -#. If :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}`, then: a. Trap. @@ -21004,7 +21001,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Pop the value :math:`{\mathit{val}'}` from the stack. -#. If :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}null}~{\mathit{heaptype}}`, then: +#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}`, then: a. Trap. @@ -23758,7 +23755,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. If :math:`{{\mathit{NULL}}_0^?} = \mathsf{null}`, then: - a. Return :math:`(\mathsf{ref{.}null}~{\mathit{ht}})`. + a. Return :math:`\mathsf{ref{.}null}`. #. Assert: Due to validation, :math:`{{\mathit{NULL}}_0^?}` is not defined. @@ -24220,11 +24217,11 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i 1) Return :math:`{{\mathrm{ipopcnt}}}_{N}(i)`. - #. Assert: Due to validation, :math:`{\mathit{unop}}` is some :math:`{\mathsf{extend}}{{\mathit{sz}}}{\mathsf{\_}}{\mathsf{s}}`. + #. If :math:`{\mathit{unop}}` is some :math:`{\mathsf{extend}}{{\mathit{sz}}}{\mathsf{\_}}{\mathsf{s}}`, then: - #. Let :math:`({\mathsf{extend}}{M}{\mathsf{\_}}{\mathsf{s}})` be the destructuring of :math:`{\mathit{unop}}`. + 1) Let :math:`({\mathsf{extend}}{M}{\mathsf{\_}}{\mathsf{s}})` be the destructuring of :math:`{\mathit{unop}}`. - #. Return :math:`{{{{\mathrm{iextend}}}_{N, M}^{\mathsf{s}}}}{(i)}`. + #) Return :math:`{{{{\mathrm{iextend}}}_{N, M}^{\mathsf{s}}}}{(i)}`. #. Assert: Due to validation, :math:`{\mathit{numtype}}` is :math:`{\mathsf{f}}{N}`. @@ -28679,9 +28676,8 @@ Vec_ok Ref_ok - the reference value ref is valid with the reference type rt if: - Either: - - ref is (REF.NULL ht). - - rt is (REF ?(NULL) ht'). - - the heap type ht' matches the heap type ht. + - ref is REF.NULL_ADDR. + - rt is (REF ?(NULL) BOT). - Or: - ref is (REF.I31_NUM i). - rt is (REF ?() I31). @@ -28708,16 +28704,16 @@ Ref_ok - ref is (REF.HOST_ADDR a). - rt is (REF ?() ANY). - Or: - - ref is (REF.EXTERN addrref). + - ref is (REF.EXTERN ref'). - rt is (REF ?() EXTERN). - - the reference value addrref is valid with the reference type (REF ?() ANY). + - the reference value ref' is valid with the reference type (REF ?() ANY). + - ref' is not REF.NULL_ADDR. - Or: - ref is valid with the reference type rt'. - rt' matches rt. Ref_ok/null -- the reference value (REF.NULL ht) is valid with the reference type (REF ?(NULL) ht') if: - - the heap type ht' matches the heap type ht. +- the reference value REF.NULL_ADDR is valid with the reference type (REF ?(NULL) BOT). Ref_ok/i31 - the reference value (REF.I31_NUM i) is valid with the reference type (REF ?() I31). @@ -28745,8 +28741,9 @@ Ref_ok/host - the reference value (REF.HOST_ADDR a) is valid with the reference type (REF ?() ANY). Ref_ok/extern -- the reference value (REF.EXTERN addrref) is valid with the reference type (REF ?() EXTERN) if: - - the reference value addrref is valid with the reference type (REF ?() ANY). +- the reference value (REF.EXTERN ref) is valid with the reference type (REF ?() EXTERN) if: + - the reference value ref is valid with the reference type (REF ?() ANY). + - ref is not REF.NULL_ADDR. Ref_ok/sub - the reference value ref is valid with the reference type rt if: @@ -28910,7 +28907,7 @@ Step_read/return_call_ref-frame-* yy 2. Assert: Due to validation, a value is on the top of the stack. 3. Pop the value val'' from the stack. 4. Assert: Due to validation, the first non-value entry of the stack is a FRAME_. -5. If val'' is some REF.NULL, then: +5. If (val'' = REF.NULL_ADDR), then: a. Trap. 6. Assert: Due to validation, val'' is some REF.FUNC_ADDR. 7. Let (REF.FUNC_ADDR a) be val''. @@ -29206,7 +29203,7 @@ Step_pure/br_table l* l' Step_pure/br_on_null l 1. Assert: Due to validation, a value is on the top of the stack. 2. Pop the value val from the stack. -3. If val is some REF.NULL, then: +3. If (val = REF.NULL_ADDR), then: a. Execute the instruction (BR l). 4. Else: a. Push the value val to the stack. @@ -29214,7 +29211,7 @@ Step_pure/br_on_null l Step_pure/br_on_non_null l 1. Assert: Due to validation, a value is on the top of the stack. 2. Pop the value val from the stack. -3. If val is some REF.NULL, then: +3. If (val = REF.NULL_ADDR), then: a. Do nothing. 4. Else: a. Push the value val to the stack. @@ -29280,7 +29277,7 @@ Step_pure/ref.i31 Step_pure/ref.is_null 1. Assert: Due to validation, a value of value type ref is on the top of the stack. 2. Pop the value ref from the stack. -3. If ref is some REF.NULL, then: +3. If (ref = REF.NULL_ADDR), then: a. Push the value (I32.CONST 1) to the stack. 4. Else: a. Push the value (I32.CONST 0) to the stack. @@ -29288,7 +29285,7 @@ Step_pure/ref.is_null Step_pure/ref.as_non_null 1. Assert: Due to validation, a value of value type ref is on the top of the stack. 2. Pop the value ref from the stack. -3. If ref is some REF.NULL, then: +3. If (ref = REF.NULL_ADDR), then: a. Trap. 4. Push the value ref to the stack. @@ -29297,7 +29294,7 @@ Step_pure/ref.eq 2. Pop the value ref_2 from the stack. 3. Assert: Due to validation, a value of value type ref is on the top of the stack. 4. Pop the value ref_1 from the stack. -5. If (ref_1 is some REF.NULL /\ ref_2 is some REF.NULL), then: +5. If ((ref_1 = REF.NULL_ADDR) /\ (ref_2 = REF.NULL_ADDR)), then: a. Push the value (I32.CONST 1) to the stack. 6. Else if (ref_1 = ref_2), then: a. Push the value (I32.CONST 1) to the stack. @@ -29307,7 +29304,7 @@ Step_pure/ref.eq Step_pure/i31.get sx 1. Assert: Due to validation, a value is on the top of the stack. 2. Pop the value val from the stack. -3. If val is some REF.NULL, then: +3. If (val = REF.NULL_ADDR), then: a. Trap. 4. Assert: Due to validation, val is some REF.I31_NUM. 5. Let (REF.I31_NUM i) be val. @@ -29322,21 +29319,21 @@ Step_pure/array.new x 6. Execute the instruction (ARRAY.NEW_FIXED x n). Step_pure/extern.convert_any -1. Assert: Due to validation, a value is on the top of the stack. -2. Pop the value val from the stack. -3. If val is some REF.NULL, then: - a. Push the value (REF.NULL EXTERN) to the stack. -4. If val is addrref, then: - a. Push the value (REF.EXTERN val) to the stack. +1. Assert: Due to validation, a value of value type ref is on the top of the stack. +2. Pop the value ref from the stack. +3. If (ref = REF.NULL_ADDR), then: + a. Push the value REF.NULL_ADDR to the stack. +4. Else: + a. Push the value (REF.EXTERN ref) to the stack. Step_pure/any.convert_extern 1. Assert: Due to validation, a value is on the top of the stack. 2. Pop the value val from the stack. -3. If val is some REF.NULL, then: - a. Push the value (REF.NULL ANY) to the stack. +3. If (val = REF.NULL_ADDR), then: + a. Push the value REF.NULL_ADDR to the stack. 4. If val is some REF.EXTERN, then: - a. Let (REF.EXTERN addrref) be val. - b. Push the value addrref to the stack. + a. Let (REF.EXTERN ref) be val. + b. Push the value ref to the stack. Step_pure/unop nt unop 1. Assert: Due to validation, a value of value type nt is on the top of the stack. @@ -29605,7 +29602,7 @@ Step_read/call_ref yy 1. Let z be the current state. 2. Assert: Due to validation, a value is on the top of the stack. 3. Pop the value val' from the stack. -4. If val' is some REF.NULL, then: +4. If (val' = REF.NULL_ADDR), then: a. Trap. 5. Assert: Due to validation, val' is some REF.FUNC_ADDR. 6. Let (REF.FUNC_ADDR a) be val'. @@ -29649,7 +29646,7 @@ Step_read/return_call_ref yy a. Assert: Due to validation, the first non-value entry of the stack is a FRAME_. b. Assert: Due to validation, a value is on the top of the stack. c. Pop the value val'' from the stack. - d. If val'' is some REF.NULL, then: + d. If (val'' = REF.NULL_ADDR), then: 1) Trap. e. Assert: Due to validation, val'' is some REF.FUNC_ADDR. f. Let (REF.FUNC_ADDR a) be val''. @@ -29668,7 +29665,7 @@ Step_read/throw_ref 1. Let z be the current state. 2. Assert: Due to validation, a value is on the top of the stack. 3. Pop the value val' from the stack. -4. If val' is some REF.NULL, then: +4. If (val' = REF.NULL_ADDR), then: a. Trap. 5. If val' is some REF.EXN_ADDR, then: a. Let (REF.EXN_ADDR a) be val'. @@ -30020,9 +30017,8 @@ Step_read/memory.init x y g. Push the value (I32.CONST (n - 1)) to the stack. h. Execute the instruction (MEMORY.INIT x y). -Step_read/ref.null (_IDX x) -1. Let z be the current state. -2. Push the value (REF.NULL $type(z, x)) to the stack. +Step_read/ref.null ht +1. Push the value REF.NULL_ADDR to the stack. Step_read/ref.func x 1. Let z be the current state. @@ -30066,7 +30062,7 @@ Step_read/struct.get sx? x i 1. Let z be the current state. 2. Assert: Due to validation, a value is on the top of the stack. 3. Pop the value val from the stack. -4. If val is some REF.NULL, then: +4. If (val = REF.NULL_ADDR), then: a. Trap. 5. Assert: Due to validation, val is some REF.STRUCT_ADDR. 6. Let (REF.STRUCT_ADDR a) be val. @@ -30124,23 +30120,23 @@ Step_read/array.get sx? x 3. Pop the value (I32.CONST i) from the stack. 4. Assert: Due to validation, a value is on the top of the stack. 5. Pop the value val from the stack. -6. If val is some REF.NULL, then: +6. If (val = REF.NULL_ADDR), then: a. Trap. 7. Assert: Due to validation, val is some REF.ARRAY_ADDR. 8. Let (REF.ARRAY_ADDR a) be val. -9. If ((a < |$arrayinst(z)|) /\ (i >= |$arrayinst(z)[a].FIELDS|)), then: +9. Assert: Due to validation, (a < |$arrayinst(z)|). +10. If (i >= |$arrayinst(z)[a].FIELDS|), then: a. Trap. -10. If ((i < |$arrayinst(z)[a].FIELDS|) /\ (a < |$arrayinst(z)|)), then: - a. Assert: Due to validation, $Expand($type(z, x)) is some ARRAY. - b. Let (ARRAY fieldtype_0) be $Expand($type(z, x)). - c. Let (mut? zt) be fieldtype_0. - d. Push the value $unpackfield_(zt, sx?, $arrayinst(z)[a].FIELDS[i]) to the stack. +11. Assert: Due to validation, $Expand($type(z, x)) is some ARRAY. +12. Let (ARRAY fieldtype_0) be $Expand($type(z, x)). +13. Let (mut? zt) be fieldtype_0. +14. Push the value $unpackfield_(zt, sx?, $arrayinst(z)[a].FIELDS[i]) to the stack. Step_read/array.len 1. Let z be the current state. 2. Assert: Due to validation, a value is on the top of the stack. 3. Pop the value val from the stack. -4. If val is some REF.NULL, then: +4. If (val = REF.NULL_ADDR), then: a. Trap. 5. Assert: Due to validation, val is some REF.ARRAY_ADDR. 6. Let (REF.ARRAY_ADDR a) be val. @@ -30157,7 +30153,7 @@ Step_read/array.fill x 7. Pop the value (I32.CONST i) from the stack. 8. Assert: Due to validation, a value is on the top of the stack. 9. Pop the value val' from the stack. -10. If val' is some REF.NULL, then: +10. If (val' = REF.NULL_ADDR), then: a. Trap. 11. Assert: Due to validation, val' is some REF.ARRAY_ADDR. 12. Let (REF.ARRAY_ADDR a) be val'. @@ -30190,9 +30186,9 @@ Step_read/array.copy x_1 x_2 9. Pop the value (I32.CONST i_1) from the stack. 10. Assert: Due to validation, a value is on the top of the stack. 11. Pop the value val' from the stack. -12. If (val' is some REF.NULL /\ val is ref), then: +12. If ((val' = REF.NULL_ADDR) /\ val is ref), then: a. Trap. -13. If (val is some REF.NULL /\ val' is ref), then: +13. If ((val = REF.NULL_ADDR) /\ val' is ref), then: a. Trap. 14. If val' is some REF.ARRAY_ADDR, then: a. Let (REF.ARRAY_ADDR a_1) be val'. @@ -30245,7 +30241,7 @@ Step_read/array.init_elem x y 7. Pop the value (I32.CONST i) from the stack. 8. Assert: Due to validation, a value is on the top of the stack. 9. Pop the value val from the stack. -10. If val is some REF.NULL, then: +10. If (val = REF.NULL_ADDR), then: a. Trap. 11. Assert: Due to validation, val is some REF.ARRAY_ADDR. 12. Let (REF.ARRAY_ADDR a) be val. @@ -30277,7 +30273,7 @@ Step_read/array.init_data x y 7. Pop the value (I32.CONST i) from the stack. 8. Assert: Due to validation, a value is on the top of the stack. 9. Pop the value val from the stack. -10. If val is some REF.NULL, then: +10. If (val = REF.NULL_ADDR), then: a. Trap. 11. Assert: Due to validation, val is some REF.ARRAY_ADDR. 12. Let (REF.ARRAY_ADDR a) be val. @@ -30435,7 +30431,7 @@ Step/struct.set x i 3. Pop the value val from the stack. 4. Assert: Due to validation, a value is on the top of the stack. 5. Pop the value val' from the stack. -6. If val' is some REF.NULL, then: +6. If (val' = REF.NULL_ADDR), then: a. Trap. 7. Assert: Due to validation, val' is some REF.STRUCT_ADDR. 8. Let (REF.STRUCT_ADDR a) be val'. @@ -30465,7 +30461,7 @@ Step/array.set x 5. Pop the value (I32.CONST i) from the stack. 6. Assert: Due to validation, a value is on the top of the stack. 7. Pop the value val' from the stack. -8. If val' is some REF.NULL, then: +8. If (val' = REF.NULL_ADDR), then: a. Trap. 9. Assert: Due to validation, val' is some REF.ARRAY_ADDR. 10. Let (REF.ARRAY_ADDR a) be val'. @@ -31746,7 +31742,7 @@ default_ valtype 4. Assert: Due to validation, valtype is some REF. 5. Let (REF NULL_0? ht) be valtype. 6. If (NULL_0? = ?(NULL)), then: - a. Return ?((REF.NULL ht)). + a. Return ?(REF.NULL_ADDR). 7. Assert: Due to validation, NULL_0? is not defined. 8. Return ?(). @@ -31959,9 +31955,9 @@ unop_ numtype unop_ i 1) Return [$ictz_($sizenn(numtype), i)]. c. If (unop_ = POPCNT), then: 1) Return [$ipopcnt_($sizenn(numtype), i)]. - d. Assert: Due to validation, unop_ is some EXTEND. - e. Let (EXTEND M) be unop_. - f. Return [$iextend_($sizenn(numtype), M, S, i)]. + d. If unop_ is some EXTEND, then: + 1) Let (EXTEND M) be unop_. + 2) Return [$iextend_($sizenn(numtype), M, S, i)]. 2. Assert: Due to validation, numtype is Fnn. 3. If (unop_ = ABS), then: a. Return $fabs_($sizenn(numtype), i). diff --git a/spectec/test-prose/doc/exec/runtime-in.rst b/spectec/test-prose/doc/exec/runtime-in.rst index a1a8ba63ab..57a867d36a 100644 --- a/spectec/test-prose/doc/exec/runtime-in.rst +++ b/spectec/test-prose/doc/exec/runtime-in.rst @@ -7,14 +7,12 @@ Values ~~~~~~ .. _syntax-num: -.. _syntax-addrref: .. _syntax-ref: .. _syntax-val: $${syntax+: num - {addrref - ref} + ref val } diff --git a/spectec/test-splice/TEST.md b/spectec/test-splice/TEST.md index 900b542e66..cc8249e9da 100644 --- a/spectec/test-splice/TEST.md +++ b/spectec/test-splice/TEST.md @@ -229,7 +229,7 @@ $$ {{\mathrm{default}}}_{{\mathsf{i}}{N}} & = & ({\mathsf{i}}{N}{.}\mathsf{const}~0) \\ {{\mathrm{default}}}_{{\mathsf{f}}{N}} & = & ({\mathsf{f}}{N}{.}\mathsf{const}~{+0}) \\ {{\mathrm{default}}}_{{\mathsf{v}}{N}} & = & ({\mathsf{v}}{N}{.}\mathsf{const}~0) \\ -{{\mathrm{default}}}_{\mathsf{ref}~\mathsf{null}~{\mathit{ht}}} & = & (\mathsf{ref{.}null}~{\mathit{ht}}) \\ +{{\mathrm{default}}}_{\mathsf{ref}~\mathsf{null}~{\mathit{ht}}} & = & \mathsf{ref{.}null} \\ {{\mathrm{default}}}_{\mathsf{ref}~{\mathit{ht}}} & = & \epsilon \\ \end{array} $$ @@ -292,7 +292,6 @@ warning: syntax `abbreviated` was never spliced warning: syntax `absheaptype/syn` was never spliced warning: syntax `absheaptype/sem` was never spliced warning: syntax `addr` was never spliced -warning: syntax `addrref` was never spliced warning: syntax `addrtype` was never spliced warning: syntax `arrayaddr` was never spliced warning: syntax `arrayinst` was never spliced @@ -1368,7 +1367,7 @@ warning: rule `Step_read/memory.copy-gt` was never spliced warning: rule `Step_read/memory.init-oob` was never spliced warning: rule `Step_read/memory.init-zero` was never spliced warning: rule `Step_read/memory.init-succ` was never spliced -warning: rule `Step_read/ref.null-idx` was never spliced +warning: rule `Step_read/ref.null` was never spliced warning: rule `Step_read/ref.func` was never spliced warning: rule `Step_read/ref.test-true` was never spliced warning: rule `Step_read/ref.test-false` was never spliced