diff --git a/document/core/appendix/implementation.rst b/document/core/appendix/implementation.rst index 15fe69357c..43baa84e20 100644 --- a/document/core/appendix/implementation.rst +++ b/document/core/appendix/implementation.rst @@ -110,7 +110,7 @@ For a module given in :ref:`text format `, additional limitations may be i Validation ~~~~~~~~~~ -An implementation may defer :ref:`validation ` of individual :ref:`functions ` until they are first :ref:`invoked `. +An implementation may defer :ref:`validation ` of individual :ref:`functions ` until they are first :ref:`called `. If a function turns out to be invalid, then the invocation, and every consecutive call to the same function, results in a :ref:`trap `. diff --git a/document/core/exec/instructions.rst b/document/core/exec/instructions.rst index 622a407ec3..a98869ba90 100644 --- a/document/core/exec/instructions.rst +++ b/document/core/exec/instructions.rst @@ -141,29 +141,9 @@ $${rule: {Step_read/call}} .. _exec-call_ref: -:math:`\CALLREF~x` -.................. +$${rule-prose: Step_read/call_ref} -.. todo:: (*) Prose not spliced, for the prose merges the two cases of null and non-null references. - -1. Assert: due to :ref:`validation `, a null or :ref:`function reference ` is on the top of the stack. - -2. Pop the reference value :math:`r` from the stack. - -3. If :math:`r` is :math:`\REFNULL~\X{ht}`, then: - - a. Trap. - -4. Assert: due to :ref:`validation `, :math:`r` is a :ref:`function reference `. - -5. Let :math:`\REFFUNCADDR~a` be the reference :math:`r`. - -6. :ref:`Invoke ` the function instance at address :math:`a`. - -$${rule: {Step_read/call_ref-null}} - -.. note:: - The formal rule for calling a non-null function reference is described :ref:`below `. +$${rule: {Step_read/call_ref-*}} .. _exec-call_indirect: @@ -272,18 +252,19 @@ $${rule: Step_pure/label-vals} Exception Handling ~~~~~~~~~~~~~~~~~~ -The following auxiliary rules define the semantics of entering and exiting ${:TRY_TABLE} blocks. +The following auxiliary rules define the semantics of entering and exiting ${:TRY_TABLE} blocks, +and of throwing exceptions. .. _exec-handler-enter: Entering :math:`\instr^\ast` with label :math:`L` and exception handler :math:`H` ................................................................................. -1. Push :math:`H` to the stack. +1. Push ${:H} to the stack. -2. Push :math:`L` onto the stack. +2. Push ${:L} onto the stack. -3. Jump to the start of the instruction sequence :math:`\instr^\ast`. +3. Jump to the start of the instruction sequence ${:instr*}. .. note:: No formal reduction rule is needed for entering an exception :ref:`handler ` @@ -298,23 +279,33 @@ Exiting an exception handler When the end of a ${:TRY_TABLE} block is reached without a jump, :ref:`exception `, or :ref:`trap `, then the following steps are performed. -1. Let :math:`m` be the number of values on the top of the stack. +1. Let ${:m} be the number of values on the top of the stack. -2. Pop the values :math:`\val^m` from the stack. +2. Pop the values ${:val^m} from the stack. 3. Assert: due to :ref:`validation `, a handler and a label are now on the top of the stack. 4. Pop the label from the stack. -5. Pop the handler :math:`H` from the stack. +5. Pop the handler ${:H} from the stack. -6. Push :math:`\val^m` back to the stack. +6. Push ${:val^m} back to the stack. -7. Jump to the position after the end of the administrative instruction associated with the handler :math:`H`. +7. Jump to the position after the end of the administrative instruction associated with the handler ${:H}. $${rule: Step_pure/handler-vals} +.. _exec-throw_addr: + +Throwing an exception +..................... + +$${rule-prose: Step_read/throw_addr} + +$${rule: Step_read/throw_addr-*} + + .. index:: ! call, function, function instance, label, frame Function Calls @@ -325,32 +316,11 @@ through one of the :ref:`call instructions ` and returning from it. -.. _exec-invoke: - -Invocation of :ref:`function reference ` :math:`(\REFFUNCADDR~a)` -.................................................................................. - -1. Assert: due to :ref:`validation `, :math:`S.\SFUNCS[a]` exists. - -2. Let :math:`f` be the :ref:`function instance `, :math:`S.\SFUNCS[a]`. - -3. Let :math:`\TFUNC~[t_1^n] \Tarrow [t_2^m]` be the :ref:`composite type ` :math:`\expanddt(\X{f}.\FITYPE)`. - -4. Let :math:`\FUNC~x~\local^\ast~\instr^\ast` be the :ref:`function ` :math:`f.\FICODE`. - -5. Assert: due to :ref:`validation `, :math:`n` values are on the top of the stack. - -6. Pop the values :math:`\val^n` from the stack. - -7. Let :math:`F` be the :ref:`frame ` :math:`\{ \AMODULE~F.\FIMODULE, \ALOCALS~\val^n~(\default_t)^\ast \}`. - -8. Push the activation of :math:`f` with arity :math:`m` to the stack. - -9. Let :math:`L` be the :ref:`label ` whose arity is :math:`m` and whose continuation is the end of the function. +.. _exec-call_addr: -10. :ref:`Enter ` the instruction sequence :math:`\instr^\ast` with label :math:`L` and no values. +$${rule-prose: Step_read/call_addr} -$${rule: {Step_read/call_ref-func}} +$${rule: {Step_read/call_addr}} .. note:: For non-defaultable types, the respective local is left uninitialized by these rules. @@ -363,19 +333,19 @@ Returning from a function When the end of a function is reached without a jump (including through |RETURN|), or an :ref:`exception ` or :ref:`trap ` aborting it, then the following steps are performed. -1. Let :math:`F` be the :ref:`current ` :ref:`frame `. +1. Let ${:F} be the :ref:`current ` :ref:`frame `. -2. Let :math:`n` be the arity of the activation of :math:`F`. +2. Let ${:n} be the arity of the activation of ${:F}. -3. Assert: due to :ref:`validation `, there are :math:`n` values on the top of the stack. +3. Assert: due to :ref:`validation `, there are ${:n} values on the top of the stack. -4. Pop the results :math:`\val^n` from the stack. +4. Pop the results ${:val^n} from the stack. -5. Assert: due to :ref:`validation `, the frame :math:`F` is now on the top of the stack. +5. Assert: due to :ref:`validation `, the frame ${:F} is now on the top of the stack. 6. Pop the frame from the stack. -7. Push :math:`\val^n` back to the stack. +7. Push ${:val^n} back to the stack. 8. Jump to the instruction after the original call. @@ -1183,4 +1153,4 @@ $${rule: Eval_expr} .. note:: Evaluation iterates this reduction rule until reaching a value. - Expressions constituting :ref:`function ` bodies are executed during function :ref:`invocation `. + Expressions constituting :ref:`function ` bodies are executed during function :ref:`calls `. diff --git a/document/core/exec/runtime.rst b/document/core/exec/runtime.rst index 1143b82cba..994b829743 100644 --- a/document/core/exec/runtime.rst +++ b/document/core/exec/runtime.rst @@ -69,7 +69,7 @@ Results ~~~~~~~ A *result* is the outcome of a computation. -It is either a sequence of :ref:`values `, a thrown :ref:`exception `, or a :ref:`trap `. +It is either a sequence of :ref:`values `, a thrown :ref:`exception `, or a :ref:`trap `. $${syntax: result} @@ -578,6 +578,9 @@ Conventions .. index:: ! administrative instructions, function, function instance, function address, label, frame, instruction, trap, call, memory, memory instance, table, table instance, element, data, segment, tag, tag instance, tag address, exception, reftype, handler, caught, caught exception pair:: abstract syntax; administrative instruction .. _syntax-trap: +.. _syntax-throw_addr: +.. _syntax-call_addr: +.. _syntax-return_call_addr: .. _syntax-instr-admin: Administrative Instructions @@ -595,6 +598,11 @@ A :ref:`reference ` represents a :ref:`reference ` value 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 `. +The variants of the ${:CALL} and ${:RETURN_CALL} instructions with a :ref:`function address ` represent an imminent call to a specific target function. + +Similarly, the variant of the ${:THROW} instruction with an :ref:`exception address ` represents an exception that is being thrown. +Such exceptions are propagated through nested instruction sequences until a matching handler is found. + The ${:TRAP} instruction represents the occurrence of a trap. Traps are bubbled up through nested instruction sequences, ultimately reducing the entire program to a single ${:TRAP} instruction, signalling abrupt termination. diff --git a/document/core/util/macros.def b/document/core/util/macros.def index cd9472676e..c095c11be0 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -1543,6 +1543,9 @@ .. |REFEXNADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}exn}} .. |REFHOSTADDR| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}host}} .. |REFEXTERN| mathdef:: \xref{exec/runtime}{syntax-ref}{\K{ref{.}extern}} +.. |CALLADDR| mathdef:: \xref{exec/runtime}{syntax-call_addr}{\K{call}} +.. |RETURNCALLADDR| mathdef:: \xref{exec/runtime}{syntax-return_call_addr}{\K{return_call}} +.. |THROWADDR| mathdef:: \xref{exec/runtime}{syntax-throw_addr}{\K{throw}} .. |TRAP| mathdef:: \xref{exec/runtime}{syntax-trap}{\K{trap}} diff --git a/specification/wasm-3.0/1.3-syntax.instructions.spectec b/specification/wasm-3.0/1.3-syntax.instructions.spectec index 8571df71d6..49153cbb9c 100644 --- a/specification/wasm-3.0/1.3-syntax.instructions.spectec +++ b/specification/wasm-3.0/1.3-syntax.instructions.spectec @@ -241,12 +241,12 @@ syntax instr/br hint(desc "branch instruction") = ... syntax instr/call hint(desc "function instruction") = ... | CALL funcidx - | CALL_REF typeuse - | CALL_INDIRECT tableidx typeuse + | CALL_REF typeidx + | CALL_INDIRECT tableidx typeidx | RETURN | RETURN_CALL funcidx - | RETURN_CALL_REF typeuse - | RETURN_CALL_INDIRECT tableidx typeuse + | RETURN_CALL_REF typeidx + | RETURN_CALL_INDIRECT tableidx typeidx | ... syntax instr/exn hint(desc "exception instructions") = ... @@ -455,14 +455,14 @@ def $free_instr(BR_ON_CAST_FAIL labelidx reftype_1 reftype_2) = $free_labelidx(labelidx) ++ $free_reftype(reftype_1) ++ $free_reftype(reftype_2) def $free_instr(CALL funcidx) = $free_funcidx(funcidx) -def $free_instr(CALL_REF typeuse) = $free_typeuse(typeuse) -def $free_instr(CALL_INDIRECT tableidx typeuse) = - $free_tableidx(tableidx) ++ $free_typeuse(typeuse) +def $free_instr(CALL_REF typeidx) = $free_typeidx(typeidx) +def $free_instr(CALL_INDIRECT tableidx typeidx) = + $free_tableidx(tableidx) ++ $free_typeidx(typeidx) def $free_instr(RETURN) = {} def $free_instr(RETURN_CALL funcidx) = $free_funcidx(funcidx) -def $free_instr(RETURN_CALL_REF typeuse) = $free_typeuse(typeuse) -def $free_instr(RETURN_CALL_INDIRECT tableidx typeuse) = - $free_tableidx(tableidx) ++ $free_typeuse(typeuse) +def $free_instr(RETURN_CALL_REF typeidx) = $free_typeidx(typeidx) +def $free_instr(RETURN_CALL_INDIRECT tableidx typeidx) = + $free_tableidx(tableidx) ++ $free_typeidx(typeidx) def $free_instr(THROW tagidx) = $free_tagidx(tagidx) def $free_instr(THROW_REF) = {} diff --git a/specification/wasm-3.0/2.3-validation.instructions.spectec b/specification/wasm-3.0/2.3-validation.instructions.spectec index 62ec9c61db..cecfc66d07 100644 --- a/specification/wasm-3.0/2.3-validation.instructions.spectec +++ b/specification/wasm-3.0/2.3-validation.instructions.spectec @@ -117,11 +117,11 @@ rule Instr_ok/call: -- Expand: C.FUNCS[x] ~~ FUNC t_1* -> t_2* rule Instr_ok/call_ref: - C |- CALL_REF (_IDX x) : t_1* (REF NULL (_IDX x)) -> t_2* + C |- CALL_REF x : t_1* (REF NULL (_IDX x)) -> t_2* -- Expand: C.TYPES[x] ~~ FUNC t_1* -> t_2* rule Instr_ok/call_indirect: - C |- CALL_INDIRECT x (_IDX y) : t_1* at -> t_2* + C |- CALL_INDIRECT x y : t_1* at -> t_2* -- if C.TABLES[x] = at lim rt -- Reftype_sub: C |- rt <: (REF NULL FUNC) -- Expand: C.TYPES[y] ~~ FUNC t_1* -> t_2* @@ -141,7 +141,7 @@ rule Instr_ok/return_call: ;; TODO(3, rossberg): enable t_2* <: C.RETURN rule Instr_ok/return_call_ref: - C |- RETURN_CALL_REF (_IDX x) : t_3* t_1* (REF NULL (_IDX x)) -> t_4* + C |- RETURN_CALL_REF x : t_3* t_1* (REF NULL (_IDX x)) -> t_4* -- Expand: C.TYPES[x] ~~ FUNC t_1* -> t_2* -- if C.RETURN = (t'_2*) -- Resulttype_sub: C |- t_2* <: t'_2* @@ -149,7 +149,7 @@ rule Instr_ok/return_call_ref: ;; TODO(3, rossberg): enable t_2* <: C.RETURN rule Instr_ok/return_call_indirect: - C |- RETURN_CALL_INDIRECT x (_IDX y) : t_3* t_1* at -> t_4* + C |- RETURN_CALL_INDIRECT x y : t_3* t_1* at -> t_4* -- if C.TABLES[x] = at lim rt -- Reftype_sub: C |- rt <: (REF NULL FUNC) ---- diff --git a/specification/wasm-3.0/4.0-execution.configurations.spectec b/specification/wasm-3.0/4.0-execution.configurations.spectec index f1a7284359..6ef117b6eb 100644 --- a/specification/wasm-3.0/4.0-execution.configurations.spectec +++ b/specification/wasm-3.0/4.0-execution.configurations.spectec @@ -46,7 +46,7 @@ syntax val hint(desc "value") = | num | vec | ref syntax result hint(desc "result") = - | _VALS val* | `(REF.EXN_ADDR exnaddr) THROW_REF | TRAP + | _VALS val* | THROW_ADDR exnaddr | TRAP var r : ref var res : result @@ -136,6 +136,9 @@ syntax instr/admin hint(desc "administrative instruction") = | LABEL_ n `{instr*} instr* hint(show LABEL_%#% %%) | FRAME_ n `{frame} instr* hint(show FRAME_%#% %%) | HANDLER_ n `{catch*} instr* hint(show HANDLER_%#% %%) + | CALL_ADDR funcaddr + | RETURN_CALL_ADDR funcaddr + | THROW_ADDR exnaddr | TRAP diff --git a/specification/wasm-3.0/4.3-execution.instructions.spectec b/specification/wasm-3.0/4.3-execution.instructions.spectec index 04a132b661..54e826c219 100644 --- a/specification/wasm-3.0/4.3-execution.instructions.spectec +++ b/specification/wasm-3.0/4.3-execution.instructions.spectec @@ -167,14 +167,17 @@ rule Step_read/br_on_cast_fail-fail: ;; Function instructions rule Step_read/call: - z; (CALL x) ~> (REF.FUNC_ADDR a) (CALL_REF $funcinst(z)[a].TYPE) + z; (CALL x) ~> (CALL_ADDR a) -- if $moduleinst(z).FUNCS[x] = a rule Step_read/call_ref-null: - z; (REF.NULL_ADDR) (CALL_REF yy) ~> TRAP + z; (REF.NULL_ADDR) (CALL_REF x) ~> TRAP rule Step_read/call_ref-func: - z; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) + z; (REF.FUNC_ADDR a) (CALL_REF x) ~> (CALL_ADDR a) + +rule Step_read/call_addr: + z; val^n (CALL_ADDR a) ~> (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) ---- -- if $funcinst(z)[a] = fi -- Expand: fi.TYPE ~~ FUNC t_1^n -> t_2^m @@ -183,30 +186,32 @@ rule Step_read/call_ref-func: rule Step_read/return_call: - z; (RETURN_CALL x) ~> (REF.FUNC_ADDR a) (RETURN_CALL_REF $funcinst(z)[a].TYPE) + z; (RETURN_CALL x) ~> (RETURN_CALL_ADDR a) -- if $moduleinst(z).FUNCS[x] = a +rule Step_read/return_call_ref-null: + z; (REF.NULL_ADDR) (RETURN_CALL_REF x) ~> TRAP -rule Step_read/return_call_ref-label: - z; (LABEL_ k `{instr'*} val* (RETURN_CALL_REF yy) instr*) ~> val* (RETURN_CALL_REF yy) +rule Step_read/return_call_ref-func: + z; (REF.FUNC_ADDR a) (RETURN_CALL_REF x) ~> (RETURN_CALL_ADDR a) -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_addr-label: + z; (LABEL_ k `{instr'*} val* (RETURN_CALL_ADDR a) instr*) ~> val* (RETURN_CALL_ADDR a) -rule Step_read/return_call_ref-frame-null: - z; (FRAME_ k `{f} val* (REF.NULL_ADDR) (RETURN_CALL_REF yy) instr*) ~> TRAP +rule Step_read/return_call_addr-handler: + z; (HANDLER_ k `{catch*} val* (RETURN_CALL_ADDR a) instr*) ~> val* (RETURN_CALL_ADDR a) -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) +rule Step_read/return_call_addr-frame: + z; (FRAME_ k `{f} val'* val^n (RETURN_CALL_ADDR a) instr*) ~> val^n (CALL_ADDR a) ---- -- Expand: $funcinst(z)[a].TYPE ~~ FUNC t_1^n -> t_2^m rule Step_pure/call_indirect: - (CALL_INDIRECT x yy) ~> (TABLE.GET x) (REF.CAST (REF NULL yy)) (CALL_REF yy) + (CALL_INDIRECT x y) ~> (TABLE.GET x) (REF.CAST (REF NULL (_IDX y))) (CALL_REF y) rule Step_pure/return_call_indirect: - (RETURN_CALL_INDIRECT x yy) ~> (TABLE.GET x) (REF.CAST (REF NULL yy)) (RETURN_CALL_REF yy) + (RETURN_CALL_INDIRECT x y) ~> (TABLE.GET x) (REF.CAST (REF NULL (_IDX y))) (RETURN_CALL_REF y) rule Step_pure/frame-vals: @@ -225,7 +230,7 @@ rule Step_pure/return-handler: ;; Exceptions rule Step/throw: - z; val^n (THROW x) ~> $add_exninst(z, exn); (REF.EXN_ADDR a) THROW_REF + z; val^n (THROW x) ~> $add_exninst(z, exn); (THROW_ADDR a) -- Expand: $as_deftype($tag(z, x).TYPE) ~~ FUNC t^n -> eps -- if a = |$exninst(z)| -- if exn = {TAG $tagaddr(z)[x], FIELDS val^n} @@ -233,40 +238,43 @@ rule Step/throw: rule Step_read/throw_ref-null: 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 +rule Step_read/throw_ref-addr: + z; (REF.EXN_ADDR a) THROW_REF ~> (THROW_ADDR a) + +rule Step_read/throw_addr-instrs: + z; val* (THROW_ADDR a) instr* ~> (THROW_ADDR a) ---- -- if val* =/= eps \/ instr* =/= eps -rule Step_read/throw_ref-label: - z; (LABEL_ n `{instr'*} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) THROW_REF +rule Step_read/throw_addr-label: + z; (LABEL_ n `{instr'*} (THROW_ADDR a)) ~> (THROW_ADDR a) -rule Step_read/throw_ref-frame: - z; (FRAME_ n `{f} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) THROW_REF +rule Step_read/throw_addr-frame: + z; (FRAME_ n `{f} (THROW_ADDR a)) ~> (THROW_ADDR a) -rule Step_read/throw_ref-handler-empty: - z; (HANDLER_ n `{eps} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) THROW_REF +rule Step_read/throw_addr-handler-empty: + z; (HANDLER_ n `{eps} (THROW_ADDR a)) ~> (THROW_ADDR a) -rule Step_read/throw_ref-handler-catch: - z; (HANDLER_ n `{(CATCH x l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> val* (BR l) +rule Step_read/throw_addr-handler-catch: + z; (HANDLER_ n `{(CATCH x l) catch'*} (THROW_ADDR a)) ~> val* (BR l) ---- -- if $exninst(z)[a].TAG = $tagaddr(z)[x] -- if val* = $exninst(z)[a].FIELDS -rule Step_read/throw_ref-handler-catch_ref: - z; (HANDLER_ n `{(CATCH_REF x l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> val* (REF.EXN_ADDR a) (BR l) +rule Step_read/throw_addr-handler-catch_ref: + z; (HANDLER_ n `{(CATCH_REF x l) catch'*} (THROW_ADDR a)) ~> val* (REF.EXN_ADDR a) (BR l) ---- -- if $exninst(z)[a].TAG = $tagaddr(z)[x] -- if val* = $exninst(z)[a].FIELDS -rule Step_read/throw_ref-handler-catch_all: - z; (HANDLER_ n `{(CATCH_ALL l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> (BR l) +rule Step_read/throw_addr-handler-catch_all: + z; (HANDLER_ n `{(CATCH_ALL l) catch'*} (THROW_ADDR a)) ~> (BR l) -rule Step_read/throw_ref-handler-catch_all_ref: - z; (HANDLER_ n `{(CATCH_ALL_REF l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) (BR l) +rule Step_read/throw_addr-handler-catch_all_ref: + z; (HANDLER_ n `{(CATCH_ALL_REF l) catch'*} (THROW_ADDR a)) ~> (REF.EXN_ADDR a) (BR l) -rule Step_read/throw_ref-handler-next: - z; (HANDLER_ n `{catch catch'*} (REF.EXN_ADDR a) THROW_REF) ~> (HANDLER_ n `{catch'*} (REF.EXN_ADDR a) THROW_REF) +rule Step_read/throw_addr-handler-next: + z; (HANDLER_ n `{catch catch'*} (THROW_ADDR a)) ~> (HANDLER_ n `{catch'*} (THROW_ADDR a)) ---- -- otherwise diff --git a/specification/wasm-3.0/4.4-execution.modules.spectec b/specification/wasm-3.0/4.4-execution.modules.spectec index 91b2c9b3f7..d1a1c9b62c 100644 --- a/specification/wasm-3.0/4.4-execution.modules.spectec +++ b/specification/wasm-3.0/4.4-execution.modules.spectec @@ -212,7 +212,7 @@ def $instantiate(s, module, externaddr*) = s''''; {MODULE moduleinst}; instr_E* ;; Invocation def $invoke(store, funcaddr, val*) : config -def $invoke(s, funcaddr, val*) = s; {MODULE {}}; val* (REF.FUNC_ADDR funcaddr) (CALL_REF s.FUNCS[funcaddr].TYPE) +def $invoke(s, funcaddr, val*) = s; {MODULE {}}; val* (CALL_ADDR funcaddr) ---- -- Expand: s.FUNCS[funcaddr].TYPE ~~ FUNC t_1* -> t_2* -- (Val_ok: s |- val : t_1)* diff --git a/specification/wasm-3.0/5.3-binary.instructions.spectec b/specification/wasm-3.0/5.3-binary.instructions.spectec index a08d138777..ed6a8008e2 100644 --- a/specification/wasm-3.0/5.3-binary.instructions.spectec +++ b/specification/wasm-3.0/5.3-binary.instructions.spectec @@ -44,11 +44,11 @@ grammar Binstr/control : instr = ... | 0x0E l*:Blist(Blabelidx) l_n:Blabelidx => BR_TABLE l* l_n | 0x0F => RETURN | 0x10 x:Bfuncidx => CALL x - | 0x11 y:Btypeidx x:Btableidx => CALL_INDIRECT x (_IDX y) + | 0x11 y:Btypeidx x:Btableidx => CALL_INDIRECT x y | 0x12 x:Bfuncidx => RETURN_CALL x - | 0x13 y:Btypeidx x:Btableidx => RETURN_CALL_INDIRECT x (_IDX y) - | 0x14 x:Btypeidx => CALL_REF (_IDX x) - | 0x15 x:Btypeidx => RETURN_CALL_REF (_IDX x) + | 0x13 y:Btypeidx x:Btableidx => RETURN_CALL_INDIRECT x y + | 0x14 x:Btypeidx => CALL_REF x + | 0x15 x:Btypeidx => RETURN_CALL_REF x | 0x1F bt:Bblocktype c*:Blist(Bcatch) (in:Binstr)* 0x0B => TRY_TABLE bt c* in* | 0xD5 l:Blabelidx => BR_ON_NULL l | 0xD6 l:Blabelidx => BR_ON_NON_NULL l diff --git a/specification/wasm-3.0/6.3-text.instructions.spectec b/specification/wasm-3.0/6.3-text.instructions.spectec index 645eb8325f..5a83df8a6f 100644 --- a/specification/wasm-3.0/6.3-text.instructions.spectec +++ b/specification/wasm-3.0/6.3-text.instructions.spectec @@ -110,13 +110,13 @@ grammar Tplaininstr_(I)/br : instr = ... grammar Tplaininstr_(I)/func-plain : instr = ... | "call" x:Tfuncidx_(I) => CALL x - | "call_ref" x:Ttypeidx_(I) => CALL_REF $($(_IDX x)) - | "call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => CALL_INDIRECT x $($(_IDX y)) + | "call_ref" x:Ttypeidx_(I) => CALL_REF x + | "call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => CALL_INDIRECT x y -- if I' = {LOCALS (eps)*} | "return" => RETURN | "return_call" x:Tfuncidx_(I) => RETURN_CALL x - | "return_call_ref" x:Ttypeidx_(I) => RETURN_CALL_REF $($(_IDX x)) - | "return_call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => RETURN_CALL_INDIRECT x $($(_IDX y)) + | "return_call_ref" x:Ttypeidx_(I) => RETURN_CALL_REF x + | "return_call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => RETURN_CALL_INDIRECT x y -- if I' = {LOCALS (eps)*} | ... diff --git a/specification/wasm-3.0/7.1-soundness.configurations.spectec b/specification/wasm-3.0/7.1-soundness.configurations.spectec index 1ce3881425..aef0e8a142 100644 --- a/specification/wasm-3.0/7.1-soundness.configurations.spectec +++ b/specification/wasm-3.0/7.1-soundness.configurations.spectec @@ -11,20 +11,6 @@ rule Instr_ok2/plain: s; C |- instr : t_1* ->_(x*) t_2* -- Instr_ok: C |- instr : t_1* ->_(x*) t_2* -rule Instr_ok2/call_ref: - s; C |- CALL_REF yy : t_1* (REF NULL yy) -> t_2* - -- Typeuse_ok: C |- yy : OK - -- Expand_use: yy ~~_C FUNC t_1* -> t_2* - -;; TODO(3, rossberg): enable t_2* <: C.RETURN -rule Instr_ok2/return_call_ref: - s; C |- RETURN_CALL_REF yy : t_3* t_1* (REF NULL yy) -> t_4* - -- Typeuse_ok: C |- yy : OK - -- Expand_use: yy ~~_C FUNC t_1* -> t_2* - -- if C.RETURN = (t'_2*) - -- Resulttype_sub: C |- t_2* <: t'_2* - -- Instrtype_ok: C |- t_3* -> t_4* : OK - rule Instr_ok2/ref: s; C |- ref : eps -> rt -- Ref_ok: s |- ref : rt @@ -45,6 +31,23 @@ rule Instr_ok2/handler: -- (Catch_ok: C |- catch : OK)* -- Instrs_ok2: s; C |- instr* : eps ->_(x*) t* +rule Instr_ok2/call_addr: + s; C |- CALL_ADDR a : t_1* -> t_2* + -- Expand: s.FUNCS[a].TYPE ~~ FUNC t_1* -> t_2* + +;; TODO(3, rossberg): enable t_2* <: C.RETURN +rule Instr_ok2/return_call_addr: + s; C |- RETURN_CALL_ADDR a : t_3* t_1* -> t_4* + -- Expand: s.FUNCS[a].TYPE ~~ FUNC t_1* -> t_2* + -- if C.RETURN = (t'_2*) + -- Resulttype_sub: C |- t_2* <: t'_2* + -- Instrtype_ok: C |- t_3* -> t_4* : OK + +rule Instr_ok2/throw_addr: + s; C |- THROW_ADDR a : t_1* -> t_2* + -- if s.EXNS[a] = exn + -- Instrtype_ok: C |- t_1* -> t_2* : OK + rule Instr_ok2/trap: s; C |- TRAP : t_1* -> t_2* -- Instrtype_ok: C |- t_1* -> t_2* : OK diff --git a/specification/wasm-latest/1.3-syntax.instructions.spectec b/specification/wasm-latest/1.3-syntax.instructions.spectec index 8571df71d6..49153cbb9c 100644 --- a/specification/wasm-latest/1.3-syntax.instructions.spectec +++ b/specification/wasm-latest/1.3-syntax.instructions.spectec @@ -241,12 +241,12 @@ syntax instr/br hint(desc "branch instruction") = ... syntax instr/call hint(desc "function instruction") = ... | CALL funcidx - | CALL_REF typeuse - | CALL_INDIRECT tableidx typeuse + | CALL_REF typeidx + | CALL_INDIRECT tableidx typeidx | RETURN | RETURN_CALL funcidx - | RETURN_CALL_REF typeuse - | RETURN_CALL_INDIRECT tableidx typeuse + | RETURN_CALL_REF typeidx + | RETURN_CALL_INDIRECT tableidx typeidx | ... syntax instr/exn hint(desc "exception instructions") = ... @@ -455,14 +455,14 @@ def $free_instr(BR_ON_CAST_FAIL labelidx reftype_1 reftype_2) = $free_labelidx(labelidx) ++ $free_reftype(reftype_1) ++ $free_reftype(reftype_2) def $free_instr(CALL funcidx) = $free_funcidx(funcidx) -def $free_instr(CALL_REF typeuse) = $free_typeuse(typeuse) -def $free_instr(CALL_INDIRECT tableidx typeuse) = - $free_tableidx(tableidx) ++ $free_typeuse(typeuse) +def $free_instr(CALL_REF typeidx) = $free_typeidx(typeidx) +def $free_instr(CALL_INDIRECT tableidx typeidx) = + $free_tableidx(tableidx) ++ $free_typeidx(typeidx) def $free_instr(RETURN) = {} def $free_instr(RETURN_CALL funcidx) = $free_funcidx(funcidx) -def $free_instr(RETURN_CALL_REF typeuse) = $free_typeuse(typeuse) -def $free_instr(RETURN_CALL_INDIRECT tableidx typeuse) = - $free_tableidx(tableidx) ++ $free_typeuse(typeuse) +def $free_instr(RETURN_CALL_REF typeidx) = $free_typeidx(typeidx) +def $free_instr(RETURN_CALL_INDIRECT tableidx typeidx) = + $free_tableidx(tableidx) ++ $free_typeidx(typeidx) def $free_instr(THROW tagidx) = $free_tagidx(tagidx) def $free_instr(THROW_REF) = {} diff --git a/specification/wasm-latest/2.3-validation.instructions.spectec b/specification/wasm-latest/2.3-validation.instructions.spectec index 62ec9c61db..cecfc66d07 100644 --- a/specification/wasm-latest/2.3-validation.instructions.spectec +++ b/specification/wasm-latest/2.3-validation.instructions.spectec @@ -117,11 +117,11 @@ rule Instr_ok/call: -- Expand: C.FUNCS[x] ~~ FUNC t_1* -> t_2* rule Instr_ok/call_ref: - C |- CALL_REF (_IDX x) : t_1* (REF NULL (_IDX x)) -> t_2* + C |- CALL_REF x : t_1* (REF NULL (_IDX x)) -> t_2* -- Expand: C.TYPES[x] ~~ FUNC t_1* -> t_2* rule Instr_ok/call_indirect: - C |- CALL_INDIRECT x (_IDX y) : t_1* at -> t_2* + C |- CALL_INDIRECT x y : t_1* at -> t_2* -- if C.TABLES[x] = at lim rt -- Reftype_sub: C |- rt <: (REF NULL FUNC) -- Expand: C.TYPES[y] ~~ FUNC t_1* -> t_2* @@ -141,7 +141,7 @@ rule Instr_ok/return_call: ;; TODO(3, rossberg): enable t_2* <: C.RETURN rule Instr_ok/return_call_ref: - C |- RETURN_CALL_REF (_IDX x) : t_3* t_1* (REF NULL (_IDX x)) -> t_4* + C |- RETURN_CALL_REF x : t_3* t_1* (REF NULL (_IDX x)) -> t_4* -- Expand: C.TYPES[x] ~~ FUNC t_1* -> t_2* -- if C.RETURN = (t'_2*) -- Resulttype_sub: C |- t_2* <: t'_2* @@ -149,7 +149,7 @@ rule Instr_ok/return_call_ref: ;; TODO(3, rossberg): enable t_2* <: C.RETURN rule Instr_ok/return_call_indirect: - C |- RETURN_CALL_INDIRECT x (_IDX y) : t_3* t_1* at -> t_4* + C |- RETURN_CALL_INDIRECT x y : t_3* t_1* at -> t_4* -- if C.TABLES[x] = at lim rt -- Reftype_sub: C |- rt <: (REF NULL FUNC) ---- diff --git a/specification/wasm-latest/4.0-execution.configurations.spectec b/specification/wasm-latest/4.0-execution.configurations.spectec index f1a7284359..6ef117b6eb 100644 --- a/specification/wasm-latest/4.0-execution.configurations.spectec +++ b/specification/wasm-latest/4.0-execution.configurations.spectec @@ -46,7 +46,7 @@ syntax val hint(desc "value") = | num | vec | ref syntax result hint(desc "result") = - | _VALS val* | `(REF.EXN_ADDR exnaddr) THROW_REF | TRAP + | _VALS val* | THROW_ADDR exnaddr | TRAP var r : ref var res : result @@ -136,6 +136,9 @@ syntax instr/admin hint(desc "administrative instruction") = | LABEL_ n `{instr*} instr* hint(show LABEL_%#% %%) | FRAME_ n `{frame} instr* hint(show FRAME_%#% %%) | HANDLER_ n `{catch*} instr* hint(show HANDLER_%#% %%) + | CALL_ADDR funcaddr + | RETURN_CALL_ADDR funcaddr + | THROW_ADDR exnaddr | TRAP diff --git a/specification/wasm-latest/4.3-execution.instructions.spectec b/specification/wasm-latest/4.3-execution.instructions.spectec index 04a132b661..54e826c219 100644 --- a/specification/wasm-latest/4.3-execution.instructions.spectec +++ b/specification/wasm-latest/4.3-execution.instructions.spectec @@ -167,14 +167,17 @@ rule Step_read/br_on_cast_fail-fail: ;; Function instructions rule Step_read/call: - z; (CALL x) ~> (REF.FUNC_ADDR a) (CALL_REF $funcinst(z)[a].TYPE) + z; (CALL x) ~> (CALL_ADDR a) -- if $moduleinst(z).FUNCS[x] = a rule Step_read/call_ref-null: - z; (REF.NULL_ADDR) (CALL_REF yy) ~> TRAP + z; (REF.NULL_ADDR) (CALL_REF x) ~> TRAP rule Step_read/call_ref-func: - z; val^n (REF.FUNC_ADDR a) (CALL_REF yy) ~> (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) + z; (REF.FUNC_ADDR a) (CALL_REF x) ~> (CALL_ADDR a) + +rule Step_read/call_addr: + z; val^n (CALL_ADDR a) ~> (FRAME_ m `{f} (LABEL_ m `{eps} instr*)) ---- -- if $funcinst(z)[a] = fi -- Expand: fi.TYPE ~~ FUNC t_1^n -> t_2^m @@ -183,30 +186,32 @@ rule Step_read/call_ref-func: rule Step_read/return_call: - z; (RETURN_CALL x) ~> (REF.FUNC_ADDR a) (RETURN_CALL_REF $funcinst(z)[a].TYPE) + z; (RETURN_CALL x) ~> (RETURN_CALL_ADDR a) -- if $moduleinst(z).FUNCS[x] = a +rule Step_read/return_call_ref-null: + z; (REF.NULL_ADDR) (RETURN_CALL_REF x) ~> TRAP -rule Step_read/return_call_ref-label: - z; (LABEL_ k `{instr'*} val* (RETURN_CALL_REF yy) instr*) ~> val* (RETURN_CALL_REF yy) +rule Step_read/return_call_ref-func: + z; (REF.FUNC_ADDR a) (RETURN_CALL_REF x) ~> (RETURN_CALL_ADDR a) -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_addr-label: + z; (LABEL_ k `{instr'*} val* (RETURN_CALL_ADDR a) instr*) ~> val* (RETURN_CALL_ADDR a) -rule Step_read/return_call_ref-frame-null: - z; (FRAME_ k `{f} val* (REF.NULL_ADDR) (RETURN_CALL_REF yy) instr*) ~> TRAP +rule Step_read/return_call_addr-handler: + z; (HANDLER_ k `{catch*} val* (RETURN_CALL_ADDR a) instr*) ~> val* (RETURN_CALL_ADDR a) -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) +rule Step_read/return_call_addr-frame: + z; (FRAME_ k `{f} val'* val^n (RETURN_CALL_ADDR a) instr*) ~> val^n (CALL_ADDR a) ---- -- Expand: $funcinst(z)[a].TYPE ~~ FUNC t_1^n -> t_2^m rule Step_pure/call_indirect: - (CALL_INDIRECT x yy) ~> (TABLE.GET x) (REF.CAST (REF NULL yy)) (CALL_REF yy) + (CALL_INDIRECT x y) ~> (TABLE.GET x) (REF.CAST (REF NULL (_IDX y))) (CALL_REF y) rule Step_pure/return_call_indirect: - (RETURN_CALL_INDIRECT x yy) ~> (TABLE.GET x) (REF.CAST (REF NULL yy)) (RETURN_CALL_REF yy) + (RETURN_CALL_INDIRECT x y) ~> (TABLE.GET x) (REF.CAST (REF NULL (_IDX y))) (RETURN_CALL_REF y) rule Step_pure/frame-vals: @@ -225,7 +230,7 @@ rule Step_pure/return-handler: ;; Exceptions rule Step/throw: - z; val^n (THROW x) ~> $add_exninst(z, exn); (REF.EXN_ADDR a) THROW_REF + z; val^n (THROW x) ~> $add_exninst(z, exn); (THROW_ADDR a) -- Expand: $as_deftype($tag(z, x).TYPE) ~~ FUNC t^n -> eps -- if a = |$exninst(z)| -- if exn = {TAG $tagaddr(z)[x], FIELDS val^n} @@ -233,40 +238,43 @@ rule Step/throw: rule Step_read/throw_ref-null: 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 +rule Step_read/throw_ref-addr: + z; (REF.EXN_ADDR a) THROW_REF ~> (THROW_ADDR a) + +rule Step_read/throw_addr-instrs: + z; val* (THROW_ADDR a) instr* ~> (THROW_ADDR a) ---- -- if val* =/= eps \/ instr* =/= eps -rule Step_read/throw_ref-label: - z; (LABEL_ n `{instr'*} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) THROW_REF +rule Step_read/throw_addr-label: + z; (LABEL_ n `{instr'*} (THROW_ADDR a)) ~> (THROW_ADDR a) -rule Step_read/throw_ref-frame: - z; (FRAME_ n `{f} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) THROW_REF +rule Step_read/throw_addr-frame: + z; (FRAME_ n `{f} (THROW_ADDR a)) ~> (THROW_ADDR a) -rule Step_read/throw_ref-handler-empty: - z; (HANDLER_ n `{eps} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) THROW_REF +rule Step_read/throw_addr-handler-empty: + z; (HANDLER_ n `{eps} (THROW_ADDR a)) ~> (THROW_ADDR a) -rule Step_read/throw_ref-handler-catch: - z; (HANDLER_ n `{(CATCH x l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> val* (BR l) +rule Step_read/throw_addr-handler-catch: + z; (HANDLER_ n `{(CATCH x l) catch'*} (THROW_ADDR a)) ~> val* (BR l) ---- -- if $exninst(z)[a].TAG = $tagaddr(z)[x] -- if val* = $exninst(z)[a].FIELDS -rule Step_read/throw_ref-handler-catch_ref: - z; (HANDLER_ n `{(CATCH_REF x l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> val* (REF.EXN_ADDR a) (BR l) +rule Step_read/throw_addr-handler-catch_ref: + z; (HANDLER_ n `{(CATCH_REF x l) catch'*} (THROW_ADDR a)) ~> val* (REF.EXN_ADDR a) (BR l) ---- -- if $exninst(z)[a].TAG = $tagaddr(z)[x] -- if val* = $exninst(z)[a].FIELDS -rule Step_read/throw_ref-handler-catch_all: - z; (HANDLER_ n `{(CATCH_ALL l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> (BR l) +rule Step_read/throw_addr-handler-catch_all: + z; (HANDLER_ n `{(CATCH_ALL l) catch'*} (THROW_ADDR a)) ~> (BR l) -rule Step_read/throw_ref-handler-catch_all_ref: - z; (HANDLER_ n `{(CATCH_ALL_REF l) catch'*} (REF.EXN_ADDR a) THROW_REF) ~> (REF.EXN_ADDR a) (BR l) +rule Step_read/throw_addr-handler-catch_all_ref: + z; (HANDLER_ n `{(CATCH_ALL_REF l) catch'*} (THROW_ADDR a)) ~> (REF.EXN_ADDR a) (BR l) -rule Step_read/throw_ref-handler-next: - z; (HANDLER_ n `{catch catch'*} (REF.EXN_ADDR a) THROW_REF) ~> (HANDLER_ n `{catch'*} (REF.EXN_ADDR a) THROW_REF) +rule Step_read/throw_addr-handler-next: + z; (HANDLER_ n `{catch catch'*} (THROW_ADDR a)) ~> (HANDLER_ n `{catch'*} (THROW_ADDR a)) ---- -- otherwise diff --git a/specification/wasm-latest/4.4-execution.modules.spectec b/specification/wasm-latest/4.4-execution.modules.spectec index 91b2c9b3f7..d1a1c9b62c 100644 --- a/specification/wasm-latest/4.4-execution.modules.spectec +++ b/specification/wasm-latest/4.4-execution.modules.spectec @@ -212,7 +212,7 @@ def $instantiate(s, module, externaddr*) = s''''; {MODULE moduleinst}; instr_E* ;; Invocation def $invoke(store, funcaddr, val*) : config -def $invoke(s, funcaddr, val*) = s; {MODULE {}}; val* (REF.FUNC_ADDR funcaddr) (CALL_REF s.FUNCS[funcaddr].TYPE) +def $invoke(s, funcaddr, val*) = s; {MODULE {}}; val* (CALL_ADDR funcaddr) ---- -- Expand: s.FUNCS[funcaddr].TYPE ~~ FUNC t_1* -> t_2* -- (Val_ok: s |- val : t_1)* diff --git a/specification/wasm-latest/5.3-binary.instructions.spectec b/specification/wasm-latest/5.3-binary.instructions.spectec index a08d138777..ed6a8008e2 100644 --- a/specification/wasm-latest/5.3-binary.instructions.spectec +++ b/specification/wasm-latest/5.3-binary.instructions.spectec @@ -44,11 +44,11 @@ grammar Binstr/control : instr = ... | 0x0E l*:Blist(Blabelidx) l_n:Blabelidx => BR_TABLE l* l_n | 0x0F => RETURN | 0x10 x:Bfuncidx => CALL x - | 0x11 y:Btypeidx x:Btableidx => CALL_INDIRECT x (_IDX y) + | 0x11 y:Btypeidx x:Btableidx => CALL_INDIRECT x y | 0x12 x:Bfuncidx => RETURN_CALL x - | 0x13 y:Btypeidx x:Btableidx => RETURN_CALL_INDIRECT x (_IDX y) - | 0x14 x:Btypeidx => CALL_REF (_IDX x) - | 0x15 x:Btypeidx => RETURN_CALL_REF (_IDX x) + | 0x13 y:Btypeidx x:Btableidx => RETURN_CALL_INDIRECT x y + | 0x14 x:Btypeidx => CALL_REF x + | 0x15 x:Btypeidx => RETURN_CALL_REF x | 0x1F bt:Bblocktype c*:Blist(Bcatch) (in:Binstr)* 0x0B => TRY_TABLE bt c* in* | 0xD5 l:Blabelidx => BR_ON_NULL l | 0xD6 l:Blabelidx => BR_ON_NON_NULL l diff --git a/specification/wasm-latest/6.3-text.instructions.spectec b/specification/wasm-latest/6.3-text.instructions.spectec index 645eb8325f..5a83df8a6f 100644 --- a/specification/wasm-latest/6.3-text.instructions.spectec +++ b/specification/wasm-latest/6.3-text.instructions.spectec @@ -110,13 +110,13 @@ grammar Tplaininstr_(I)/br : instr = ... grammar Tplaininstr_(I)/func-plain : instr = ... | "call" x:Tfuncidx_(I) => CALL x - | "call_ref" x:Ttypeidx_(I) => CALL_REF $($(_IDX x)) - | "call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => CALL_INDIRECT x $($(_IDX y)) + | "call_ref" x:Ttypeidx_(I) => CALL_REF x + | "call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => CALL_INDIRECT x y -- if I' = {LOCALS (eps)*} | "return" => RETURN | "return_call" x:Tfuncidx_(I) => RETURN_CALL x - | "return_call_ref" x:Ttypeidx_(I) => RETURN_CALL_REF $($(_IDX x)) - | "return_call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => RETURN_CALL_INDIRECT x $($(_IDX y)) + | "return_call_ref" x:Ttypeidx_(I) => RETURN_CALL_REF x + | "return_call_indirect" x:Ttableidx_(I) (y,I'):Ttypeuse_(I) => RETURN_CALL_INDIRECT x y -- if I' = {LOCALS (eps)*} | ... diff --git a/specification/wasm-latest/7.1-soundness.configurations.spectec b/specification/wasm-latest/7.1-soundness.configurations.spectec index 1ce3881425..aef0e8a142 100644 --- a/specification/wasm-latest/7.1-soundness.configurations.spectec +++ b/specification/wasm-latest/7.1-soundness.configurations.spectec @@ -11,20 +11,6 @@ rule Instr_ok2/plain: s; C |- instr : t_1* ->_(x*) t_2* -- Instr_ok: C |- instr : t_1* ->_(x*) t_2* -rule Instr_ok2/call_ref: - s; C |- CALL_REF yy : t_1* (REF NULL yy) -> t_2* - -- Typeuse_ok: C |- yy : OK - -- Expand_use: yy ~~_C FUNC t_1* -> t_2* - -;; TODO(3, rossberg): enable t_2* <: C.RETURN -rule Instr_ok2/return_call_ref: - s; C |- RETURN_CALL_REF yy : t_3* t_1* (REF NULL yy) -> t_4* - -- Typeuse_ok: C |- yy : OK - -- Expand_use: yy ~~_C FUNC t_1* -> t_2* - -- if C.RETURN = (t'_2*) - -- Resulttype_sub: C |- t_2* <: t'_2* - -- Instrtype_ok: C |- t_3* -> t_4* : OK - rule Instr_ok2/ref: s; C |- ref : eps -> rt -- Ref_ok: s |- ref : rt @@ -45,6 +31,23 @@ rule Instr_ok2/handler: -- (Catch_ok: C |- catch : OK)* -- Instrs_ok2: s; C |- instr* : eps ->_(x*) t* +rule Instr_ok2/call_addr: + s; C |- CALL_ADDR a : t_1* -> t_2* + -- Expand: s.FUNCS[a].TYPE ~~ FUNC t_1* -> t_2* + +;; TODO(3, rossberg): enable t_2* <: C.RETURN +rule Instr_ok2/return_call_addr: + s; C |- RETURN_CALL_ADDR a : t_3* t_1* -> t_4* + -- Expand: s.FUNCS[a].TYPE ~~ FUNC t_1* -> t_2* + -- if C.RETURN = (t'_2*) + -- Resulttype_sub: C |- t_2* <: t'_2* + -- Instrtype_ok: C |- t_3* -> t_4* : OK + +rule Instr_ok2/throw_addr: + s; C |- THROW_ADDR a : t_1* -> t_2* + -- if s.EXNS[a] = exn + -- Instrtype_ok: C |- t_1* -> t_2* : OK + rule Instr_ok2/trap: s; C |- TRAP : t_1* -> t_2* -- Instrtype_ok: C |- t_1* -> t_2* : OK diff --git a/spectec/src/backend-interpreter/construct.ml b/spectec/src/backend-interpreter/construct.ml index b8ef93fc5b..3bbc1a5921 100644 --- a/spectec/src/backend-interpreter/construct.ml +++ b/spectec/src/backend-interpreter/construct.ml @@ -147,11 +147,6 @@ and al_to_typeuse: value -> typeuse = function | CaseV ("_DEF", _) as dt -> Def (al_to_deftype dt) | v -> error_value "typeuse" v -and al_to_idx_of_typeuse: value -> idx = function - | v when !version <= 2 -> al_to_idx v - | CaseV ("_IDX", [ idx ]) -> al_to_idx idx - | v -> error_value "idx_of_typeuse" v - and al_to_heaptype: value -> heaptype = function | CaseV (tag, []) as v -> (match tag with @@ -791,13 +786,13 @@ and al_to_instr': value -> Ast.instr' = function BrOnCastFail (al_to_idx idx, al_to_reftype rt1, al_to_reftype rt2) | CaseV ("RETURN", []) -> Return | CaseV ("CALL", [ idx ]) -> Call (al_to_idx idx) - | CaseV ("CALL_REF", [ typeuse ]) -> CallRef (al_to_idx_of_typeuse typeuse) - | CaseV ("CALL_INDIRECT", [ idx1; typeuse2 ]) -> - CallIndirect (al_to_idx idx1, al_to_idx_of_typeuse typeuse2) + | CaseV ("CALL_REF", [ idx ]) -> CallRef (al_to_idx idx) + | CaseV ("CALL_INDIRECT", [ idx1; idx2 ]) -> + CallIndirect (al_to_idx idx1, al_to_idx idx2) | CaseV ("RETURN_CALL", [ idx ]) -> ReturnCall (al_to_idx idx) - | CaseV ("RETURN_CALL_REF", [ typeuse ]) -> ReturnCallRef (al_to_idx_of_typeuse typeuse) - | CaseV ("RETURN_CALL_INDIRECT", [ idx1; typeuse2 ]) -> - ReturnCallIndirect (al_to_idx idx1, al_to_idx_of_typeuse typeuse2) + | CaseV ("RETURN_CALL_REF", [ idx ]) -> ReturnCallRef (al_to_idx idx) + | CaseV ("RETURN_CALL_INDIRECT", [ idx1; idx2 ]) -> + ReturnCallIndirect (al_to_idx idx1, al_to_idx idx2) | CaseV ("THROW", [ idx ]) -> Throw (al_to_idx idx) | CaseV ("THROW_REF", []) -> ThrowRef | CaseV ("TRY_TABLE", [ bt; catches; instrs ]) -> @@ -1155,10 +1150,6 @@ and al_of_typeuse = function | Rec n -> CaseV ("REC", [ al_of_nat32 n ]) | Def dt -> al_of_deftype dt -and al_of_typeuse_of_idx = function - | idx when !version <= 2 -> al_of_idx idx - | idx -> CaseV ("_IDX", [ al_of_idx idx ]) - and al_of_heaptype = function | UseHT tu -> al_of_typeuse tu | BotHT -> nullary "BOT" @@ -1815,14 +1806,14 @@ let rec al_of_instr instr = CaseV ("BR_ON_CAST_FAIL", [ al_of_idx idx; al_of_reftype rt1; al_of_reftype rt2 ]) | Return -> nullary "RETURN" | Call idx -> CaseV ("CALL", [ al_of_idx idx ]) - | CallRef idx -> CaseV ("CALL_REF", [ al_of_typeuse_of_idx idx ]) + | CallRef idx -> CaseV ("CALL_REF", [ al_of_idx idx ]) | CallIndirect (idx1, idx2) -> - let args = (if !version = 1 then [] else [ al_of_idx idx1 ]) @ [ al_of_typeuse_of_idx idx2 ] in + let args = (if !version = 1 then [] else [ al_of_idx idx1 ]) @ [ al_of_idx idx2 ] in CaseV ("CALL_INDIRECT", args) | ReturnCall idx -> CaseV ("RETURN_CALL", [ al_of_idx idx ]) | ReturnCallRef idx -> CaseV ("RETURN_CALL_REF", [ al_of_idx idx ]) | ReturnCallIndirect (idx1, idx2) -> - CaseV ("RETURN_CALL_INDIRECT", [ al_of_idx idx1; al_of_typeuse_of_idx idx2 ]) + CaseV ("RETURN_CALL_INDIRECT", [ al_of_idx idx1; al_of_idx idx2 ]) | Throw idx -> CaseV ("THROW", [ al_of_idx idx ]) | ThrowRef -> nullary "THROW_REF" | TryTable (bt, catches, instrs) -> diff --git a/spectec/src/il2al/preprocess.ml b/spectec/src/il2al/preprocess.ml index 8c44dc02a3..9c90fcc99c 100644 --- a/spectec/src/il2al/preprocess.ml +++ b/spectec/src/il2al/preprocess.ml @@ -91,7 +91,7 @@ let remove_or def = DecD (id, params, typ, List.concat_map remove_or_clause clauses) $ def.at | _ -> def -(* HARDCODE: Remove a reduction rule for the block context, specifically, for THROW_REF *) +(* HARDCODE: Remove a reduction rule for the block context, specifically, for THROW_ADDR *) let is_block_context_exp e = match e.it with (* instr* =/= [] *) diff --git a/spectec/src/il2al/translate.ml b/spectec/src/il2al/translate.ml index a92690a705..3ab2943fce 100644 --- a/spectec/src/il2al/translate.ml +++ b/spectec/src/il2al/translate.ml @@ -1178,11 +1178,11 @@ let rec translate_rgroup' (rule: rule_def) = | (None, b) -> Some b, List.tl blocks in - (* HARDCODE: Insert ThrowI if the current wasm instruction is throw_ref *) - let throw_block = if instr_name <> "throw_ref" then [] else - match List.hd pops |> lhs_of_prem |> it with - | TupE (e :: _) -> [throwI (translate_exp e)] - | _ -> assert false + (* HARDCODE: Insert ThrowI as the fallthrough for throw_addr when no matching + LABEL_, FRAME_, or HANDLER_ context is found, signalling an unhandled exception. *) + let throw_block = if instr_name <> "throw_addr" then [] else + let winstr = extract_winstr (List.hd rgroup) rule.at in + [throwI (translate_exp winstr)] in let ctxt_block = match ctxt_blocks with diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index 84c2e20c6c..2f099389da 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -2532,7 +2532,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-142.9 syntax instr = | NOP | UNREACHABLE @@ -2549,12 +2549,12 @@ syntax instr = | BR_ON_CAST(labelidx : labelidx, reftype : reftype, reftype : reftype) | BR_ON_CAST_FAIL(labelidx : labelidx, reftype : reftype, reftype : reftype) | CALL(funcidx) - | CALL_REF(typeuse) - | CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | CALL_REF(typeidx) + | CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | RETURN | RETURN_CALL(funcidx) - | RETURN_CALL_REF(typeuse) - | RETURN_CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | RETURN_CALL_REF(typeidx) + | RETURN_CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | THROW(tagidx) | THROW_REF | TRY_TABLE(blocktype : blocktype, list(syntax catch), `instr*` : instr*) @@ -2652,6 +2652,9 @@ syntax instr = | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) + | CALL_ADDR(funcaddr) + | RETURN_CALL_ADDR(funcaddr) + | THROW_ADDR(exnaddr) | TRAP } @@ -2742,17 +2745,17 @@ def $free_instr(instr : instr) : free ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:457.1-457.55 def $free_instr{funcidx : funcidx}(CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:458.1-458.59 - def $free_instr{typeuse : typeuse}(CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:459.1-460.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:461.1-461.29 def $free_instr(RETURN_instr) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS [], TAGS []} ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:462.1-462.62 def $free_instr{funcidx : funcidx}(RETURN_CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:463.1-463.66 - def $free_instr{typeuse : typeuse}(RETURN_CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(RETURN_CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:464.1-465.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(RETURN_CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(RETURN_CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:467.1-467.53 def $free_instr{tagidx : tagidx}(THROW_instr(tagidx)) = $free_tagidx(tagidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:468.1-468.32 @@ -3963,12 +3966,12 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:119.1-121.45 rule call_ref{C : context, x : idx, `t_1*` : valtype*, `t_2*` : valtype*}: - `%|-%:%`(C, CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:123.1-127.45 rule call_indirect{C : context, x : idx, y : idx, `t_1*` : valtype*, at : addrtype, `t_2*` : valtype*, lim : limits, rt : reftype}: - `%|-%:%`(C, CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) -- Expand: `%~~%`(C.TYPES_context[y!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -3989,7 +3992,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:143.1-148.42 rule return_call_ref{C : context, x : idx, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) @@ -3997,7 +4000,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:151.1-159.42 rule return_call_indirect{C : context, x : idx, y : idx, `t_3*` : valtype*, `t_1*` : valtype*, at : addrtype, `t_4*` : valtype*, lim : limits, rt : reftype, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) -- Expand: `%~~%`(C.TYPES_context[y!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -5908,7 +5911,7 @@ syntax vec = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(val*) - | `(REF.EXN_ADDR%)THROW_REF`(exnaddr) + | THROW_ADDR(exnaddr) | TRAP ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -6052,13 +6055,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:190.1-190.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.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:198.1-198.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -6066,13 +6069,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.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:202.1-202.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -6080,13 +6083,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.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:206.1-206.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -6094,13 +6097,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.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:210.1-210.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -6108,13 +6111,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.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:214.1-214.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -6583,12 +6586,12 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule call_indirect{x : idx, yy : typeuse}: - `%~>%`([CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) CALL_REF_instr(yy)]) + rule call_indirect{x : idx, y : idx}: + `%~>%`([CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule return_call_indirect{x : idx, yy : typeuse}: - `%~>%`([RETURN_CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) RETURN_CALL_REF_instr(yy)]) + rule return_call_indirect{x : idx, y : idx}: + `%~>%`([RETURN_CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) RETURN_CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `frame-vals`{n : n, f : frame, `val*` : val*}: @@ -6909,16 +6912,20 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) + `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [CALL_ADDR_instr(a)]) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(x)]), [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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) + rule `call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(x)]), [CALL_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule call_addr{z : state, n : n, `val*` : val*, a : addr, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) -- if ($funcinst(z)[a] = fi) -- Expand: `%~~%`(fi.TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`},), `%`_resulttype(t_2^m{t_2 <- `t_2*`},))) -- if (fi.CODE_funcinst = FUNC_funccode(x, LOCAL_local(t)*{t <- `t*`}, instr*{instr <- `instr*`})) @@ -6926,24 +6933,28 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule return_call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) + `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) + rule `return_call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr RETURN_CALL_REF_instr(x)]), [TRAP_instr]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, yy : typeuse, `instr*` : 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)]) + rule `return_call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - 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]) + rule `return_call_addr-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../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*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]) + rule `return_call_addr-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `return_call_addr-frame`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]) -- 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 @@ -6951,45 +6962,49 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a)] ++ [THROW_REF_instr] ++ instr*{instr <- `instr*`}), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_ref-addr`{z : state, a : addr}: + `%~>%`(`%;%`_config(z, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]), [THROW_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `throw_addr-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [THROW_ADDR_instr(a)] ++ instr*{instr <- `instr*`}), [THROW_ADDR_instr(a)]) -- if ((val*{val <- `val*`} =/= []) \/ (instr*{instr <- `instr*`} =/= [])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-label`{z : state, n : n, `instr'*` : instr*, a : addr}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-label`{z : state, n : n, `instr'*` : instr*, a : addr}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-frame`{z : state, n : n, f : frame, a : addr}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-frame`{z : state, n : n, f : frame, a : addr}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-empty`{z : state, n : n, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-handler-empty`{z : state, n : n, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) + rule `throw_addr-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [BR_instr(l)]) + rule `throw_addr-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]) + rule `throw_addr-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec @@ -7456,131 +7471,131 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%`_config(`%;%`_state(s, f), [`FRAME_%{%}%`_instr(n, f', instr*{instr <- `instr*`})]), `%;%`_config(`%;%`_state(s', f), [`FRAME_%{%}%`_instr(n, f'', instr'*{instr' <- `instr'*`})])) -- Step: `%~>%`(`%;%`_config(`%;%`_state(s, f'), instr*{instr <- `instr*`}), `%;%`_config(`%;%`_state(s', f''), instr'*{instr' <- `instr'*`})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:227.1-231.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:232.1-236.49 rule throw{z : state, n : n, `val*` : val*, x : idx, exn : exninst, a : addr, `t*` : valtype*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])) + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [THROW_ADDR_instr(a)])) -- Expand: `%~~%`($as_deftype($tag(z, x).TYPE_taginst), `FUNC%->%`_comptype(`%`_resulttype(t^n{t <- `t*`},), `%`_resulttype([],))) -- if (a = |$exninst(z)|) -- if (exn = {TAG $tagaddr(z)[x!`%`_idx.0], FIELDS val^n{val <- `val*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:305.1-306.56 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:313.1-314.56 rule `local.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `LOCAL.SET`_instr(x)]), `%;%`_config($with_local(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:318.1-319.58 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:326.1-327.58 rule `global.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `GLOBAL.SET`_instr(x)]), `%;%`_config($with_global(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:332.1-334.33 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:340.1-342.33 rule `table.set-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (i!`%`_num_.0 >= |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:336.1-338.32 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:344.1-346.32 rule `table.set-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config($with_table(z, x, i!`%`_num_.0, ref), [])) -- if (i!`%`_num_.0 < |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:347.1-350.46 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:355.1-358.46 rule `table.grow-succeed`{z : state, ref : ref, at : addrtype, n : n, x : idx, ti : tableinst}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config($with_tableinst(z, x, ti), [CONST_instr((at : addrtype <: numtype), `%`_num_(|$table(z, x).REFS_tableinst|,))])) -- if (ti = $growtable($table(z, x), n, ref)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:352.1-353.87 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:360.1-361.87 rule `table.grow-fail`{z : state, ref : ref, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:413.1-414.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:421.1-422.51 rule `elem.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`ELEM.DROP`_instr(x)]), `%;%`_config($with_elem(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:497.1-500.60 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:505.1-508.60 rule `store-num-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:502.1-506.29 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:510.1-514.29 rule `store-num-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $nbytes_(nt, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:508.1-511.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:516.1-519.52 rule `store-pack-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:513.1-517.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:521.1-525.52 rule `store-pack-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $ibytes_(n, $wrap__($size((Inn : Inn <: numtype)), n, c))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:519.1-522.63 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:527.1-530.63 rule `vstore-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:524.1-527.31 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:532.1-535.31 rule `vstore-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $vbytes_(V128_vectype, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:530.1-533.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:538.1-541.52 rule `vstore_lane-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:535.1-540.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:543.1-548.49 rule `vstore_lane-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx, `b*` : byte*, Jnn : Jnn, M : M}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (N = $jsize(Jnn)) -- if ((M!`%`_M.0 : nat <:> rat) = ((128 : nat <:> rat) / (N : nat <:> rat))) -- if (b*{b <- `b*`} = $ibytes_(N, `%`_iN($lanes_(`%X%`_shape((Jnn : Jnn <: lanetype), M), c)[j!`%`_laneidx.0]!`%`_lane_.0,))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:549.1-552.37 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:557.1-560.37 rule `memory.grow-succeed`{z : state, at : addrtype, n : n, x : idx, mi : meminst}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config($with_meminst(z, x, mi), [CONST_instr((at : addrtype <: numtype), `%`_num_((((|$mem(z, x).BYTES_meminst| : nat <:> rat) / ((64 * $Ki) : nat <:> rat)) : rat <:> nat),))])) -- if (mi = $growmem($mem(z, x), n)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:554.1-555.84 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:562.1-563.84 rule `memory.grow-fail`{z : state, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:615.1-616.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:623.1-624.51 rule `data.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`DATA.DROP`_instr(x)]), `%;%`_config($with_data(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:692.1-696.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:700.1-704.65 rule `struct.new`{z : state, n : n, `val*` : val*, x : idx, si : structinst, a : addr, `mut?*` : mut?*, `zt*` : storagetype*}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`STRUCT.NEW`_instr(x)]), `%;%`_config($add_structinst(z, [si]), [`REF.STRUCT_ADDR`_instr(a)])) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)^n{`mut?` <- `mut?*`, zt <- `zt*`},))) -- 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:713.1-714.55 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 rule `struct.set-null`{z : state, val : val, x : idx, i : fieldidx}: `%~>%`(`%;%`_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:716.1-719.46 + ;; ../../../../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 : fieldidx, `zt*` : storagetype*, `mut?*` : mut?*}: `%~>%`(`%;%`_config(z, [`REF.STRUCT_ADDR`_instr(a) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config($with_struct(z, a, i!`%`_fieldidx.0, $packfield_(zt*{zt <- `zt*`}[i!`%`_fieldidx.0], val)), [])) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)*{`mut?` <- `mut?*`, zt <- `zt*`},))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:732.1-737.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:740.1-745.65 rule `array.new_fixed`{z : state, n : n, `val*` : val*, x : idx, ai : arrayinst, a : addr, `mut?` : mut?, zt : storagetype}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n,))]), `%;%`_config($add_arrayinst(z, [ai]), [`REF.ARRAY_ADDR`_instr(a)])) -- 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:777.1-778.66 + ;; ../../../../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:780.1-782.39 + ;; ../../../../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}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (i!`%`_num_.0 >= |$arrayinst(z)[a].FIELDS_arrayinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:784.1-787.44 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:792.1-795.44 rule `array.set-array`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx, zt : storagetype, `mut?` : mut?}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config($with_array(z, a, i!`%`_num_.0, $packfield_(zt, val)), [])) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) @@ -7887,7 +7902,7 @@ def $instantiate(store : store, module : module, externaddr*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec def $invoke(store : store, funcaddr : funcaddr, val*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec - def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(funcaddr) CALL_REF_instr(s.FUNCS_store[funcaddr].TYPE_funcinst : deftype <: typeuse)]) + def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [CALL_ADDR_instr(funcaddr)]) -- Expand: `%~~%`(s.FUNCS_store[funcaddr].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- (Val_ok: `%|-%:%`(s, val, t_1))*{t_1 <- `t_1*`, val <- `val*`} @@ -8227,71 +8242,75 @@ relation Instr_ok2: `%;%|-%:%`(store, context, instr, instrtype) `%;%|-%:%`(s, C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instr_ok: `%|-%:%`(C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-17.43 - rule call_ref{s : store, C : context, yy : typeuse, `t_1*` : valtype*, `t_2*` : valtype*}: - `%;%|-%:%`(s, C, CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:20.1-26.42 - rule return_call_ref{s : store, C : context, yy : typeuse, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%;%|-%:%`(s, C, RETURN_CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) - -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) - -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:28.1-30.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-16.27 rule ref{s : store, C : context, ref : ref, rt : reftype}: `%;%|-%:%`(s, C, (ref : ref <: instr), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([(rt : reftype <: valtype)],))) -- Ref_ok: `%|-%:%`(s, ref, rt) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:32.1-35.68 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:18.1-21.68 rule label{s : store, C : context, n : n, `instr'*` : instr*, `instr*` : instr*, `t*` : valtype*, `t'*` : valtype*, `x'*` : idx*, `x*` : idx*}: `%;%|-%:%`(s, C, `LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr'*{instr' <- `instr'*`}, `%->_%%`_instrtype(`%`_resulttype(t'^n{t' <- `t'*`},), x'*{x' <- `x'*`}, `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [`%`_resulttype(t'^n{t' <- `t'*`},)], RETURN ?(), REFS [], RECS []} +++ C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:37.1-41.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:23.1-27.35 rule frame{s : store, C : context, n : n, f : frame, `instr*` : instr*, `t*` : valtype*, C' : context}: `%;%|-%:%`(s, C, `FRAME_%{%}%`_instr(n, f, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t^n{t <- `t*`},))) -- Frame_ok: `%|-%:%`(s, f, C') -- Expr_ok2: `%;%|-%:%`(s, C', instr*{instr <- `instr*`}, `%`_resulttype(t^n{t <- `t*`},)) -- Resulttype_ok: `%|-%:OK`({TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS [], RECS []}, `%`_resulttype(t^n{t <- `t*`},)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:43.1-46.49 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:29.1-32.49 rule handler{s : store, C : context, n : n, `catch*` : catch*, `instr*` : instr*, `t*` : valtype*, `x*` : idx*}: `%;%|-%:%`(s, C, `HANDLER_%{%}%`_instr(n, catch*{catch <- `catch*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- (Catch_ok: `%|-%:OK`(C, catch))*{catch <- `catch*`} -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:48.1-50.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:34.1-36.50 + rule call_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*}: + `%;%|-%:%`(s, C, CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:39.1-44.42 + rule return_call_addr{s : store, C : context, a : addr, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: + `%;%|-%:%`(s, C, RETURN_CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) + -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:46.1-49.42 + rule throw_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*, exn : exninst}: + `%;%|-%:%`(s, C, THROW_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (s.EXNS_store[a] = exn) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:51.1-53.42 rule trap{s : store, C : context, `t_1*` : valtype*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, TRAP_instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:5.1-6.36 relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:53.1-54.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-57.27 rule empty{s : store, C : context}: `%;%|-%:%`(s, C, [], `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([],))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-60.86 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:59.1-63.86 rule seq{s : store, C : context, instr_1 : instr, `instr_2*` : instr*, `t_1*` : valtype*, `x_1*` : idx*, `x_2*` : idx*, `t_3*` : valtype*, `t_2*` : valtype*, `init*` : init*, `t*` : valtype*}: `%;%|-%:%`(s, C, [instr_1] ++ instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`} ++ x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) -- Instr_ok2: `%;%|-%:%`(s, C, instr_1, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- (if (C.LOCALS_context[x_1!`%`_idx.0] = `%%`_localtype(init, t)))*{init <- `init*`, t <- `t*`, x_1 <- `x_1*`} -- Instrs_ok2: `%;%|-%:%`(s, $with_locals(C, x_1*{x_1 <- `x_1*`}, `%%`_localtype(SET_init, t)*{t <- `t*`}), instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_2*{t_2 <- `t_2*`},), x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:62.1-66.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:65.1-69.33 rule sub{s : store, C : context, `instr*` : instr*, it' : instrtype, it : instrtype}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it') -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it) -- Instrtype_sub: `%|-%<:%`(C, it, it') -- Instrtype_ok: `%|-%:OK`(C, it') - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:69.1-72.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:72.1-75.33 rule frame{s : store, C : context, `instr*` : instr*, `t*` : valtype*, `t_1*` : valtype*, `x*` : idx*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t*{t <- `t*`} ++ t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`} ++ t_2*{t_2 <- `t_2*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -8299,7 +8318,7 @@ relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:7.1-8.36 relation Expr_ok2: `%;%|-%:%`(store, context, expr, resulttype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:75.1-77.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:78.1-80.44 rule _{s : store, C : context, `instr*` : instr*, `t*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%`_resulttype(t*{t <- `t*`},)) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) @@ -8375,30 +8394,30 @@ relation Exninst_ok: `%|-%:OK`(store, exninst) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec rec { -;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:225.1-226.50 +;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:228.1-229.50 relation ImmutReachable: `%>>_%%`(fieldval, store, fieldval) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:239.1-242.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:242.1-245.35 rule trans{fv_1 : fieldval, s : store, fv_2 : fieldval, fv' : fieldval}: `%>>_%%`(fv_1, s, fv_2) -- ImmutReachable: `%>>_%%`(fv_1, s, fv') -- ImmutReachable: `%>>_%%`(fv', s, fv_2) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:244.1-247.20 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:247.1-250.20 rule `ref.struct`{a : addr, s : store, i : nat, `ft*` : fieldtype*, zt : storagetype}: `%>>_%%`(`REF.STRUCT_ADDR`_fieldval(a), s, s.STRUCTS_store[a].FIELDS_structinst[i]) -- Expand: `%~~%`(s.STRUCTS_store[a].TYPE_structinst, STRUCT_comptype(`%`_list(ft*{ft <- `ft*`},))) -- if (ft*{ft <- `ft*`}[i] = `%%`_fieldtype(?(), zt)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:249.1-251.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:252.1-254.42 rule `ref.array`{a : addr, s : store, i : nat, zt : storagetype}: `%>>_%%`(`REF.ARRAY_ADDR`_fieldval(a), s, s.ARRAYS_store[a].FIELDS_arrayinst[i]) -- Expand: `%~~%`(s.ARRAYS_store[a].TYPE_arrayinst, ARRAY_comptype(`%%`_fieldtype(?(), zt))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:253.1-254.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.44 rule `ref.exn`{a : addr, s : store, i : nat}: `%>>_%%`(`REF.EXN_ADDR`_fieldval(a), s, (s.EXNS_store[a].FIELDS_exninst[i] : val <: fieldval)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.28 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:259.1-260.28 rule `ref.extern`{ref : ref, s : store}: `%>>_%%`(`REF.EXTERN`_fieldval(ref), s, (ref : ref <: fieldval)) } @@ -9084,16 +9103,16 @@ grammar Binstr : instr prod 0x0F => RETURN_instr ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:46.5-46.30 prod{x : idx} {{0x10} {x:Bfuncidx}} => CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.60 - prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.53 + prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, y) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:48.5-48.37 prod{x : idx} {{0x12} {x:Bfuncidx}} => RETURN_CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.67 - prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.41 - prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(_IDX_typeuse(x)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.48 - prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.60 + prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, y) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.34 + prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(x) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.41 + prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:52.5-52.81 prod{bt : blocktype, `c*` : catch*, `in*` : instr*} {{0x1F} {bt:Bblocktype} {c*{c <- `c*`}:Blist(syntax catch, grammar Bcatch)} {in:Binstr*{in <- `in*`}} {0x0B}} => TRY_TABLE_instr(bt, `%`_list(c*{c <- `c*`},), in*{in <- `in*`}) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:53.5-53.37 @@ -11081,18 +11100,18 @@ grammar Tplaininstr_(I : I) : instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"call"} {x:Tfuncidx_(I)}} => CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod "return" => RETURN_instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"return_call"} {x:Tfuncidx_(I)}} => RETURN_CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"throw"} {x:Ttagidx_(I)}} => THROW_instr(x) diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index b856ee9989..55b30724e3 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -3910,12 +3910,12 @@ $$ & & | & \mathsf{br\_on\_cast}~{\mathit{labelidx}}~{\mathit{reftype}}~{\mathit{reftype}} \\ & & | & \mathsf{br\_on\_cast\_fail}~{\mathit{labelidx}}~{\mathit{reftype}}~{\mathit{reftype}} \\ & & | & \mathsf{call}~{\mathit{funcidx}} \\ -& & | & \mathsf{call\_ref}~{\mathit{typeuse}} \\ -& & | & \mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}} \\ +& & | & \mathsf{call\_ref}~{\mathit{typeidx}} \\ +& & | & \mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}} \\ & & | & \mathsf{return} \\ & & | & \mathsf{return\_call}~{\mathit{funcidx}} \\ -& & | & \mathsf{return\_call\_ref}~{\mathit{typeuse}} \\ -& & | & \mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}} \\ +& & | & \mathsf{return\_call\_ref}~{\mathit{typeidx}} \\ +& & | & \mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}} \\ & & | & \mathsf{throw}~{\mathit{tagidx}} \\ & & | & \mathsf{throw\_ref} \\ & & | & \mathsf{try\_table}~{\mathit{blocktype}}~{\mathit{list}}({\mathit{catch}})~{{\mathit{instr}}^\ast} \\ @@ -4097,20 +4097,20 @@ $$ \end{array} } \\ {\mathrm{free}}_{\mathit{instr}}(\mathsf{call}~{\mathit{funcidx}}) & = & {\mathrm{free}}_{\mathit{funcidx}}({\mathit{funcidx}}) \\ -{\mathrm{free}}_{\mathit{instr}}(\mathsf{call\_ref}~{\mathit{typeuse}}) & = & {\mathrm{free}}_{\mathit{typeuse}}({\mathit{typeuse}}) \\ -{\mathrm{free}}_{\mathit{instr}}(\mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}}) & = & & \\ +{\mathrm{free}}_{\mathit{instr}}(\mathsf{call\_ref}~{\mathit{typeidx}}) & = & {\mathrm{free}}_{\mathit{typeidx}}({\mathit{typeidx}}) \\ +{\mathrm{free}}_{\mathit{instr}}(\mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}}) & = & & \\ \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}} -{\mathrm{free}}_{\mathit{tableidx}}({\mathit{tableidx}}) \oplus {\mathrm{free}}_{\mathit{typeuse}}({\mathit{typeuse}}) \\ +{\mathrm{free}}_{\mathit{tableidx}}({\mathit{tableidx}}) \oplus {\mathrm{free}}_{\mathit{typeidx}}({\mathit{typeidx}}) \\ \end{array} } \\ {\mathrm{free}}_{\mathit{instr}}(\mathsf{return}) & = & \{ \} \\ {\mathrm{free}}_{\mathit{instr}}(\mathsf{return\_call}~{\mathit{funcidx}}) & = & {\mathrm{free}}_{\mathit{funcidx}}({\mathit{funcidx}}) \\ -{\mathrm{free}}_{\mathit{instr}}(\mathsf{return\_call\_ref}~{\mathit{typeuse}}) & = & {\mathrm{free}}_{\mathit{typeuse}}({\mathit{typeuse}}) \\ -{\mathrm{free}}_{\mathit{instr}}(\mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}}) & = & & \\ +{\mathrm{free}}_{\mathit{instr}}(\mathsf{return\_call\_ref}~{\mathit{typeidx}}) & = & {\mathrm{free}}_{\mathit{typeidx}}({\mathit{typeidx}}) \\ +{\mathrm{free}}_{\mathit{instr}}(\mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}}) & = & & \\ \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}} -{\mathrm{free}}_{\mathit{tableidx}}({\mathit{tableidx}}) \oplus {\mathrm{free}}_{\mathit{typeuse}}({\mathit{typeuse}}) \\ +{\mathrm{free}}_{\mathit{tableidx}}({\mathit{tableidx}}) \oplus {\mathrm{free}}_{\mathit{typeidx}}({\mathit{typeidx}}) \\ \end{array} } \\ {\mathrm{free}}_{\mathit{instr}}(\mathsf{throw}~{\mathit{tagidx}}) & = & {\mathrm{free}}_{\mathit{tagidx}}({\mathit{tagidx}}) \\ @@ -8955,7 +8955,7 @@ $$ & & | & \mathsf{ref{.}host}~{\mathit{hostaddr}} \\ & & | & \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} \\ +\mbox{(result)} & {\mathit{result}} & ::= & {{\mathit{val}}^\ast} ~~|~~ \mathsf{throw\_addr}~{\mathit{exnaddr}} ~~|~~ \mathsf{trap} \\ \end{array} $$ @@ -9059,6 +9059,9 @@ $$ & & | & {{\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} \\ +& & | & \mathsf{call\_addr}~{\mathit{funcaddr}} \\ +& & | & \mathsf{return\_call\_addr}~{\mathit{funcaddr}} \\ +& & | & \mathsf{throw\_addr}~{\mathit{exnaddr}} \\ & & | & \mathsf{trap} \\ \end{array} $$ @@ -9910,9 +9913,10 @@ $$ $$ \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})~(\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})) & \\ +{[\textsc{\scriptsize E{-}call}]} \quad & z ; (\mathsf{call}~x) & \hookrightarrow & (\mathsf{call\_addr}~a) & \quad \mbox{if}~ z{.}\mathsf{module}{.}\mathsf{funcs}{}[x] = a \\ +{[\textsc{\scriptsize E{-}call\_ref{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{call\_ref}~x) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}call\_ref{-}func}]} \quad & z ; (\mathsf{ref{.}func}~a)~(\mathsf{call\_ref}~x) & \hookrightarrow & (\mathsf{call\_addr}~a) \\ +{[\textsc{\scriptsize E{-}call\_addr}]} \quad & z ; {{\mathit{val}}^{n}}~(\mathsf{call\_addr}~a) & \hookrightarrow & ({{\mathsf{frame}}_{m}}{\{ f \}}~({{\mathsf{label}}_{m}}{\{ \epsilon \}}~{{\mathit{instr}}^\ast})) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} @@ -9929,18 +9933,12 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}return\_call}]} \quad & z ; (\mathsf{return\_call}~x) & \hookrightarrow & (\mathsf{ref{.}func}~a)~(\mathsf{return\_call\_ref}~z{.}\mathsf{funcs}{}[a]{.}\mathsf{type}) & \quad \mbox{if}~ z{.}\mathsf{module}{.}\mathsf{funcs}{}[x] = a \\ -\end{array} -$$ - -\vspace{1ex} - -$$ -\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})~(\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) & \\ +{[\textsc{\scriptsize E{-}return\_call}]} \quad & z ; (\mathsf{return\_call}~x) & \hookrightarrow & (\mathsf{return\_call\_addr}~a) & \quad \mbox{if}~ z{.}\mathsf{module}{.}\mathsf{funcs}{}[x] = a \\ +{[\textsc{\scriptsize E{-}return\_call\_ref{-}null}]} \quad & z ; (\mathsf{ref{.}null})~(\mathsf{return\_call\_ref}~x) & \hookrightarrow & \mathsf{trap} \\ +{[\textsc{\scriptsize E{-}return\_call\_ref{-}func}]} \quad & z ; (\mathsf{ref{.}func}~a)~(\mathsf{return\_call\_ref}~x) & \hookrightarrow & (\mathsf{return\_call\_addr}~a) \\ +{[\textsc{\scriptsize E{-}return\_call\_addr{-}label}]} \quad & z ; ({{\mathsf{label}}_{k}}{\{ {{\mathit{instr}'}^\ast} \}}~{{\mathit{val}}^\ast}~(\mathsf{return\_call\_addr}~a)~{{\mathit{instr}}^\ast}) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{return\_call\_addr}~a) \\ +{[\textsc{\scriptsize E{-}return\_call\_addr{-}handler}]} \quad & z ; ({{\mathsf{handler}}_{k}}{\{ {{\mathit{catch}}^\ast} \}}~{{\mathit{val}}^\ast}~(\mathsf{return\_call\_addr}~a)~{{\mathit{instr}}^\ast}) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{return\_call\_addr}~a) \\ +{[\textsc{\scriptsize E{-}return\_call\_addr{-}frame}]} \quad & z ; ({{\mathsf{frame}}_{k}}{\{ f \}}~{{\mathit{val}'}^\ast}~{{\mathit{val}}^{n}}~(\mathsf{return\_call\_addr}~a)~{{\mathit{instr}}^\ast}) & \hookrightarrow & {{\mathit{val}}^{n}}~(\mathsf{call\_addr}~a) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ z{.}\mathsf{funcs}{}[a]{.}\mathsf{type} \approx \mathsf{func}~{t_1^{n}} \rightarrow {t_2^{m}} } \\ @@ -9971,7 +9969,7 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} -{[\textsc{\scriptsize E{-}throw}]} \quad & z ; {{\mathit{val}}^{n}}~(\mathsf{throw}~x) & \hookrightarrow & z{}[{.}\mathsf{exns} \mathrel{{=}{\oplus}} {\mathit{exn}}] ; (\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref} & \quad +{[\textsc{\scriptsize E{-}throw}]} \quad & z ; {{\mathit{val}}^{n}}~(\mathsf{throw}~x) & \hookrightarrow & z{}[{.}\mathsf{exns} \mathrel{{=}{\oplus}} {\mathit{exn}}] ; (\mathsf{throw\_addr}~a) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\mathsf{tags}{}[x]{.}\mathsf{type} \approx \mathsf{func}~{t^{n}} \rightarrow \epsilon \\ {\land}~ a = {|z{.}\mathsf{exns}|} \\ @@ -9983,14 +9981,15 @@ $$ $$ \begin{array}[t]{@{}lrcl@{}l@{}} {[\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} & \\ +{[\textsc{\scriptsize E{-}throw\_ref{-}addr}]} \quad & z ; (\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref} & \hookrightarrow & (\mathsf{throw\_addr}~a) \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}instrs}]} \quad & z ; {{\mathit{val}}^\ast}~(\mathsf{throw\_addr}~a)~{{\mathit{instr}}^\ast} & \hookrightarrow & (\mathsf{throw\_addr}~a) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {{\mathit{val}}^\ast} \neq \epsilon \lor {{\mathit{instr}}^\ast} \neq \epsilon } \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}label}]} \quad & z ; ({{\mathsf{label}}_{n}}{\{ {{\mathit{instr}'}^\ast} \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & (\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref} \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}frame}]} \quad & z ; ({{\mathsf{frame}}_{n}}{\{ f \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & (\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref} \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}handler{-}empty}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ \epsilon \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & (\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref} \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}handler{-}catch}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch}~x~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{br}~l) & \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}label}]} \quad & z ; ({{\mathsf{label}}_{n}}{\{ {{\mathit{instr}'}^\ast} \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & (\mathsf{throw\_addr}~a) \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}frame}]} \quad & z ; ({{\mathsf{frame}}_{n}}{\{ f \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & (\mathsf{throw\_addr}~a) \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}handler{-}empty}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ \epsilon \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & (\mathsf{throw\_addr}~a) \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}handler{-}catch}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch}~x~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{br}~l) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} @@ -9998,7 +9997,7 @@ $$ {\land}~ {{\mathit{val}}^\ast} = z{.}\mathsf{exns}{}[a]{.}\mathsf{fields} \\ \end{array} } \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}handler{-}catch\_ref}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch\_ref}~x~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{ref{.}exn}~a)~(\mathsf{br}~l) & \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}handler{-}catch\_ref}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch\_ref}~x~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & {{\mathit{val}}^\ast}~(\mathsf{ref{.}exn}~a)~(\mathsf{br}~l) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} @@ -10006,9 +10005,9 @@ $$ {\land}~ {{\mathit{val}}^\ast} = z{.}\mathsf{exns}{}[a]{.}\mathsf{fields} \\ \end{array} } \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}handler{-}catch\_all}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch\_all}~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & (\mathsf{br}~l) \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}handler{-}catch\_all\_ref}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch\_all\_ref}~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & (\mathsf{ref{.}exn}~a)~(\mathsf{br}~l) \\ -{[\textsc{\scriptsize E{-}throw\_ref{-}handler{-}next}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ {\mathit{catch}}~{{\mathit{catch}'}^\ast} \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \hookrightarrow & ({{\mathsf{handler}}_{n}}{\{ {{\mathit{catch}'}^\ast} \}}~(\mathsf{ref{.}exn}~a)~\mathsf{throw\_ref}) & \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}handler{-}catch\_all}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch\_all}~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & (\mathsf{br}~l) \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}handler{-}catch\_all\_ref}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ (\mathsf{catch\_all\_ref}~l)~{{\mathit{catch}'}^\ast} \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & (\mathsf{ref{.}exn}~a)~(\mathsf{br}~l) \\ +{[\textsc{\scriptsize E{-}throw\_addr{-}handler{-}next}]} \quad & z ; ({{\mathsf{handler}}_{n}}{\{ {\mathit{catch}}~{{\mathit{catch}'}^\ast} \}}~(\mathsf{throw\_addr}~a)) & \hookrightarrow & ({{\mathsf{handler}}_{n}}{\{ {{\mathit{catch}'}^\ast} \}}~(\mathsf{throw\_addr}~a)) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{otherwise} } \\ @@ -11344,7 +11343,7 @@ $$ $$ \begin{array}[t]{@{}lcl@{}l@{}} -{\mathrm{invoke}}(s, {\mathit{funcaddr}}, {{\mathit{val}}^\ast}) & = & s ; \{ \mathsf{module}~\{ \} \} ; {{\mathit{val}}^\ast}~(\mathsf{ref{.}func}~{\mathit{funcaddr}})~(\mathsf{call\_ref}~s{.}\mathsf{funcs}{}[{\mathit{funcaddr}}]{.}\mathsf{type}) & \\ +{\mathrm{invoke}}(s, {\mathit{funcaddr}}, {{\mathit{val}}^\ast}) & = & s ; \{ \mathsf{module}~\{ \} \} ; {{\mathit{val}}^\ast}~(\mathsf{call\_addr}~{\mathit{funcaddr}}) & \\ && \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} @@ -14141,12 +14140,10 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -C \vdash y : \mathsf{ok} - \qquad -y \approx_{C} \mathsf{func}~{t_1^\ast} \rightarrow {t_2^\ast} +s \vdash {\mathit{ref}} : {\mathit{rt}} }{ -s ; C \vdash \mathsf{call\_ref}~y : {t_1^\ast}~(\mathsf{ref}~\mathsf{null}~y) \rightarrow {t_2^\ast} -} \, {[\textsc{\scriptsize Instr\_ok2{-}call\_ref}]} +s ; C \vdash {\mathit{ref}} : \epsilon \rightarrow {\mathit{rt}} +} \, {[\textsc{\scriptsize Instr\_ok2{-}ref}]} \qquad \end{array} $$ @@ -14154,18 +14151,27 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -C \vdash y : \mathsf{ok} - \qquad -y \approx_{C} \mathsf{func}~{t_1^\ast} \rightarrow {t_2^\ast} +s ; C \vdash {{\mathit{instr}'}^\ast} : {{t'}^{n}} \rightarrow_{{{x'}^\ast}} {t^\ast} \qquad -C{.}\mathsf{return} = ({{t'}_2^\ast}) +s ; \{ \mathsf{labels}~{({t'})^{n}} \} \oplus C \vdash {{\mathit{instr}}^\ast} : \epsilon \rightarrow_{{x^\ast}} {t^\ast} +}{ +s ; C \vdash {{\mathsf{label}}_{n}}{\{ {{\mathit{instr}'}^\ast} \}}~{{\mathit{instr}}^\ast} : \epsilon \rightarrow {t^\ast} +} \, {[\textsc{\scriptsize Instr\_ok2{-}label}]} +\qquad +\end{array} +$$ + +$$ +\begin{array}{@{}c@{}}\displaystyle +\frac{ +s \vdash f : {C'} \qquad -C \vdash {t_2^\ast} \leq {{t'}_2^\ast} +s ; {C'} \vdash {{\mathit{instr}}^\ast} : {t^{n}} \qquad -C \vdash {t_3^\ast} \rightarrow {t_4^\ast} : \mathsf{ok} +\{ \} \vdash {t^{n}} : \mathsf{ok} }{ -s ; C \vdash \mathsf{return\_call\_ref}~y : {t_3^\ast}~{t_1^\ast}~(\mathsf{ref}~\mathsf{null}~y) \rightarrow {t_4^\ast} -} \, {[\textsc{\scriptsize Instr\_ok2{-}return\_call\_ref}]} +s ; C \vdash {{\mathsf{frame}}_{n}}{\{ f \}}~{{\mathit{instr}}^\ast} : \epsilon \rightarrow {t^{n}} +} \, {[\textsc{\scriptsize Instr\_ok2{-}frame}]} \qquad \end{array} $$ @@ -14173,10 +14179,12 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -s \vdash {\mathit{ref}} : {\mathit{rt}} +(C \vdash {\mathit{catch}} : \mathsf{ok})^\ast + \qquad +s ; C \vdash {{\mathit{instr}}^\ast} : \epsilon \rightarrow_{{x^\ast}} {t^\ast} }{ -s ; C \vdash {\mathit{ref}} : \epsilon \rightarrow {\mathit{rt}} -} \, {[\textsc{\scriptsize Instr\_ok2{-}ref}]} +s ; C \vdash {{\mathsf{handler}}_{n}}{\{ {{\mathit{catch}}^\ast} \}}~{{\mathit{instr}}^\ast} : \epsilon \rightarrow {t^\ast} +} \, {[\textsc{\scriptsize Instr\_ok2{-}handler}]} \qquad \end{array} $$ @@ -14184,12 +14192,10 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -s ; C \vdash {{\mathit{instr}'}^\ast} : {{t'}^{n}} \rightarrow_{{{x'}^\ast}} {t^\ast} - \qquad -s ; \{ \mathsf{labels}~{({t'})^{n}} \} \oplus C \vdash {{\mathit{instr}}^\ast} : \epsilon \rightarrow_{{x^\ast}} {t^\ast} +s{.}\mathsf{funcs}{}[a]{.}\mathsf{type} \approx \mathsf{func}~{t_1^\ast} \rightarrow {t_2^\ast} }{ -s ; C \vdash {{\mathsf{label}}_{n}}{\{ {{\mathit{instr}'}^\ast} \}}~{{\mathit{instr}}^\ast} : \epsilon \rightarrow {t^\ast} -} \, {[\textsc{\scriptsize Instr\_ok2{-}label}]} +s ; C \vdash \mathsf{call\_addr}~a : {t_1^\ast} \rightarrow {t_2^\ast} +} \, {[\textsc{\scriptsize Instr\_ok2{-}call\_addr}]} \qquad \end{array} $$ @@ -14197,14 +14203,16 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -s \vdash f : {C'} +s{.}\mathsf{funcs}{}[a]{.}\mathsf{type} \approx \mathsf{func}~{t_1^\ast} \rightarrow {t_2^\ast} \qquad -s ; {C'} \vdash {{\mathit{instr}}^\ast} : {t^{n}} +C{.}\mathsf{return} = ({{t'}_2^\ast}) \qquad -\{ \} \vdash {t^{n}} : \mathsf{ok} +C \vdash {t_2^\ast} \leq {{t'}_2^\ast} + \qquad +C \vdash {t_3^\ast} \rightarrow {t_4^\ast} : \mathsf{ok} }{ -s ; C \vdash {{\mathsf{frame}}_{n}}{\{ f \}}~{{\mathit{instr}}^\ast} : \epsilon \rightarrow {t^{n}} -} \, {[\textsc{\scriptsize Instr\_ok2{-}frame}]} +s ; C \vdash \mathsf{return\_call\_addr}~a : {t_3^\ast}~{t_1^\ast} \rightarrow {t_4^\ast} +} \, {[\textsc{\scriptsize Instr\_ok2{-}return\_call\_addr}]} \qquad \end{array} $$ @@ -14212,12 +14220,12 @@ $$ $$ \begin{array}{@{}c@{}}\displaystyle \frac{ -(C \vdash {\mathit{catch}} : \mathsf{ok})^\ast +s{.}\mathsf{exns}{}[a] = {\mathit{exn}} \qquad -s ; C \vdash {{\mathit{instr}}^\ast} : \epsilon \rightarrow_{{x^\ast}} {t^\ast} +C \vdash {t_1^\ast} \rightarrow {t_2^\ast} : \mathsf{ok} }{ -s ; C \vdash {{\mathsf{handler}}_{n}}{\{ {{\mathit{catch}}^\ast} \}}~{{\mathit{instr}}^\ast} : \epsilon \rightarrow {t^\ast} -} \, {[\textsc{\scriptsize Instr\_ok2{-}handler}]} +s ; C \vdash \mathsf{throw\_addr}~a : {t_1^\ast} \rightarrow {t_2^\ast} +} \, {[\textsc{\scriptsize Instr\_ok2{-}throw\_addr}]} \qquad \end{array} $$ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index cbda7bd91c..9833985c7c 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -2055,7 +2055,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-142.9 syntax instr = | NOP | UNREACHABLE @@ -2072,12 +2072,12 @@ syntax instr = | BR_ON_CAST(labelidx : labelidx, reftype : reftype, reftype : reftype) | BR_ON_CAST_FAIL(labelidx : labelidx, reftype : reftype, reftype : reftype) | CALL(funcidx) - | CALL_REF(typeuse) - | CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | CALL_REF(typeidx) + | CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | RETURN | RETURN_CALL(funcidx) - | RETURN_CALL_REF(typeuse) - | RETURN_CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | RETURN_CALL_REF(typeidx) + | RETURN_CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | THROW(tagidx) | THROW_REF | TRY_TABLE(blocktype : blocktype, list(syntax catch), `instr*` : instr*) @@ -2175,6 +2175,9 @@ syntax instr = | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) + | CALL_ADDR(funcaddr) + | RETURN_CALL_ADDR(funcaddr) + | THROW_ADDR(exnaddr) | TRAP } @@ -2265,17 +2268,17 @@ def $free_instr(instr : instr) : free ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:457.1-457.55 def $free_instr{funcidx : funcidx}(CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:458.1-458.59 - def $free_instr{typeuse : typeuse}(CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:459.1-460.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:461.1-461.29 def $free_instr(RETURN_instr) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS [], TAGS []} ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:462.1-462.62 def $free_instr{funcidx : funcidx}(RETURN_CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:463.1-463.66 - def $free_instr{typeuse : typeuse}(RETURN_CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(RETURN_CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:464.1-465.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(RETURN_CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(RETURN_CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:467.1-467.53 def $free_instr{tagidx : tagidx}(THROW_instr(tagidx)) = $free_tagidx(tagidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:468.1-468.32 @@ -3486,12 +3489,12 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:119.1-121.45 rule call_ref{C : context, x : idx, `t_1*` : valtype*, `t_2*` : valtype*}: - `%|-%:%`(C, CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:123.1-127.45 rule call_indirect{C : context, x : idx, y : idx, `t_1*` : valtype*, at : addrtype, `t_2*` : valtype*, lim : limits, rt : reftype}: - `%|-%:%`(C, CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) -- Expand: `%~~%`(C.TYPES_context[y!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -3512,7 +3515,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:143.1-148.42 rule return_call_ref{C : context, x : idx, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) @@ -3520,7 +3523,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:151.1-159.42 rule return_call_indirect{C : context, x : idx, y : idx, `t_3*` : valtype*, `t_1*` : valtype*, at : addrtype, `t_4*` : valtype*, lim : limits, rt : reftype, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) -- Expand: `%~~%`(C.TYPES_context[y!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -5431,7 +5434,7 @@ syntax vec = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(val*) - | `(REF.EXN_ADDR%)THROW_REF`(exnaddr) + | THROW_ADDR(exnaddr) | TRAP ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -5575,13 +5578,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:190.1-190.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.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:198.1-198.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5589,13 +5592,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.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:202.1-202.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5603,13 +5606,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.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:206.1-206.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5617,13 +5620,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.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:210.1-210.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -5631,13 +5634,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.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:214.1-214.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -6106,12 +6109,12 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule call_indirect{x : idx, yy : typeuse}: - `%~>%`([CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) CALL_REF_instr(yy)]) + rule call_indirect{x : idx, y : idx}: + `%~>%`([CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule return_call_indirect{x : idx, yy : typeuse}: - `%~>%`([RETURN_CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) RETURN_CALL_REF_instr(yy)]) + rule return_call_indirect{x : idx, y : idx}: + `%~>%`([RETURN_CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) RETURN_CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `frame-vals`{n : n, f : frame, `val*` : val*}: @@ -6432,16 +6435,20 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) + `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [CALL_ADDR_instr(a)]) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(x)]), [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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) + rule `call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(x)]), [CALL_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule call_addr{z : state, n : n, `val*` : val*, a : addr, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) -- if ($funcinst(z)[a] = fi) -- Expand: `%~~%`(fi.TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`},), `%`_resulttype(t_2^m{t_2 <- `t_2*`},))) -- if (fi.CODE_funcinst = FUNC_funccode(x, LOCAL_local(t)*{t <- `t*`}, instr*{instr <- `instr*`})) @@ -6449,24 +6456,28 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule return_call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) + `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) + rule `return_call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr RETURN_CALL_REF_instr(x)]), [TRAP_instr]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `return_call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, yy : typeuse, `instr*` : 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)]) + rule `return_call_addr-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - 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]) + rule `return_call_addr-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../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*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]) + rule `return_call_addr-frame`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]) -- 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 @@ -6474,45 +6485,49 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a)] ++ [THROW_REF_instr] ++ instr*{instr <- `instr*`}), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_ref-addr`{z : state, a : addr}: + `%~>%`(`%;%`_config(z, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]), [THROW_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `throw_addr-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [THROW_ADDR_instr(a)] ++ instr*{instr <- `instr*`}), [THROW_ADDR_instr(a)]) -- if ((val*{val <- `val*`} =/= []) \/ (instr*{instr <- `instr*`} =/= [])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-label`{z : state, n : n, `instr'*` : instr*, a : addr}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-label`{z : state, n : n, `instr'*` : instr*, a : addr}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-frame`{z : state, n : n, f : frame, a : addr}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-frame`{z : state, n : n, f : frame, a : addr}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-empty`{z : state, n : n, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-handler-empty`{z : state, n : n, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) + rule `throw_addr-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [BR_instr(l)]) + rule `throw_addr-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]) + rule `throw_addr-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec @@ -6979,131 +6994,131 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%`_config(`%;%`_state(s, f), [`FRAME_%{%}%`_instr(n, f', instr*{instr <- `instr*`})]), `%;%`_config(`%;%`_state(s', f), [`FRAME_%{%}%`_instr(n, f'', instr'*{instr' <- `instr'*`})])) -- Step: `%~>%`(`%;%`_config(`%;%`_state(s, f'), instr*{instr <- `instr*`}), `%;%`_config(`%;%`_state(s', f''), instr'*{instr' <- `instr'*`})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:227.1-231.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:232.1-236.49 rule throw{z : state, n : n, `val*` : val*, x : idx, exn : exninst, a : addr, `t*` : valtype*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])) + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [THROW_ADDR_instr(a)])) -- Expand: `%~~%`($as_deftype($tag(z, x).TYPE_taginst), `FUNC%->%`_comptype(`%`_resulttype(t^n{t <- `t*`},), `%`_resulttype([],))) -- if (a = |$exninst(z)|) -- if (exn = {TAG $tagaddr(z)[x!`%`_idx.0], FIELDS val^n{val <- `val*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:305.1-306.56 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:313.1-314.56 rule `local.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `LOCAL.SET`_instr(x)]), `%;%`_config($with_local(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:318.1-319.58 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:326.1-327.58 rule `global.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `GLOBAL.SET`_instr(x)]), `%;%`_config($with_global(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:332.1-334.33 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:340.1-342.33 rule `table.set-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (i!`%`_num_.0 >= |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:336.1-338.32 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:344.1-346.32 rule `table.set-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config($with_table(z, x, i!`%`_num_.0, ref), [])) -- if (i!`%`_num_.0 < |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:347.1-350.46 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:355.1-358.46 rule `table.grow-succeed`{z : state, ref : ref, at : addrtype, n : n, x : idx, ti : tableinst}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config($with_tableinst(z, x, ti), [CONST_instr((at : addrtype <: numtype), `%`_num_(|$table(z, x).REFS_tableinst|,))])) -- if (ti = $growtable($table(z, x), n, ref)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:352.1-353.87 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:360.1-361.87 rule `table.grow-fail`{z : state, ref : ref, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:413.1-414.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:421.1-422.51 rule `elem.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`ELEM.DROP`_instr(x)]), `%;%`_config($with_elem(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:497.1-500.60 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:505.1-508.60 rule `store-num-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:502.1-506.29 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:510.1-514.29 rule `store-num-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $nbytes_(nt, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:508.1-511.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:516.1-519.52 rule `store-pack-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:513.1-517.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:521.1-525.52 rule `store-pack-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $ibytes_(n, $wrap__($size((Inn : Inn <: numtype)), n, c))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:519.1-522.63 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:527.1-530.63 rule `vstore-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:524.1-527.31 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:532.1-535.31 rule `vstore-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $vbytes_(V128_vectype, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:530.1-533.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:538.1-541.52 rule `vstore_lane-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:535.1-540.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:543.1-548.49 rule `vstore_lane-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx, `b*` : byte*, Jnn : Jnn, M : M}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (N = $jsize(Jnn)) -- if ((M!`%`_M.0 : nat <:> rat) = ((128 : nat <:> rat) / (N : nat <:> rat))) -- if (b*{b <- `b*`} = $ibytes_(N, `%`_iN($lanes_(`%X%`_shape((Jnn : Jnn <: lanetype), M), c)[j!`%`_laneidx.0]!`%`_lane_.0,))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:549.1-552.37 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:557.1-560.37 rule `memory.grow-succeed`{z : state, at : addrtype, n : n, x : idx, mi : meminst}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config($with_meminst(z, x, mi), [CONST_instr((at : addrtype <: numtype), `%`_num_((((|$mem(z, x).BYTES_meminst| : nat <:> rat) / ((64 * $Ki) : nat <:> rat)) : rat <:> nat),))])) -- if (mi = $growmem($mem(z, x), n)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:554.1-555.84 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:562.1-563.84 rule `memory.grow-fail`{z : state, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:615.1-616.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:623.1-624.51 rule `data.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`DATA.DROP`_instr(x)]), `%;%`_config($with_data(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:692.1-696.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:700.1-704.65 rule `struct.new`{z : state, n : n, `val*` : val*, x : idx, si : structinst, a : addr, `mut?*` : mut?*, `zt*` : storagetype*}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`STRUCT.NEW`_instr(x)]), `%;%`_config($add_structinst(z, [si]), [`REF.STRUCT_ADDR`_instr(a)])) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)^n{`mut?` <- `mut?*`, zt <- `zt*`},))) -- 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:713.1-714.55 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 rule `struct.set-null`{z : state, val : val, x : idx, i : fieldidx}: `%~>%`(`%;%`_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:716.1-719.46 + ;; ../../../../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 : fieldidx, `zt*` : storagetype*, `mut?*` : mut?*}: `%~>%`(`%;%`_config(z, [`REF.STRUCT_ADDR`_instr(a) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config($with_struct(z, a, i!`%`_fieldidx.0, $packfield_(zt*{zt <- `zt*`}[i!`%`_fieldidx.0], val)), [])) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)*{`mut?` <- `mut?*`, zt <- `zt*`},))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:732.1-737.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:740.1-745.65 rule `array.new_fixed`{z : state, n : n, `val*` : val*, x : idx, ai : arrayinst, a : addr, `mut?` : mut?, zt : storagetype}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n,))]), `%;%`_config($add_arrayinst(z, [ai]), [`REF.ARRAY_ADDR`_instr(a)])) -- 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:777.1-778.66 + ;; ../../../../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:780.1-782.39 + ;; ../../../../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}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (i!`%`_num_.0 >= |$arrayinst(z)[a].FIELDS_arrayinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:784.1-787.44 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:792.1-795.44 rule `array.set-array`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx, zt : storagetype, `mut?` : mut?}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config($with_array(z, a, i!`%`_num_.0, $packfield_(zt, val)), [])) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) @@ -7410,7 +7425,7 @@ def $instantiate(store : store, module : module, externaddr*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec def $invoke(store : store, funcaddr : funcaddr, val*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec - def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(funcaddr) CALL_REF_instr(s.FUNCS_store[funcaddr].TYPE_funcinst : deftype <: typeuse)]) + def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [CALL_ADDR_instr(funcaddr)]) -- Expand: `%~~%`(s.FUNCS_store[funcaddr].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- (Val_ok: `%|-%:%`(s, val, t_1))*{t_1 <- `t_1*`, val <- `val*`} @@ -7750,71 +7765,75 @@ relation Instr_ok2: `%;%|-%:%`(store, context, instr, instrtype) `%;%|-%:%`(s, C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instr_ok: `%|-%:%`(C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-17.43 - rule call_ref{s : store, C : context, yy : typeuse, `t_1*` : valtype*, `t_2*` : valtype*}: - `%;%|-%:%`(s, C, CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:20.1-26.42 - rule return_call_ref{s : store, C : context, yy : typeuse, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%;%|-%:%`(s, C, RETURN_CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) - -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) - -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:28.1-30.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-16.27 rule ref{s : store, C : context, ref : ref, rt : reftype}: `%;%|-%:%`(s, C, (ref : ref <: instr), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([(rt : reftype <: valtype)],))) -- Ref_ok: `%|-%:%`(s, ref, rt) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:32.1-35.68 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:18.1-21.68 rule label{s : store, C : context, n : n, `instr'*` : instr*, `instr*` : instr*, `t*` : valtype*, `t'*` : valtype*, `x'*` : idx*, `x*` : idx*}: `%;%|-%:%`(s, C, `LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr'*{instr' <- `instr'*`}, `%->_%%`_instrtype(`%`_resulttype(t'^n{t' <- `t'*`},), x'*{x' <- `x'*`}, `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [`%`_resulttype(t'^n{t' <- `t'*`},)], RETURN ?(), REFS [], RECS []} +++ C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:37.1-41.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:23.1-27.35 rule frame{s : store, C : context, n : n, f : frame, `instr*` : instr*, `t*` : valtype*, C' : context}: `%;%|-%:%`(s, C, `FRAME_%{%}%`_instr(n, f, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t^n{t <- `t*`},))) -- Frame_ok: `%|-%:%`(s, f, C') -- Expr_ok2: `%;%|-%:%`(s, C', instr*{instr <- `instr*`}, `%`_resulttype(t^n{t <- `t*`},)) -- Resulttype_ok: `%|-%:OK`({TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS [], RECS []}, `%`_resulttype(t^n{t <- `t*`},)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:43.1-46.49 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:29.1-32.49 rule handler{s : store, C : context, n : n, `catch*` : catch*, `instr*` : instr*, `t*` : valtype*, `x*` : idx*}: `%;%|-%:%`(s, C, `HANDLER_%{%}%`_instr(n, catch*{catch <- `catch*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- (Catch_ok: `%|-%:OK`(C, catch))*{catch <- `catch*`} -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:48.1-50.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:34.1-36.50 + rule call_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*}: + `%;%|-%:%`(s, C, CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:39.1-44.42 + rule return_call_addr{s : store, C : context, a : addr, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: + `%;%|-%:%`(s, C, RETURN_CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) + -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:46.1-49.42 + rule throw_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*, exn : exninst}: + `%;%|-%:%`(s, C, THROW_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (s.EXNS_store[a] = exn) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:51.1-53.42 rule trap{s : store, C : context, `t_1*` : valtype*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, TRAP_instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:5.1-6.36 relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:53.1-54.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-57.27 rule empty{s : store, C : context}: `%;%|-%:%`(s, C, [], `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([],))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-60.86 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:59.1-63.86 rule seq{s : store, C : context, instr_1 : instr, `instr_2*` : instr*, `t_1*` : valtype*, `x_1*` : idx*, `x_2*` : idx*, `t_3*` : valtype*, `t_2*` : valtype*, `init*` : init*, `t*` : valtype*}: `%;%|-%:%`(s, C, [instr_1] ++ instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`} ++ x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) -- Instr_ok2: `%;%|-%:%`(s, C, instr_1, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- (if (C.LOCALS_context[x_1!`%`_idx.0] = `%%`_localtype(init, t)))*{init <- `init*`, t <- `t*`, x_1 <- `x_1*`} -- Instrs_ok2: `%;%|-%:%`(s, $with_locals(C, x_1*{x_1 <- `x_1*`}, `%%`_localtype(SET_init, t)*{t <- `t*`}), instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_2*{t_2 <- `t_2*`},), x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:62.1-66.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:65.1-69.33 rule sub{s : store, C : context, `instr*` : instr*, it' : instrtype, it : instrtype}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it') -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it) -- Instrtype_sub: `%|-%<:%`(C, it, it') -- Instrtype_ok: `%|-%:OK`(C, it') - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:69.1-72.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:72.1-75.33 rule frame{s : store, C : context, `instr*` : instr*, `t*` : valtype*, `t_1*` : valtype*, `x*` : idx*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t*{t <- `t*`} ++ t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`} ++ t_2*{t_2 <- `t_2*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -7822,7 +7841,7 @@ relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:7.1-8.36 relation Expr_ok2: `%;%|-%:%`(store, context, expr, resulttype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:75.1-77.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:78.1-80.44 rule _{s : store, C : context, `instr*` : instr*, `t*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%`_resulttype(t*{t <- `t*`},)) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) @@ -7898,30 +7917,30 @@ relation Exninst_ok: `%|-%:OK`(store, exninst) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec rec { -;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:225.1-226.50 +;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:228.1-229.50 relation ImmutReachable: `%>>_%%`(fieldval, store, fieldval) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:239.1-242.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:242.1-245.35 rule trans{fv_1 : fieldval, s : store, fv_2 : fieldval, fv' : fieldval}: `%>>_%%`(fv_1, s, fv_2) -- ImmutReachable: `%>>_%%`(fv_1, s, fv') -- ImmutReachable: `%>>_%%`(fv', s, fv_2) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:244.1-247.20 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:247.1-250.20 rule `ref.struct`{a : addr, s : store, i : nat, `ft*` : fieldtype*, zt : storagetype}: `%>>_%%`(`REF.STRUCT_ADDR`_fieldval(a), s, s.STRUCTS_store[a].FIELDS_structinst[i]) -- Expand: `%~~%`(s.STRUCTS_store[a].TYPE_structinst, STRUCT_comptype(`%`_list(ft*{ft <- `ft*`},))) -- if (ft*{ft <- `ft*`}[i] = `%%`_fieldtype(?(), zt)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:249.1-251.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:252.1-254.42 rule `ref.array`{a : addr, s : store, i : nat, zt : storagetype}: `%>>_%%`(`REF.ARRAY_ADDR`_fieldval(a), s, s.ARRAYS_store[a].FIELDS_arrayinst[i]) -- Expand: `%~~%`(s.ARRAYS_store[a].TYPE_arrayinst, ARRAY_comptype(`%%`_fieldtype(?(), zt))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:253.1-254.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.44 rule `ref.exn`{a : addr, s : store, i : nat}: `%>>_%%`(`REF.EXN_ADDR`_fieldval(a), s, (s.EXNS_store[a].FIELDS_exninst[i] : val <: fieldval)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.28 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:259.1-260.28 rule `ref.extern`{ref : ref, s : store}: `%>>_%%`(`REF.EXTERN`_fieldval(ref), s, (ref : ref <: fieldval)) } @@ -8607,16 +8626,16 @@ grammar Binstr : instr prod 0x0F => RETURN_instr ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:46.5-46.30 prod{x : idx} {{0x10} {x:Bfuncidx}} => CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.60 - prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.53 + prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, y) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:48.5-48.37 prod{x : idx} {{0x12} {x:Bfuncidx}} => RETURN_CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.67 - prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.41 - prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(_IDX_typeuse(x)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.48 - prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.60 + prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, y) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.34 + prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(x) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.41 + prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:52.5-52.81 prod{bt : blocktype, `c*` : catch*, `in*` : instr*} {{0x1F} {bt:Bblocktype} {c*{c <- `c*`}:Blist(syntax catch, grammar Bcatch)} {in:Binstr*{in <- `in*`}} {0x0B}} => TRY_TABLE_instr(bt, `%`_list(c*{c <- `c*`},), in*{in <- `in*`}) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:53.5-53.37 @@ -10604,18 +10623,18 @@ grammar Tplaininstr_(I : I) : instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"call"} {x:Tfuncidx_(I)}} => CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod "return" => RETURN_instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"return_call"} {x:Tfuncidx_(I)}} => RETURN_CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"throw"} {x:Ttagidx_(I)}} => THROW_instr(x) @@ -13930,7 +13949,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-142.9 syntax instr = | NOP | UNREACHABLE @@ -13947,12 +13966,12 @@ syntax instr = | BR_ON_CAST(labelidx : labelidx, reftype : reftype, reftype : reftype) | BR_ON_CAST_FAIL(labelidx : labelidx, reftype : reftype, reftype : reftype) | CALL(funcidx) - | CALL_REF(typeuse) - | CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | CALL_REF(typeidx) + | CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | RETURN | RETURN_CALL(funcidx) - | RETURN_CALL_REF(typeuse) - | RETURN_CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | RETURN_CALL_REF(typeidx) + | RETURN_CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | THROW(tagidx) | THROW_REF | TRY_TABLE(blocktype : blocktype, list(syntax catch), `instr*` : instr*) @@ -14050,6 +14069,9 @@ syntax instr = | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) + | CALL_ADDR(funcaddr) + | RETURN_CALL_ADDR(funcaddr) + | THROW_ADDR(exnaddr) | TRAP } @@ -14140,17 +14162,17 @@ def $free_instr(instr : instr) : free ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:457.1-457.55 def $free_instr{funcidx : funcidx}(CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:458.1-458.59 - def $free_instr{typeuse : typeuse}(CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:459.1-460.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:461.1-461.29 def $free_instr(RETURN_instr) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS [], TAGS []} ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:462.1-462.62 def $free_instr{funcidx : funcidx}(RETURN_CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:463.1-463.66 - def $free_instr{typeuse : typeuse}(RETURN_CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(RETURN_CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:464.1-465.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(RETURN_CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(RETURN_CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:467.1-467.53 def $free_instr{tagidx : tagidx}(THROW_instr(tagidx)) = $free_tagidx(tagidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:468.1-468.32 @@ -15361,12 +15383,12 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:119.1-121.45 rule call_ref{C : context, x : idx, `t_1*` : valtype*, `t_2*` : valtype*}: - `%|-%:%`(C, CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:123.1-127.45 rule call_indirect{C : context, x : idx, y : idx, `t_1*` : valtype*, at : addrtype, `t_2*` : valtype*, lim : limits, rt : reftype}: - `%|-%:%`(C, CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) -- Expand: `%~~%`(C.TYPES_context[y!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -15387,7 +15409,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:143.1-148.42 rule return_call_ref{C : context, x : idx, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) @@ -15395,7 +15417,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:151.1-159.42 rule return_call_indirect{C : context, x : idx, y : idx, `t_3*` : valtype*, `t_1*` : valtype*, at : addrtype, `t_4*` : valtype*, lim : limits, rt : reftype, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) -- Expand: `%~~%`(C.TYPES_context[y!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -17306,7 +17328,7 @@ syntax vec = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(val*) - | `(REF.EXN_ADDR%)THROW_REF`(exnaddr) + | THROW_ADDR(exnaddr) | TRAP ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -17450,13 +17472,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:190.1-190.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.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:198.1-198.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17464,13 +17486,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.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:202.1-202.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17478,13 +17500,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.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:206.1-206.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17492,13 +17514,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.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:210.1-210.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17506,13 +17528,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.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:214.1-214.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -17983,12 +18005,12 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule call_indirect{x : idx, yy : typeuse}: - `%~>%`([CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) CALL_REF_instr(yy)]) + rule call_indirect{x : idx, y : idx}: + `%~>%`([CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule return_call_indirect{x : idx, yy : typeuse}: - `%~>%`([RETURN_CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) RETURN_CALL_REF_instr(yy)]) + rule return_call_indirect{x : idx, y : idx}: + `%~>%`([RETURN_CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) RETURN_CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `frame-vals`{n : n, f : frame, `val*` : val*}: @@ -18309,16 +18331,20 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) + `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [CALL_ADDR_instr(a)]) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(x)]), [TRAP_instr]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(x)]), [CALL_ADDR_instr(a)]) ;; ../../../../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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) + rule call_addr{z : state, n : n, `val*` : val*, a : addr, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) -- if ($funcinst(z)[a] = fi) -- Expand: `%~~%`(fi.TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`},), `%`_resulttype(t_2^m{t_2 <- `t_2*`},))) -- if (fi.CODE_funcinst = FUNC_funccode(x, LOCAL_local(t)*{t <- `t*`}, instr*{instr <- `instr*`})) @@ -18326,24 +18352,28 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule return_call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) + `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) + rule `return_call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr RETURN_CALL_REF_instr(x)]), [TRAP_instr]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `return_call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, yy : typeuse, `instr*` : 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)]) + rule `return_call_addr-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - 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]) + rule `return_call_addr-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../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*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]) + rule `return_call_addr-frame`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]) -- 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 @@ -18351,45 +18381,49 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a)] ++ [THROW_REF_instr] ++ instr*{instr <- `instr*`}), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_ref-addr`{z : state, a : addr}: + `%~>%`(`%;%`_config(z, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]), [THROW_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `throw_addr-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [THROW_ADDR_instr(a)] ++ instr*{instr <- `instr*`}), [THROW_ADDR_instr(a)]) -- if ((val*{val <- `val*`} =/= []) \/ (instr*{instr <- `instr*`} =/= [])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-label`{z : state, n : n, `instr'*` : instr*, a : addr}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-label`{z : state, n : n, `instr'*` : instr*, a : addr}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-frame`{z : state, n : n, f : frame, a : addr}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-frame`{z : state, n : n, f : frame, a : addr}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-empty`{z : state, n : n, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-handler-empty`{z : state, n : n, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) + rule `throw_addr-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [BR_instr(l)]) + rule `throw_addr-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]) + rule `throw_addr-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec @@ -18856,131 +18890,131 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%`_config(`%;%`_state(s, f), [`FRAME_%{%}%`_instr(n, f', instr*{instr <- `instr*`})]), `%;%`_config(`%;%`_state(s', f), [`FRAME_%{%}%`_instr(n, f'', instr'*{instr' <- `instr'*`})])) -- Step: `%~>%`(`%;%`_config(`%;%`_state(s, f'), instr*{instr <- `instr*`}), `%;%`_config(`%;%`_state(s', f''), instr'*{instr' <- `instr'*`})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:227.1-231.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:232.1-236.49 rule throw{z : state, n : n, `val*` : val*, x : idx, exn : exninst, a : addr, `t*` : valtype*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])) + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [THROW_ADDR_instr(a)])) -- Expand: `%~~%`($as_deftype($tag(z, x).TYPE_taginst), `FUNC%->%`_comptype(`%`_resulttype(t^n{t <- `t*`},), `%`_resulttype([],))) -- if (a = |$exninst(z)|) -- if (exn = {TAG $tagaddr(z)[x!`%`_idx.0], FIELDS val^n{val <- `val*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:305.1-306.56 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:313.1-314.56 rule `local.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `LOCAL.SET`_instr(x)]), `%;%`_config($with_local(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:318.1-319.58 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:326.1-327.58 rule `global.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `GLOBAL.SET`_instr(x)]), `%;%`_config($with_global(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:332.1-334.33 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:340.1-342.33 rule `table.set-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (i!`%`_num_.0 >= |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:336.1-338.32 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:344.1-346.32 rule `table.set-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config($with_table(z, x, i!`%`_num_.0, ref), [])) -- if (i!`%`_num_.0 < |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:347.1-350.46 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:355.1-358.46 rule `table.grow-succeed`{z : state, ref : ref, at : addrtype, n : n, x : idx, ti : tableinst}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config($with_tableinst(z, x, ti), [CONST_instr((at : addrtype <: numtype), `%`_num_(|$table(z, x).REFS_tableinst|,))])) -- if (ti = !($growtable($table(z, x), n, ref))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:352.1-353.87 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:360.1-361.87 rule `table.grow-fail`{z : state, ref : ref, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:413.1-414.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:421.1-422.51 rule `elem.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`ELEM.DROP`_instr(x)]), `%;%`_config($with_elem(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:497.1-500.60 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:505.1-508.60 rule `store-num-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:502.1-506.29 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:510.1-514.29 rule `store-num-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $nbytes_(nt, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:508.1-511.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:516.1-519.52 rule `store-pack-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:513.1-517.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:521.1-525.52 rule `store-pack-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $ibytes_(n, $wrap__($size((Inn : Inn <: numtype)), n, c))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:519.1-522.63 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:527.1-530.63 rule `vstore-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:524.1-527.31 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:532.1-535.31 rule `vstore-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $vbytes_(V128_vectype, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:530.1-533.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:538.1-541.52 rule `vstore_lane-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:535.1-540.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:543.1-548.49 rule `vstore_lane-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx, `b*` : byte*, Jnn : Jnn, M : M}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (N = $jsize(Jnn)) -- if ((M!`%`_M.0 : nat <:> rat) = ((128 : nat <:> rat) / (N : nat <:> rat))) -- if (b*{b <- `b*`} = $ibytes_(N, `%`_iN($lanes_(`%X%`_shape((Jnn : Jnn <: lanetype), M), c)[j!`%`_laneidx.0]!`%`_lane_.0,))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:549.1-552.37 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:557.1-560.37 rule `memory.grow-succeed`{z : state, at : addrtype, n : n, x : idx, mi : meminst}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config($with_meminst(z, x, mi), [CONST_instr((at : addrtype <: numtype), `%`_num_((((|$mem(z, x).BYTES_meminst| : nat <:> rat) / ((64 * $Ki) : nat <:> rat)) : rat <:> nat),))])) -- if (mi = !($growmem($mem(z, x), n))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:554.1-555.84 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:562.1-563.84 rule `memory.grow-fail`{z : state, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:615.1-616.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:623.1-624.51 rule `data.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`DATA.DROP`_instr(x)]), `%;%`_config($with_data(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:692.1-696.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:700.1-704.65 rule `struct.new`{z : state, n : n, `val*` : val*, x : idx, si : structinst, a : addr, `mut?*` : mut?*, `zt*` : storagetype*}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`STRUCT.NEW`_instr(x)]), `%;%`_config($add_structinst(z, [si]), [`REF.STRUCT_ADDR`_instr(a)])) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)^n{`mut?` <- `mut?*`, zt <- `zt*`},))) -- 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:713.1-714.55 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 rule `struct.set-null`{z : state, val : val, x : idx, i : fieldidx}: `%~>%`(`%;%`_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:716.1-719.46 + ;; ../../../../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 : fieldidx, `zt*` : storagetype*, `mut?*` : mut?*}: `%~>%`(`%;%`_config(z, [`REF.STRUCT_ADDR`_instr(a) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config($with_struct(z, a, i!`%`_fieldidx.0, $packfield_(zt*{zt <- `zt*`}[i!`%`_fieldidx.0], val)), [])) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)*{`mut?` <- `mut?*`, zt <- `zt*`},))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:732.1-737.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:740.1-745.65 rule `array.new_fixed`{z : state, n : n, `val*` : val*, x : idx, ai : arrayinst, a : addr, `mut?` : mut?, zt : storagetype}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n,))]), `%;%`_config($add_arrayinst(z, [ai]), [`REF.ARRAY_ADDR`_instr(a)])) -- 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:777.1-778.66 + ;; ../../../../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:780.1-782.39 + ;; ../../../../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}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (i!`%`_num_.0 >= |$arrayinst(z)[a].FIELDS_arrayinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:784.1-787.44 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:792.1-795.44 rule `array.set-array`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx, zt : storagetype, `mut?` : mut?}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config($with_array(z, a, i!`%`_num_.0, $packfield_(zt, val)), [])) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) @@ -19287,7 +19321,7 @@ def $instantiate(store : store, module : module, externaddr*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec def $invoke(store : store, funcaddr : funcaddr, val*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec - def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(funcaddr) CALL_REF_instr(s.FUNCS_store[funcaddr].TYPE_funcinst : deftype <: typeuse)]) + def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [CALL_ADDR_instr(funcaddr)]) -- Expand: `%~~%`(s.FUNCS_store[funcaddr].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- (Val_ok: `%|-%:%`(s, val, t_1))*{t_1 <- `t_1*`, val <- `val*`} @@ -19627,71 +19661,75 @@ relation Instr_ok2: `%;%|-%:%`(store, context, instr, instrtype) `%;%|-%:%`(s, C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instr_ok: `%|-%:%`(C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-17.43 - rule call_ref{s : store, C : context, yy : typeuse, `t_1*` : valtype*, `t_2*` : valtype*}: - `%;%|-%:%`(s, C, CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:20.1-26.42 - rule return_call_ref{s : store, C : context, yy : typeuse, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%;%|-%:%`(s, C, RETURN_CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) - -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) - -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:28.1-30.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-16.27 rule ref{s : store, C : context, ref : ref, rt : reftype}: `%;%|-%:%`(s, C, (ref : ref <: instr), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([(rt : reftype <: valtype)],))) -- Ref_ok: `%|-%:%`(s, ref, rt) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:32.1-35.68 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:18.1-21.68 rule label{s : store, C : context, n : n, `instr'*` : instr*, `instr*` : instr*, `t*` : valtype*, `t'*` : valtype*, `x'*` : idx*, `x*` : idx*}: `%;%|-%:%`(s, C, `LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr'*{instr' <- `instr'*`}, `%->_%%`_instrtype(`%`_resulttype(t'^n{t' <- `t'*`},), x'*{x' <- `x'*`}, `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [`%`_resulttype(t'^n{t' <- `t'*`},)], RETURN ?(), REFS [], RECS []} +++ C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:37.1-41.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:23.1-27.35 rule frame{s : store, C : context, n : n, f : frame, `instr*` : instr*, `t*` : valtype*, C' : context}: `%;%|-%:%`(s, C, `FRAME_%{%}%`_instr(n, f, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t^n{t <- `t*`},))) -- Frame_ok: `%|-%:%`(s, f, C') -- Expr_ok2: `%;%|-%:%`(s, C', instr*{instr <- `instr*`}, `%`_resulttype(t^n{t <- `t*`},)) -- Resulttype_ok: `%|-%:OK`({TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS [], RECS []}, `%`_resulttype(t^n{t <- `t*`},)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:43.1-46.49 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:29.1-32.49 rule handler{s : store, C : context, n : n, `catch*` : catch*, `instr*` : instr*, `t*` : valtype*, `x*` : idx*}: `%;%|-%:%`(s, C, `HANDLER_%{%}%`_instr(n, catch*{catch <- `catch*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- (Catch_ok: `%|-%:OK`(C, catch))*{catch <- `catch*`} -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:48.1-50.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:34.1-36.50 + rule call_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*}: + `%;%|-%:%`(s, C, CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:39.1-44.42 + rule return_call_addr{s : store, C : context, a : addr, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: + `%;%|-%:%`(s, C, RETURN_CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) + -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:46.1-49.42 + rule throw_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*, exn : exninst}: + `%;%|-%:%`(s, C, THROW_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (s.EXNS_store[a] = exn) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:51.1-53.42 rule trap{s : store, C : context, `t_1*` : valtype*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, TRAP_instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:5.1-6.36 relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:53.1-54.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-57.27 rule empty{s : store, C : context}: `%;%|-%:%`(s, C, [], `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([],))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-60.86 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:59.1-63.86 rule seq{s : store, C : context, instr_1 : instr, `instr_2*` : instr*, `t_1*` : valtype*, `x_1*` : idx*, `x_2*` : idx*, `t_3*` : valtype*, `t_2*` : valtype*, `init*` : init*, `t*` : valtype*}: `%;%|-%:%`(s, C, [instr_1] ++ instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`} ++ x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) -- Instr_ok2: `%;%|-%:%`(s, C, instr_1, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- (if (C.LOCALS_context[x_1!`%`_idx.0] = `%%`_localtype(init, t)))*{init <- `init*`, t <- `t*`, x_1 <- `x_1*`} -- Instrs_ok2: `%;%|-%:%`(s, $with_locals(C, x_1*{x_1 <- `x_1*`}, `%%`_localtype(SET_init, t)*{t <- `t*`}), instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_2*{t_2 <- `t_2*`},), x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:62.1-66.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:65.1-69.33 rule sub{s : store, C : context, `instr*` : instr*, it' : instrtype, it : instrtype}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it') -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it) -- Instrtype_sub: `%|-%<:%`(C, it, it') -- Instrtype_ok: `%|-%:OK`(C, it') - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:69.1-72.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:72.1-75.33 rule frame{s : store, C : context, `instr*` : instr*, `t*` : valtype*, `t_1*` : valtype*, `x*` : idx*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t*{t <- `t*`} ++ t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`} ++ t_2*{t_2 <- `t_2*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -19699,7 +19737,7 @@ relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:7.1-8.36 relation Expr_ok2: `%;%|-%:%`(store, context, expr, resulttype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:75.1-77.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:78.1-80.44 rule _{s : store, C : context, `instr*` : instr*, `t*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%`_resulttype(t*{t <- `t*`},)) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) @@ -19775,30 +19813,30 @@ relation Exninst_ok: `%|-%:OK`(store, exninst) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec rec { -;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:225.1-226.50 +;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:228.1-229.50 relation ImmutReachable: `%>>_%%`(fieldval, store, fieldval) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:239.1-242.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:242.1-245.35 rule trans{fv_1 : fieldval, s : store, fv_2 : fieldval, fv' : fieldval}: `%>>_%%`(fv_1, s, fv_2) -- ImmutReachable: `%>>_%%`(fv_1, s, fv') -- ImmutReachable: `%>>_%%`(fv', s, fv_2) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:244.1-247.20 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:247.1-250.20 rule `ref.struct`{a : addr, s : store, i : nat, `ft*` : fieldtype*, zt : storagetype}: `%>>_%%`(`REF.STRUCT_ADDR`_fieldval(a), s, s.STRUCTS_store[a].FIELDS_structinst[i]) -- Expand: `%~~%`(s.STRUCTS_store[a].TYPE_structinst, STRUCT_comptype(`%`_list(ft*{ft <- `ft*`},))) -- if (ft*{ft <- `ft*`}[i] = `%%`_fieldtype(?(), zt)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:249.1-251.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:252.1-254.42 rule `ref.array`{a : addr, s : store, i : nat, zt : storagetype}: `%>>_%%`(`REF.ARRAY_ADDR`_fieldval(a), s, s.ARRAYS_store[a].FIELDS_arrayinst[i]) -- Expand: `%~~%`(s.ARRAYS_store[a].TYPE_arrayinst, ARRAY_comptype(`%%`_fieldtype(?(), zt))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:253.1-254.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.44 rule `ref.exn`{a : addr, s : store, i : nat}: `%>>_%%`(`REF.EXN_ADDR`_fieldval(a), s, (s.EXNS_store[a].FIELDS_exninst[i] : val <: fieldval)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.28 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:259.1-260.28 rule `ref.extern`{ref : ref, s : store}: `%>>_%%`(`REF.EXTERN`_fieldval(ref), s, (ref : ref <: fieldval)) } @@ -20484,16 +20522,16 @@ grammar Binstr : instr prod 0x0F => RETURN_instr ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:46.5-46.30 prod{x : idx} {{0x10} {x:Bfuncidx}} => CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.60 - prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.53 + prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, y) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:48.5-48.37 prod{x : idx} {{0x12} {x:Bfuncidx}} => RETURN_CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.67 - prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.41 - prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(_IDX_typeuse(x)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.48 - prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.60 + prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, y) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.34 + prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(x) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.41 + prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:52.5-52.81 prod{bt : blocktype, `c*` : catch*, `in*` : instr*} {{0x1F} {bt:Bblocktype} {c*{c <- `c*`}:Blist(syntax catch, grammar Bcatch)} {in:Binstr*{in <- `in*`}} {0x0B}} => TRY_TABLE_instr(bt, `%`_list(c*{c <- `c*`},), in*{in <- `in*`}) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:53.5-53.37 @@ -22481,18 +22519,18 @@ grammar Tplaininstr_(I : I) : instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"call"} {x:Tfuncidx_(I)}} => CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod "return" => RETURN_instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"return_call"} {x:Tfuncidx_(I)}} => RETURN_CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"throw"} {x:Ttagidx_(I)}} => THROW_instr(x) @@ -25807,7 +25845,7 @@ syntax frame = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-139.9 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:133.1-142.9 syntax instr = | NOP | UNREACHABLE @@ -25824,12 +25862,12 @@ syntax instr = | BR_ON_CAST(labelidx : labelidx, reftype : reftype, reftype : reftype) | BR_ON_CAST_FAIL(labelidx : labelidx, reftype : reftype, reftype : reftype) | CALL(funcidx) - | CALL_REF(typeuse) - | CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | CALL_REF(typeidx) + | CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | RETURN | RETURN_CALL(funcidx) - | RETURN_CALL_REF(typeuse) - | RETURN_CALL_INDIRECT(tableidx : tableidx, typeuse : typeuse) + | RETURN_CALL_REF(typeidx) + | RETURN_CALL_INDIRECT(tableidx : tableidx, typeidx : typeidx) | THROW(tagidx) | THROW_REF | TRY_TABLE(blocktype : blocktype, list(syntax catch), `instr*` : instr*) @@ -25927,6 +25965,9 @@ syntax instr = | `LABEL_%{%}%`(n : n, `instr*` : instr*, `instr*` : instr*) | `FRAME_%{%}%`(n : n, frame : frame, `instr*` : instr*) | `HANDLER_%{%}%`(n : n, `catch*` : catch*, `instr*` : instr*) + | CALL_ADDR(funcaddr) + | RETURN_CALL_ADDR(funcaddr) + | THROW_ADDR(exnaddr) | TRAP } @@ -26017,17 +26058,17 @@ def $free_instr(instr : instr) : free ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:457.1-457.55 def $free_instr{funcidx : funcidx}(CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:458.1-458.59 - def $free_instr{typeuse : typeuse}(CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:459.1-460.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:461.1-461.29 def $free_instr(RETURN_instr) = {TYPES [], FUNCS [], GLOBALS [], TABLES [], MEMS [], ELEMS [], DATAS [], LOCALS [], LABELS [], TAGS []} ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:462.1-462.62 def $free_instr{funcidx : funcidx}(RETURN_CALL_instr(funcidx)) = $free_funcidx(funcidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:463.1-463.66 - def $free_instr{typeuse : typeuse}(RETURN_CALL_REF_instr(typeuse)) = $free_typeuse(typeuse) + def $free_instr{typeidx : typeidx}(RETURN_CALL_REF_instr(typeidx)) = $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:464.1-465.53 - def $free_instr{tableidx : tableidx, typeuse : typeuse}(RETURN_CALL_INDIRECT_instr(tableidx, typeuse)) = $free_tableidx(tableidx) +++ $free_typeuse(typeuse) + def $free_instr{tableidx : tableidx, typeidx : typeidx}(RETURN_CALL_INDIRECT_instr(tableidx, typeidx)) = $free_tableidx(tableidx) +++ $free_typeidx(typeidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:467.1-467.53 def $free_instr{tagidx : tagidx}(THROW_instr(tagidx)) = $free_tagidx(tagidx) ;; ../../../../specification/wasm-latest/1.3-syntax.instructions.spectec:468.1-468.32 @@ -27276,13 +27317,13 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:119.1-121.45 rule call_ref{C : context, x : idx, `t_1*` : valtype*, `t_2*` : valtype*}: - `%|-%:%`(C, CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (x!`%`_idx.0 < |C.TYPES_context|) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:123.1-127.45 rule call_indirect{C : context, x : idx, y : idx, `t_1*` : valtype*, at : addrtype, `t_2*` : valtype*, lim : limits, rt : reftype}: - `%|-%:%`(C, CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + `%|-%:%`(C, CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (x!`%`_idx.0 < |C.TABLES_context|) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) @@ -27306,7 +27347,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:143.1-148.42 rule return_call_ref{C : context, x : idx, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_REF_instr(_IDX_typeuse(x)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_REF_instr(x), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), _IDX_heaptype(x))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- if (x!`%`_idx.0 < |C.TYPES_context|) -- Expand: `%~~%`(C.TYPES_context[x!`%`_idx.0], `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) @@ -27315,7 +27356,7 @@ relation Instr_ok: `%|-%:%`(context, instr, instrtype) ;; ../../../../specification/wasm-latest/2.3-validation.instructions.spectec:151.1-159.42 rule return_call_indirect{C : context, x : idx, y : idx, `t_3*` : valtype*, `t_1*` : valtype*, at : addrtype, `t_4*` : valtype*, lim : limits, rt : reftype, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + `%|-%:%`(C, RETURN_CALL_INDIRECT_instr(x, y), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [(at : addrtype <: valtype)],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) -- if (x!`%`_idx.0 < |C.TABLES_context|) -- if (C.TABLES_context[x!`%`_idx.0] = `%%%`_tabletype(at, lim, rt)) -- Reftype_sub: `%|-%<:%`(C, rt, REF_reftype(?(NULL_null), FUNC_heaptype)) @@ -29310,7 +29351,7 @@ syntax vec = ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec syntax result = | _VALS(val*) - | `(REF.EXN_ADDR%)THROW_REF`(exnaddr) + | THROW_ADDR(exnaddr) | TRAP ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec @@ -29454,13 +29495,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:190.1-190.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.86 def $tagsxa(externaddr*) : tagaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:199.1-199.23 def $tagsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.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:198.1-198.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.57 def $tagsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tagsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -29468,13 +29509,13 @@ def $tagsxa(externaddr*) : tagaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:191.1-191.89 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.89 def $globalsxa(externaddr*) : globaladdr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:200.1-200.26 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:203.1-203.26 def $globalsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:201.1-201.51 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.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:202.1-202.63 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.63 def $globalsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $globalsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -29482,13 +29523,13 @@ def $globalsxa(externaddr*) : globaladdr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:192.1-192.86 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:195.1-195.86 def $memsxa(externaddr*) : memaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:204.1-204.23 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:207.1-207.23 def $memsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:205.1-205.42 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.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:206.1-206.57 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.57 def $memsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $memsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -29496,13 +29537,13 @@ def $memsxa(externaddr*) : memaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:193.1-193.88 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:196.1-196.88 def $tablesxa(externaddr*) : tableaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:208.1-208.25 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:211.1-211.25 def $tablesxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:209.1-209.48 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.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:210.1-210.61 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.61 def $tablesxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $tablesxa(xa*{xa <- `xa*`}) -- otherwise } @@ -29510,13 +29551,13 @@ def $tablesxa(externaddr*) : tableaddr* ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec rec { -;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:194.1-194.87 +;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:197.1-197.87 def $funcsxa(externaddr*) : funcaddr* - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:212.1-212.24 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:215.1-215.24 def $funcsxa([]) = [] - ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:213.1-213.45 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:216.1-216.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:214.1-214.59 + ;; ../../../../specification/wasm-latest/4.0-execution.configurations.spectec:217.1-217.59 def $funcsxa{externaddr : externaddr, `xa*` : externaddr*}([externaddr] ++ xa*{xa <- `xa*`}) = $funcsxa(xa*{xa <- `xa*`}) -- otherwise } @@ -29996,12 +30037,12 @@ relation Step_pure: `%~>%`(instr*, instr*) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule call_indirect{x : idx, yy : typeuse}: - `%~>%`([CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) CALL_REF_instr(yy)]) + rule call_indirect{x : idx, y : idx}: + `%~>%`([CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule return_call_indirect{x : idx, yy : typeuse}: - `%~>%`([RETURN_CALL_INDIRECT_instr(x, yy)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), (yy : typeuse <: heaptype))) RETURN_CALL_REF_instr(yy)]) + rule return_call_indirect{x : idx, y : idx}: + `%~>%`([RETURN_CALL_INDIRECT_instr(x, y)], [`TABLE.GET`_instr(x) `REF.CAST`_instr(REF_reftype(?(NULL_null), _IDX_heaptype(y))) RETURN_CALL_REF_instr(y)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule `frame-vals`{n : n, f : frame, `val*` : val*}: @@ -30333,18 +30374,21 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) - -- if (a < |$funcinst(z)|) + `%~>%`(`%;%`_config(z, [CALL_instr(x)]), [CALL_ADDR_instr(a)]) -- if (x!`%`_idx.0 < |$moduleinst(z).FUNCS_moduleinst|) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `call_ref-null`{z : state, yy : typeuse}: - `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(yy)]), [TRAP_instr]) + rule `call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr CALL_REF_instr(x)]), [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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) + rule `call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(x)]), [CALL_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule call_addr{z : state, n : n, `val*` : val*, a : addr, m : m, f : frame, `instr*` : instr*, fi : funcinst, `t_1*` : valtype*, `t_2*` : valtype*, x : idx, `t*` : valtype*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]), [`FRAME_%{%}%`_instr(m, f, [`LABEL_%{%}%`_instr(m, [], instr*{instr <- `instr*`})])]) -- if (a < |$funcinst(z)|) -- if ($funcinst(z)[a] = fi) -- Expand: `%~~%`(fi.TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`},), `%`_resulttype(t_2^m{t_2 <- `t_2*`},))) @@ -30353,26 +30397,29 @@ relation Step_read: `%~>%`(config, instr*) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec rule return_call{z : state, x : idx, a : addr}: - `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr($funcinst(z)[a].TYPE_funcinst : deftype <: typeuse)]) - -- if (a < |$funcinst(z)|) + `%~>%`(`%;%`_config(z, [RETURN_CALL_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) -- if (x!`%`_idx.0 < |$moduleinst(z).FUNCS_moduleinst|) -- if ($moduleinst(z).FUNCS_moduleinst[x!`%`_idx.0] = a) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, yy : typeuse, `instr*` : instr*}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_REF_instr(yy)]) + rule `return_call_ref-null`{z : state, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.NULL_ADDR`_instr RETURN_CALL_REF_instr(x)]), [TRAP_instr]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `return_call_ref-func`{z : state, a : addr, x : idx}: + `%~>%`(`%;%`_config(z, [`REF.FUNC_ADDR`_instr(a) RETURN_CALL_REF_instr(x)]), [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `return_call_ref-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, yy : typeuse, `instr*` : 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)]) + rule `return_call_addr-label`{z : state, k : n, `instr'*` : instr*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(k, instr'*{instr' <- `instr'*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - 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]) + rule `return_call_addr-handler`{z : state, k : n, `catch*` : catch*, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(k, catch*{catch <- `catch*`}, (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)*{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)]) ;; ../../../../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*}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a)] ++ [RETURN_CALL_REF_instr(yy)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(a) CALL_REF_instr(yy)]) + rule `return_call_addr-frame`{z : state, k : n, f : frame, `val'*` : val*, n : n, `val*` : val*, a : addr, `instr*` : instr*, `t_1*` : valtype*, m : m, `t_2*` : valtype*}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(k, f, (val' : val <: instr)*{val' <- `val'*`} ++ (val : val <: instr)^n{val <- `val*`} ++ [RETURN_CALL_ADDR_instr(a)] ++ instr*{instr <- `instr*`})]), (val : val <: instr)^n{val <- `val*`} ++ [CALL_ADDR_instr(a)]) -- if (a < |$funcinst(z)|) -- Expand: `%~~%`($funcinst(z)[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1^n{t_1 <- `t_1*`},), `%`_resulttype(t_2^m{t_2 <- `t_2*`},))) @@ -30381,49 +30428,53 @@ relation Step_read: `%~>%`(config, instr*) `%~>%`(`%;%`_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*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a)] ++ [THROW_REF_instr] ++ instr*{instr <- `instr*`}), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_ref-addr`{z : state, a : addr}: + `%~>%`(`%;%`_config(z, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]), [THROW_ADDR_instr(a)]) + + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec + rule `throw_addr-instrs`{z : state, `val*` : val*, a : addr, `instr*` : instr*}: + `%~>%`(`%;%`_config(z, (val : val <: instr)*{val <- `val*`} ++ [THROW_ADDR_instr(a)] ++ instr*{instr <- `instr*`}), [THROW_ADDR_instr(a)]) -- if ((val*{val <- `val*`} =/= []) \/ (instr*{instr <- `instr*`} =/= [])) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-label`{z : state, n : n, `instr'*` : instr*, a : addr}: - `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-label`{z : state, n : n, `instr'*` : instr*, a : addr}: + `%~>%`(`%;%`_config(z, [`LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-frame`{z : state, n : n, f : frame, a : addr}: - `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-frame`{z : state, n : n, f : frame, a : addr}: + `%~>%`(`%;%`_config(z, [`FRAME_%{%}%`_instr(n, f, [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-empty`{z : state, n : n, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr]) + rule `throw_addr-handler-empty`{z : state, n : n, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [], [THROW_ADDR_instr(a)])]), [THROW_ADDR_instr(a)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) + rule `throw_addr-handler-catch`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [BR_instr(l)]) -- if (a < |$exninst(z)|) -- if (x!`%`_idx.0 < |$tagaddr(z)|) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_ref`{z : state, n : n, x : idx, l : labelidx, `catch'*` : catch*, a : addr, `val*` : val*}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_REF_catch(x, l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), (val : val <: instr)*{val <- `val*`} ++ [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) -- if (a < |$exninst(z)|) -- if (x!`%`_idx.0 < |$tagaddr(z)|) -- if ($exninst(z)[a].TAG_exninst = $tagaddr(z)[x!`%`_idx.0]) -- if (val*{val <- `val*`} = $exninst(z)[a].FIELDS_exninst) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [BR_instr(l)]) + rule `throw_addr-handler-catch_all`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) + rule `throw_addr-handler-catch_all_ref`{z : state, n : n, l : labelidx, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [CATCH_ALL_REF_catch(l)] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`REF.EXN_ADDR`_instr(a) BR_instr(l)]) ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec - rule `throw_ref-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: - `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])]) + rule `throw_addr-handler-next`{z : state, n : n, catch : catch, `catch'*` : catch*, a : addr}: + `%~>%`(`%;%`_config(z, [`HANDLER_%{%}%`_instr(n, [catch] ++ catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]), [`HANDLER_%{%}%`_instr(n, catch'*{catch' <- `catch'*`}, [THROW_ADDR_instr(a)])]) -- otherwise ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec @@ -30909,82 +30960,82 @@ relation Step: `%~>%`(config, config) `%~>%`(`%;%`_config(`%;%`_state(s, f), [`FRAME_%{%}%`_instr(n, f', instr*{instr <- `instr*`})]), `%;%`_config(`%;%`_state(s', f), [`FRAME_%{%}%`_instr(n, f'', instr'*{instr' <- `instr'*`})])) -- Step: `%~>%`(`%;%`_config(`%;%`_state(s, f'), instr*{instr <- `instr*`}), `%;%`_config(`%;%`_state(s', f''), instr'*{instr' <- `instr'*`})) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:227.1-231.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:232.1-236.49 rule throw{z : state, n : n, `val*` : val*, x : idx, exn : exninst, a : addr, `t*` : valtype*}: - `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [`REF.EXN_ADDR`_instr(a) THROW_REF_instr])) + `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [THROW_instr(x)]), `%;%`_config($add_exninst(z, [exn]), [THROW_ADDR_instr(a)])) -- Expand: `%~~%`($as_deftype($tag(z, x).TYPE_taginst), `FUNC%->%`_comptype(`%`_resulttype(t^n{t <- `t*`},), `%`_resulttype([],))) -- if (a = |$exninst(z)|) -- if (x!`%`_idx.0 < |$tagaddr(z)|) -- if (exn = {TAG $tagaddr(z)[x!`%`_idx.0], FIELDS val^n{val <- `val*`}}) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:305.1-306.56 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:313.1-314.56 rule `local.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `LOCAL.SET`_instr(x)]), `%;%`_config($with_local(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:318.1-319.58 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:326.1-327.58 rule `global.set`{z : state, val : val, x : idx}: `%~>%`(`%;%`_config(z, [(val : val <: instr) `GLOBAL.SET`_instr(x)]), `%;%`_config($with_global(z, x, val), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:332.1-334.33 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:340.1-342.33 rule `table.set-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (i!`%`_num_.0 >= |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:336.1-338.32 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:344.1-346.32 rule `table.set-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), ref : ref, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) (ref : ref <: instr) `TABLE.SET`_instr(x)]), `%;%`_config($with_table(z, x, i!`%`_num_.0, ref), [])) -- if (i!`%`_num_.0 < |$table(z, x).REFS_tableinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:347.1-350.46 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:355.1-358.46 rule `table.grow-succeed`{z : state, ref : ref, at : addrtype, n : n, x : idx, ti : tableinst}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config($with_tableinst(z, x, ti), [CONST_instr((at : addrtype <: numtype), `%`_num_(|$table(z, x).REFS_tableinst|,))])) -- if ($growtable($table(z, x), n, ref) =/= ?()) -- if (ti = !($growtable($table(z, x), n, ref))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:352.1-353.87 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:360.1-361.87 rule `table.grow-fail`{z : state, ref : ref, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [(ref : ref <: instr) CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `TABLE.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:413.1-414.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:421.1-422.51 rule `elem.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`ELEM.DROP`_instr(x)]), `%;%`_config($with_elem(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:497.1-500.60 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:505.1-508.60 rule `store-num-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:502.1-506.29 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:510.1-514.29 rule `store-num-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), nt : numtype, c : num_(nt), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr(nt, c) STORE_instr(nt, ?(), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($size(nt) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $nbytes_(nt, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:508.1-511.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:516.1-519.52 rule `store-pack-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:513.1-517.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:521.1-525.52 rule `store-pack-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), Inn : Inn, c : num_((Inn : Inn <: numtype)), n : n, x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) CONST_instr((Inn : Inn <: numtype), c) STORE_instr((Inn : Inn <: numtype), ?(`%`_storeop_(`%`_sz(n,),)), x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((n : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $ibytes_(n, $wrap__($size((Inn : Inn <: numtype)), n, c))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:519.1-522.63 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:527.1-530.63 rule `vstore-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:524.1-527.31 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:532.1-535.31 rule `vstore-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), x : idx, ao : memarg, `b*` : byte*}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_instr(V128_vectype, x, ao)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), ((($vsize(V128_vectype) : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (b*{b <- `b*`} = $vbytes_(V128_vectype, c)) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:530.1-533.52 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:538.1-541.52 rule `vstore_lane-oob`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config(z, [TRAP_instr])) -- if (((i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0) + (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat)) > |$mem(z, x).BYTES_meminst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:535.1-540.49 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:543.1-548.49 rule `vstore_lane-val`{z : state, at : addrtype, i : num_((at : addrtype <: numtype)), c : vec_(V128_Vnn), N : N, x : idx, ao : memarg, j : laneidx, `b*` : byte*, Jnn : Jnn, M : M}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), i) VCONST_instr(V128_vectype, c) VSTORE_LANE_instr(V128_vectype, `%`_sz(N,), x, ao, j)]), `%;%`_config($with_mem(z, x, (i!`%`_num_.0 + ao.OFFSET_memarg!`%`_u64.0), (((N : nat <:> rat) / (8 : nat <:> rat)) : rat <:> nat), b*{b <- `b*`}), [])) -- if (N = $jsize(Jnn)) @@ -30992,54 +31043,54 @@ relation Step: `%~>%`(config, config) -- if (j!`%`_laneidx.0 < |$lanes_(`%X%`_shape((Jnn : Jnn <: lanetype), M), c)|) -- if (b*{b <- `b*`} = $ibytes_(N, `%`_iN($lanes_(`%X%`_shape((Jnn : Jnn <: lanetype), M), c)[j!`%`_laneidx.0]!`%`_lane_.0,))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:549.1-552.37 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:557.1-560.37 rule `memory.grow-succeed`{z : state, at : addrtype, n : n, x : idx, mi : meminst}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config($with_meminst(z, x, mi), [CONST_instr((at : addrtype <: numtype), `%`_num_((((|$mem(z, x).BYTES_meminst| : nat <:> rat) / ((64 * $Ki) : nat <:> rat)) : rat <:> nat),))])) -- if ($growmem($mem(z, x), n) =/= ?()) -- if (mi = !($growmem($mem(z, x), n))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:554.1-555.84 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:562.1-563.84 rule `memory.grow-fail`{z : state, at : addrtype, n : n, x : idx}: `%~>%`(`%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_(n,)) `MEMORY.GROW`_instr(x)]), `%;%`_config(z, [CONST_instr((at : addrtype <: numtype), `%`_num_($inv_signed_($size((at : addrtype <: numtype)), - (1 : nat <:> int)),))])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:615.1-616.51 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:623.1-624.51 rule `data.drop`{z : state, x : idx}: `%~>%`(`%;%`_config(z, [`DATA.DROP`_instr(x)]), `%;%`_config($with_data(z, x, []), [])) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:692.1-696.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:700.1-704.65 rule `struct.new`{z : state, n : n, `val*` : val*, x : idx, si : structinst, a : addr, `mut?*` : mut?*, `zt*` : storagetype*}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`STRUCT.NEW`_instr(x)]), `%;%`_config($add_structinst(z, [si]), [`REF.STRUCT_ADDR`_instr(a)])) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)^n{`mut?` <- `mut?*`, zt <- `zt*`},))) -- 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:713.1-714.55 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:721.1-722.55 rule `struct.set-null`{z : state, val : val, x : idx, i : fieldidx}: `%~>%`(`%;%`_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:716.1-719.46 + ;; ../../../../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 : fieldidx, `zt*` : storagetype*, `mut?*` : mut?*}: `%~>%`(`%;%`_config(z, [`REF.STRUCT_ADDR`_instr(a) (val : val <: instr) `STRUCT.SET`_instr(x, i)]), `%;%`_config($with_struct(z, a, i!`%`_fieldidx.0, $packfield_(zt*{zt <- `zt*`}[i!`%`_fieldidx.0], val)), [])) -- if (i!`%`_fieldidx.0 < |zt*{zt <- `zt*`}|) -- Expand: `%~~%`($type(z, x), STRUCT_comptype(`%`_list(`%%`_fieldtype(mut?{mut <- `mut?`}, zt)*{`mut?` <- `mut?*`, zt <- `zt*`},))) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:732.1-737.65 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:740.1-745.65 rule `array.new_fixed`{z : state, n : n, `val*` : val*, x : idx, ai : arrayinst, a : addr, `mut?` : mut?, zt : storagetype}: `%~>%`(`%;%`_config(z, (val : val <: instr)^n{val <- `val*`} ++ [`ARRAY.NEW_FIXED`_instr(x, `%`_u32(n,))]), `%;%`_config($add_arrayinst(z, [ai]), [`REF.ARRAY_ADDR`_instr(a)])) -- 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:777.1-778.66 + ;; ../../../../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:780.1-782.39 + ;; ../../../../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}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config(z, [TRAP_instr])) -- if (a < |$arrayinst(z)|) -- if (i!`%`_num_.0 >= |$arrayinst(z)[a].FIELDS_arrayinst|) - ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:784.1-787.44 + ;; ../../../../specification/wasm-latest/4.3-execution.instructions.spectec:792.1-795.44 rule `array.set-array`{z : state, a : addr, i : num_(I32_numtype), val : val, x : idx, zt : storagetype, `mut?` : mut?}: `%~>%`(`%;%`_config(z, [`REF.ARRAY_ADDR`_instr(a) CONST_instr(I32_numtype, i) (val : val <: instr) `ARRAY.SET`_instr(x)]), `%;%`_config($with_array(z, a, i!`%`_num_.0, $packfield_(zt, val)), [])) -- Expand: `%~~%`($type(z, x), ARRAY_comptype(`%%`_fieldtype(mut?{mut <- `mut?`}, zt))) @@ -31346,7 +31397,7 @@ def $instantiate(store : store, module : module, externaddr*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec def $invoke(store : store, funcaddr : funcaddr, val*) : config ;; ../../../../specification/wasm-latest/4.4-execution.modules.spectec - def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [`REF.FUNC_ADDR`_instr(funcaddr) CALL_REF_instr(s.FUNCS_store[funcaddr].TYPE_funcinst : deftype <: typeuse)]) + def $invoke{s : store, funcaddr : funcaddr, `val*` : val*, `t_1*` : valtype*, `t_2*` : valtype*}(s, funcaddr, val*{val <- `val*`}) = `%;%`_config(`%;%`_state(s, {LOCALS [], MODULE {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], EXPORTS []}}), (val : val <: instr)*{val <- `val*`} ++ [CALL_ADDR_instr(funcaddr)]) -- Expand: `%~~%`(s.FUNCS_store[funcaddr].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- (Val_ok: `%|-%:%`(s, val, t_1))*{t_1 <- `t_1*`, val <- `val*`} @@ -31699,57 +31750,64 @@ relation Instr_ok2: `%;%|-%:%`(store, context, instr, instrtype) `%;%|-%:%`(s, C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instr_ok: `%|-%:%`(C, instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-17.43 - rule call_ref{s : store, C : context, yy : typeuse, `t_1*` : valtype*, `t_2*` : valtype*}: - `%;%|-%:%`(s, C, CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:20.1-26.42 - rule return_call_ref{s : store, C : context, yy : typeuse, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: - `%;%|-%:%`(s, C, RETURN_CALL_REF_instr(yy), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`} ++ [REF_valtype(?(NULL_null), (yy : typeuse <: heaptype))],), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - -- Typeuse_ok: `%|-%:OK`(C, yy) - -- Expand_use: `%~~_%%`(yy, C, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) - -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) - -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) - -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) - - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:28.1-30.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:14.1-16.27 rule ref{s : store, C : context, ref : ref, rt : reftype}: `%;%|-%:%`(s, C, (ref : ref <: instr), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([(rt : reftype <: valtype)],))) -- Ref_ok: `%|-%:%`(s, ref, rt) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:32.1-35.68 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:18.1-21.68 rule label{s : store, C : context, n : n, `instr'*` : instr*, `instr*` : instr*, `t*` : valtype*, `t'*` : valtype*, `x'*` : idx*, `x*` : idx*}: `%;%|-%:%`(s, C, `LABEL_%{%}%`_instr(n, instr'*{instr' <- `instr'*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr'*{instr' <- `instr'*`}, `%->_%%`_instrtype(`%`_resulttype(t'^n{t' <- `t'*`},), x'*{x' <- `x'*`}, `%`_resulttype(t*{t <- `t*`},))) -- Instrs_ok2: `%;%|-%:%`(s, {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [`%`_resulttype(t'^n{t' <- `t'*`},)], RETURN ?(), REFS [], RECS []} +++ C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:37.1-41.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:23.1-27.35 rule frame{s : store, C : context, n : n, f : frame, `instr*` : instr*, `t*` : valtype*, C' : context}: `%;%|-%:%`(s, C, `FRAME_%{%}%`_instr(n, f, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t^n{t <- `t*`},))) -- Frame_ok: `%|-%:%`(s, f, C') -- Expr_ok2: `%;%|-%:%`(s, C', instr*{instr <- `instr*`}, `%`_resulttype(t^n{t <- `t*`},)) -- Resulttype_ok: `%|-%:OK`({TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS [], LABELS [], RETURN ?(), REFS [], RECS []}, `%`_resulttype(t^n{t <- `t*`},)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:43.1-46.49 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:29.1-32.49 rule handler{s : store, C : context, n : n, `catch*` : catch*, `instr*` : instr*, `t*` : valtype*, `x*` : idx*}: `%;%|-%:%`(s, C, `HANDLER_%{%}%`_instr(n, catch*{catch <- `catch*`}, instr*{instr <- `instr*`}), `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) -- (Catch_ok: `%|-%:OK`(C, catch))*{catch <- `catch*`} -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:48.1-50.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:34.1-36.50 + rule call_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*}: + `%;%|-%:%`(s, C, CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (a < |s.FUNCS_store|) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:39.1-44.42 + rule return_call_addr{s : store, C : context, a : addr, `t_3*` : valtype*, `t_1*` : valtype*, `t_4*` : valtype*, `t_2*` : valtype*, `t'_2*` : valtype*}: + `%;%|-%:%`(s, C, RETURN_CALL_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`} ++ t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + -- if (a < |s.FUNCS_store|) + -- Expand: `%~~%`(s.FUNCS_store[a].TYPE_funcinst, `FUNC%->%`_comptype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (C.RETURN_context = ?(`%`_resulttype(t'_2*{t'_2 <- `t'_2*`},))) + -- Resulttype_sub: `%|-%<:%`(C, `%`_resulttype(t_2*{t_2 <- `t_2*`},), `%`_resulttype(t'_2*{t'_2 <- `t'_2*`},)) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_3*{t_3 <- `t_3*`},), [], `%`_resulttype(t_4*{t_4 <- `t_4*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:46.1-49.42 + rule throw_addr{s : store, C : context, a : addr, `t_1*` : valtype*, `t_2*` : valtype*, exn : exninst}: + `%;%|-%:%`(s, C, THROW_ADDR_instr(a), `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + -- if (a < |s.EXNS_store|) + -- if (s.EXNS_store[a] = exn) + -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) + + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:51.1-53.42 rule trap{s : store, C : context, `t_1*` : valtype*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, TRAP_instr, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) -- Instrtype_ok: `%|-%:OK`(C, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), [], `%`_resulttype(t_2*{t_2 <- `t_2*`},))) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:5.1-6.36 relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:53.1-54.27 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-57.27 rule empty{s : store, C : context}: `%;%|-%:%`(s, C, [], `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype([],))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:56.1-60.86 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:59.1-63.86 rule seq{s : store, C : context, instr_1 : instr, `instr_2*` : instr*, `t_1*` : valtype*, `x_1*` : idx*, `x_2*` : idx*, `t_3*` : valtype*, `t_2*` : valtype*, `init*` : init*, `t*` : valtype*}: `%;%|-%:%`(s, C, [instr_1] ++ instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`} ++ x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) -- Instr_ok2: `%;%|-%:%`(s, C, instr_1, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x_1*{x_1 <- `x_1*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -31759,14 +31817,14 @@ relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) -- (if (C.LOCALS_context[x_1!`%`_idx.0] = `%%`_localtype(init, t)))*{init <- `init*`, t <- `t*`, x_1 <- `x_1*`} -- Instrs_ok2: `%;%|-%:%`(s, $with_locals(C, x_1*{x_1 <- `x_1*`}, `%%`_localtype(SET_init, t)*{t <- `t*`}), instr_2*{instr_2 <- `instr_2*`}, `%->_%%`_instrtype(`%`_resulttype(t_2*{t_2 <- `t_2*`},), x_2*{x_2 <- `x_2*`}, `%`_resulttype(t_3*{t_3 <- `t_3*`},))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:62.1-66.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:65.1-69.33 rule sub{s : store, C : context, `instr*` : instr*, it' : instrtype, it : instrtype}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it') -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, it) -- Instrtype_sub: `%|-%<:%`(C, it, it') -- Instrtype_ok: `%|-%:OK`(C, it') - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:69.1-72.33 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:72.1-75.33 rule frame{s : store, C : context, `instr*` : instr*, `t*` : valtype*, `t_1*` : valtype*, `x*` : idx*, `t_2*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t*{t <- `t*`} ++ t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t*{t <- `t*`} ++ t_2*{t_2 <- `t_2*`},))) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype(t_1*{t_1 <- `t_1*`},), x*{x <- `x*`}, `%`_resulttype(t_2*{t_2 <- `t_2*`},))) @@ -31774,7 +31832,7 @@ relation Instrs_ok2: `%;%|-%:%`(store, context, instr*, instrtype) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:7.1-8.36 relation Expr_ok2: `%;%|-%:%`(store, context, expr, resulttype) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:75.1-77.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:78.1-80.44 rule _{s : store, C : context, `instr*` : instr*, `t*` : valtype*}: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%`_resulttype(t*{t <- `t*`},)) -- Instrs_ok2: `%;%|-%:%`(s, C, instr*{instr <- `instr*`}, `%->_%%`_instrtype(`%`_resulttype([],), [], `%`_resulttype(t*{t <- `t*`},))) @@ -31853,15 +31911,15 @@ relation Exninst_ok: `%|-%:OK`(store, exninst) ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec rec { -;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:225.1-226.50 +;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:228.1-229.50 relation ImmutReachable: `%>>_%%`(fieldval, store, fieldval) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:239.1-242.35 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:242.1-245.35 rule trans{fv_1 : fieldval, s : store, fv_2 : fieldval, fv' : fieldval}: `%>>_%%`(fv_1, s, fv_2) -- ImmutReachable: `%>>_%%`(fv_1, s, fv') -- ImmutReachable: `%>>_%%`(fv', s, fv_2) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:244.1-247.20 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:247.1-250.20 rule `ref.struct`{a : addr, s : store, i : nat, `ft*` : fieldtype*, zt : storagetype}: `%>>_%%`(`REF.STRUCT_ADDR`_fieldval(a), s, s.STRUCTS_store[a].FIELDS_structinst[i]) -- if (i < |s.STRUCTS_store[a].FIELDS_structinst|) @@ -31870,20 +31928,20 @@ relation ImmutReachable: `%>>_%%`(fieldval, store, fieldval) -- if (i < |ft*{ft <- `ft*`}|) -- if (ft*{ft <- `ft*`}[i] = `%%`_fieldtype(?(), zt)) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:249.1-251.42 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:252.1-254.42 rule `ref.array`{a : addr, s : store, i : nat, zt : storagetype}: `%>>_%%`(`REF.ARRAY_ADDR`_fieldval(a), s, s.ARRAYS_store[a].FIELDS_arrayinst[i]) -- if (i < |s.ARRAYS_store[a].FIELDS_arrayinst|) -- if (a < |s.ARRAYS_store|) -- Expand: `%~~%`(s.ARRAYS_store[a].TYPE_arrayinst, ARRAY_comptype(`%%`_fieldtype(?(), zt))) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:253.1-254.44 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.44 rule `ref.exn`{a : addr, s : store, i : nat}: `%>>_%%`(`REF.EXN_ADDR`_fieldval(a), s, (s.EXNS_store[a].FIELDS_exninst[i] : val <: fieldval)) -- if (i < |s.EXNS_store[a].FIELDS_exninst|) -- if (a < |s.EXNS_store|) - ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:256.1-257.28 + ;; ../../../../specification/wasm-latest/7.1-soundness.configurations.spectec:259.1-260.28 rule `ref.extern`{ref : ref, s : store}: `%>>_%%`(`REF.EXTERN`_fieldval(ref), s, (ref : ref <: fieldval)) } @@ -32599,16 +32657,16 @@ grammar Binstr : instr prod 0x0F => RETURN_instr ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:46.5-46.30 prod{x : idx} {{0x10} {x:Bfuncidx}} => CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.60 - prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:47.5-47.53 + prod{x : idx, y : idx} {{0x11} {y:Btypeidx} {x:Btableidx}} => CALL_INDIRECT_instr(x, y) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:48.5-48.37 prod{x : idx} {{0x12} {x:Bfuncidx}} => RETURN_CALL_instr(x) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.67 - prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.41 - prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(_IDX_typeuse(x)) - ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.48 - prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:49.5-49.60 + prod{x : idx, y : idx} {{0x13} {y:Btypeidx} {x:Btableidx}} => RETURN_CALL_INDIRECT_instr(x, y) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:50.5-50.34 + prod{x : idx} {{0x14} {x:Btypeidx}} => CALL_REF_instr(x) + ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:51.5-51.41 + prod{x : idx} {{0x15} {x:Btypeidx}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:52.5-52.81 prod{bt : blocktype, `c*` : catch*, `in*` : instr*} {{0x1F} {bt:Bblocktype} {c*{c <- `c*`}:Blist(syntax catch, grammar Bcatch)} {in:Binstr*{in <- `in*`}} {0x0B}} => TRY_TABLE_instr(bt, `%`_list(c*{c <- `c*`},), in*{in <- `in*`}) ;; ../../../../specification/wasm-latest/5.3-binary.instructions.spectec:53.5-53.37 @@ -34596,18 +34654,18 @@ grammar Tplaininstr_(I : I) : instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"call"} {x:Tfuncidx_(I)}} => CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"call_ref"} {x:Ttypeidx_(I)}} => CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod "return" => RETURN_instr ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"return_call"} {x:Tfuncidx_(I)}} => RETURN_CALL_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(_IDX_typeuse(x)) + prod{x : idx} {{"return_call_ref"} {x:Ttypeidx_(I)}} => RETURN_CALL_REF_instr(x) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec - prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, _IDX_typeuse(y)) + prod{x : idx, y : idx, I' : I} {{"return_call_indirect"} {x:Ttableidx_(I)} {(y, I'):Ttypeuse_(I)}} => RETURN_CALL_INDIRECT_instr(x, y) -- if (I' = {TYPES [], TAGS [], GLOBALS [], MEMS [], TABLES [], FUNCS [], DATAS [], ELEMS [], LOCALS ?(`%`_name([],))*{}, LABELS [], FIELDS [], TYPEDEFS []}) ;; ../../../../specification/wasm-latest/6.3-text.instructions.spectec prod{x : idx} {{"throw"} {x:Ttagidx_(I)}} => THROW_instr(x) diff --git a/spectec/test-prose/TEST.md b/spectec/test-prose/TEST.md index eb29715364..1838c39ce9 100644 --- a/spectec/test-prose/TEST.md +++ b/spectec/test-prose/TEST.md @@ -18016,34 +18016,6 @@ The frame :math:`\{ \mathsf{locals}~{({{\mathit{val}}^?})^\ast},\;\allowbreak \m * The instruction :math:`{\mathit{instr}}` is :ref:`valid ` with the instruction type :math:`{{\mathit{valtype}}^\ast}~{\rightarrow}_{{{\mathit{localidx}}^\ast}}\,{{\mathit{valtype}'}^\ast}`. - * Or: - - * The instruction :math:`{\mathit{instr}}` is of the form :math:`(\mathsf{call\_ref}~y)`. - - * The value type sequence :math:`{{\mathit{valtype}}^\ast}` is of the form :math:`{t_1^\ast}~(\mathsf{ref}~\mathsf{null}~y)`. - - * The local index sequence :math:`{{\mathit{localidx}}^\ast}` is empty. - - * The type use :math:`y` is :ref:`valid `. - - * The :ref:`expansion ` of :math:`C` is :math:`(\mathsf{func}~{t_1^\ast}~\rightarrow~{{\mathit{valtype}'}^\ast})`. - * Or: - - * The instruction :math:`{\mathit{instr}}` is of the form :math:`(\mathsf{return\_call\_ref}~y)`. - - * The value type sequence :math:`{{\mathit{valtype}}^\ast}` is of the form :math:`{t_3^\ast}~{t_1^\ast}~(\mathsf{ref}~\mathsf{null}~y)`. - - * The local index sequence :math:`{{\mathit{localidx}}^\ast}` is empty. - - * The type use :math:`y` is :ref:`valid `. - - * The :ref:`expansion ` of :math:`C` is :math:`(\mathsf{func}~{t_1^\ast}~\rightarrow~{t_2^\ast})`. - - * The result type :math:`C{.}\mathsf{return}` is of the form :math:`{{t'}_2^\ast}`. - - * The result type :math:`{t_2^\ast}` :ref:`matches ` the result type :math:`{{t'}_2^\ast}`. - - * The instruction type :math:`{t_3^\ast}~\rightarrow~{{\mathit{valtype}'}^\ast}` is :ref:`valid `. * Or: * The instruction :math:`{\mathit{instr}}` is of the form :math:`{\mathit{ref}}`. @@ -18094,45 +18066,54 @@ The frame :math:`\{ \mathsf{locals}~{({{\mathit{val}}^?})^\ast},\;\allowbreak \m * :math:`{{\mathit{instr}''}^\ast}` is valid with :math:`\epsilon~{\rightarrow}_{{x^\ast}}\,{{\mathit{valtype}'}^\ast}`. * Or: - * The instruction :math:`{\mathit{instr}}` is of the form :math:`\mathsf{trap}`. + * The instruction :math:`{\mathit{instr}}` is of the form :math:`(\mathsf{call\_addr}~a)`. * The local index sequence :math:`{{\mathit{localidx}}^\ast}` is empty. - * The instruction type :math:`{{\mathit{valtype}}^\ast}~\rightarrow~{{\mathit{valtype}'}^\ast}` is :ref:`valid `. - + * The function instance :math:`s{.}\mathsf{funcs}{}[a]` exists. + * The :ref:`expansion ` of :math:`s{.}\mathsf{funcs}{}[a]{.}\mathsf{type}` is :math:`(\mathsf{func}~{{\mathit{valtype}}^\ast}~\rightarrow~{{\mathit{valtype}'}^\ast})`. + * Or: + * The instruction :math:`{\mathit{instr}}` is of the form :math:`(\mathsf{return\_call\_addr}~a)`. -:math:`{\mathit{instr}}` is valid with :math:`{t_1^\ast}~{\rightarrow}_{{x^\ast}}\,{t_2^\ast}` if: + * The value type sequence :math:`{{\mathit{valtype}}^\ast}` is of the form :math:`{t_3^\ast}~{t_1^\ast}`. + * The local index sequence :math:`{{\mathit{localidx}}^\ast}` is empty. - * The instruction :math:`{\mathit{instr}}` is :ref:`valid ` with the instruction type :math:`{t_1^\ast}~{\rightarrow}_{{x^\ast}}\,{t_2^\ast}`. + * The function instance :math:`s{.}\mathsf{funcs}{}[a]` exists. + * The :ref:`expansion ` of :math:`s{.}\mathsf{funcs}{}[a]{.}\mathsf{type}` is :math:`(\mathsf{func}~{t_1^\ast}~\rightarrow~{t_2^\ast})`. + * The result type :math:`C{.}\mathsf{return}` is of the form :math:`{{t'}_2^\ast}`. + * The result type :math:`{t_2^\ast}` :ref:`matches ` the result type :math:`{{t'}_2^\ast}`. -:math:`(\mathsf{call\_ref}~y)` is valid with :math:`{t_1^\ast}~(\mathsf{ref}~\mathsf{null}~y)~\rightarrow~{t_2^\ast}` if: + * The instruction type :math:`{t_3^\ast}~\rightarrow~{{\mathit{valtype}'}^\ast}` is :ref:`valid `. + * Or: + * The instruction :math:`{\mathit{instr}}` is of the form :math:`(\mathsf{throw\_addr}~a)`. - * The type use :math:`y` is :ref:`valid `. + * The local index sequence :math:`{{\mathit{localidx}}^\ast}` is empty. - * The :ref:`expansion ` of :math:`C` is :math:`(\mathsf{func}~{t_1^\ast}~\rightarrow~{t_2^\ast})`. + * The exception instance :math:`s{.}\mathsf{exns}{}[a]` exists. + * The instruction type :math:`{{\mathit{valtype}}^\ast}~\rightarrow~{{\mathit{valtype}'}^\ast}` is :ref:`valid `. + * Or: + * The instruction :math:`{\mathit{instr}}` is of the form :math:`\mathsf{trap}`. + * The local index sequence :math:`{{\mathit{localidx}}^\ast}` is empty. -:math:`(\mathsf{return\_call\_ref}~y)` is valid with :math:`{t_3^\ast}~{t_1^\ast}~(\mathsf{ref}~\mathsf{null}~y)~\rightarrow~{t_4^\ast}` if: + * The instruction type :math:`{{\mathit{valtype}}^\ast}~\rightarrow~{{\mathit{valtype}'}^\ast}` is :ref:`valid `. - * The type use :math:`y` is :ref:`valid `. - * The :ref:`expansion ` of :math:`C` is :math:`(\mathsf{func}~{t_1^\ast}~\rightarrow~{t_2^\ast})`. - * The result type :math:`C{.}\mathsf{return}` is of the form :math:`{{t'}_2^\ast}`. +:math:`{\mathit{instr}}` is valid with :math:`{t_1^\ast}~{\rightarrow}_{{x^\ast}}\,{t_2^\ast}` if: - * The result type :math:`{t_2^\ast}` :ref:`matches ` the result type :math:`{{t'}_2^\ast}`. - * The instruction type :math:`{t_3^\ast}~\rightarrow~{t_4^\ast}` is :ref:`valid `. + * The instruction :math:`{\mathit{instr}}` is :ref:`valid ` with the instruction type :math:`{t_1^\ast}~{\rightarrow}_{{x^\ast}}\,{t_2^\ast}`. @@ -18179,6 +18160,42 @@ The frame :math:`\{ \mathsf{locals}~{({{\mathit{val}}^?})^\ast},\;\allowbreak \m +:math:`(\mathsf{call\_addr}~a)` is valid with :math:`{t_1^\ast}~\rightarrow~{t_2^\ast}` if: + + + * The function instance :math:`s{.}\mathsf{funcs}{}[a]` exists. + + * The :ref:`expansion ` of :math:`s{.}\mathsf{funcs}{}[a]{.}\mathsf{type}` is :math:`(\mathsf{func}~{t_1^\ast}~\rightarrow~{t_2^\ast})`. + + + + +:math:`(\mathsf{return\_call\_addr}~a)` is valid with :math:`{t_3^\ast}~{t_1^\ast}~\rightarrow~{t_4^\ast}` if: + + + * The function instance :math:`s{.}\mathsf{funcs}{}[a]` exists. + + * The :ref:`expansion ` of :math:`s{.}\mathsf{funcs}{}[a]{.}\mathsf{type}` is :math:`(\mathsf{func}~{t_1^\ast}~\rightarrow~{t_2^\ast})`. + + * The result type :math:`C{.}\mathsf{return}` is of the form :math:`{{t'}_2^\ast}`. + + * The result type :math:`{t_2^\ast}` :ref:`matches ` the result type :math:`{{t'}_2^\ast}`. + + * The instruction type :math:`{t_3^\ast}~\rightarrow~{t_4^\ast}` is :ref:`valid `. + + + + +:math:`(\mathsf{throw\_addr}~a)` is valid with :math:`{t_1^\ast}~\rightarrow~{t_2^\ast}` if: + + + * The exception instance :math:`s{.}\mathsf{exns}{}[a]` exists. + + * The instruction type :math:`{t_1^\ast}~\rightarrow~{t_2^\ast}` is :ref:`valid `. + + + + :math:`\mathsf{trap}` is valid with :math:`{t_1^\ast}~\rightarrow~{t_2^\ast}` if: @@ -18563,74 +18580,23 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Execute the instruction :math:`(\mathsf{br}~l - 1)`. -:math:`\mathsf{return\_call\_ref}~y` -.................................... - - -1. Let :math:`z` be the current state. - -#. Assert: Due to validation, a value is on the top of the stack. - -#. Pop the value :math:`{\mathit{val}''}` from the stack. - -#. Assert: Due to validation, the first non-value entry of the stack is a :math:`\mathsf{frame}`. - -#. If :math:`{\mathit{val}''} = \mathsf{ref{.}null}`, then: - - a. Trap. - -#. Assert: Due to validation, :math:`{\mathit{val}''}` is some :math:`\mathsf{ref{.}func}~{\mathit{funcaddr}}`. - -#. Let :math:`(\mathsf{ref{.}func}~a)` be the destructuring of :math:`{\mathit{val}''}`. - -#. Assert: Due to validation, :math:`a < {|z{.}\mathsf{funcs}|}`. - -#. Assert: Due to validation, the :ref:`expansion ` of :math:`z{.}\mathsf{funcs}{}[a]{.}\mathsf{type}` is some :math:`\mathsf{func}~{\mathit{resulttype}} \rightarrow {\mathit{resulttype}}`. - -#. Let :math:`(\mathsf{func}~{t_1^{n}}~\rightarrow~{t_2^{m}})` be the destructuring of the :ref:`expansion ` of :math:`z{.}\mathsf{funcs}{}[a]{.}\mathsf{type}`. - -#. Assert: Due to validation, there are at least :math:`n` values on the top of the stack. - -#. Pop the values :math:`{{\mathit{val}}^{n}}` from the stack. - -#. Pop all values :math:`{{\mathit{val}'}^\ast}` from the top of the stack. - -#. Pop the :math:`\mathsf{frame}` from the stack. - -#. Push the values :math:`{{\mathit{val}}^{n}}` to the stack. - -#. Push the value :math:`(\mathsf{ref{.}func}~a)` to the stack. - -#. Execute the instruction :math:`(\mathsf{call\_ref}~y)`. - - -:math:`\mathsf{throw\_ref}` -........................... - - -1. Assert: Due to validation, a value is on the top of the stack. +:math:`\mathsf{throw\_addr}~a` +.............................. -#. Pop the value :math:`(\mathsf{ref{.}exn}~a)` from the stack. -#. Pop all values :math:`{{\mathit{val}}^\ast}` from the top of the stack. +1. Pop all values :math:`{{\mathit{val}}^\ast}` from the top of the stack. #. Assert: Due to validation, :math:`{{\mathit{val}}^\ast} \neq \epsilon`. -#. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. +#. Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. -#. Execute the instruction :math:`\mathsf{throw\_ref}`. - -:math:`\mathsf{throw\_ref}` -........................... +:math:`\mathsf{throw\_addr}~a` +.............................. 1. Let :math:`z` be the current state. -#. Assert: Due to validation, a value is on the top of the stack. - -#. Pop the value :math:`(\mathsf{ref{.}exn}~a)` from the stack. - #. Assert: Due to validation, the first non-value entry of the stack is a :math:`\mathsf{handler}`. #. Let :math:`H` be the topmost :math:`\mathsf{handler}`. @@ -18643,9 +18609,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i a. Pop the :math:`\mathsf{handler}` from the stack. - #. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. - - #. Execute the instruction :math:`\mathsf{throw\_ref}`. + #. Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. #. Else if :math:`a \geq {|z{.}\mathsf{exns}|}`, then: @@ -18665,13 +18629,9 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #) Pop the :math:`\mathsf{handler}` from the stack. - #) Let :math:`{H'}` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - - #) Push the :math:`\mathsf{handler}` :math:`{H'}`. - - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #) Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + #) Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. #. Else: @@ -18707,13 +18667,9 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #) Pop the :math:`\mathsf{handler}` from the stack. - #) Let :math:`{H'}` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - - #) Push the :math:`\mathsf{handler}` :math:`{H'}`. - - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #) Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + #) Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. #. Else if :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch\_ref}~{\mathit{tagidx}}~{\mathit{labelidx}}`, then: @@ -18725,13 +18681,9 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #) Pop the :math:`\mathsf{handler}` from the stack. - #) Let :math:`{H'}` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - - #) Push the :math:`\mathsf{handler}` :math:`{H'}`. - - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #) Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + #) Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. #) Else: @@ -18761,11 +18713,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #) Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #) Push the :math:`\mathsf{handler}` :math:`H`. - - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. - - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + #) Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. #) Else: @@ -20038,30 +19986,33 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Let :math:`a` be the address :math:`z{.}\mathsf{module}{.}\mathsf{funcs}{}[x]`. -#. Assert: Due to validation, :math:`a < {|z{.}\mathsf{funcs}|}`. +#. Execute the instruction :math:`(\mathsf{call\_addr}~a)`. -#. Push the value :math:`(\mathsf{ref{.}func}~a)` to the stack. -#. Execute the instruction :math:`(\mathsf{call\_ref}~z{.}\mathsf{funcs}{}[a]{.}\mathsf{type})`. +:math:`\mathsf{call\_ref}~x` +............................ -:math:`\mathsf{call\_ref}~y` -............................ +1. Assert: Due to validation, a value is on the top of the stack. +#. Pop the value :math:`{\mathit{val}}` from the stack. -1. Let :math:`z` be the current state. +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: -#. Assert: Due to validation, a value is on the top of the stack. + a. Trap. -#. Pop the value :math:`{\mathit{val}'}` from the stack. +#. Assert: Due to validation, :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}func}~{\mathit{funcaddr}}`. -#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}`, then: +#. Let :math:`(\mathsf{ref{.}func}~a)` be the destructuring of :math:`{\mathit{val}}`. - a. Trap. +#. Execute the instruction :math:`(\mathsf{call\_addr}~a)`. -#. Assert: Due to validation, :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}func}~{\mathit{funcaddr}}`. -#. Let :math:`(\mathsf{ref{.}func}~a)` be the destructuring of :math:`{\mathit{val}'}`. +:math:`\mathsf{call\_addr}~a` +............................. + + +1. Let :math:`z` be the current state. #. Assert: Due to validation, :math:`a < {|z{.}\mathsf{funcs}|}`. @@ -20108,15 +20059,30 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Let :math:`a` be the address :math:`z{.}\mathsf{module}{.}\mathsf{funcs}{}[x]`. -#. Assert: Due to validation, :math:`a < {|z{.}\mathsf{funcs}|}`. +#. Execute the instruction :math:`(\mathsf{return\_call\_addr}~a)`. -#. Push the value :math:`(\mathsf{ref{.}func}~a)` to the stack. -#. Execute the instruction :math:`(\mathsf{return\_call\_ref}~z{.}\mathsf{funcs}{}[a]{.}\mathsf{type})`. +:math:`\mathsf{return\_call\_ref}~x` +.................................... -:math:`\mathsf{return\_call\_ref}~y` -.................................... +1. Assert: Due to validation, a value is on the top of the stack. + +#. Pop the value :math:`{\mathit{val}}` from the stack. + +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: + + a. Trap. + +#. Assert: Due to validation, :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}func}~{\mathit{funcaddr}}`. + +#. Let :math:`(\mathsf{ref{.}func}~a)` be the destructuring of :math:`{\mathit{val}}`. + +#. Execute the instruction :math:`(\mathsf{return\_call\_addr}~a)`. + + +:math:`\mathsf{return\_call\_addr}~a` +..................................... 1. Let :math:`z` be the current state. @@ -20129,7 +20095,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Push the values :math:`{{\mathit{val}}^\ast}` to the stack. - #. Execute the instruction :math:`(\mathsf{return\_call\_ref}~y)`. + #. Execute the instruction :math:`(\mathsf{return\_call\_addr}~a)`. #. Else if the first non-value entry of the stack is a :math:`\mathsf{handler}`, then: @@ -20139,24 +20105,12 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Push the values :math:`{{\mathit{val}}^\ast}` to the stack. - #. Execute the instruction :math:`(\mathsf{return\_call\_ref}~y)`. + #. Execute the instruction :math:`(\mathsf{return\_call\_addr}~a)`. #. Else: a. Assert: Due to validation, the first non-value entry of the stack is a :math:`\mathsf{frame}`. - #. Assert: Due to validation, a value is on the top of the stack. - - #. Pop the value :math:`{\mathit{val}''}` from the stack. - - #. If :math:`{\mathit{val}''} = \mathsf{ref{.}null}`, then: - - 1) Trap. - - #. Assert: Due to validation, :math:`{\mathit{val}''}` is some :math:`\mathsf{ref{.}func}~{\mathit{funcaddr}}`. - - #. Let :math:`(\mathsf{ref{.}func}~a)` be the destructuring of :math:`{\mathit{val}''}`. - #. Assert: Due to validation, :math:`a < {|z{.}\mathsf{funcs}|}`. #. Assert: Due to validation, the :ref:`expansion ` of :math:`z{.}\mathsf{funcs}{}[a]{.}\mathsf{type}` is some :math:`\mathsf{func}~{\mathit{resulttype}} \rightarrow {\mathit{resulttype}}`. @@ -20173,214 +20127,185 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Push the values :math:`{{\mathit{val}}^{n}}` to the stack. - #. Push the value :math:`(\mathsf{ref{.}func}~a)` to the stack. - - #. Execute the instruction :math:`(\mathsf{call\_ref}~y)`. + #. Execute the instruction :math:`(\mathsf{call\_addr}~a)`. :math:`\mathsf{throw\_ref}` ........................... -1. Let :math:`z` be the current state. - -#. Assert: Due to validation, a value is on the top of the stack. +1. Assert: Due to validation, a value is on the top of the stack. -#. Pop the value :math:`{\mathit{val}'}` from the stack. +#. Pop the value :math:`{\mathit{val}}` from the stack. -#. If :math:`{\mathit{val}'} = \mathsf{ref{.}null}`, then: +#. If :math:`{\mathit{val}} = \mathsf{ref{.}null}`, then: a. Trap. -#. If :math:`{\mathit{val}'}` is some :math:`\mathsf{ref{.}exn}~{\mathit{exnaddr}}`, then: - - a. Let :math:`(\mathsf{ref{.}exn}~a)` be the destructuring of :math:`{\mathit{val}'}`. - - #. Pop all values :math:`{{\mathit{val}}^\ast}` from the top of the stack. +#. Assert: Due to validation, :math:`{\mathit{val}}` is some :math:`\mathsf{ref{.}exn}~{\mathit{exnaddr}}`. - #. If :math:`{{\mathit{val}}^\ast} \neq \epsilon`, then: +#. Let :math:`(\mathsf{ref{.}exn}~a)` be the destructuring of :math:`{\mathit{val}}`. - 1) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. +#. Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. - #) Execute the instruction :math:`\mathsf{throw\_ref}`. - #. Else if the first non-value entry of the stack is a :math:`\mathsf{label}`, then: - - 1) Pop the :math:`\mathsf{label}` from the stack. - - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. - - #) Execute the instruction :math:`\mathsf{throw\_ref}`. +:math:`\mathsf{throw\_addr}~a` +.............................. - #. Else: - 1) If the first non-value entry of the stack is a :math:`\mathsf{frame}`, then: +1. Let :math:`z` be the current state. - a) Pop the :math:`\mathsf{frame}` from the stack. +#. Pop all values :math:`{{\mathit{val}}^\ast}` from the top of the stack. - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. +#. If :math:`{{\mathit{val}}^\ast} \neq \epsilon`, then: - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + a. Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. - #) Else if the first non-value entry of the stack is not a :math:`\mathsf{handler}`, then: +#. Else if the first non-value entry of the stack is a :math:`\mathsf{label}`, then: - a) Throw the exception :math:`{\mathit{val}'}` as a result. + a. Pop the :math:`\mathsf{label}` from the stack. - #) Else: + #. Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. - a) Let :math:`H` be the topmost :math:`\mathsf{handler}`. - - #) Let :math:`n` be the arity of :math:`H` +#. Else: - #) Let :math:`{{\mathit{catch}''}^\ast}` be the catch handler of :math:`H` + a. If the first non-value entry of the stack is a :math:`\mathsf{frame}`, then: - #) If :math:`{{\mathit{catch}''}^\ast} = \epsilon`, then: + 1) Pop the :math:`\mathsf{frame}` from the stack. - 1. Pop the :math:`\mathsf{handler}` from the stack. + #) Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. - #. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #. Else if the first non-value entry of the stack is not a :math:`\mathsf{handler}`, then: - #. Execute the instruction :math:`\mathsf{throw\_ref}`. + 1) Throw the exception :math:`(\mathsf{throw\_addr}~a)` as a result. - #) Else if :math:`a \geq {|z{.}\mathsf{exns}|}`, then: + #. Else: - 1. Let :math:`{\mathit{catch}}_0~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. + 1) Let :math:`H` be the topmost :math:`\mathsf{handler}`. - #. If :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch\_all}~{\mathit{labelidx}}`, then: + #) Let :math:`n` be the arity of :math:`H` - a. Let :math:`(\mathsf{catch\_all}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. + #) Let :math:`{{\mathit{catch}''}^\ast}` be the catch handler of :math:`H` - #. Pop the :math:`\mathsf{handler}` from the stack. + #) If :math:`{{\mathit{catch}''}^\ast} = \epsilon`, then: - #. Execute the instruction :math:`(\mathsf{br}~l)`. + a) Pop the :math:`\mathsf{handler}` from the stack. - #. Else if :math:`{\mathit{catch}}_0` is not some :math:`\mathsf{catch\_all\_ref}~{\mathit{labelidx}}`, then: + #) Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. - a. Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. + #) Else if :math:`a \geq {|z{.}\mathsf{exns}|}`, then: - #. Pop the :math:`\mathsf{handler}` from the stack. + a) Let :math:`{\mathit{catch}}_0~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. - #. Let :math:`{H'}` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. + #) If :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch\_all}~{\mathit{labelidx}}`, then: - #. Push the :math:`\mathsf{handler}` :math:`{H'}`. + 1. Let :math:`(\mathsf{catch\_all}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - #. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #. Pop the :math:`\mathsf{handler}` from the stack. - #. Execute the instruction :math:`\mathsf{throw\_ref}`. + #. Execute the instruction :math:`(\mathsf{br}~l)`. - #. Else: + #) Else if :math:`{\mathit{catch}}_0` is not some :math:`\mathsf{catch\_all\_ref}~{\mathit{labelidx}}`, then: - a. Let :math:`(\mathsf{catch\_all\_ref}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. + 1. Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. - #. Pop the :math:`\mathsf{handler}` from the stack. + #. Pop the :math:`\mathsf{handler}` from the stack. - #. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #. Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #. Execute the instruction :math:`(\mathsf{br}~l)`. + #. Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. #) Else: - 1. Let :math:`{{\mathit{val}}^\ast}` be :math:`z{.}\mathsf{exns}{}[a]{.}\mathsf{fields}`. + 1. Let :math:`(\mathsf{catch\_all\_ref}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - #. Let :math:`{\mathit{catch}}_0~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. + #. Pop the :math:`\mathsf{handler}` from the stack. - #. If :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch}~{\mathit{tagidx}}~{\mathit{labelidx}}`, then: - - a. Let :math:`(\mathsf{catch}~x~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - - #. If :math:`x < {|z{.}\mathsf{module}{.}\mathsf{tags}|}` and :math:`z{.}\mathsf{exns}{}[a]{.}\mathsf{tag} = z{.}\mathsf{module}{.}\mathsf{tags}{}[x]`, then: - - 1) Pop the :math:`\mathsf{handler}` from the stack. - - #) Push the values :math:`{{\mathit{val}}^\ast}` to the stack. + #. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. - #) Execute the instruction :math:`(\mathsf{br}~l)`. + #. Execute the instruction :math:`(\mathsf{br}~l)`. - #. Else: + #) Else: - 1) Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. + a) Let :math:`{{\mathit{val}}^\ast}` be :math:`z{.}\mathsf{exns}{}[a]{.}\mathsf{fields}`. - #) Pop the :math:`\mathsf{handler}` from the stack. + #) Let :math:`{\mathit{catch}}_0~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. - #) Let :math:`{H'}` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. + #) If :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch}~{\mathit{tagidx}}~{\mathit{labelidx}}`, then: - #) Push the :math:`\mathsf{handler}` :math:`{H'}`. + 1. Let :math:`(\mathsf{catch}~x~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #. If :math:`x < {|z{.}\mathsf{module}{.}\mathsf{tags}|}` and :math:`z{.}\mathsf{exns}{}[a]{.}\mathsf{tag} = z{.}\mathsf{module}{.}\mathsf{tags}{}[x]`, then: - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + a. Pop the :math:`\mathsf{handler}` from the stack. - #. Else if :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch\_ref}~{\mathit{tagidx}}~{\mathit{labelidx}}`, then: + #. Push the values :math:`{{\mathit{val}}^\ast}` to the stack. - a. Let :math:`(\mathsf{catch\_ref}~x~l)` be the destructuring of :math:`{\mathit{catch}}_0`. + #. Execute the instruction :math:`(\mathsf{br}~l)`. - #. If :math:`x \geq {|z{.}\mathsf{module}{.}\mathsf{tags}|}` or :math:`z{.}\mathsf{exns}{}[a]{.}\mathsf{tag} \neq z{.}\mathsf{module}{.}\mathsf{tags}{}[x]`, then: + #. Else: - 1) Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. + a. Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. - #) Pop the :math:`\mathsf{handler}` from the stack. + #. Pop the :math:`\mathsf{handler}` from the stack. - #) Let :math:`{H'}` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. + #. Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #) Push the :math:`\mathsf{handler}` :math:`{H'}`. + #. Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #) Else if :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch\_ref}~{\mathit{tagidx}}~{\mathit{labelidx}}`, then: - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + 1. Let :math:`(\mathsf{catch\_ref}~x~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - #. Else: + #. If :math:`x \geq {|z{.}\mathsf{module}{.}\mathsf{tags}|}` or :math:`z{.}\mathsf{exns}{}[a]{.}\mathsf{tag} \neq z{.}\mathsf{module}{.}\mathsf{tags}{}[x]`, then: - 1) Pop the :math:`\mathsf{handler}` from the stack. + a. Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. - #) Push the values :math:`{{\mathit{val}}^\ast}` to the stack. + #. Pop the :math:`\mathsf{handler}` from the stack. - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #. Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #) Execute the instruction :math:`(\mathsf{br}~l)`. + #. Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. #. Else: - a. If :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch\_all}~{\mathit{labelidx}}`, then: - - 1) Let :math:`(\mathsf{catch\_all}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - - #) Pop the :math:`\mathsf{handler}` from the stack. + a. Pop the :math:`\mathsf{handler}` from the stack. - #) Execute the instruction :math:`(\mathsf{br}~l)`. + #. Push the values :math:`{{\mathit{val}}^\ast}` to the stack. - #. Else if :math:`{\mathit{catch}}_0` is not some :math:`\mathsf{catch\_all\_ref}~{\mathit{labelidx}}`, then: + #. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. - 1) Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. + #. Execute the instruction :math:`(\mathsf{br}~l)`. - #) Pop the :math:`\mathsf{handler}` from the stack. + #) Else: - #) Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. + 1. If :math:`{\mathit{catch}}_0` is some :math:`\mathsf{catch\_all}~{\mathit{labelidx}}`, then: - #) Push the :math:`\mathsf{handler}` :math:`H`. + a. Let :math:`(\mathsf{catch\_all}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #. Pop the :math:`\mathsf{handler}` from the stack. - #) Execute the instruction :math:`\mathsf{throw\_ref}`. + #. Execute the instruction :math:`(\mathsf{br}~l)`. - #. Else: + #. Else if :math:`{\mathit{catch}}_0` is not some :math:`\mathsf{catch\_all\_ref}~{\mathit{labelidx}}`, then: - 1) Let :math:`(\mathsf{catch\_all\_ref}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. + a. Let :math:`{\mathit{catch}}~{{\mathit{catch}'}^\ast}` be :math:`{{\mathit{catch}''}^\ast}`. - #) Pop the :math:`\mathsf{handler}` from the stack. + #. Pop the :math:`\mathsf{handler}` from the stack. - #) Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. + #. Let :math:`H` be the :math:`\mathsf{handler}` whose arity is :math:`n` and whose catch handler is :math:`{{\mathit{catch}'}^\ast}`. - #) Execute the instruction :math:`(\mathsf{br}~l)`. + #. Enter the block :math:`(\mathsf{throw\_addr}~a)~\mathsf{handler}` with the :math:`\mathsf{handler}` :math:`H`. -#. Else: + #. Else: - a. Assert: Due to validation, the first non-value entry of the stack is not a :math:`\mathsf{label}`. + a. Let :math:`(\mathsf{catch\_all\_ref}~l)` be the destructuring of :math:`{\mathit{catch}}_0`. - #. Assert: Due to validation, the first non-value entry of the stack is not a :math:`\mathsf{frame}`. + #. Pop the :math:`\mathsf{handler}` from the stack. - #. Assert: Due to validation, the first non-value entry of the stack is not a :math:`\mathsf{handler}`. + #. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. - #. Throw the exception :math:`{\mathit{val}'}` as a result. + #. Execute the instruction :math:`(\mathsf{br}~l)`. :math:`\mathsf{try\_table}~{\mathit{bt}}~{{\mathit{catch}}^\ast}~{{\mathit{instr}}^\ast}` @@ -21527,9 +21452,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Append :math:`{\mathit{exn}}` to :math:`z{.}\mathsf{exns}`. -#. Push the value :math:`(\mathsf{ref{.}exn}~a)` to the stack. - -#. Execute the instruction :math:`\mathsf{throw\_ref}`. +#. Execute the instruction :math:`(\mathsf{throw\_addr}~a)`. :math:`\mathsf{local{.}set}~x` @@ -23771,17 +23694,17 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Return :math:`{\mathrm{free}}_{\mathit{funcidx}}({\mathit{funcidx}})`. -#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{call\_ref}~{\mathit{typeuse}}`, then: +#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{call\_ref}~{\mathit{typeidx}}`, then: - a. Let :math:`(\mathsf{call\_ref}~{\mathit{typeuse}})` be the destructuring of :math:`{\mathit{instr}'}`. + a. Let :math:`(\mathsf{call\_ref}~{\mathit{typeidx}})` be the destructuring of :math:`{\mathit{instr}'}`. - #. Return :math:`{\mathrm{free}}_{\mathit{typeuse}}({\mathit{typeuse}})`. + #. Return :math:`{\mathrm{free}}_{\mathit{typeidx}}({\mathit{typeidx}})`. -#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}}`, then: +#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}}`, then: - a. Let :math:`(\mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}})` be the destructuring of :math:`{\mathit{instr}'}`. + a. Let :math:`(\mathsf{call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}})` be the destructuring of :math:`{\mathit{instr}'}`. - #. Return `$free_tableidx(tableidx) ++ $free_typeuse(typeuse)`. + #. Return `$free_tableidx(tableidx) ++ $free_typeidx(typeidx)`. #. If :math:`{\mathit{instr}'} = \mathsf{return}`, then: @@ -23793,17 +23716,17 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Return :math:`{\mathrm{free}}_{\mathit{funcidx}}({\mathit{funcidx}})`. -#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{return\_call\_ref}~{\mathit{typeuse}}`, then: +#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{return\_call\_ref}~{\mathit{typeidx}}`, then: - a. Let :math:`(\mathsf{return\_call\_ref}~{\mathit{typeuse}})` be the destructuring of :math:`{\mathit{instr}'}`. + a. Let :math:`(\mathsf{return\_call\_ref}~{\mathit{typeidx}})` be the destructuring of :math:`{\mathit{instr}'}`. - #. Return :math:`{\mathrm{free}}_{\mathit{typeuse}}({\mathit{typeuse}})`. + #. Return :math:`{\mathrm{free}}_{\mathit{typeidx}}({\mathit{typeidx}})`. -#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}}`, then: +#. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}}`, then: - a. Let :math:`(\mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeuse}})` be the destructuring of :math:`{\mathit{instr}'}`. + a. Let :math:`(\mathsf{return\_call\_indirect}~{\mathit{tableidx}}~{\mathit{typeidx}})` be the destructuring of :math:`{\mathit{instr}'}`. - #. Return `$free_tableidx(tableidx) ++ $free_typeuse(typeuse)`. + #. Return `$free_tableidx(tableidx) ++ $free_typeidx(typeidx)`. #. If :math:`{\mathit{instr}'}` is some :math:`\mathsf{throw}~{\mathit{tagidx}}`, then: @@ -27453,9 +27376,7 @@ The instruction sequence :math:`(\mathsf{block}~{\mathit{blocktype}}~{{\mathit{i #. Push the values :math:`{{\mathit{val}}^\ast}` to the stack. -#. Push the value :math:`(\mathsf{ref{.}func}~{\mathit{funcaddr}})` to the stack. - -#. Execute the instruction :math:`(\mathsf{call\_ref}~s{.}\mathsf{funcs}{}[{\mathit{funcaddr}}]{.}\mathsf{type})`. +#. Execute the instruction :math:`(\mathsf{call\_addr}~{\mathit{funcaddr}})`. #. Pop the values :math:`{{\mathit{val}'}^{k}}` from the stack. @@ -28613,12 +28534,12 @@ Instr_ok/call - The :ref:`expansion ` of C.FUNCS[x] is (FUNC t_1* -> t_2*). Instr_ok/call_ref -- the instruction (CALL_REF (_IDX x)) is valid with the instruction type t_1* :: [(REF ?(NULL) (_IDX x))] -> t_2* if: +- the instruction (CALL_REF x) is valid with the instruction type t_1* :: [(REF ?(NULL) (_IDX x))] -> t_2* if: - the type C.TYPES[x] exists. - The :ref:`expansion ` of C.TYPES[x] is (FUNC t_1* -> t_2*). Instr_ok/call_indirect -- the instruction (CALL_INDIRECT x (_IDX y)) is valid with the instruction type t_1* :: [at] -> t_2* if: +- the instruction (CALL_INDIRECT x y) is valid with the instruction type t_1* :: [at] -> t_2* if: - the table C.TABLES[x] exists. - C.TABLES[x] is (at lim rt). - the reference type rt matches the reference type (REF ?(NULL) FUNC). @@ -28639,7 +28560,7 @@ Instr_ok/return_call - the instruction type t_3* -> t_4* is valid. Instr_ok/return_call_ref -- the instruction (RETURN_CALL_REF (_IDX x)) is valid with the instruction type t_3* :: t_1* :: [(REF ?(NULL) (_IDX x))] -> t_4* if: +- the instruction (RETURN_CALL_REF x) is valid with the instruction type t_3* :: t_1* :: [(REF ?(NULL) (_IDX x))] -> t_4* if: - the type C.TYPES[x] exists. - The :ref:`expansion ` of C.TYPES[x] is (FUNC t_1* -> t_2*). - the result type C.RETURN is ?(t'_2*). @@ -28647,7 +28568,7 @@ Instr_ok/return_call_ref - the instruction type t_3* -> t_4* is valid. Instr_ok/return_call_indirect -- the instruction (RETURN_CALL_INDIRECT x (_IDX y)) is valid with the instruction type t_3* :: t_1* :: [at] -> t_4* if: +- the instruction (RETURN_CALL_INDIRECT x y) is valid with the instruction type t_3* :: t_1* :: [at] -> t_4* if: - the table C.TABLES[x] exists. - C.TABLES[x] is (at lim rt). - the reference type rt matches the reference type (REF ?(NULL) FUNC). @@ -29883,25 +29804,10 @@ Instr_ok2 - instr is valid with valtype* ->_ localidx* valtype'* if: - Either: - the instruction instr is valid with the instruction type valtype* ->_ localidx* valtype'*. - - Or: - - instr is (CALL_REF yy). - - the value type sequence valtype* is t_1* :: [(REF ?(NULL) yy)]. - - the local index sequence localidx* is []. - - the type use yy is valid. - - The :ref:`expansion ` of C is (FUNC t_1* -> valtype'*). - - Or: - - instr is (RETURN_CALL_REF yy). - - valtype* is t_3* :: t_1* :: [(REF ?(NULL) yy)]. - - localidx* is []. - - yy is valid. - - The :ref:`expansion ` of C is (FUNC t_1* -> t_2*). - - the result type C.RETURN is ?(t'_2*). - - the result type t_2* matches the result type t'_2*. - - the instruction type t_3* -> valtype'* is valid. - Or: - instr is ref. - - valtype* is []. - - localidx* is []. + - the value type sequence valtype* is []. + - the local index sequence localidx* is []. - the value type sequence valtype'* is [rt]. - the reference value ref is valid with the reference type rt. - Or: @@ -29925,27 +29831,33 @@ Instr_ok2 - the catch clause catch is valid. - instr''* is valid with [] ->_ x* valtype'*. - Or: - - instr is TRAP. + - instr is (CALL_ADDR a). + - localidx* is []. + - the function instance s.FUNCS[a] exists. + - The :ref:`expansion ` of s.FUNCS[a].TYPE is (FUNC valtype* -> valtype'*). + - Or: + - instr is (RETURN_CALL_ADDR a). + - valtype* is t_3* :: t_1*. + - localidx* is []. + - s.FUNCS[a] exists. + - The :ref:`expansion ` of s.FUNCS[a].TYPE is (FUNC t_1* -> t_2*). + - the result type C.RETURN is ?(t'_2*). + - the result type t_2* matches the result type t'_2*. + - the instruction type t_3* -> valtype'* is valid. + - Or: + - instr is (THROW_ADDR a). - localidx* is []. + - the exception instance s.EXNS[a] exists. - the instruction type valtype* -> valtype'* is valid. + - Or: + - instr is TRAP. + - localidx* is []. + - valtype* -> valtype'* is valid. Instr_ok2/plain - instr is valid with t_1* ->_ x* t_2* if: - the instruction instr is valid with the instruction type t_1* ->_ x* t_2*. -Instr_ok2/call_ref -- (CALL_REF yy) is valid with t_1* :: [(REF ?(NULL) yy)] -> t_2* if: - - the type use yy is valid. - - The :ref:`expansion ` of C is (FUNC t_1* -> t_2*). - -Instr_ok2/return_call_ref -- (RETURN_CALL_REF yy) is valid with t_3* :: t_1* :: [(REF ?(NULL) yy)] -> t_4* if: - - the type use yy is valid. - - The :ref:`expansion ` of C is (FUNC t_1* -> t_2*). - - the result type C.RETURN is ?(t'_2*). - - the result type t_2* matches the result type t'_2*. - - the instruction type t_3* -> t_4* is valid. - Instr_ok2/ref - ref is valid with [] -> [rt] if: - the reference value ref is valid with the reference type rt. @@ -29967,6 +29879,24 @@ Instr_ok2/handler - the catch clause catch is valid. - instr* is valid with [] ->_ x* t*. +Instr_ok2/call_addr +- (CALL_ADDR a) is valid with t_1* -> t_2* if: + - the function instance s.FUNCS[a] exists. + - The :ref:`expansion ` of s.FUNCS[a].TYPE is (FUNC t_1* -> t_2*). + +Instr_ok2/return_call_addr +- (RETURN_CALL_ADDR a) is valid with t_3* :: t_1* -> t_4* if: + - the function instance s.FUNCS[a] exists. + - The :ref:`expansion ` of s.FUNCS[a].TYPE is (FUNC t_1* -> t_2*). + - the result type C.RETURN is ?(t'_2*). + - the result type t_2* matches the result type t'_2*. + - the instruction type t_3* -> t_4* is valid. + +Instr_ok2/throw_addr +- (THROW_ADDR a) is valid with t_1* -> t_2* if: + - the exception instance s.EXNS[a] exists. + - the instruction type t_1* -> t_2* is valid. + Instr_ok2/trap - TRAP is valid with t_1* -> t_2* if: - the instruction type t_1* -> t_2* is valid. @@ -30161,45 +30091,19 @@ Step_pure/br-label-* l c. Push the values val* to the stack. d. Execute the instruction (BR (l - 1)). -Step_read/return_call_ref-frame-* 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. Assert: Due to validation, the first non-value entry of the stack is a FRAME_. -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''. -8. Assert: Due to validation, (a < |$funcinst(z)|). -9. Assert: Due to validation, $Expand($funcinst(z)[a].TYPE) is some ->. -10. Let (FUNC t_1^n -> t_2^m) be $Expand($funcinst(z)[a].TYPE). -11. Assert: Due to validation, there are at least n values on the top of the stack. -12. Pop the values val^n from the stack. -13. Pop all values val'* from the top of the stack. -14. Pop the frame (FRAME_ _ { _ }) from the stack. -15. Push the values val^n to the stack. -16. Push the value (REF.FUNC_ADDR a) to the stack. -17. Execute the instruction (CALL_REF yy). - -Step_read/throw_ref-instrs-* -1. Assert: Due to validation, a value is on the top of the stack. -2. Pop the value (REF.EXN_ADDR a) from the stack. -3. Pop all values val* from the top of the stack. -4. Assert: Due to validation, (val* =/= []). -5. Push the value (REF.EXN_ADDR a) to the stack. -6. Execute the instruction THROW_REF. +Step_read/throw_addr-instrs-* a +1. Pop all values val* from the top of the stack. +2. Assert: Due to validation, (val* =/= []). +3. Execute the instruction (THROW_ADDR a). -Step_read/throw_ref-handler-* +Step_read/throw_addr-handler-* a 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 (REF.EXN_ADDR a) from the stack. -4. Assert: Due to validation, the first non-value entry of the stack is a HANDLER_. -5. Let (HANDLER_ n { catch''* }) be the topmost HANDLER_. -6. If (catch''* = []), then: +2. Assert: Due to validation, the first non-value entry of the stack is a HANDLER_. +3. Let (HANDLER_ n { catch''* }) be the topmost HANDLER_. +4. If (catch''* = []), then: a. Pop the handler (HANDLER_ _ { _ }) from the stack. - b. Push the value (REF.EXN_ADDR a) to the stack. - c. Execute the instruction THROW_REF. -7. Else if (a >= |$exninst(z)|), then: + b. Execute the instruction (THROW_ADDR a). +5. Else if (a >= |$exninst(z)|), then: a. Let [catch_0] :: catch'* be catch''*. b. If catch_0 is some CATCH_ALL, then: 1) Let (CATCH_ALL l) be catch_0. @@ -30208,15 +30112,13 @@ Step_read/throw_ref-handler-* c. Else if catch_0 is not CATCH_ALL_REF, then: 1) Let [catch] :: catch'* be catch''*. 2) Pop the handler (HANDLER_ _ { _ }) from the stack. - 3) Push the handler (HANDLER_ n { catch'* }) to the stack. - 4) Push the value (REF.EXN_ADDR a) to the stack. - 5) Execute the instruction THROW_REF. + 3) Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). d. Else: 1) Let (CATCH_ALL_REF l) be catch_0. 2) Pop the handler (HANDLER_ _ { _ }) from the stack. 3) Push the value (REF.EXN_ADDR a) to the stack. 4) Execute the instruction (BR l). -8. Else: +6. Else: a. Let val* be $exninst(z)[a].FIELDS. b. Let [catch_0] :: catch'* be catch''*. c. If catch_0 is some CATCH, then: @@ -30228,17 +30130,13 @@ Step_read/throw_ref-handler-* 3) Else: a) Let [catch] :: catch'* be catch''*. b) Pop the handler (HANDLER_ _ { _ }) from the stack. - c) Push the handler (HANDLER_ n { catch'* }) to the stack. - d) Push the value (REF.EXN_ADDR a) to the stack. - e) Execute the instruction THROW_REF. + c) Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). d. Else if catch_0 is some CATCH_REF, then: 1) Let (CATCH_REF x l) be catch_0. 2) If ((x >= |$tagaddr(z)|) \/ ($exninst(z)[a].TAG =/= $tagaddr(z)[x])), then: a) Let [catch] :: catch'* be catch''*. b) Pop the handler (HANDLER_ _ { _ }) from the stack. - c) Push the handler (HANDLER_ n { catch'* }) to the stack. - d) Push the value (REF.EXN_ADDR a) to the stack. - e) Execute the instruction THROW_REF. + c) Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). 3) Else: a) Pop the handler (HANDLER_ _ { _ }) from the stack. b) Push the values val* to the stack. @@ -30251,9 +30149,7 @@ Step_read/throw_ref-handler-* f. Else if catch_0 is not CATCH_ALL_REF, then: 1) Let [catch] :: catch'* be catch''*. 2) Pop the handler (HANDLER_ _ { _ }) from the stack. - 3) Push the handler (HANDLER_ n { catch'* }) to the stack. - 4) Push the value (REF.EXN_ADDR a) to the stack. - 5) Execute the instruction THROW_REF. + 3) Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). g. Else: 1) Let (CATCH_ALL_REF l) be catch_0. 2) Pop the handler (HANDLER_ _ { _ }) from the stack. @@ -30476,15 +30372,15 @@ Step_pure/br_on_non_null l a. Push the value val to the stack. b. Execute the instruction (BR l). -Step_pure/call_indirect x yy +Step_pure/call_indirect x y 1. Execute the instruction (TABLE.GET x). -2. Execute the instruction (REF.CAST (REF ?(NULL) yy)). -3. Execute the instruction (CALL_REF yy). +2. Execute the instruction (REF.CAST (REF ?(NULL) (_IDX y))). +3. Execute the instruction (CALL_REF y). -Step_pure/return_call_indirect x yy +Step_pure/return_call_indirect x y 1. Execute the instruction (TABLE.GET x). -2. Execute the instruction (REF.CAST (REF ?(NULL) yy)). -3. Execute the instruction (RETURN_CALL_REF yy). +2. Execute the instruction (REF.CAST (REF ?(NULL) (_IDX y))). +3. Execute the instruction (RETURN_CALL_REF y). Step_pure/frame 1. Let (FRAME_ n { f }) be the topmost FRAME_. @@ -30851,166 +30747,153 @@ Step_read/call x 1. Let z be the current state. 2. Assert: Due to validation, (x < |$moduleinst(z).FUNCS|). 3. Let a be $moduleinst(z).FUNCS[x]. -4. Assert: Due to validation, (a < |$funcinst(z)|). -5. Push the value (REF.FUNC_ADDR a) to the stack. -6. Execute the instruction (CALL_REF $funcinst(z)[a].TYPE). +4. Execute the instruction (CALL_ADDR a). -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' = REF.NULL_ADDR), then: +Step_read/call_ref x +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 = 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'. -7. Assert: Due to validation, (a < |$funcinst(z)|). -8. Let fi be $funcinst(z)[a]. -9. Assert: Due to validation, fi.CODE is some FUNC. -10. Let (FUNC x local_0* instr*) be fi.CODE. -11. Let t* be []. -12. For each local_0 in local_0*, do: +4. Assert: Due to validation, val is some REF.FUNC_ADDR. +5. Let (REF.FUNC_ADDR a) be val. +6. Execute the instruction (CALL_ADDR a). + +Step_read/call_addr a +1. Let z be the current state. +2. Assert: Due to validation, (a < |$funcinst(z)|). +3. Let fi be $funcinst(z)[a]. +4. Assert: Due to validation, fi.CODE is some FUNC. +5. Let (FUNC x local_0* instr*) be fi.CODE. +6. Let t* be []. +7. For each local_0 in local_0*, do: a. Let (LOCAL t) be local_0. b. Append t to the t*. -13. Assert: Due to validation, $Expand(fi.TYPE) is some ->. -14. Let (FUNC t_1^n -> t_2^m) be $Expand(fi.TYPE). -15. Assert: Due to validation, there are at least n values on the top of the stack. -16. Pop the values val^n from the stack. -17. Let f be { LOCALS: ?(val)^n :: $default_(t)*; MODULE: fi.MODULE }. -18. Push the frame (FRAME_ m { f }) to the stack. -19. Enter instr* with label (LABEL_ m { [] }). +8. Assert: Due to validation, $Expand(fi.TYPE) is some ->. +9. Let (FUNC t_1^n -> t_2^m) be $Expand(fi.TYPE). +10. Assert: Due to validation, there are at least n values on the top of the stack. +11. Pop the values val^n from the stack. +12. Let f be { LOCALS: ?(val)^n :: $default_(t)*; MODULE: fi.MODULE }. +13. Push the frame (FRAME_ m { f }) to the stack. +14. Enter instr* with label (LABEL_ m { [] }). Step_read/return_call x 1. Let z be the current state. 2. Assert: Due to validation, (x < |$moduleinst(z).FUNCS|). 3. Let a be $moduleinst(z).FUNCS[x]. -4. Assert: Due to validation, (a < |$funcinst(z)|). -5. Push the value (REF.FUNC_ADDR a) to the stack. -6. Execute the instruction (RETURN_CALL_REF $funcinst(z)[a].TYPE). +4. Execute the instruction (RETURN_CALL_ADDR a). + +Step_read/return_call_ref x +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 = REF.NULL_ADDR), then: + a. Trap. +4. Assert: Due to validation, val is some REF.FUNC_ADDR. +5. Let (REF.FUNC_ADDR a) be val. +6. Execute the instruction (RETURN_CALL_ADDR a). -Step_read/return_call_ref yy +Step_read/return_call_addr a 1. Let z be the current state. 2. If the first non-value entry of the stack is a LABEL_, then: a. Pop all values val* from the top of the stack. b. Pop the label (LABEL_ _ { _ }) from the stack. c. Push the values val* to the stack. - d. Execute the instruction (RETURN_CALL_REF yy). + d. Execute the instruction (RETURN_CALL_ADDR a). 3. Else if the first non-value entry of the stack is a HANDLER_, then: a. Pop all values val* from the top of the stack. b. Pop the handler (HANDLER_ _ { _ }) from the stack. c. Push the values val* to the stack. - d. Execute the instruction (RETURN_CALL_REF yy). + d. Execute the instruction (RETURN_CALL_ADDR a). 4. Else: 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'' = 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''. - g. Assert: Due to validation, (a < |$funcinst(z)|). - h. Assert: Due to validation, $Expand($funcinst(z)[a].TYPE) is some ->. - i. Let (FUNC t_1^n -> t_2^m) be $Expand($funcinst(z)[a].TYPE). - j. Assert: Due to validation, there are at least n values on the top of the stack. - k. Pop the values val^n from the stack. - l. Pop all values val'* from the top of the stack. - m. Pop the frame (FRAME_ _ { _ }) from the stack. - n. Push the values val^n to the stack. - o. Push the value (REF.FUNC_ADDR a) to the stack. - p. Execute the instruction (CALL_REF yy). + b. Assert: Due to validation, (a < |$funcinst(z)|). + c. Assert: Due to validation, $Expand($funcinst(z)[a].TYPE) is some ->. + d. Let (FUNC t_1^n -> t_2^m) be $Expand($funcinst(z)[a].TYPE). + e. Assert: Due to validation, there are at least n values on the top of the stack. + f. Pop the values val^n from the stack. + g. Pop all values val'* from the top of the stack. + h. Pop the frame (FRAME_ _ { _ }) from the stack. + i. Push the values val^n to the stack. + j. Execute the instruction (CALL_ADDR a). 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' = REF.NULL_ADDR), then: +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 = REF.NULL_ADDR), then: a. Trap. -5. If val' is some REF.EXN_ADDR, then: - a. Let (REF.EXN_ADDR a) be val'. - b. Pop all values val* from the top of the stack. - c. If (val* =/= []), then: - 1) Push the value (REF.EXN_ADDR a) to the stack. - 2) Execute the instruction THROW_REF. - d. Else if the first non-value entry of the stack is a LABEL_, then: - 1) Pop the label (LABEL_ _ { _ }) from the stack. - 2) Push the value (REF.EXN_ADDR a) to the stack. - 3) Execute the instruction THROW_REF. - e. Else if the first non-value entry of the stack is a FRAME_, then: - 1) Pop the frame (FRAME_ _ { _ }) from the stack. - 2) Push the value (REF.EXN_ADDR a) to the stack. - 3) Execute the instruction THROW_REF. - f. Else if the first non-value entry of the stack is not a HANDLER_, then: - 1) Throw the exception val' as a result. - g. Else: - 1) Let (HANDLER_ n { catch''* }) be the topmost HANDLER_. - 2) If (catch''* = []), then: - a) Pop the handler (HANDLER_ _ { _ }) from the stack. - b) Push the value (REF.EXN_ADDR a) to the stack. - c) Execute the instruction THROW_REF. - 3) Else if (a >= |$exninst(z)|), then: - a) Let [catch_0] :: catch'* be catch''*. - b) If catch_0 is some CATCH_ALL, then: - 1. Let (CATCH_ALL l) be catch_0. - 2. Pop the handler (HANDLER_ _ { _ }) from the stack. - 3. Execute the instruction (BR l). - c) Else if catch_0 is not CATCH_ALL_REF, then: - 1. Let [catch] :: catch'* be catch''*. - 2. Pop the handler (HANDLER_ _ { _ }) from the stack. - 3. Push the handler (HANDLER_ n { catch'* }) to the stack. - 4. Push the value (REF.EXN_ADDR a) to the stack. - 5. Execute the instruction THROW_REF. - d) Else: - 1. Let (CATCH_ALL_REF l) be catch_0. - 2. Pop the handler (HANDLER_ _ { _ }) from the stack. - 3. Push the value (REF.EXN_ADDR a) to the stack. - 4. Execute the instruction (BR l). +4. Assert: Due to validation, val is some REF.EXN_ADDR. +5. Let (REF.EXN_ADDR a) be val. +6. Execute the instruction (THROW_ADDR a). + +Step_read/throw_addr a +1. Let z be the current state. +2. Pop all values val* from the top of the stack. +3. If (val* =/= []), then: + a. Execute the instruction (THROW_ADDR a). +4. Else if the first non-value entry of the stack is a LABEL_, then: + a. Pop the label (LABEL_ _ { _ }) from the stack. + b. Execute the instruction (THROW_ADDR a). +5. Else if the first non-value entry of the stack is a FRAME_, then: + a. Pop the frame (FRAME_ _ { _ }) from the stack. + b. Execute the instruction (THROW_ADDR a). +6. Else if the first non-value entry of the stack is not a HANDLER_, then: + a. Throw the exception (THROW_ADDR a) as a result. +7. Else: + a. Let (HANDLER_ n { catch''* }) be the topmost HANDLER_. + b. If (catch''* = []), then: + 1) Pop the handler (HANDLER_ _ { _ }) from the stack. + 2) Execute the instruction (THROW_ADDR a). + c. Else if (a >= |$exninst(z)|), then: + 1) Let [catch_0] :: catch'* be catch''*. + 2) If catch_0 is some CATCH_ALL, then: + a) Let (CATCH_ALL l) be catch_0. + b) Pop the handler (HANDLER_ _ { _ }) from the stack. + c) Execute the instruction (BR l). + 3) Else if catch_0 is not CATCH_ALL_REF, then: + a) Let [catch] :: catch'* be catch''*. + b) Pop the handler (HANDLER_ _ { _ }) from the stack. + c) Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). 4) Else: - a) Let val* be $exninst(z)[a].FIELDS. - b) Let [catch_0] :: catch'* be catch''*. - c) If catch_0 is some CATCH, then: - 1. Let (CATCH x l) be catch_0. - 2. If ((x < |$tagaddr(z)|) /\ ($exninst(z)[a].TAG = $tagaddr(z)[x])), then: - a. Pop the handler (HANDLER_ _ { _ }) from the stack. - b. Push the values val* to the stack. - c. Execute the instruction (BR l). - 3. Else: - a. Let [catch] :: catch'* be catch''*. - b. Pop the handler (HANDLER_ _ { _ }) from the stack. - c. Push the handler (HANDLER_ n { catch'* }) to the stack. - d. Push the value (REF.EXN_ADDR a) to the stack. - e. Execute the instruction THROW_REF. - d) Else if catch_0 is some CATCH_REF, then: - 1. Let (CATCH_REF x l) be catch_0. - 2. If ((x >= |$tagaddr(z)|) \/ ($exninst(z)[a].TAG =/= $tagaddr(z)[x])), then: - a. Let [catch] :: catch'* be catch''*. - b. Pop the handler (HANDLER_ _ { _ }) from the stack. - c. Push the handler (HANDLER_ n { catch'* }) to the stack. - d. Push the value (REF.EXN_ADDR a) to the stack. - e. Execute the instruction THROW_REF. - 3. Else: - a. Pop the handler (HANDLER_ _ { _ }) from the stack. - b. Push the values val* to the stack. - c. Push the value (REF.EXN_ADDR a) to the stack. - d. Execute the instruction (BR l). - e) Else if catch_0 is some CATCH_ALL, then: - 1. Let (CATCH_ALL l) be catch_0. - 2. Pop the handler (HANDLER_ _ { _ }) from the stack. + a) Let (CATCH_ALL_REF l) be catch_0. + b) Pop the handler (HANDLER_ _ { _ }) from the stack. + c) Push the value (REF.EXN_ADDR a) to the stack. + d) Execute the instruction (BR l). + d. Else: + 1) Let val* be $exninst(z)[a].FIELDS. + 2) Let [catch_0] :: catch'* be catch''*. + 3) If catch_0 is some CATCH, then: + a) Let (CATCH x l) be catch_0. + b) If ((x < |$tagaddr(z)|) /\ ($exninst(z)[a].TAG = $tagaddr(z)[x])), then: + 1. Pop the handler (HANDLER_ _ { _ }) from the stack. + 2. Push the values val* to the stack. 3. Execute the instruction (BR l). - f) Else if catch_0 is not CATCH_ALL_REF, then: + c) Else: 1. Let [catch] :: catch'* be catch''*. 2. Pop the handler (HANDLER_ _ { _ }) from the stack. - 3. Push the handler (HANDLER_ n { catch'* }) to the stack. - 4. Push the value (REF.EXN_ADDR a) to the stack. - 5. Execute the instruction THROW_REF. - g) Else: - 1. Let (CATCH_ALL_REF l) be catch_0. + 3. Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). + 4) Else if catch_0 is some CATCH_REF, then: + a) Let (CATCH_REF x l) be catch_0. + b) If ((x >= |$tagaddr(z)|) \/ ($exninst(z)[a].TAG =/= $tagaddr(z)[x])), then: + 1. Let [catch] :: catch'* be catch''*. 2. Pop the handler (HANDLER_ _ { _ }) from the stack. + 3. Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). + c) Else: + 1. Pop the handler (HANDLER_ _ { _ }) from the stack. + 2. Push the values val* to the stack. 3. Push the value (REF.EXN_ADDR a) to the stack. 4. Execute the instruction (BR l). -6. Else: - a. Assert: Due to validation, the first non-value entry of the stack is not a LABEL_. - b. Assert: Due to validation, the first non-value entry of the stack is not a FRAME_. - c. Assert: Due to validation, the first non-value entry of the stack is not a HANDLER_. - d. Throw the exception val' as a result. + 5) Else if catch_0 is some CATCH_ALL, then: + a) Let (CATCH_ALL l) be catch_0. + b) Pop the handler (HANDLER_ _ { _ }) from the stack. + c) Execute the instruction (BR l). + 6) Else if catch_0 is not CATCH_ALL_REF, then: + a) Let [catch] :: catch'* be catch''*. + b) Pop the handler (HANDLER_ _ { _ }) from the stack. + c) Enter [(THROW_ADDR a)] :: [HANDLER_] with label (HANDLER_ n { catch'* }). + 7) Else: + a) Let (CATCH_ALL_REF l) be catch_0. + b) Pop the handler (HANDLER_ _ { _ }) from the stack. + c) Push the value (REF.EXN_ADDR a) to the stack. + d) Execute the instruction (BR l). Step_read/try_table bt catch* instr* 1. Let z be the current state. @@ -31566,8 +31449,7 @@ Step/throw x 8. Pop the values val^n from the stack. 9. Let exn be { TAG: $tagaddr(z)[x]; FIELDS: val^n }. 10. Perform $add_exninst(z, [exn]). -11. Push the value (REF.EXN_ADDR a) to the stack. -12. Execute the instruction THROW_REF. +11. Execute the instruction (THROW_ADDR a). Step/local.set x 1. Let z be the current state. @@ -32601,22 +32483,22 @@ free_instr instr' a. Let (CALL funcidx) be instr'. b. Return $free_funcidx(funcidx). 16. If instr' is some CALL_REF, then: - a. Let (CALL_REF typeuse) be instr'. - b. Return $free_typeuse(typeuse). + a. Let (CALL_REF typeidx) be instr'. + b. Return $free_typeidx(typeidx). 17. If instr' is some CALL_INDIRECT, then: - a. Let (CALL_INDIRECT tableidx typeuse) be instr'. - b. Return $free_tableidx(tableidx) ++ $free_typeuse(typeuse). + a. Let (CALL_INDIRECT tableidx typeidx) be instr'. + b. Return $free_tableidx(tableidx) ++ $free_typeidx(typeidx). 18. If (instr' = RETURN), then: a. Return {}. 19. If instr' is some RETURN_CALL, then: a. Let (RETURN_CALL funcidx) be instr'. b. Return $free_funcidx(funcidx). 20. If instr' is some RETURN_CALL_REF, then: - a. Let (RETURN_CALL_REF typeuse) be instr'. - b. Return $free_typeuse(typeuse). + a. Let (RETURN_CALL_REF typeidx) be instr'. + b. Return $free_typeidx(typeidx). 21. If instr' is some RETURN_CALL_INDIRECT, then: - a. Let (RETURN_CALL_INDIRECT tableidx typeuse) be instr'. - b. Return $free_tableidx(tableidx) ++ $free_typeuse(typeuse). + a. Let (RETURN_CALL_INDIRECT tableidx typeidx) be instr'. + b. Return $free_tableidx(tableidx) ++ $free_typeidx(typeidx). 22. If instr' is some THROW, then: a. Let (THROW tagidx) be instr'. b. Return $free_tagidx(tagidx). @@ -34334,11 +34216,10 @@ invoke s funcaddr val* 4. Let k be |t_2*|. 5. Push the frame (FRAME_ k { { MODULE: {} } }) to the stack. 6. Push the values val* to the stack. -7. Push the value (REF.FUNC_ADDR funcaddr) to the stack. -8. Execute the instruction (CALL_REF s.FUNCS[funcaddr].TYPE). -9. Pop the values val'^k from the stack. -10. Pop the frame (FRAME_ k { { MODULE: {} } }) from the stack. -11. Return val'^k. +7. Execute the instruction (CALL_ADDR funcaddr). +8. Pop the values val'^k from the stack. +9. Pop the frame (FRAME_ k { { MODULE: {} } }) from the stack. +10. Return val'^k. concat_idctxt idctxt* 1. If (idctxt* = []), then: diff --git a/spectec/test-splice/TEST.md b/spectec/test-splice/TEST.md index 89290fc118..b468732ffa 100644 --- a/spectec/test-splice/TEST.md +++ b/spectec/test-splice/TEST.md @@ -1184,12 +1184,13 @@ warning: rule `Instr_ok/vextternop` was never spliced warning: rule `Instr_ok/vnarrow` was never spliced warning: rule `Instr_ok/vcvtop` was never spliced warning: rule `Instr_ok2/plain` was never spliced -warning: rule `Instr_ok2/call_ref` was never spliced -warning: rule `Instr_ok2/return_call_ref` was never spliced warning: rule `Instr_ok2/ref` was never spliced warning: rule `Instr_ok2/label` was never spliced warning: rule `Instr_ok2/frame` was never spliced warning: rule `Instr_ok2/handler` was never spliced +warning: rule `Instr_ok2/call_addr` was never spliced +warning: rule `Instr_ok2/return_call_addr` was never spliced +warning: rule `Instr_ok2/throw_addr` was never spliced warning: rule `Instr_ok2/trap` was never spliced warning: rule `Instrs_ok/empty` was spliced more than once warning: rule `Instrs_ok/instr` was never spliced @@ -1367,21 +1368,24 @@ warning: rule `Step_read/br_on_cast_fail-fail` was never spliced warning: rule `Step_read/call` was never spliced warning: rule `Step_read/call_ref-null` was never spliced warning: rule `Step_read/call_ref-func` was never spliced +warning: rule `Step_read/call_addr` was never spliced warning: rule `Step_read/return_call` was never spliced -warning: rule `Step_read/return_call_ref-label` was never spliced -warning: rule `Step_read/return_call_ref-handler` was never spliced -warning: rule `Step_read/return_call_ref-frame-null` was never spliced -warning: rule `Step_read/return_call_ref-frame-addr` was never spliced +warning: rule `Step_read/return_call_ref-null` was never spliced +warning: rule `Step_read/return_call_ref-func` was never spliced +warning: rule `Step_read/return_call_addr-label` was never spliced +warning: rule `Step_read/return_call_addr-handler` was never spliced +warning: rule `Step_read/return_call_addr-frame` was never spliced warning: rule `Step_read/throw_ref-null` was never spliced -warning: rule `Step_read/throw_ref-instrs` was never spliced -warning: rule `Step_read/throw_ref-label` was never spliced -warning: rule `Step_read/throw_ref-frame` was never spliced -warning: rule `Step_read/throw_ref-handler-empty` was never spliced -warning: rule `Step_read/throw_ref-handler-catch` was never spliced -warning: rule `Step_read/throw_ref-handler-catch_ref` was never spliced -warning: rule `Step_read/throw_ref-handler-catch_all` was never spliced -warning: rule `Step_read/throw_ref-handler-catch_all_ref` was never spliced -warning: rule `Step_read/throw_ref-handler-next` was never spliced +warning: rule `Step_read/throw_ref-addr` was never spliced +warning: rule `Step_read/throw_addr-instrs` was never spliced +warning: rule `Step_read/throw_addr-label` was never spliced +warning: rule `Step_read/throw_addr-frame` was never spliced +warning: rule `Step_read/throw_addr-handler-empty` was never spliced +warning: rule `Step_read/throw_addr-handler-catch` was never spliced +warning: rule `Step_read/throw_addr-handler-catch_ref` was never spliced +warning: rule `Step_read/throw_addr-handler-catch_all` was never spliced +warning: rule `Step_read/throw_addr-handler-catch_all_ref` was never spliced +warning: rule `Step_read/throw_addr-handler-next` was never spliced warning: rule `Step_read/try_table` was never spliced warning: rule `Step_read/local.get` was never spliced warning: rule `Step_read/global.get` was never spliced @@ -2200,13 +2204,14 @@ warning: rule prose `Instr_ok/vvternop` was never spliced warning: rule prose `Instr_ok/vvtestop` was never spliced warning: rule prose `Instr_ok/vvunop` was never spliced warning: rule prose `Instr_ok2` was never spliced -warning: rule prose `Instr_ok2/call_ref` was never spliced +warning: rule prose `Instr_ok2/call_addr` was never spliced warning: rule prose `Instr_ok2/frame` was never spliced warning: rule prose `Instr_ok2/handler` was never spliced warning: rule prose `Instr_ok2/label` was never spliced warning: rule prose `Instr_ok2/plain` was never spliced warning: rule prose `Instr_ok2/ref` was never spliced -warning: rule prose `Instr_ok2/return_call_ref` was never spliced +warning: rule prose `Instr_ok2/return_call_addr` was never spliced +warning: rule prose `Instr_ok2/throw_addr` was never spliced warning: rule prose `Instr_ok2/trap` was never spliced warning: rule prose `Instrs_ok` was never spliced warning: rule prose `Instrs_ok/empty` was never spliced @@ -2357,6 +2362,7 @@ warning: rule prose `Step_read/block` was never spliced warning: rule prose `Step_read/br_on_cast` was never spliced warning: rule prose `Step_read/br_on_cast_fail` was never spliced warning: rule prose `Step_read/call` was never spliced +warning: rule prose `Step_read/call_addr` was never spliced warning: rule prose `Step_read/call_ref` was never spliced warning: rule prose `Step_read/global.get` was never spliced warning: rule prose `Step_read/load` was never spliced @@ -2375,8 +2381,8 @@ warning: rule prose `Step_read/ref.func` was never spliced warning: rule prose `Step_read/ref.null` was never spliced warning: rule prose `Step_read/ref.test` was never spliced warning: rule prose `Step_read/return_call` was never spliced +warning: rule prose `Step_read/return_call_addr` was never spliced warning: rule prose `Step_read/return_call_ref` was never spliced -warning: rule prose `Step_read/return_call_ref-frame-*` was never spliced warning: rule prose `Step_read/struct.get` was never spliced warning: rule prose `Step_read/struct.new_default` was never spliced warning: rule prose `Step_read/table.copy` was never spliced @@ -2386,9 +2392,10 @@ warning: rule prose `Step_read/table.get` was never spliced warning: rule prose `Step_read/table.init` was never spliced warning: rule prose `Step_read/table.init-oob-*` was never spliced warning: rule prose `Step_read/table.size` was never spliced +warning: rule prose `Step_read/throw_addr` was never spliced +warning: rule prose `Step_read/throw_addr-handler-*` was never spliced +warning: rule prose `Step_read/throw_addr-instrs-*` was never spliced warning: rule prose `Step_read/throw_ref` was never spliced -warning: rule prose `Step_read/throw_ref-handler-*` was never spliced -warning: rule prose `Step_read/throw_ref-instrs-*` was never spliced warning: rule prose `Step_read/try_table` was never spliced warning: rule prose `Step_read/vload` was never spliced warning: rule prose `Step_read/vload-pack-*` was never spliced