From 9bdf29949a881813b21d27915be86f8577e59dac Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Tue, 24 Feb 2026 23:14:05 +0100 Subject: [PATCH 1/4] [spec] Narrow definition of null ref values --- .../4.0-execution.configurations.spectec | 2 +- .../4.3-execution.instructions.spectec | 2 +- .../4.0-execution.configurations.spectec | 2 +- .../4.3-execution.instructions.spectec | 2 +- spectec/doc/example/output/NanoWasm.pdf | Bin 245512 -> 245512 bytes spectec/test-frontend/TEST.md | 5 ++++- spectec/test-latex/TEST.md | 4 ++-- spectec/test-middlend/TEST.md | 15 ++++++++++++--- spectec/test-splice/TEST.md | 2 +- 9 files changed, 23 insertions(+), 11 deletions(-) diff --git a/specification/wasm-3.0/4.0-execution.configurations.spectec b/specification/wasm-3.0/4.0-execution.configurations.spectec index d7c2ce8f93..f1b6665f5c 100644 --- a/specification/wasm-3.0/4.0-execution.configurations.spectec +++ b/specification/wasm-3.0/4.0-execution.configurations.spectec @@ -43,7 +43,7 @@ syntax addrref hint(desc "address value") = syntax ref hint(desc "reference value") hint(macro "reff") = | addrref - | REF.NULL heaptype + | REF.NULL heaptype -- if $free_heaptype(heaptype) = {} syntax val hint(desc "value") = | num | vec | ref diff --git a/specification/wasm-3.0/4.3-execution.instructions.spectec b/specification/wasm-3.0/4.3-execution.instructions.spectec index 8ed03426ac..a2e0e78bd3 100644 --- a/specification/wasm-3.0/4.3-execution.instructions.spectec +++ b/specification/wasm-3.0/4.3-execution.instructions.spectec @@ -622,7 +622,7 @@ rule Step/data.drop: ;; Reference instructions -rule Step_read/ref.null-idx: +rule Step_read/ref.null: z; (REF.NULL (_IDX x)) ~> (REF.NULL $type(z, x)) rule Step_read/ref.func: diff --git a/specification/wasm-latest/4.0-execution.configurations.spectec b/specification/wasm-latest/4.0-execution.configurations.spectec index d7c2ce8f93..f1b6665f5c 100644 --- a/specification/wasm-latest/4.0-execution.configurations.spectec +++ b/specification/wasm-latest/4.0-execution.configurations.spectec @@ -43,7 +43,7 @@ syntax addrref hint(desc "address value") = syntax ref hint(desc "reference value") hint(macro "reff") = | addrref - | REF.NULL heaptype + | REF.NULL heaptype -- if $free_heaptype(heaptype) = {} syntax val hint(desc "value") = | num | vec | ref diff --git a/specification/wasm-latest/4.3-execution.instructions.spectec b/specification/wasm-latest/4.3-execution.instructions.spectec index 8ed03426ac..a2e0e78bd3 100644 --- a/specification/wasm-latest/4.3-execution.instructions.spectec +++ b/specification/wasm-latest/4.3-execution.instructions.spectec @@ -622,7 +622,7 @@ rule Step/data.drop: ;; Reference instructions -rule Step_read/ref.null-idx: +rule Step_read/ref.null: z; (REF.NULL (_IDX x)) ~> (REF.NULL $type(z, x)) rule Step_read/ref.func: diff --git a/spectec/doc/example/output/NanoWasm.pdf b/spectec/doc/example/output/NanoWasm.pdf index a720e239bac6443a8a4e1faaf73e3ed9df060098..6129f201d910af772ad1be399e4f2e4e89788b42 100644 GIT binary patch delta 114 zcmeD9$JgV?!eY!|9S+nPs8u?KWGP3)!3<9gPfJoL!yF%?(YQ jOif+P%#6&PjGavlT`f#4%$*(W6l@47+5TZSvjj5$Bh(%* delta 114 zcmeD9$Jg%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: + rule `ref.null`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index 4a45e4ccff..558731783b 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -8872,7 +8872,7 @@ $$ & & | & \mathsf{ref{.}host}~{\mathit{hostaddr}} \\ & & | & \mathsf{ref{.}extern}~{\mathit{addrref}} \\ \mbox{(reference value)} & {\mathit{ref}} & ::= & {\mathit{addrref}} \\ -& & | & \mathsf{ref{.}null}~{\mathit{heaptype}} \\ +& & | & \mathsf{ref{.}null}~{\mathit{heaptype}} & \quad \mbox{if}~ {\mathrm{free}}_{\mathit{heaptype}}({\mathit{heaptype}}) = \{ \} \\ \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} @@ -10292,7 +10292,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}~x) & \hookrightarrow & (\mathsf{ref{.}null}~z{.}\mathsf{types}{}[x]) \\ {[\textsc{\scriptsize E{-}ref.func}]} \quad & z ; (\mathsf{ref{.}func}~x) & \hookrightarrow & (\mathsf{ref{.}func}~z{.}\mathsf{module}{.}\mathsf{funcs}{}[x]) \\ \end{array} $$ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index ce7873e553..0f1df9a225 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -2041,6 +2041,7 @@ syntax val = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -5381,6 +5382,7 @@ syntax ref = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = @@ -5461,6 +5463,7 @@ syntax fieldval = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -6666,7 +6669,7 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: + rule `ref.null`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec @@ -13431,6 +13434,7 @@ syntax val = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -16771,6 +16775,7 @@ syntax ref = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = @@ -16851,6 +16856,7 @@ syntax fieldval = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -18058,7 +18064,7 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: + rule `ref.null`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec @@ -24823,6 +24829,7 @@ syntax val = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -28287,6 +28294,7 @@ syntax ref = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = @@ -28367,6 +28375,7 @@ syntax fieldval = | `REF.HOST_ADDR`(hostaddr : hostaddr) | `REF.EXTERN`(addrref : addrref) | `REF.NULL`(heaptype : heaptype) + -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -29606,7 +29615,7 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null-idx`{z : state, x : idx}: + rule `ref.null`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`REF.NULL`_instr(_IDX_heaptype(x))]), [`REF.NULL`_instr(($type(z, x) : deftype <: heaptype))]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec diff --git a/spectec/test-splice/TEST.md b/spectec/test-splice/TEST.md index 1b03a9fa19..9a99f98614 100644 --- a/spectec/test-splice/TEST.md +++ b/spectec/test-splice/TEST.md @@ -1368,7 +1368,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 From 1c342af08133398be9a2b5781a6e14d349f26a4f Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Wed, 25 Feb 2026 08:31:53 +0100 Subject: [PATCH 2/4] Fix splice --- document/core/exec/instructions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index ecf34f60bf..2f4b8754e1 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -695,7 +695,7 @@ Reference Instructions 4. Push the value :math:`\REFNULL~\deftype` to the stack. -$${rule: {Step_read/ref.null-*}} +$${rule: {Step_read/ref.null}} .. note:: No formal reduction rule is required for the case |REFNULL| |ABSHEAPTYPE|, From 7378873fecc541b75f6b8d9cbc1c3b306cd155d2 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Wed, 25 Feb 2026 09:57:46 +0100 Subject: [PATCH 3/4] Introduce REF.NULL_ADDR --- .github/workflows/ci-spec.yml | 6 +- document/core/exec/instructions.rst | 12 +- document/core/exec/runtime.rst | 6 +- document/core/exec/values.rst | 5 - document/core/util/macros.def | 2 +- interpreter/README.md | 2 +- interpreter/exec/eval.ml | 48 +- interpreter/host/spectest.ml | 6 +- interpreter/runtime/value.ml | 16 +- interpreter/script/js.ml | 29 +- interpreter/script/runner.ml | 2 +- interpreter/text/arrange.ml | 2 +- interpreter/text/parser.mly | 3 +- specification/Makefile | 8 +- specification/diff-wasm-latest.sh | 11 +- specification/sync-wasm-latest.sh | 64 ++ .../4.0-execution.configurations.spectec | 11 +- .../wasm-3.0/4.1-execution.values.spectec | 10 +- .../4.3-execution.instructions.spectec | 50 +- .../4.0-execution.configurations.spectec | 11 +- .../wasm-latest/4.1-execution.values.spectec | 10 +- .../4.3-execution.instructions.spectec | 50 +- spectec/Makefile | 3 + spectec/doc/example/output/NanoWasm.pdf | Bin 245512 -> 245508 bytes spectec/src/backend-interpreter/construct.ml | 6 +- spectec/src/backend-interpreter/host.ml | 7 +- .../src/backend-interpreter/interpreter.ml | 13 +- spectec/src/backend-interpreter/relation.ml | 22 +- spectec/src/exe-spectec/main.ml | 2 +- spectec/src/il2al/translate.ml | 6 +- spectec/src/il2al/translate.mli | 2 + spectec/test-frontend/TEST.md | 252 +++--- spectec/test-latex/TEST.md | 68 +- spectec/test-middlend/TEST.md | 756 +++++++++--------- spectec/test-prose/TEST.md | 208 +++-- spectec/test-prose/doc/exec/runtime-in.rst | 4 +- spectec/test-splice/TEST.md | 3 +- 37 files changed, 857 insertions(+), 859 deletions(-) create mode 100644 specification/sync-wasm-latest.sh diff --git a/.github/workflows/ci-spec.yml b/.github/workflows/ci-spec.yml index 9d73c79363..9bd1806938 100644 --- a/.github/workflows/ci-spec.yml +++ b/.github/workflows/ci-spec.yml @@ -2,12 +2,12 @@ name: CI for specs on: push: - branches: [ main, wasm-3.0 ] + branches: [ main ] paths: [ .github/**, document/**, spectec/**, specification/** ] pull_request: - branches: [ main, wasm-3.0 ] - paths: [ .github/**, document/**, spectec/**, specification/** ] + branches: [ main ] + paths: [ .github/**, document/**, spectec/src/**, specification/** ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index 2f4b8754e1..06dcf15520 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -687,20 +687,10 @@ 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]`. - -4. Push the value :math:`\REFNULL~\deftype` to the stack. +$${rule-prose: Step_read/ref.null} $${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 `. - .. _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/Makefile b/specification/Makefile index 917d2c966d..4bb8d93258 100644 --- a/specification/Makefile +++ b/specification/Makefile @@ -37,7 +37,13 @@ check-all: check-1.0 check-2.0 check-3.0 check-latest @echo All Wasm specs checked OK. check-diff: - ./diff-wasm-latest.sh + bash ./diff-wasm-latest.sh + + +# Sync + +sync-diff: + bash ./sync-wasm-latest.sh # Build diff --git a/specification/diff-wasm-latest.sh b/specification/diff-wasm-latest.sh index b2672473db..1da4202315 100755 --- a/specification/diff-wasm-latest.sh +++ b/specification/diff-wasm-latest.sh @@ -1,9 +1,10 @@ #!/bin/bash # Identify the highest versioned directory -HIGHEST_VER=$(ls -d wasm-[0-9]* 2>/dev/null | sort -V | tail -n 1) +HIGHEST=$(ls -d wasm-[0-9]* 2>/dev/null | sort -V | tail -n 1) -if [ -z "$HIGHEST_VER" ]; then +# Check that highest exists +if [ -z "$HIGHEST" ]; then echo "❌ Error: No wasm-X.Y versioned directories found in specification/" exit 1 fi @@ -17,14 +18,14 @@ if [ ! -d "$LATEST" ]; then fi # Diff the highest version with wasm-latest and check that the diff is empty -echo "Checking for differences between $HIGHEST_VER and $LATEST..." +echo "Checking for differences between $HIGHEST and $LATEST..." -if diff -qr "$HIGHEST_VER" "$LATEST" > /dev/null; then +if diff -qr "$HIGHEST" "$LATEST" > /dev/null; then echo "✅ Success: Contents match. No changes needed." else echo "🔍 Differences detected:" echo "--------------------------------" - diff -U0 -r "$HIGHEST_VER" "$LATEST" + diff -U0 -r "$HIGHEST" "$LATEST" echo "--------------------------------" exit 1 fi diff --git a/specification/sync-wasm-latest.sh b/specification/sync-wasm-latest.sh new file mode 100644 index 0000000000..c7b5d4e4d7 --- /dev/null +++ b/specification/sync-wasm-latest.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Identify the highest versioned directory +HIGHEST=$(ls -d wasm-[0-9]* 2>/dev/null | sort -V | tail -n 1) + +# Check that highest exists +if [ -z "$HIGHEST" ]; then + echo "❌ Error: No wasm-X.Y versioned directories found in specification/" + exit 1 +fi + +LATEST="wasm-latest" + +# Check that wasm-latest exists +if [ ! -d "$LATEST" ]; then + echo "❌ Error: $LATEST does not exist." + exit 1 +fi + +# Sync the highest version with wasm-latest, depending on which is newer +echo "Synchronizing $HIGHEST with $LATEST..." + +HIGHEST_FILES=$(cd $HIGHEST && ls *.spectec) +LATEST_FILES=$(cd $LATEST && ls *.spectec) + +LATEST_CHANGED=0 +HIGHEST_CHANGED=0 + +for FILE in $HIGHEST_FILES; do + if [ ! -f "$LATEST/$FILE" ]; then + echo "Added file $HIGHEST/$FILE" + ((++HIGHEST_CHANGED)) + elif [ "$HIGHEST/$FILE" -nt "$LATEST/$FILE" ] && ! diff -q "$HIGHEST/$FILE" "$LATEST/$FILE" >/dev/null; then + echo "Modified file $HIGHEST/$FILE" + ((++HIGHEST_CHANGED)) + fi +done + +for FILE in $LATEST_FILES; do + if [ ! -f "$HIGHEST/$FILE" ]; then + echo "Added file $LATEST/$FILE" + ((++LATEST_CHANGED)) + elif [ "$LATEST/$FILE" -nt "$HIGHEST/$FILE" ] && ! diff -q "$HIGHEST/$FILE" "$LATEST/$FILE" >/dev/null; then + echo "Modified file $LATEST/$FILE" + ((++LATEST_CHANGED)) + fi +done + +if [ $LATEST_CHANGED -gt 0 ] && [ $HIGHEST_CHANGED -gt 0 ]; then + echo "❌ Error: Changes in both $HIGHEST and $LATEST." + exit 1 +fi + +for FILE in $HIGHEST_FILES; do + if [ ! -f "$LATEST/$FILE" ] || ([ "$HIGHEST/$FILE" -nt "$LATEST/$FILE" ] && ! diff -q "$HIGHEST/$FILE" "$LATEST/$FILE" >/dev/null); then + cp "$HIGHEST/$FILE" "$LATEST/$FILE" + fi +done + +for FILE in $LATEST_FILES; do + if [ ! -f "$HIGHEST/$FILE" ] || ([ "$LATEST/$FILE" -nt "$HIGHEST/$FILE" ] && ! diff -q "$HIGHEST/$FILE" "$LATEST/$FILE" >/dev/null); then + cp "$LATEST/$FILE" "$HIGHEST/$FILE" + fi +done diff --git a/specification/wasm-3.0/4.0-execution.configurations.spectec b/specification/wasm-3.0/4.0-execution.configurations.spectec index f1b6665f5c..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 -- if $free_heaptype(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 a2e0e78bd3..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 @@ -623,7 +623,7 @@ rule Step/data.drop: ;; Reference instructions rule Step_read/ref.null: - z; (REF.NULL (_IDX x)) ~> (REF.NULL $type(z, x)) + 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 f1b6665f5c..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 -- if $free_heaptype(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 a2e0e78bd3..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 @@ -623,7 +623,7 @@ rule Step/data.drop: ;; Reference instructions rule Step_read/ref.null: - z; (REF.NULL (_IDX x)) ~> (REF.NULL $type(z, x)) + 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/Makefile b/spectec/Makefile index a3e7e40eaf..ed4ae2bb3c 100644 --- a/spectec/Makefile +++ b/spectec/Makefile @@ -109,6 +109,9 @@ spec-clean: check%: (cd ../specification && make $@) +sync%: + (cd ../specification && make $@) + # Cleanup diff --git a/spectec/doc/example/output/NanoWasm.pdf b/spectec/doc/example/output/NanoWasm.pdf index 6129f201d910af772ad1be399e4f2e4e89788b42..4130c51fad9eebc6c39bd3ecf0cf7485435b2d31 100644 GIT binary patch delta 879 zcmeD9$Jg?YZ-bc-qrv0@%$k!EgiZ;(IBPlK%H)EtA8HHhJ=gmjZ?+b0w-#muVy5lZ z!pzqfvYQ%M8k-xNPnX=vECb_gx7o^E$QEd3YGmMK>}q1geKZVP<4#;A-gV zVq#!mYG7oiU_($zESJ7dYF>IthJu-;Dacv%s#Co4eFG)h_P>8~Z*`Pz?#0tD|E_x# zR;uY9y*EBK>dPu;;d%!iAK#-4f`*?|os@i3jxFi5SNPND=fk5S^zHL3o67IIuSZp{ z-8_Hu*)#ukMea;JBUJqQ*IJYLhWeI1MH3iTm$Z9uo?y-{VfXyGfMLz$tCP4K1#c`^ ztti?ow4vTJ+*gaW`heJ7#vsWXvz0!*_*NXrr}g5~%T+t>uxq{Kdg0NTXQ1r$!o;Qf z(-w`T$x~gVla>d%Eq_`n;U_6t@h9%wLW(T~8cP3x;PWAmm))-UyYmS-HEzmUCTcj(y{ zdGZ!azYYc(F!VJ(e!ybE>DTC3AjQ*Y{6NQo{akZm0b>l)-j|o}y~q@I?At4GVEPW$ zb;Zd%Jv&0{FFgn};MCiF)h584Pi=*mdUWc|^m~i{Stmtq5_dB&mvYyuI`m->2)7=S= zZ|CLeOUiVrpO2n8LA&b?n_KBg?>^lIEyc}(dK-*Y3~se;alJNS&E5sq-j?{SPDnrD zH;2cvv$L^E@vDHIfli8qmn-`Ole-I!=UQB>+96n*C%(O;)8ydCdX1gZ~|dx zHbX5F8f+35un+-34`IuKlevGk%FT-^+8&g7muB2vecWrM{(beS$L{{)(emA4 zUKcp41g+xsWZ;(b34j#o5)#+}zN_$<)-v%*@E#$=KP{ z(AC1!!ra->PQiwtl2|T%pVYkck_-hiOAC;@>Sd=``illiwC#V-cbe5DKtzCb-GQmT zE-?auf&wY*tb#E&qPhP!Y}~lT)bL_PQqB)9=cJz2)~()uSYOFsICkvNj2AZfpP$Sv zKWABdZtnBGnK$jtS8wQvOv-y(KjoRxv!(2wd`1t+6!MON=&f=UjNJKDGI-=Awo?`RSqyCas&WuIsdIf_|)^tmZ}DG#Aae zZ5e^{#8OMvOv-S6V{+={mOXrjH5X6nlU4bp$am57LT2{Y1&!-E{dVWGSnjf!+gB=K za&hbBmru?vXk9nk&)!o`hH-7)$+BNsU3yD3DyJ;^(;ervyZ-jQIYH9J+h?raeu2~K z&Z@MM?c6fVcOO{1U{pWgS->@iZSMn~7tHC7_7?2tnz<7gVptA8$oREI);3pwXQMdt z525V`O7nV}yz{QUH?3gtX*iu{%73M|vGAGK=1hZ^VZWoxmmdfj(DKM<4b-8_RI(mQV!Snn?z_CMm)?yPj&5t~`8)&0DAI&%)qM zcPBiK&igr?r|-z*=as5Yy4FOWU!hldawB7aYKqw**0MGhx7!o8osgRJRbxfzYw2rR zHzYR+t2_H8B`t{aux;Vy;g)O*y2z#C%l@K7TH`|14#C*G=GnVkW5+90XI>Kp4#UTymuq51Xc?Io9H+`ezO zwD9|}elOv7&c$An->oj6vh2?L`mkAL^-*g~9{=-HJGSO`f9X=o^H26^#eO`qS8wU+ zc|Y&1HhFJ*@`~|NR{wc_jQsD_cx?Rav`xHO$AaZm<37P&1$I8>TIE@e+!vldZp$YH^ys_N?R#svT;;($;9 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..480a0cef79 100644 --- a/spectec/src/backend-interpreter/host.ml +++ b/spectec/src/backend-interpreter/host.ml @@ -69,13 +69,14 @@ 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 nullref, funcref = if !Construct.version <= 2 then - nullary "FUNCREF" + nullary "REF.NULL_ADDR", nullary "FUNCREF" else + CaseV ("REF.NULL", [ nullary "FUNC" ]), CaseV ("REF", [some "NULL"; nullary "FUNC"]) in + let nulls = Array.make 10 nullref 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 16878b2572..d4dbf9084d 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/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 3cb03bcbf1..b4b2739934 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -1959,32 +1959,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) @@ -1992,12 +1966,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 @@ -2039,19 +2019,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -2063,7 +2063,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 @@ -2173,12 +2173,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*) @@ -3319,7 +3320,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)) = ?() @@ -5382,18 +5383,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -5466,14 +5455,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -5542,13 +5530,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 } @@ -5556,13 +5544,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 } @@ -5570,13 +5558,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 } @@ -5584,13 +5572,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 } @@ -5598,13 +5586,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 } @@ -5824,43 +5812,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}: @@ -6026,9 +6014,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}: @@ -6036,9 +6024,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}: @@ -6099,9 +6087,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}: @@ -6109,9 +6097,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}: @@ -6119,9 +6107,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}: @@ -6135,8 +6123,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}: @@ -6147,20 +6135,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)}: @@ -6376,8 +6366,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*}: @@ -6401,8 +6391,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*}: @@ -6410,8 +6400,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*}: @@ -6679,8 +6669,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null`{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}: @@ -6715,8 +6705,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?*}: @@ -6752,8 +6742,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}: @@ -6766,16 +6756,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}: @@ -6794,12 +6784,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}: @@ -6832,8 +6822,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}: @@ -6858,8 +6848,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}: @@ -7021,9 +7011,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?*}: @@ -7036,9 +7026,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 558731783b..3f05225d28 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -8864,15 +8864,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}} & \quad \mbox{if}~ {\mathrm{free}}_{\mathit{heaptype}}({\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} @@ -8974,7 +8973,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} \\ @@ -9316,7 +9315,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} $$ @@ -9378,9 +9377,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} @@ -9453,9 +9451,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} @@ -9736,7 +9736,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} $$ @@ -9745,7 +9745,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} $$ @@ -9781,7 +9781,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 @@ -9809,7 +9809,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}} @@ -9852,7 +9852,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 @@ -10292,7 +10292,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}ref.null}]} \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} $$ @@ -10307,7 +10307,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} $$ @@ -10316,7 +10316,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} $$ @@ -10325,7 +10325,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} @@ -10361,7 +10361,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} $$ @@ -10393,7 +10393,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} @@ -10405,7 +10405,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} @@ -10483,7 +10483,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 @@ -10496,7 +10496,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 @@ -10509,7 +10509,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} $$ @@ -10518,7 +10518,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 & & \\ @@ -10528,8 +10528,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}|} @@ -10585,7 +10585,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}|} @@ -10617,7 +10617,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}|} @@ -10657,8 +10657,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} $$ @@ -10666,8 +10666,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 0f1df9a225..a7cbe0cbc9 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -1949,32 +1949,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) @@ -1982,12 +1956,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 @@ -2029,19 +2009,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -2053,7 +2053,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 @@ -2163,12 +2163,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*) @@ -3309,7 +3310,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)) = ?() @@ -5372,18 +5373,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -5456,14 +5445,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -5532,13 +5520,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 } @@ -5546,13 +5534,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 } @@ -5560,13 +5548,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 } @@ -5574,13 +5562,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 } @@ -5588,13 +5576,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 } @@ -5814,43 +5802,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}: @@ -6016,9 +6004,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}: @@ -6026,9 +6014,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}: @@ -6089,9 +6077,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}: @@ -6099,9 +6087,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}: @@ -6109,9 +6097,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}: @@ -6125,8 +6113,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}: @@ -6137,20 +6125,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)}: @@ -6366,8 +6356,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*}: @@ -6391,8 +6381,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*}: @@ -6400,8 +6390,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*}: @@ -6669,8 +6659,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null`{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}: @@ -6705,8 +6695,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?*}: @@ -6742,8 +6732,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}: @@ -6756,16 +6746,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}: @@ -6784,12 +6774,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}: @@ -6822,8 +6812,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}: @@ -6848,8 +6838,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}: @@ -7011,9 +7001,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?*}: @@ -7026,9 +7016,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}: @@ -13342,32 +13332,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) @@ -13375,12 +13339,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 @@ -13422,19 +13392,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -13446,7 +13436,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 @@ -13556,12 +13546,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*) @@ -14702,7 +14693,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)) = ?() @@ -16765,18 +16756,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -16849,14 +16828,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -16925,13 +16903,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 } @@ -16939,13 +16917,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 } @@ -16953,13 +16931,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 } @@ -16967,13 +16945,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 } @@ -16981,13 +16959,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 } @@ -17209,43 +17187,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}: @@ -17411,9 +17389,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}: @@ -17421,9 +17399,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}: @@ -17484,9 +17462,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}: @@ -17494,9 +17472,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}: @@ -17504,9 +17482,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}: @@ -17520,8 +17498,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}: @@ -17532,20 +17510,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)}: @@ -17761,8 +17741,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*}: @@ -17786,8 +17766,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*}: @@ -17795,8 +17775,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*}: @@ -18064,8 +18044,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null`{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}: @@ -18100,8 +18080,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?*}: @@ -18137,8 +18117,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}: @@ -18151,16 +18131,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}: @@ -18179,12 +18159,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}: @@ -18217,8 +18197,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}: @@ -18243,8 +18223,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}: @@ -18406,9 +18386,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?*}: @@ -18421,9 +18401,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}: @@ -24737,32 +24717,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) @@ -24770,12 +24724,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 @@ -24817,19 +24777,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax frame = @@ -24841,7 +24821,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 @@ -24951,12 +24931,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*) @@ -26123,7 +26104,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)) = ?() @@ -28284,18 +28265,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(`val*` : val*) @@ -28368,14 +28337,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) - -- if ($free_heaptype(heaptype) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS []}) + | `REF.EXTERN`(ref : ref) | PACK(packtype : packtype, iN($psizenn(packtype))) ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -28444,13 +28412,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 } @@ -28458,13 +28426,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 } @@ -28472,13 +28440,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 } @@ -28486,13 +28454,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 } @@ -28500,13 +28468,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 } @@ -28728,47 +28696,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}: @@ -28939,9 +28907,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}: @@ -28949,9 +28917,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}: @@ -29012,9 +28980,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}: @@ -29022,9 +28990,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}: @@ -29032,9 +29000,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}: @@ -29048,8 +29016,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}: @@ -29060,20 +29028,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)}: @@ -29302,8 +29272,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*}: @@ -29330,8 +29300,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*}: @@ -29340,8 +29310,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*}: @@ -29615,8 +29585,8 @@ relation Step_read: `%~>%`(config, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `ref.null`{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}: @@ -29653,8 +29623,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?*}: @@ -29694,8 +29664,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}: @@ -29711,8 +29681,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}: @@ -29720,8 +29690,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}: @@ -29741,12 +29711,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}: @@ -29781,8 +29751,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}: @@ -29809,8 +29779,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}: @@ -29978,9 +29948,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?*}: @@ -29994,9 +29964,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 ea9df342d5..af332efbd9 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -17262,11 +17262,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: @@ -17314,11 +17312,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}'}`. @@ -17328,10 +17328,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})`. @@ -17384,10 +17381,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}`. @@ -17712,7 +17711,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. @@ -18343,7 +18342,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)`. @@ -18360,7 +18359,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. @@ -18504,7 +18503,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. @@ -18521,7 +18520,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. @@ -18540,7 +18539,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. @@ -18561,7 +18560,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. @@ -18593,17 +18592,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}` @@ -18614,15 +18613,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: +#. Assert: Due to validation, :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}extern}~{\mathit{ref}}`. - a. Let :math:`(\mathsf{ref{.}extern}~{\mathit{addrref}})` be the destructuring of :math:`{\mathit{val}}`. +#. 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}}` @@ -19196,7 +19195,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. @@ -19290,7 +19289,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. @@ -19329,7 +19328,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. @@ -20067,13 +20066,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` @@ -20166,7 +20163,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. @@ -20286,7 +20283,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. @@ -20294,19 +20291,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}` @@ -20319,7 +20316,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. @@ -20354,7 +20351,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. @@ -20421,11 +20418,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. @@ -20532,7 +20529,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. @@ -20597,7 +20594,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. @@ -20926,7 +20923,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. @@ -20988,7 +20985,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. @@ -23682,7 +23679,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. @@ -28595,9 +28592,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). @@ -28624,16 +28620,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). @@ -28661,8 +28657,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: @@ -28826,7 +28823,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''. @@ -29122,7 +29119,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. @@ -29130,7 +29127,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. @@ -29196,7 +29193,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. @@ -29204,7 +29201,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. @@ -29213,7 +29210,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. @@ -29223,7 +29220,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. @@ -29238,21 +29235,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. -4. If val is some REF.EXTERN, then: - a. Let (REF.EXTERN addrref) be val. - b. Push the value addrref to the stack. +3. If (val = REF.NULL_ADDR), then: + a. Push the value REF.NULL_ADDR to the stack. +4. Assert: Due to validation, val is some REF.EXTERN. +5. Let (REF.EXTERN ref) be val. +6. 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. @@ -29521,7 +29518,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'. @@ -29565,7 +29562,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''. @@ -29584,7 +29581,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'. @@ -29936,9 +29933,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. @@ -29982,7 +29978,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. @@ -30040,23 +30036,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. @@ -30073,7 +30069,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'. @@ -30106,9 +30102,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'. @@ -30161,7 +30157,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. @@ -30193,7 +30189,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. @@ -30351,7 +30347,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'. @@ -30381,7 +30377,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'. @@ -31633,7 +31629,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 ?(). 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 9a99f98614..70837f5ca4 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 From 28fa30316ed8331e9271be0424658925e1142555 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Wed, 25 Feb 2026 20:18:04 +0100 Subject: [PATCH 4/4] Fix version condition --- spectec/src/backend-interpreter/host.ml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spectec/src/backend-interpreter/host.ml b/spectec/src/backend-interpreter/host.ml index 480a0cef79..7fb04491c2 100644 --- a/spectec/src/backend-interpreter/host.ml +++ b/spectec/src/backend-interpreter/host.ml @@ -69,14 +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 nullref, funcref = + let null, funcref = if !Construct.version <= 2 then - nullary "REF.NULL_ADDR", nullary "FUNCREF" + CaseV ("REF.NULL", [ nullary "FUNC" ]), nullary "FUNCREF" else - CaseV ("REF.NULL", [ nullary "FUNC" ]), - CaseV ("REF", [some "NULL"; nullary "FUNC"]) + nullary "REF.NULL_ADDR", CaseV ("REF", [some "NULL"; nullary "FUNC"]) in - let nulls = Array.make 10 nullref 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