Instructions

WebAssembly computation is performed by executing individual instructions.

Parametric Instructions

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{nop}}\)

  1. Do nothing.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & \href{../syntax/instructions.html#syntax-instr-control}{\mathsf{nop}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{unreachable}}\)

  1. Trap.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & \href{../syntax/instructions.html#syntax-instr-control}{\mathsf{unreachable}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-parametric}{\mathsf{drop}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  3. Do nothing.

Todo

  1. Remove trailing “Do nothing.”

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~\href{../syntax/instructions.html#syntax-instr-parametric}{\mathsf{drop}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-parametric}{\mathsf{select}}~{({t^\ast})^?}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) from the stack.

  3. Assert: Due to validation, a value is on the top of the stack.

  4. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_2\) from the stack.

  5. Assert: Due to validation, a value is on the top of the stack.

  6. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_1\) from the stack.

  7. If \(c\) is not \(0\), then:

  1. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_1\) to the stack.

  1. Else:

  1. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_2\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_1~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_2~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/instructions.html#syntax-instr-parametric}{\mathsf{select}}~{({t^\ast})^?}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_1 & \quad \mbox{if}~ c \neq 0 \\ & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_1~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_2~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/instructions.html#syntax-instr-parametric}{\mathsf{select}}~{({t^\ast})^?}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}_2 & \quad \mbox{if}~ c = 0 \\ \end{array}\end{split}\]

Note

In future versions of WebAssembly, \(\mathsf{select}\) may allow more than one value per choice.

Numeric Instructions

Numeric instructions are defined in terms of the generic numeric operators. The mapping of numeric instructions to their underlying operators is expressed by the following definition:

\[\begin{split}\begin{array}{lll@{\qquad}l} \mathit{op}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}}(i_1,\dots,i_k) &=& \href{../Step_pure/numerics.html#int-ops}{\mathrm{i}\mathit{op}}_N(i_1,\dots,i_k) \\ \mathit{op}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{f}\scriptstyle\kern-0.1emN}}(z_1,\dots,z_k) &=& \href{../Step_pure/numerics.html#float-ops}{\mathrm{f}\mathit{op}}_N(z_1,\dots,z_k) \\ \end{array}\end{split}\]

And for conversion operators:

\[\begin{split}\begin{array}{lll@{\qquad}l} \href{../syntax/instructions.html#syntax-cvtop}{\mathit{cvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{t_1,t_2}(c) &=& \href{../Step_pure/numerics.html#convert-ops}{\mathit{cvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{|t_1|,|t_2|}(c) \\ \end{array}\end{split}\]

Where the underlying operators are partial, the corresponding instruction will trap when the result is not defined. Where the underlying operators are non-deterministic, because they may return one of multiple possible NaN values, so are the corresponding instructions.

Note

For example, the result of instruction \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{add}}\) applied to operands \(i_1, i_2\) invokes \(\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{add}}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}}(i_1, i_2)\), which maps to the generic \(\href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{32}(i_1, i_2)\) via the above definition. Similarly, \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle64}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{trunc}}\mathsf{\_}\href{../syntax/types.html#syntax-numtype}{\mathsf{f\scriptstyle32}}\mathsf{\_s}\) applied to \(z\) invokes \(\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{trunc}}^{\mathsf{s}}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{f\scriptstyle32}},\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle64}}}(z)\), which maps to the generic \(\href{../exec/numerics.html#op-trunc}{\mathrm{trunc}^{\mathsf{s}}}_{32,64}(z)\).

\(t\mathsf{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\)

  1. Push the value \(t.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) to the stack.

Note

No formal reduction rule is required for this instruction, since \(\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}\) instructions already are values.

\({\mathit{nt}} {.} {\mathit{unop}}\)

  1. Assert: Due to validation, a value of value type \({\mathit{nt}}\) is on the top of the stack.

  2. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. If \({|{{\mathit{unop}}}{{}_{{\mathit{nt}}}(c_1)}|}\) is less than or equal to \(0\), then:

  1. Trap.

  1. Let \(c\) be an element of \({{\mathit{unop}}}{{}_{{\mathit{nt}}}(c_1)}\).

  2. Push the value \(({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

  1. SpecTec currently defines the image of unop as a sequence, not a set.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}} {.} {\mathit{unop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\mathit{unop}}}{{}_{{\mathit{nt}}}(c_1)} \\ & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}} {.} {\mathit{unop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ {{\mathit{unop}}}{{}_{{\mathit{nt}}}(c_1)} = \epsilon \\ \end{array}\end{split}\]

\({\mathit{nt}} {.} {\mathit{binop}}\)

  1. Assert: Due to validation, a value of value type \({\mathit{nt}}\) is on the top of the stack.

  2. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0\) is on the top of the stack.

  4. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. If \({|{{\mathit{binop}}}{{}_{{\mathit{nt}}}(c_1, c_2)}|}\) is less than or equal to \(0\), then:

  1. Trap.

  1. Let \(c\) be an element of \({{\mathit{binop}}}{{}_{{\mathit{nt}}}(c_1, c_2)}\).

  2. Push the value \(({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

  1. SpecTec currently defines the image of binop as a sequence, not a set.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{nt}} {.} {\mathit{binop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\mathit{binop}}}{{}_{{\mathit{nt}}}(c_1, c_2)} \\ & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{nt}} {.} {\mathit{binop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ {{\mathit{binop}}}{{}_{{\mathit{nt}}}(c_1, c_2)} = \epsilon \\ \end{array}\end{split}\]

\({\mathit{nt}} {.} {\mathit{testop}}\)

  1. Assert: Due to validation, a value of value type \({\mathit{nt}}\) is on the top of the stack.

  2. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. Let \(c\) be \({{\mathit{testop}}}{{}_{{\mathit{nt}}}(c_1)}\).

  4. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

  1. SpecTec currently defines the image of testop as a sequence, not a set.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}} {.} {\mathit{testop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{\mathit{testop}}}{{}_{{\mathit{nt}}}(c_1)} \\ \end{array}\end{split}\]

\({\mathit{nt}} {.} {\mathit{relop}}\)

  1. Assert: Due to validation, a value of value type \({\mathit{nt}}\) is on the top of the stack.

  2. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0\) is on the top of the stack.

  4. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Let \(c\) be \({{\mathit{relop}}}{{}_{{\mathit{nt}}}(c_1, c_2)}\).

  6. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

  1. SpecTec currently defines the image of testop as a sequence, not a set.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{nt}} {.} {\mathit{relop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{\mathit{relop}}}{{}_{{\mathit{nt}}}(c_1, c_2)} \\ \end{array}\end{split}\]

\({\mathit{nt}}_2 {.} {{\mathit{cvtop}}}{\mathsf{\_}}{{\mathit{nt}}_1}\)

  1. Assert: Due to validation, a value of value type \({\mathit{nt}}_1\) is on the top of the stack.

  2. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. If \({|{{\mathit{cvtop}}}{{}_{{\mathit{nt}}_1, {\mathit{nt}}_2}(c_1)}|}\) is less than or equal to \(0\), then:

  1. Trap.

  1. Let \(c\) be an element of \({{\mathit{cvtop}}}{{}_{{\mathit{nt}}_1, {\mathit{nt}}_2}(c_1)}\).

  2. Push the value \(({\mathit{nt}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

  1. SpecTec currently defines the image of testop as a sequence, not a set.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({\mathit{nt}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}}_2 {.} {{\mathit{cvtop}}}{\mathsf{\_}}{{\mathit{nt}}_1}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathit{nt}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\mathit{cvtop}}}{{}_{{\mathit{nt}}_1, {\mathit{nt}}_2}(c_1)} \\ & ({\mathit{nt}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{nt}}_2 {.} {{\mathit{cvtop}}}{\mathsf{\_}}{{\mathit{nt}}_1}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ {{\mathit{cvtop}}}{{}_{{\mathit{nt}}_1, {\mathit{nt}}_2}(c_1)} = \epsilon \\ \end{array}\end{split}\]

Reference Instructions

\(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~x\)

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Push the value \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x]) \\ \end{array}\end{split}\]

Note

No formal reduction rule is required for the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\) \(\href{../syntax/types.html#syntax-absheaptype}{\mathit{absheaptype}}\), since the instruction form is already a value.

\(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}func}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \(x\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}|}\).

  3. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}{}[x])\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}func}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}{}[x]) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}is\_null}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  3. If \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1)\) to the stack.

  1. Else:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0)\) to the stack.

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}is\_null}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1) & \quad \mbox{if}~ {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} = (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}}) \\ & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}is\_null}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0) & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}as\_non\_null}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  3. If \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. Push the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) to the stack.

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}as\_non\_null}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} = (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}}) \\ & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}as\_non\_null}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}eq}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2\) from the stack.

  3. Assert: Due to validation, a value is on the top of the stack.

  4. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1\) from the stack.

  5. If \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. If \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1)\) to the stack.

  1. Else if \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1\) is \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2\), then:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1)\) to the stack.

  1. Else:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0)\) to the stack.

  1. Else if \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1\) is \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2\), then:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1)\) to the stack.

  1. Else:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0)\) to the stack.

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}eq}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1) & \quad \mbox{if}~ {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1 = (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}}_1) \land {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2 = (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}}_2) \\ & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}eq}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1) & \quad \mbox{otherwise, if}~ {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1 = {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2 \\ & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_1~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}_2~\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}eq}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0) & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}test}}~{\mathit{rt}}\)

  1. Let \(({\mathsf{frame}}_{}\,\{~f~\})\) be the current \(\mathsf{frame}\) context.

  2. Assert: Due to validation, a value is on the top of the stack.

  3. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  4. Let \({\mathit{rt}'}\) be \({\mathrm{Ref}}_{\mathit{type}}({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}})\).

  5. If \({\mathit{rt}'}\) matches \({{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}})\), then:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1)\) to the stack.

  1. Else:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0)\) to the stack.

Todo

Below is the actual prose. (9) Need to handle RulePr s |- ref : rt properly in prose instead of $ref_type_of

  1. Let \(F\) be the current frame.

  2. Let \(\mathit{rt}_1\) be the reference type \(\href{../exec/types.html#type-inst}{\mathrm{clos}}_{F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}(\mathit{rt})\).

  3. Assert: due to validation, \(\mathit{rt}_1\) is closed.

  4. Assert: due to validation, a reference value is on the top of the stack.

  5. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  6. Assert: due to validation, the reference value is valid with some reference type.

  7. Let \(\mathit{rt}_2\) be the reference type of \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  8. If the reference type \(\mathit{rt}_2\) matches \(\mathit{rt}_1\), then:

    1. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1\) to the stack.

  9. Else:

    1. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}test}}~{\mathit{rt}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~1) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ s \vdash {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} : {\mathit{rt}'} \\ {\land}~ \{ \begin{array}[t]{@{}l@{}} \}\end{array} \href{../valid/matching.html#match-reftype}{\vdash} {\mathit{rt}'} \href{../valid/matching.html#match-reftype}{\leq} {{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}}) \\ \end{array} \\ & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}test}}~{\mathit{rt}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~0) & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}cast}}~{\mathit{rt}}\)

  1. Let \(({\mathsf{frame}}_{}\,\{~f~\})\) be the current \(\mathsf{frame}\) context.

  2. Assert: Due to validation, a value is on the top of the stack.

  3. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  4. Let \({\mathit{rt}'}\) be \({\mathrm{Ref}}_{\mathit{type}}({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}})\).

  5. If \({\mathit{rt}'}\) does not match \({{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}})\), then:

  1. Trap.

  1. Push the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) to the stack.

Todo

Below is the actual prose. (9) Need to handle RulePr s |- ref : rt properly in prose instead of $ref_type_of

  1. Let \(F\) be the current frame.

  2. Let \(\mathit{rt}_1\) be the reference type \(\href{../exec/types.html#type-inst}{\mathrm{clos}}_{F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}(\mathit{rt})\).

  3. Assert: due to validation, \(\mathit{rt}_1\) is closed.

  4. Assert: due to validation, a reference value is on the top of the stack.

  5. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  6. Assert: due to validation, the reference value is valid with some reference type.

  7. Let \(\mathit{rt}_2\) be the reference type of \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  8. If the reference type \(\mathit{rt}_2\) matches \(\mathit{rt}_1\), then:

    1. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) back to the stack.

  9. Else:

    1. Trap.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}cast}}~{\mathit{rt}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ s \vdash {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} : {\mathit{rt}'} \\ {\land}~ \{ \begin{array}[t]{@{}l@{}} \}\end{array} \href{../valid/matching.html#match-reftype}{\vdash} {\mathit{rt}'} \href{../valid/matching.html#match-reftype}{\leq} {{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}}) \\ \end{array} \\ & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}cast}}~{\mathit{rt}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-i31}{\mathsf{ref{.}i\scriptstyle31}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  3. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}i31}}~{{\href{../exec/numerics.html#op-wrap}{\mathrm{wrap}}}}_{32, 31}(i))\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~\href{../syntax/instructions.html#syntax-instr-i31}{\mathsf{ref{.}i\scriptstyle31}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}i31}}~{{\href{../exec/numerics.html#op-wrap}{\mathrm{wrap}}}}_{32, 31}(i)) \\ \end{array}\end{split}\]

\({\href{../syntax/instructions.html#syntax-instr-i31}{\mathsf{i{\scriptstyle31}{.}get}}}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  3. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}i31}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}i31}}~i)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{31, 32}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{(i)})\) to the stack.

Todo

Below is the actual prose. (3) Introduce if-let instruction instead of “is of the case”. (4) Guarantees from validation can help simplify the prose.

  1. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{i\scriptstyle31}})\) is on the top of the stack.

  2. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  3. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

    1. Trap.

  4. Assert: due to validation, a \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is a scalar reference.

  5. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}i31}}~i\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  6. Let \(j\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{31,32}(i)\).

  7. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~({\href{../syntax/instructions.html#syntax-instr-i31}{\mathsf{i{\scriptstyle31}{.}get}}}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}i31}}~i)~({\href{../syntax/instructions.html#syntax-instr-i31}{\mathsf{i{\scriptstyle31}{.}get}}}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{31, 32}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{(i)}) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}new}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}\).

  3. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^{n}})\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  4. Let \({({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})^{n}}\) be \({{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^{n}}\).

  5. Let \(a\) be \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}|}\).

  6. Assert: Due to validation, there are at least \(n\) values on the top of the stack.

  7. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) from the stack.

  8. Let \({\mathit{si}}\) be \(\{ \begin{array}[t]{@{}l@{}}\href{../exec/runtime.html#syntax-structinst}{\mathsf{type}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x],\; \href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}~{{{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{\mathit{zt}}}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}})^{n}} \}\end{array}\).

  9. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a)\) to the stack.

  10. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}} \mathrel{{=}{\oplus}} {\mathit{si}}]\).

Todo

Below is the actual prose. (3’) Introduce let binding instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is a structure type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~\mathit{ft}^\ast\) be the expanded structure type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Let \(n\) be the length of the field type sequence \(\mathit{ft}^\ast\).

  7. Assert: due to validation, \(n\) values are on the top of the stack.

  8. Pop the \(n\) values \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\) from the stack.

  9. For every value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}_i\) in \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\) and corresponding field type \(\mathit{ft}_i\) in \(\mathit{ft}^\ast\):

    1. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}_i\) be the result of computing \(\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}_{\mathit{ft}_i}(\href{../exec/runtime.html#syntax-val}{\mathit{val}}_i))\).

  10. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}^\ast\) the concatenation of all field values \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}_i\).

  11. Let \(\mathit{si}\) be the structure instance \(\{\href{../exec/runtime.html#syntax-structinst}{\mathsf{type}}~\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}, \href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}~\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}^\ast\}\).

  12. Let \(a\) be the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}\).

  13. Append \(\mathit{si}\) to \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}\).

  14. Push the structure reference \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}new}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}} \mathrel{{=}{\oplus}} {\mathit{si}}] ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}})^{n}} \\ {\land}~ a = {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}|} \\ {\land}~ {\mathit{si}} = \{ \begin{array}[t]{@{}l@{}} \href{../exec/runtime.html#syntax-structinst}{\mathsf{type}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x],\; \href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}~{({{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{\mathit{zt}}}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}))^{n}} \}\end{array} \\ \end{array} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}new\_default}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}\).

  3. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^\ast})\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  4. Let \({({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})^\ast}\) be \({{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^\ast}\).

  5. Assert: Due to validation, for all \({({\mathit{zt}})^\ast}\), \({{\href{../exec/runtime.html#default-val}{\mathrm{default}}}}_{{\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}})}\) is defined.

  6. Let \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) be \({{{\href{../exec/runtime.html#default-val}{\mathrm{default}}}}_{{\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}})}^\ast}\).

  7. Assert: Due to validation, \({|{\mathit{val*}}|}\) is \({|{\mathit{zt*}}|}\).

  8. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) to the stack.

  9. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}new}}~x)\).

Todo

Below is the actual prose. (3’) Introduce let binding instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is a structure type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~\mathit{ft}^\ast\) be the expanded structure type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Let \(n\) be the length of the field type sequence \(\mathit{ft}^\ast\).

  7. For every field type \(\mathit{ft}_i\) in \(\mathit{ft}^\ast\):

    1. Let \(t_i\) be the value type \(\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}(\mathit{ft}_i)\).

    2. Assert: due to validation, \(\href{../exec/runtime.html#default-val}{\mathrm{default}}_{t_i}\) is defined.

    3. Push the value \(\href{../exec/runtime.html#default-val}{\mathrm{default}}_{t_i}\) to the stack.

  8. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}new}}~x)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}new\_default}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}new}}~x) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}})^\ast} \\ {\land}~ ({{\href{../exec/runtime.html#default-val}{\mathrm{default}}}}_{{\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}})} = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}})^\ast \\ \end{array} \\ \end{array}\end{split}\]

\({\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x~i\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value is on the top of the stack.

  3. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  4. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(i\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}{}[a]{.}\href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}|}\) and \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}|}\), then:

  1. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}\).

  2. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^\ast})\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  3. Let \({({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})^\ast}\) be \({{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^\ast}\).

  4. If \(i\) is less than \({|{{\mathit{zt}}^\ast}|}\), then:

  1. Push the value \({{{{\href{../exec/runtime.html#aux-unpackfield}{\mathrm{unpack}}}}_{{{\mathit{zt}}^\ast}{}[i]}^{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}}}{(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}{}[a]{.}\href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}{}[i])}\) to the stack.

Todo

Below is the actual prose. (3) Introduce if-let instruction instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is a structure type with at least \(y + 1\) fields.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~\mathit{ft}^\ast\) be the expanded structure type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Let \(\mathit{ft}_y\) be the \(y\)-th field type of \(\mathit{ft}^\ast\).

  7. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~x)\) is on the top of the stack.

  8. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  9. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

    1. Trap.

  10. Assert: due to validation, a \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is a structure reference.

  11. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  12. Assert: due to validation, the structure instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}[a]\) exists and has at least \(y + 1\) fields.

  13. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}\) be the field value \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}[a].\href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}[y]\).

  14. Let \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) be the result of computing \(\href{../exec/runtime.html#aux-unpackfield}{\mathrm{unpack}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{\mathit{ft}_y}(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}))\).

  15. Push the value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~({\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x~i) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a)~({\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x~i) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{{{\href{../exec/runtime.html#aux-unpackfield}{\mathrm{unpack}}}}_{{{\mathit{zt}}^\ast}{}[i]}^{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}}}{(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}{}[a]{.}\href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}{}[i])} & \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}})^\ast} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}set}}~x~i\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value is on the top of the stack.

  3. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  4. Assert: Due to validation, a value is on the top of the stack.

  5. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  6. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}\).

  3. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^\ast})\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  4. Let \({({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})^\ast}\) be \({{\href{../syntax/types.html#syntax-fieldtype}{\mathit{fieldtype}}}_0^\ast}\).

  5. If \(i\) is less than \({|{{\mathit{zt}}^\ast}|}\), then:

  1. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}{}[a]{.}\href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}{}[i] = {{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{{\mathit{zt}}^\ast}{}[i]}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}})]\).

Todo

Below is the actual prose. (3) Introduce if-let instruction instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is a structure type with at least \(y + 1\) fields.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~\mathit{ft}^\ast\) be the expanded structure type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Let \(\mathit{ft}_y\) be the \(y\)-th field type of \(\mathit{ft}^\ast\).

  7. Assert: due to validation, a value is on the top of the stack.

  8. Pop the value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) from the stack.

  9. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~x)\) is on the top of the stack.

  10. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  11. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

  1. Trap.

  1. Assert: due to validation, a \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is a structure reference.

  2. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  3. Assert: due to validation, the structure instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}[a]\) exists and has at least \(y + 1\) fields.

  4. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}\) be the result of computing \(\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}_{\mathit{ft}_y}(\href{../exec/runtime.html#syntax-val}{\mathit{val}}))\).

  5. Replace the field value \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}[a].\href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}[y]\) with \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}set}}~x~i) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-struct}{\mathsf{struct{.}set}}~x~i) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}{}[a]{.}\href{../exec/runtime.html#syntax-structinst}{\mathsf{fields}}{}[i] = {{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{{\mathit{zt}}^\ast}{}[i]}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}})] ; \epsilon & \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{struct}}~{({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}})^\ast} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new}}~x\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  3. Assert: Due to validation, a value is on the top of the stack.

  4. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  5. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) to the stack.

  6. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_default}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}\).

  5. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~{\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0)\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  6. Let \(({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})\) be \({\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0\).

  7. Assert: Due to validation, \({{\href{../exec/runtime.html#default-val}{\mathrm{default}}}}_{{\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}})}\) is defined.

  8. Let \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) be \({{\href{../exec/runtime.html#default-val}{\mathrm{default}}}}_{{\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}})}\).

  9. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) to the stack.

  10. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n)\).

Todo

Below is the actual prose. (3’) Introduce let binding instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is an array type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~\mathit{ft}\) be the expanded array type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Assert: due to validation, a value of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  7. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n\) from the stack.

  8. Let \(t\) be the value type \(\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}(\mathit{ft})\).

  9. Assert: due to validation, \(\href{../exec/runtime.html#default-val}{\mathrm{default}}_t\) is defined.

  10. Push the value \(\href{../exec/runtime.html#default-val}{\mathrm{default}}_t\) to the stack \(n\) times.

  11. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_default}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) \\ {\land}~ {{\href{../exec/runtime.html#default-val}{\mathrm{default}}}}_{{\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}})} = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} \\ \end{array} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}\).

  3. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~{\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0)\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  4. Let \(({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})\) be \({\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0\).

  5. Let \(a\) be \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\).

  6. Assert: Due to validation, there are at least \(n\) values on the top of the stack.

  7. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) from the stack.

  8. Let \({\mathit{ai}}\) be \(\{ \begin{array}[t]{@{}l@{}}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{type}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x],\; \href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}~{{{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{\mathit{zt}}}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}})^{n}} \}\end{array}\).

  9. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) to the stack.

  10. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}} \mathrel{{=}{\oplus}} {\mathit{ai}}]\).

Todo

Below is the actual prose. (3’) Introduce let binding instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is a array type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~\mathit{ft}\) be the expanded array type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Assert: due to validation, \(n\) values are on the top of the stack.

  7. Pop the \(n\) values \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\) from the stack.

  8. For every value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}_i\) in \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\):

    1. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}_i\) be the result of computing \(\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}_{\mathit{ft}}(\href{../exec/runtime.html#syntax-val}{\mathit{val}}_i))\).

  9. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}^\ast\) be the concatenation of all field values \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}_i\).

  10. Let \(\mathit{ai}\) be the array instance \(\{\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{type}}~\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}, \href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}~\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}^\ast\}\).

  11. Let \(a\) be the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}\).

  12. Append \(\mathit{ai}\) to \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}\).

  13. Push the array reference \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}} \mathrel{{=}{\oplus}} {\mathit{ai}}] ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) \\ {\land}~ a = {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|} \land {\mathit{ai}} = \{ \begin{array}[t]{@{}l@{}} \href{../exec/runtime.html#syntax-arrayinst}{\mathsf{type}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x],\; \href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}~{({{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{\mathit{zt}}}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}))^{n}} \}\end{array} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_data}}~x~y\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  6. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}\).

  7. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~{\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0)\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  8. Let \(({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})\) be \({\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0\).

  9. If \(i + n \cdot {|{\mathit{zt}}|} / 8\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. Assert: Due to validation, the length of \(({\mathit{fresh}}_1)\) for which \({\href{../syntax/conventions.html#notation-concat}{\bigoplus}}\, {\mathit{fresh}}_1\) \(=\) \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}{}[i : n \cdot {|{\mathit{zt}}|} / 8]\) is \(n\).

  2. Let \({{\href{../syntax/values.html#syntax-byte}{\mathit{byte}}}^\ast}\) be the result for which \({\href{../syntax/conventions.html#notation-concat}{\bigoplus}}\, {{\href{../syntax/values.html#syntax-byte}{\mathit{byte}}}^\ast}\) \(=\) \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}{}[i : n \cdot {|{\mathit{zt}}|} / 8]\).

  3. Let \({c^\ast}\) be the result for which for all \({({\href{../syntax/values.html#syntax-byte}{\mathit{byte}}})^\ast}\), \({{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{zt}}}({c^\ast})\) is \({\href{../syntax/values.html#syntax-byte}{\mathit{byte}}}\).

  4. Push the values \({{\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}}){.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{\href{../exec/numerics.html#aux-unpacknum}{\mathrm{unpack}}}}_{{\mathit{zt}}}(c)^{n}}\) to the stack.

  5. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n)\).

Todo

Below is the actual prose. (7) Render $inverse_ with display hint.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is an array type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~\mathit{ft}\) be the expanded array type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Assert: due to validation, the data address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{datas}}[y]\) exists.

  7. Let \(\mathit{da}\) be the data address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{datas}}[y]\).

  8. Assert: due to validation, the data instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}[\mathit{da}]\) exists.

  9. Let \(\href{../exec/runtime.html#syntax-datainst}{\mathit{datainst}}\) be the data instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}[\mathit{da}]\).

  10. Assert: due to validation, two values of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) are on the top of the stack.

  11. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n\) from the stack.

  12. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~s\) from the stack.

  13. Assert: due to validation, the field type \(\mathit{ft}\) has a defined bit width.

  14. Let \(z\) be the bit width of field type \(\mathit{ft}\) divided by eight.

  15. If the sum of \(s\) and \(n\) times \(z\) is larger than the length of \(\href{../exec/runtime.html#syntax-datainst}{\mathit{datainst}}.\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}\), then:

    1. Trap.

  16. Let \(b^\ast\) be the byte sequence \(\href{../exec/runtime.html#syntax-datainst}{\mathit{datainst}}.\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}[s \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} n \cdot z]\).

  17. Let \(t\) be the value type \(\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}(\mathit{ft})\).

  18. For each of the \(n\) consecutive subsequences \({b'}^z\) of \(b^\ast\):

    1. Assert: due to validation, \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\mathit{ft}}\) is defined.

    2. Let \(c_i\) be the constant for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\mathit{ft}}(c_i)\) is \({b'}^z\).

    3. Push the value \(t.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_i\) to the stack.

  19. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_data}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) \\ {\land}~ i + n \cdot {|{\mathit{zt}}|} / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}|} \\ \end{array} } \\ & z ; (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_data}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {({\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}}){.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{\href{../exec/numerics.html#aux-unpacknum}{\mathrm{unpack}}}}_{{\mathit{zt}}}(c))^{n}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) \\ {\land}~ {\href{../syntax/conventions.html#notation-concat}{\bigoplus}}\, {{{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{zt}}}(c)^{n}} = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}{}[i : n \cdot {|{\mathit{zt}}|} / 8] \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_elem}}~x~y\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  6. If \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. Assert: Due to validation, \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}{}[i : n]|}\) is \(n\).

  2. Let \({{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}^\ast}\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}{}[i : n]\).

  3. Push the values \({{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}^{n}}\) to the stack.

  4. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_elem}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|} \\ & z ; (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_elem}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}^{n}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}~x~n) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}^{n}} = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}{}[i : n] } \\ \end{array}\end{split}\]

\({\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  4. Assert: Due to validation, a value is on the top of the stack.

  5. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  6. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\) and \(i\) is greater than or equal to \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|}\), then:

  1. Trap.

  1. If \(i\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|}\) and \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\), then:

  1. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}\).

  2. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~{\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0)\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  3. Let \(({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})\) be \({\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0\).

  4. Push the value \({{{{\href{../exec/runtime.html#aux-unpackfield}{\mathrm{unpack}}}}_{{\mathit{zt}}}^{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}}}{(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}{}[i])}\) to the stack.

Todo

Below is the actual prose. (3) Introduce if-let instruction instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is an array type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~\mathit{ft}\) be the expanded array type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Assert: due to validation, a value of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  7. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  8. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~x)\) is on the top of the stack.

  9. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  10. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

  1. Trap.

  1. Assert: due to validation, \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is an array reference.

  2. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  3. Assert: due to validation, the array instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a]\) exists.

  4. If \(n\) is larger than or equal to the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a].\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}\), then:

    1. Trap.

  5. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}\) be the field value \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a].\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}[i]\).

  6. Let \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) be the result of computing \(\href{../exec/runtime.html#aux-unpackfield}{\mathrm{unpack}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{\mathit{ft}}(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}))\).

  7. Push the value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i \geq {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{{{\href{../exec/runtime.html#aux-unpackfield}{\mathrm{unpack}}}}_{{\mathit{zt}}}^{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}}}{(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}{}[i])} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x\)

  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 \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  6. Assert: Due to validation, a value is on the top of the stack.

  7. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  8. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\) and \(i\) is greater than or equal to \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|}\), then:

  1. Trap.

  1. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}\).

  2. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~{\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0)\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  3. Let \(({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})\) be \({\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0\).

  4. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}{}[i] = {{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{\mathit{zt}}}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}})]\).

Todo

Below is the actual prose. (3) Introduce if-let instruction instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is an array type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~\mathit{ft}\) be the expanded array type of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Assert: due to validation, a value is on the top of the stack.

  7. Pop the value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) from the stack.

  8. Assert: due to validation, a value of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  9. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  10. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~x)\) is on the top of the stack.

  11. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  12. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

  1. Trap.

  1. Assert: due to validation, \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is an array reference.

  2. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  3. Assert: due to validation, the array instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a]\) exists.

  4. If \(n\) is larger than or equal to the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a].\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}\), then:

    1. Trap.

  5. Let \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}\) be the result of computing \(\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}_{\mathit{ft}}(\href{../exec/runtime.html#syntax-val}{\mathit{val}}))\).

  6. Replace the field value \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a].\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}[i]\) with \(\href{../exec/runtime.html#syntax-fieldval}{\mathit{fieldval}}\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i \geq {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}{}[i] = {{\href{../exec/runtime.html#aux-packfield}{\mathrm{pack}}}}_{{\mathit{zt}}}({\href{../exec/runtime.html#syntax-val}{\mathit{val}}})] ; \epsilon & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}len}}\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value is on the top of the stack.

  3. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  4. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\), then:

  1. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|})\) to the stack.

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}len}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}len}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|}) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}fill}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value is on the top of the stack.

  5. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  6. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  7. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  8. Assert: Due to validation, a value is on the top of the stack.

  9. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  10. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(a\) is greater than or equal to \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\), then:

  1. Do nothing.

  1. Else if \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else:

  1. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) to the stack.

  2. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

  3. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  4. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x)\).

  5. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) to the stack.

  6. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)\) to the stack.

  7. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  8. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  9. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}fill}}~x)\).

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x) \\ (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}fill}}~x) \end{array} & \mbox{otherwise} \\ \end{array} } \\ \end{array}\end{split}\]

Todo

Below is the actual prose. (3) Introduce if-let instruction instead of “is of the case”. (5) Use “the expansion of” instead of $expand function application. + Too deeply nested

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[y]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[y]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is an array type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~\href{../syntax/types.html#syntax-mut}{\mathit{mut}}~\mathit{st}\) be the expanded array type \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Assert: due to validation, a value of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  7. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n\) from the stack.

  8. Assert: due to validation, a value of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  9. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~s\) from the stack.

  10. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~y)\) is on the top of the stack.

  11. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_2\) from the stack.

  12. Assert: due to validation, a value of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  13. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~d\) from the stack.

  14. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~x)\) is on the top of the stack.

  15. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_1\) from the stack.

  16. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_1\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

  1. Trap.

  1. Assert: due to validation, \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_1\) is an array reference.

  2. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_1\).

  3. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_2\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

  1. Trap.

  1. Assert: due to validation, \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_2\) is an array reference.

  2. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}_2\).

  3. Assert: due to validation, the array instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a_1]\) exists.

  4. Assert: due to validation, the array instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a_2]\) exists.

  5. If \(d + n\) is larger than the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a_1].\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}\), then:

    1. Trap.

  6. If \(s + n\) is larger than the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a_2].\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}\), then:

    1. Trap.

  7. If \(n = 0\), then:

    1. Return.

  8. If \(d \leq s\), then:

    1. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1\) to the stack.

    2. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~d\) to the stack.

    3. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2\) to the stack.

    4. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~s\) to the stack.

    5. Execute \(\mathrm{getfield}(\mathit{st})\).

    6. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x\).

    7. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1\) to the stack.

    8. Assert: due to the earlier check against the array size, \(d+1 < 2^{32}\).

    9. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(d+1)\) to the stack.

    10. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2\) to the stack.

    11. Assert: due to the earlier check against the array size, \(s+1 < 2^{32}\).

    12. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(s+1)\) to the stack.

  9. Else:

    1. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1\) to the stack.

    2. Assert: due to the earlier check against the array size, \(d+n-1 < 2^{32}\).

    3. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(d+n-1)\) to the stack.

    4. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2\) to the stack.

    5. Assert: due to the earlier check against the array size, \(s+n-1 < 2^{32}\).

    6. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(s+n-1)\) to the stack.

    7. Execute \(\mathrm{getfield}(\mathit{st})\).

    8. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x\).

    9. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1\) to the stack.

    10. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~d\) to the stack.

    11. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2\) to the stack.

    12. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~s\) to the stack.

  10. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(n-1)\) to the stack.

  11. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x~y\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}}_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}}_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i_1 + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a_1]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|} } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i_2 + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a_2]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|} } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{otherwise, if}~ n = 0 } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1) \\ (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2) \\ ({\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x_2)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x_1) \\ (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + 1)~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) \end{array} & & \\ \multicolumn{3}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}} \quad \begin{array}[t]{@{}l@{}} \mbox{otherwise, if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x_2] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}_2) \\ {\land}~ i_1 \leq i_2 \land {{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?} = {\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}({\mathit{zt}}_2) \\ \end{array} \\ \end{array} } \\ \end{array} } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + n - 1) \\ (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + n - 1) \\ ({\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}get}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?}}~x_2)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x_1) \\ (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}copy}}~x_1~x_2) \end{array} & & \\ \multicolumn{3}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}} \quad \begin{array}[t]{@{}l@{}} \mbox{otherwise, if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x_2] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}_2) \\ {\land}~ {{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}^?} = {\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}({\mathit{zt}}_2) \\ \end{array} \\ \end{array} } \\ \end{array} } \\ \end{array}\end{split}\]

Where:

\[\begin{split}\begin{array}[t]{@{}lcl@{}l@{}} {\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}({\href{../syntax/types.html#syntax-consttype}{\mathit{consttype}}}) & = & \epsilon \\ {\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}({\href{../syntax/types.html#syntax-packtype}{\mathit{packtype}}}) & = & \href{../syntax/instructions.html#syntax-sx}{\mathsf{s}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)\) from the stack.

  6. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  7. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  8. Assert: Due to validation, a value is on the top of the stack.

  9. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  10. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\) and \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|}\), then:

  1. Trap.

  1. If \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}\), then:

  1. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~{\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0)\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x])\).

  2. Let \(({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}, {\mathit{zt}})\) be \({\href{../syntax/types.html#syntax-arraytype}{\mathit{arraytype}}}_0\).

  3. If \(j + n \cdot {|{\mathit{zt}}|} / 8\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else:

  1. Let \(c\) be the result for which \({{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{zt}}}(c)\) \(=\) \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}{}[j : {|{\mathit{zt}}|} / 8]\).

  2. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) to the stack.

  3. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

  4. Push the value \({\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}}){.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{\href{../exec/numerics.html#aux-unpacknum}{\mathrm{unpack}}}}_{{\mathit{zt}}}(c)\) to the stack.

  5. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x)\).

  6. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) to the stack.

  7. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)\) to the stack.

  8. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + {|{\mathit{zt}}|} / 8)\) to the stack.

  9. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  10. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y)\).

  1. Else if \(n\) is \(0\), then:

  1. Do nothing.

Todo

Below is the actual prose. (7) Render $inverse_ with display hint.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\) exists.

  3. Let \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[x]\).

  4. Assert: due to validation, the expansion of \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\) is an array type.

  5. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~\mathit{ft}\) be the expanded array type \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\).

  6. Assert: due to validation, the data address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{datas}}[y]\) exists.

  7. Let \(\mathit{da}\) be the data address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{datas}}[y]\).

  8. Assert: due to validation, the data instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}[\mathit{da}]\) exists.

  9. Let \(\href{../exec/runtime.html#syntax-datainst}{\mathit{datainst}}\) be the data instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}[\mathit{da}]\).

  10. Assert: due to validation, three values of type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) are on the top of the stack.

  11. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n\) from the stack.

  12. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~s\) from the stack.

  13. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~d\) from the stack.

  14. Assert: due to validation, a value of type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~x)\) is on the top of the stack.

  15. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  16. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~t\), then:

  1. Trap.

  1. Assert: due to validation, \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is an array reference.

  2. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a\) be the reference value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  3. Assert: due to validation, the array instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a]\) exists.

  4. Assert: due to validation, the field type \(\mathit{ft}\) has a defined bit width.

  5. Let \(z\) be the bit width of field type \(\mathit{ft}\) divided by eight.

  6. If \(d + n\) is larger than the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}[a].\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}\), or the sum of \(s\) and \(n\) times \(z\) is larger than the length of \(\href{../exec/runtime.html#syntax-datainst}{\mathit{datainst}}.\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}\), then:

    1. Trap.

  7. If \(n = 0\), then:

    1. Return.

  8. Let \(b^\ast\) be the byte sequence \(\href{../exec/runtime.html#syntax-datainst}{\mathit{datainst}}.\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}[s \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} z]\).

  9. Let \(t\) be the value type \(\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}(\mathit{ft})\).

  10. Assert: due to validation, \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\mathit{ft}}\) is defined.

  11. Let \(c\) be the constant for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\mathit{ft}}(c)\) is \(b^\ast\).

  12. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a\) to the stack.

  13. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~d\) to the stack.

  14. Push the value \(t.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) to the stack.

  15. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x\).

  16. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a\) to the stack.

  17. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(d+1)\) to the stack.

  18. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(s+z)\) to the stack.

  19. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~(n-1)\) to the stack.

  20. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|} } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) \\ {\land}~ j + n \cdot {|{\mathit{zt}}|} / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}|} \\ \end{array} } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{otherwise, if}~ n = 0 } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathit{zt}}){.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{\href{../exec/numerics.html#aux-unpacknum}{\mathrm{unpack}}}}_{{\mathit{zt}}}(c))~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x) \\ (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + {|{\mathit{zt}}|} / 8)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_data}}~x~y) \end{array} & & \\ \multicolumn{3}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}} \quad \begin{array}[t]{@{}l@{}} \mbox{otherwise, if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{types}}{}[x] \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{array}}~({\href{../syntax/types.html#syntax-mut}{\mathsf{mut}}^?}~{\mathit{zt}}) \\ {\land}~ {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{zt}}}(c) = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}{}[j : {|{\mathit{zt}}|} / 8] \\ \end{array} \\ \end{array} } \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)\) from the stack.

  6. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  7. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  8. Assert: Due to validation, a value is on the top of the stack.

  9. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  10. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Trap.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}|}\) and \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|}\), then:

  1. Trap.

  1. If \(j + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else if \(j\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|}\), then:

  1. Let \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}{}[j]\).

  2. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) to the stack.

  3. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

  4. Push the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) to the stack.

  5. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x)\).

  6. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) to the stack.

  7. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)\) to the stack.

  8. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + 1)\) to the stack.

  9. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  10. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y)\).

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{fields}}|} } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ j + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|} } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{otherwise, if}~ n = 0 } \\ & z ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}set}}~x) \\ (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}init\_elem}}~x~y) \end{array} & & \\ \multicolumn{3}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}} \quad \mbox{otherwise, if}~ {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}{}[j] \\ \end{array} } \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-extern}{\mathsf{any{.}convert\_extern}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  3. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Push the value \((\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{any}})\) to the stack.

  1. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}extern}}\), then:

  1. Let \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}extern}}~{\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}})\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. Push the value \({\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}}\) to the stack.

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~\href{../syntax/instructions.html#syntax-instr-extern}{\mathsf{any{.}convert\_extern}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{any}}) \\ & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}extern}}~{\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}})~\href{../syntax/instructions.html#syntax-instr-extern}{\mathsf{any{.}convert\_extern}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-extern}{\mathsf{extern{.}convert\_any}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) from the stack.

  3. If \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Push the value \((\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{extern}})\) to the stack.

  1. If the type of \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is address value, then:

  1. Let \({\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}}\) be \({\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}extern}}~{\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}})\) to the stack.

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~\href{../syntax/instructions.html#syntax-instr-extern}{\mathsf{extern{.}convert\_any}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{extern}}) \\ & {\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}}~\href{../syntax/instructions.html#syntax-instr-extern}{\mathsf{extern{.}convert\_any}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}extern}}~{\href{../exec/runtime.html#syntax-addrref}{\mathit{addrref}}}) \\ \end{array}\end{split}\]

Vector Instructions

Vector instructions that operate bitwise are handled as integer operations of respective bit width.

\[\begin{split}\begin{array}{lll@{\qquad}l} \mathit{op}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v}\scriptstyle\kern-0.1emN}}(i_1,\dots,i_k) &=& \href{../Step_pure/numerics.html#int-ops}{\mathrm{i}\mathit{op}}_N(i_1,\dots,i_k) \\ \end{array}\end{split}\]

Most other vector instructions are defined in terms of numeric operators that are applied lane-wise according to the given shape.

\[\begin{split}\begin{array}{llll} \mathit{op}_{t\mathsf{x}N}(n_1,\dots,n_k) &=& \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t\mathsf{x}N}(\href{../Step_pure/instructions.html#exec-instr-numeric}{\mathit{op}}_t(i_1,\dots,i_k)^\ast) & \qquad(\mathrel{\mbox{if}} i_1^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(n_1) \land \dots \land i_k^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(n_k) \\ \end{array}\end{split}\]

Note

For example, the result of instruction \(\mathsf{i32x4}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{add}}\) applied to operands \(v_1, v_2\) invokes \(\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{add}}_{\mathsf{i32x4}}(v_1, v_2)\), which maps to \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\mathsf{i32x4}}(\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{add}}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}}(i_1, i_2)^\ast)\), where \(i_1^\ast\) and \(i_2^\ast\) are sequences resulting from invoking \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\mathsf{i32x4}}(v_1)\) and \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\mathsf{i32x4}}(v_2)\) respectively.

For non-deterministic operators this definition is generalized to sets:

\[\begin{split}\begin{array}{lll} \mathit{op}_{t\mathsf{x}N}(n_1,\dots,n_k) &=& \{ \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t\mathsf{x}N}(i^\ast) ~|~ i^\ast \in \Large\times\href{../Step_pure/instructions.html#exec-instr-numeric}{\mathit{op}}_t(i_1,\dots,i_k)^\ast \land i_1^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(n_1) \land \dots \land i_k^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(n_k) \} \\ \end{array}\end{split}\]

where \(\Large\times \{x^\ast\}^N\) transforms a sequence of \(N\) sets of values into a set of sequences of \(N\) values by computing the set product:

\[\begin{array}{lll} \Large\times (S_1 \dots S_N) &=& \{ x_1 \dots x_N ~|~ x_1 \in S_1 \land \dots \land x_N \in S_N \} \end{array}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\)

  1. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) to the stack.

Note

No formal reduction rule is required for this instruction, since \(\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}\) instructions coincide with values.

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} {\href{../syntax/instructions.html#syntax-vvunop}{\mathit{vvunop}}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. Assert: Due to validation, \({|{{\href{../syntax/instructions.html#syntax-vvunop}{\mathit{vvunop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1)}|}\) is greater than \(0\).

  4. Let \(c\) be an element of \({{\href{../syntax/instructions.html#syntax-vvunop}{\mathit{vvunop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1)}\).

  5. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} {\href{../syntax/instructions.html#syntax-vvunop}{\mathit{vvunop}}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\href{../syntax/instructions.html#syntax-vvunop}{\mathit{vvunop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1)} \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} {\href{../syntax/instructions.html#syntax-vvbinop}{\mathit{vvbinop}}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Assert: Due to validation, \({|{{\href{../syntax/instructions.html#syntax-vvbinop}{\mathit{vvbinop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1, c_2)}|}\) is greater than \(0\).

  6. Let \(c\) be an element of \({{\href{../syntax/instructions.html#syntax-vvbinop}{\mathit{vvbinop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1, c_2)}\).

  7. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} {\href{../syntax/instructions.html#syntax-vvbinop}{\mathit{vvbinop}}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\href{../syntax/instructions.html#syntax-vvbinop}{\mathit{vvbinop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1, c_2)} \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} {\href{../syntax/instructions.html#syntax-vvternop}{\mathit{vvternop}}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_3)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  5. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  6. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  7. Assert: Due to validation, \({|{{\href{../syntax/instructions.html#syntax-vvternop}{\mathit{vvternop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1, c_2, c_3)}|}\) is greater than \(0\).

  8. Let \(c\) be an element of \({{\href{../syntax/instructions.html#syntax-vvternop}{\mathit{vvternop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1, c_2, c_3)}\).

  9. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_3)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} {\href{../syntax/instructions.html#syntax-vvternop}{\mathit{vvternop}}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ c \in {{\href{../syntax/instructions.html#syntax-vvternop}{\mathit{vvternop}}}}{{}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c_1, c_2, c_3)} } \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} \href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{any\_true}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. Let \(c\) be \({{\href{../exec/numerics.html#op-ine}{\mathrm{ine}}}}_{{|\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}|}}(c_1, 0)\).

  4. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}} {.} \href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{any\_true}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{\href{../exec/numerics.html#op-ine}{\mathrm{ine}}}}_{{|\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}|}}(c_1, 0) \\ \end{array}\end{split}\]

\({\mathit{sh}} {.} {\mathit{vunop}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. If \({|{{\mathit{vunop}}}{{}_{{\mathit{sh}}}(c_1)}|}\) is less than or equal to \(0\), then:

  1. Trap.

  1. Let \(c\) be an element of \({{\mathit{vunop}}}{{}_{{\mathit{sh}}}(c_1)}\).

  2. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{sh}} {.} {\mathit{vunop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\mathit{vunop}}}{{}_{{\mathit{sh}}}(c_1)} \\ & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{sh}} {.} {\mathit{vunop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ {{\mathit{vunop}}}{{}_{{\mathit{sh}}}(c_1)} = \epsilon \\ \end{array}\end{split}\]

\({\mathit{sh}} {.} {\mathit{vbinop}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. If \({|{{\mathit{vbinop}}}{{}_{{\mathit{sh}}}(c_1, c_2)}|}\) is less than or equal to \(0\), then:

  1. Trap.

  1. Let \(c\) be an element of \({{\mathit{vbinop}}}{{}_{{\mathit{sh}}}(c_1, c_2)}\).

  2. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

  1. SpecTec currently defines the image of vbinop as a sequence, not a set.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{sh}} {.} {\mathit{vbinop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\mathit{vbinop}}}{{}_{{\mathit{sh}}}(c_1, c_2)} \\ & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{sh}} {.} {\mathit{vbinop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ {{\mathit{vbinop}}}{{}_{{\mathit{sh}}}(c_1, c_2)} = \epsilon \\ \end{array}\end{split}\]

\({\mathit{sh}} {.} {\mathit{vternop}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_3)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  5. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  6. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  7. If \({|{{\mathit{vternop}}}{{}_{{\mathit{sh}}}(c_1, c_2, c_3)}|}\) is less than or equal to \(0\), then:

  1. Trap.

  1. Let \(c\) be an element of \({{\mathit{vternop}}}{{}_{{\mathit{sh}}}(c_1, c_2, c_3)}\).

  2. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_3)~({\mathit{sh}} {.} {\mathit{vternop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c \in {{\mathit{vternop}}}{{}_{{\mathit{sh}}}(c_1, c_2, c_3)} \\ & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_3)~({\mathit{sh}} {.} {\mathit{vternop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ {{\mathit{vternop}}}{{}_{{\mathit{sh}}}(c_1, c_2, c_3)} = \epsilon \\ \end{array}\end{split}\]

\({\mathit{sh}} {.} {\mathit{vtestop}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. Let \(i\) be \({{\mathit{vtestop}}}{{}_{{\mathit{sh}}}(c_1)}\).

  4. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{sh}} {.} {\mathit{vtestop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i) & \quad \mbox{if}~ i = {{\mathit{vtestop}}}{{}_{{\mathit{sh}}}(c_1)} \\ \end{array}\end{split}\]

\({\mathit{sh}} {.} {\mathit{vrelop}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Let \(c\) be \({{\mathit{vrelop}}}{{}_{{\mathit{sh}}}(c_1, c_2)}\).

  6. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{sh}} {.} {\mathit{vrelop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{\mathit{vrelop}}}{{}_{{\mathit{sh}}}(c_1, c_2)} \\ \end{array}\end{split}\]

\({\mathit{sh}} {.} {\mathit{vshiftop}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Let \(c\) be \({{\mathit{vshiftop}}}{{}_{{\mathit{sh}}}}{(c_1, i)}\).

  6. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~s\) from the stack.

  3. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  5. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(c_1)\).

  6. Let \(j^\ast\) be the result of computing \(\href{../syntax/instructions.html#syntax-vshiftop}{\mathit{vishiftop}}_{t}(i^\ast, s^N)\).

  7. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t\mathsf{x}N}(j^\ast)\).

  8. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\mathit{sh}} {.} {\mathit{vshiftop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{\mathit{vshiftop}}}{{}_{{\mathit{sh}}}}{(c_1, i)} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~s)~t\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-vshiftop}{\mathit{vishiftop}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & i^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(c_1) \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t\mathsf{x}N}(\href{../syntax/instructions.html#syntax-vshiftop}{\mathit{vishiftop}}_{t}(i^\ast, s^N))) \end{array} \end{array}\end{split}\]

\({\mathit{sh}}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{bitmask}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. Let \(c\) be \({\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{bitmask}}}{{}_{{\mathit{sh}}}(c_1)}\).

  4. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) from the stack.

  3. Let \(i_1^N\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(c)\).

  4. Let \(B\) be the bit width \(|t|\) of value type \(t\).

  5. Let \(i_2^N\) be the result of computing \(\href{../exec/numerics.html#op-ilt}{\mathrm{ilt\_s}}_{B}(i_1^N, 0^N)\).

  6. Let \(j^\ast\) be the concatenation of the two sequences \(i_2^N\) and \(0^{32-N}\).

  7. Let \(i\) be the result of computing \(\href{../exec/numerics.html#aux-ibits}{\mathrm{ibits}}_{32}^{-1}(j^\ast)\).

  8. Push the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) onto the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{sh}}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{bitmask}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{bitmask}}}{{}_{{\mathit{sh}}}(c_1)} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c)~t\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{bitmask}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i) & (\mathrel{\mbox{if}} i = \href{../exec/numerics.html#aux-ibits}{\mathrm{ibits}}_{32}^{-1}(\href{../exec/numerics.html#op-ilt}{\mathrm{ilt\_s}}_{|t|}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t\mathsf{x}N}(c), 0^N))) \\ \end{array}\end{split}\]

\({\mathit{sh}} {.} {\mathit{swizzlop}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Let \(c\) be \({{\mathit{swizzlop}}}{{}_{{\mathit{sh}}}(c_1, c_2)}\).

  6. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to validation, two values of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) are on the top of the stack.

  2. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2\) from the stack.

  3. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2)\).

  4. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  5. Let \(j^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1)\).

  6. Let \(c^\ast\) be the concatenation of the two sequences \(j^\ast\) and \(0^{240}\).

  7. Let \(c'\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c^\ast[ i^\ast[0] ] \dots c^\ast[ i^\ast[15] ])\).

  8. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c'\) onto the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{sh}} {.} {\mathit{swizzlop}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{\mathit{swizzlop}}}{{}_{{\mathit{sh}}}(c_1, c_2)} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2)~\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{swizzle}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c') \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & i^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2) \\ \wedge & c^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1)~0^{240} \\ \wedge & c' = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c^\ast[ i^\ast[0] ] \dots c^\ast[ i^\ast[15] ])) \end{array} \end{array}\end{split}\]

\({\mathit{sh}}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{shuffle}}~{i^\ast}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Let \(c\) be \({\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{shuffle}}}{{}_{{\mathit{sh}}}({i^\ast}, c_1, c_2)}\).

  6. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to validation, two values of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) are on the top of the stack.

  2. Assert: due to validation, for all \(x_i\) in \(x^\ast\) it holds that \(x_i < 32\).

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2\) from the stack.

  4. Let \(i_2^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2)\).

  5. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  6. Let \(i_1^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1)\).

  7. Let \(i^\ast\) be the concatenation of the two sequences \(i_1^\ast\) and \(i_2^\ast\).

  8. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(i^\ast[x^\ast[0]] \dots i^\ast[x^\ast[15]])\).

  9. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{sh}}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{shuffle}}~{i^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{shuffle}}}{{}_{{\mathit{sh}}}({i^\ast}, c_1, c_2)} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2)~(\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{shuffle}}~x^\ast) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & i^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1)~\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2) \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(i^\ast[x^\ast[0]] \dots i^\ast[x^\ast[15]])) \end{array} \end{array}\end{split}\]

\({{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{splat}}\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. Assert: Due to validation, \({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0\) is \({\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathsf{i}}{N})\).

  4. Let \(c\) be \({{{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}^{{-1}}}}{({{{\href{../exec/numerics.html#aux-packnum}{\mathrm{pack}}}}_{{\mathsf{i}}{N}}(c_1)^{M}})}\).

  5. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Let \(t\) be the type \(\href{../valid/instructions.html#aux-unpackshape}{\mathrm{unpack}}(\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}})\).

  2. Assert: due to validation, a value of value type \(t\) is on the top of the stack.

  3. Pop the value \(t.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1\) from the stack.

  4. Let \(N\) be the integer \(\href{../syntax/instructions.html#aux-dim}{\mathrm{dim}}(\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}})\).

  5. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}}(c_1^N)\).

  6. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathsf{i}}{N}){.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{splat}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}^{{-1}}}}{({{{\href{../exec/numerics.html#aux-packnum}{\mathrm{pack}}}}_{{\mathsf{i}}{N}}(c_1)^{M}})} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{lcl@{\qquad}l} (t\mathsf{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{splat}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) & (\mathrel{\mbox{if}} t = \href{../valid/instructions.html#aux-unpackshape}{\mathrm{unpack}}(\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}) \wedge c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}}(c_1^{\href{../syntax/instructions.html#aux-dim}{\mathrm{dim}}(\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}})})) \\ \end{array}\end{split}\]

\({{{\mathit{lt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{extract\_lane}}}{\mathsf{\_}}{{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}}~i\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. If \({{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is not defined and the type of \({\mathit{lt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is number type, then:

  1. Let \({\mathit{nt}}\) be \({\mathit{lt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(i\) is less than \({|{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathit{nt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1)|}\), then:

  1. Let \(c_2\) be \({{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathit{nt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1){}[i]\).

  2. Push the value \(({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) to the stack.

  1. If the type of \({\mathit{lt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is packed type, then:

  1. Let \({\mathit{pt}}\) be \({\mathit{lt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \({{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is defined, then:

  1. Let \({\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}\) be \({{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\).

  2. If \(i\) is less than \({|{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathit{pt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1)|}\), then:

  1. Let \(c_2\) be \({{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{{|{\mathit{pt}}|}, 32}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{({{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathit{pt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1){}[i])}\).

  2. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to validation, \(x < N\).

  2. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  4. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}N}(c_1)\).

  5. Let \(t_2\) be the type \(\href{../valid/instructions.html#aux-unpackshape}{\mathrm{unpack}}(t_1\mathsf{x}N)\).

  6. Let \(c_2\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{sx^?}_{t_1,t_2}(i^\ast[x])\).

  7. Push the value \(t_2.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({{\mathit{nt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{extract\_lane}}~i) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2) & \quad \mbox{if}~ c_2 = {{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathit{nt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1){}[i] \\ & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({{{\mathit{pt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{extract\_lane}}}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}~i) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2) & \quad \mbox{if}~ c_2 = {{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{{|{\mathit{pt}}|}, 32}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{({{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathit{pt}}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1){}[i])} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(t_1\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{extract\_lane}}~x) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (t_2\mathsf{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & t_2 = \href{../valid/instructions.html#aux-unpackshape}{\mathrm{unpack}}(t_1\mathsf{x}N) \\ \wedge & c_2 = \href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{sx^?}_{t_1,t_2}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}N}(c_1)[x])) \end{array} \end{array}\end{split}\]

\({{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{replace\_lane}}~i\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, \({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0\) is \({\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathsf{i}}{N})\).

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  6. Let \(c\) be \({{{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}^{{-1}}}}{({{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1){}[{}[i] = {{\href{../exec/numerics.html#aux-packnum}{\mathrm{pack}}}}_{{\mathsf{i}}{N}}(c_2)])}\).

  7. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to validation, \(x < \href{../syntax/instructions.html#aux-dim}{\mathrm{dim}}(\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}})\).

  2. Let \(t_2\) be the type \(\href{../valid/instructions.html#aux-unpackshape}{\mathrm{unpack}}(\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}})\).

  3. Assert: due to validation, a value of value type \(t_1\) is on the top of the stack.

  4. Pop the value \(t_2.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2\) from the stack.

  5. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  6. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  7. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}}(c_1)\).

  8. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}}(i^\ast \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} [x] = c_2)\).

  9. Push \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) on the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\href{../syntax/types.html#aux-unpack}{\mathrm{unpack}}}({\mathsf{i}}{N}){.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{replace\_lane}}~i) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}^{{-1}}}}{({{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1){}[{}[i] = {{\href{../exec/numerics.html#aux-packnum}{\mathrm{pack}}}}_{{\mathsf{i}}{N}}(c_2)])} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(t_2\mathsf{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~(\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{replace\_lane}}~x) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & i^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}}(c_1) \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathit{shape}}}(i^\ast \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} [x] = c_2)) \end{array} \end{array}\end{split}\]

\({\mathit{sh}}_2 {.} {{\mathit{vextunop}}}{\mathsf{\_}}{{\mathit{sh}}_1}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  3. Let \(c\) be \({{\mathit{vextunop}}}{{}_{{\mathit{sh}}_1, {\mathit{sh}}_2}(c_1)}\).

  4. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to syntax, \(N = M / 2\).

  2. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  4. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)\).

  5. Let \((j_1~j_2)^\ast\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(i^\ast)\).

  6. Let \(k^\ast\) be the result of computing \(\href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{|t_2|}(j_1, j_2)^\ast\).

  7. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(k^\ast)\).

  8. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{sh}}_2 {.} {{\mathit{vextunop}}}{\mathsf{\_}}{{\mathit{sh}}_1}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ {{\mathit{vextunop}}}{{}_{{\mathit{sh}}_1, {\mathit{sh}}_2}(c_1)} = c \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{extadd\_pairwise}}\_t_1\mathsf{x}M\_\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & (i_1~i_2)^\ast = \href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)) \\ \wedge & j^\ast = \href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{|t_2|}(i_1, i_2)^\ast \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(j^\ast)) \end{array} \end{array}\end{split}\]

\({\mathit{sh}}_2 {.} {{\mathit{vextbinop}}}{\mathsf{\_}}{{\mathit{sh}}_1}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Let \(c\) be \({{\mathit{vextbinop}}}{{}_{{\mathit{sh}}_1, {\mathit{sh}}_2}(c_1, c_2)}\).

  6. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to syntax, \(N = M / 2\).

  2. Assert: due to validation, two values of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) are on the top of the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2\) from the stack.

  4. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  5. Let \(i_1^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)\).

  6. Let \(i_2^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_2)\).

  7. If \(\href{../syntax/instructions.html#syntax-half}{\mathit{half}}\) is \(\mathsf{low}\), then:

    1. Let \(j_1^\ast\) be the sequence \(i_1^\ast[0 \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N]\).

    2. Let \(j_2^\ast\) be the sequence \(i_2^\ast[0 \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N]\).

  8. Else:

    1. Let \(j_1^\ast\) be the sequence \(i_1^\ast[N \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N]\).

    2. Let \(j_2^\ast\) be the sequence \(i_2^\ast[N \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N]\).

  9. Let \(k_1^\ast\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(j_1^\ast)\).

  10. Let \(k_2^\ast\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(j_2^\ast)\).

  11. Let \(k^\ast\) be the result of computing \(\href{../exec/numerics.html#op-imul}{\mathrm{imul}}_{|t_2|}(k_1^\ast, k_2^\ast)\).

  12. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(k^\ast)\).

  13. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({\mathit{sh}}_2 {.} {{\mathit{vextbinop}}}{\mathsf{\_}}{{\mathit{sh}}_1}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ {{\mathit{vextbinop}}}{{}_{{\mathit{sh}}_1, {\mathit{sh}}_2}(c_1, c_2)} = c \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2)~t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{extmul}}\mathsf{\_}\href{../syntax/instructions.html#syntax-half}{\mathit{half}}\mathsf{\_}t_1\mathsf{x}M\_\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & i^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)[\href{../syntax/instructions.html#syntax-half}{\mathit{half}}(0, N) \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N] \\ \wedge & j^\ast = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_2)[\href{../syntax/instructions.html#syntax-half}{\mathit{half}}(0, N) \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N] \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(\href{../exec/numerics.html#op-imul}{\mathrm{imul}}_{|t_2|}(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(i^\ast), \href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(j^\ast)))) \end{array}\end{split}\]

where:

\[\begin{split}\begin{array}{lcl} \mathsf{low}(x, y) &=& x \\ \mathsf{high}(x, y) &=& y \\ \end{array}\end{split}\]

\(\mathsf{i32x4.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{dot}}\mathsf{\_i16x8\_s}\)

Todo

(*) Prose not spliced, for this seems to be WIP on @Andreas.

  1. Assert: due to validation, two values of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) are on the top of the stack.

  2. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2\) from the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  4. Let \(i_1^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle16}x\scriptstyle8}}}(c_1)\).

  5. Let \(j_1^\ast\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{s}}}_{16,32}(i_1^\ast)\).

  6. Let \(i_2^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle16}x\scriptstyle8}}}(c_2)\).

  7. Let \(j_2^\ast\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{s}}}_{16,32}(i_2^\ast)\).

  8. Let \((k_1~k_2)^\ast\) be the result of computing \(\href{../exec/numerics.html#op-imul}{\mathrm{imul}}_{32}(j_1^\ast, j_2^\ast)\).

  9. Let \(k^\ast\) be the result of computing \(\href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{32}(k_1, k_2)^\ast\).

  10. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle32}x\scriptstyle4}}}(k^\ast)\).

  11. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2)~\mathsf{i32x4.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{dot}}\mathsf{\_i16x8\_s} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & (i_1~i_2)^\ast = \href{../exec/numerics.html#op-imul}{\mathrm{imul}}_{32}(\href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{s}}}_{16,32}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle16}x\scriptstyle8}}}(c_1)), \href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{s}}}_{16,32}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle16}x\scriptstyle8}}}(c_2))) \\ \wedge & j^\ast = \href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{32}(i_1, i_2)^\ast \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle32}x\scriptstyle4}}}(j^\ast)) \end{array} \end{array}\end{split}\]

\({{\mathit{sh}}_2{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{narrow}}}{\mathsf{\_}}{{\mathit{sh}}_1}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)\) from the stack.

  3. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  4. Pop the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)\) from the stack.

  5. Let \(c\) be \({\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{narrow}}}{{{}_{{\mathit{sh}}_1, {\mathit{sh}}_2}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{(c_1, c_2)}\).

  6. Push the value \((\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

Todo

Below is the actual prose.

  1. Assert: due to syntax, \(N = 2\cdot M\).

  2. Assert: due to validation, two values of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) are on the top of the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2\) from the stack.

  4. Let \(i_2^M\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_2)\).

  5. Let \(d_2^M\) be the result of computing \(\href{../exec/numerics.html#op-narrow}{\mathrm{narrow}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(i_2^M)\).

  6. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  7. Let \(i_1^M\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)\).

  8. Let \(d_1^M\) be the result of computing \(\href{../exec/numerics.html#op-narrow}{\mathrm{narrow}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(i_1^M)\).

  9. Let \(j^N\) be the concatenation of the two sequences \(d_1^M\) and \(d_2^M\).

  10. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(j^N)\).

  11. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_2)~({{\mathit{sh}}_2{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{narrow}}}{\mathsf{\_}}{{\mathit{sh}}_1}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{narrow}}}{{{}_{{\mathit{sh}}_1, {\mathit{sh}}_2}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{(c_1, c_2)} \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2)~t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{narrow}}\_t_1\mathsf{x}M\_\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & d_1^M = \href{../exec/numerics.html#op-narrow}{\mathrm{narrow}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}( \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)) \\ \wedge & d_2^M = \href{../exec/numerics.html#op-narrow}{\mathrm{narrow}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}( \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_2)) \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(d_1^M~d_2^M)) \end{array} \end{array}\end{split}\]

Todo

move more of this to numerics

  1. Assert: due to validation, two values of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) are on the top of the stack.

  2. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2\) from the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  4. Let \((i_1~i_2)^8\) be the result of computing \(\href{../exec/numerics.html#op-irelaxed-dot-mul}{\mathrm{irelaxed\_dot\_mul}}_{8, 16}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1), \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2))\)

  5. Let \(j^8\) be the result of computing \(\href{../exec/numerics.html#op-iadd-sat}{\mathrm{iadd\_sat\_s}}_{16}(i_1, i_2)^8\).

  6. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle16}x\scriptstyle8}}}(j^8)\).

  7. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}{l} \begin{array}{llcl@{\qquad}l} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2)~\mathsf{i16x8.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{relaxed\_dot}}\mathsf{\_i8x16\_i7x16\_s} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & (i_1~i_2)^8 = \href{../exec/numerics.html#op-irelaxed-dot-mul}{\mathrm{irelaxed\_dot\_mul}}_{8,16}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1), \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2)) \\ \wedge & j^8 = \href{../exec/numerics.html#op-iadd-sat}{\mathrm{iadd\_sat\_s}}_{16}(i_1, i_2)^8 \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle16}x\scriptstyle8}}}(j^8)) \end{array} \end{array}\end{split}\]

Todo

move more of this to numerics

  1. Assert: due to validation, three values of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) are on the top of the stack.

  2. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_3\) from the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2\) from the stack.

  4. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  5. Let \((i_1~i_2)^8\) be the result of computing \(\href{../exec/numerics.html#op-irelaxed-dot-mul}{\mathrm{irelaxed\_dot\_mul}}_{8, 16}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1), \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2))\)

  6. Let \((j_1~j_2)^4\) be the result of computing \(\href{../exec/numerics.html#op-iadd-sat}{\mathrm{iadd\_sat\_s}}_{16}(i_1, i_2)^8\).

  7. Let \(j^4\) be the result of computing \(\href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{32}(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{s}_{16, 32}(j_1), \href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{s}_{16, 32}(j_2))^4\).

  8. Let \(k^4\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle32}x\scriptstyle4}}}(c_3)\).

  9. Let \(l^4\) be the result of computing \(\href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{32}(j, k)^4\).

  10. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle32}x\scriptstyle4}}}(l^4)\).

  11. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}{l} \begin{array}{llcl@{\qquad}l} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_2)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_3)~\mathsf{i32x4.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{relaxed\_dot}}\mathsf{\_i8x16\_i7x16\_add\_s} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & (i_1~i_2)^8 = \href{../exec/numerics.html#op-irelaxed-dot-mul}{\mathrm{irelaxed\_dot\_mul}}_{8,16}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_1), \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle8}x\scriptstyle16}}}(c_2)) \\ \wedge & (j_1~j_2)^4 = \href{../exec/numerics.html#op-iadd-sat}{\mathrm{iadd\_sat\_s}}_{16}(i_1, i_2)^8 \\ \wedge & j^4 = \href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{32}(\href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{s}}}_{16,32}(j_1), \href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{s}}}_{16,32}(j_2))^4 \\ \wedge & k^4 = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle32}x\scriptstyle4}}}(c_3) \\ \wedge & l^4 = \href{../exec/numerics.html#op-iadd}{\mathrm{iadd}}_{32}(j, k)^4 \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/instructions.html#syntax-shape}{\mathsf{i{\scriptstyle32}x\scriptstyle4}}}(l^4)) \end{array} \end{array}\end{split}\]

\(t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}\mathsf{\_}t_1\mathsf{x}M\mathsf{\_}\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}\)

Todo

move more of this to numerics

Todo

(*) Prose not spliced, for it has merged multiple rules for vcvtop into one algorithm.

  1. Assert: due to syntax, \(N = M\).

  2. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  4. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)\).

  5. Let \(j^\ast\) be the result of computing \(\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(i^\ast)\).

  6. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(j^\ast)\).

  7. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\mathit{sh}}_2 {.} {{\mathit{vcvtop}}}{\mathsf{\_}}{{{\mathit{zero}}^?}}{\mathsf{\_}}{{\mathit{sh}}_1}{\mathsf{\_}}{{{\mathit{half}}^?}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \quad \mbox{if}~ c = {{\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}}}_{{\mathit{sh}}_1, {\mathit{sh}}_2}({\mathit{vcvtop}}, {{\mathit{half}}^?}, {{\mathit{zero}}^?}, c_1) \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}\mathsf{\_}t_1\mathsf{x}M\mathsf{\_}\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{|t_1|,|t_2|}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)))) \end{array} \end{array}\end{split}\]

\(t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}\mathsf{\_}\href{../syntax/instructions.html#syntax-half}{\mathit{half}}\mathsf{\_}t_1\mathsf{x}M\mathsf{\_}\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?\)

Todo

move more of this to numerics

Todo

(*) Prose not spliced, for it has merged multiple rules for vcvtop into one algorithm.

  1. Assert: due to syntax, \(N = M / 2\).

  2. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  4. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)\).

  5. If \(\href{../syntax/instructions.html#syntax-half}{\mathit{half}}\) is \(\mathsf{low}\), then:

    1. Let \(j^\ast\) be the sequence \(i^\ast[0 \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N]\).

  6. Else:

    1. Let \(j^\ast\) be the sequence \(i^\ast[N \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N]\).

  7. Let \(k^\ast\) be the result of computing \(\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{|t_1|,|t_2|}(j^\ast)\).

  8. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(k^\ast)\).

  9. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}\mathsf{\_}\href{../syntax/instructions.html#syntax-half}{\mathit{half}}\mathsf{\_}t_1\mathsf{x}M\mathsf{\_}\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^? &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{|t_1|,|t_2|}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)[\href{../syntax/instructions.html#syntax-half}{\mathit{half}}(0, N) \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N]))) \end{array} \end{array}\end{split}\]

where:

\[\begin{split}\begin{array}{lcl} \mathsf{low}(x, y) &=& x \\ \mathsf{high}(x, y) &=& y \\ \end{array}\end{split}\]

\(t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}\mathsf{\_}t_1\mathsf{x}M\mathsf{\_}\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?\mathsf{\_zero}\)

Todo

(*) Prose not spliced, for it has merged multiple rules for vcvtop into one algorithm.

  1. Assert: due to syntax, \(N = 2 \cdot M\).

  2. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  3. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1\) from the stack.

  4. Let \(i^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1)\).

  5. Let \(j^\ast\) be the result of computing \(\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{|t_1|,|t_2|}(i^\ast)\).

  6. Let \(k^\ast\) be the concatenation of the two sequences \(j^\ast\) and \(0^M\).

  7. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(k^\ast)\).

  8. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c\) onto the stack.

\[\begin{split}\begin{array}{l} \begin{array}{lcl@{\qquad}l} (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c_1)~t_2\mathsf{x}N\mathsf{.}\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}\mathsf{\_}t_1\mathsf{x}M\mathsf{\_}\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?\mathsf{\_zero} &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c) \\ \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{t_2\mathsf{x}N}(\href{../syntax/instructions.html#syntax-vcvtop}{\mathit{vcvtop}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}^?}_{|t_1|,|t_2|}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{t_1\mathsf{x}M}(c_1))~0^M)) \end{array} \end{array}\end{split}\]

Variable Instructions

\(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}get}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{locals}}{}[x]\) is defined.

  3. Let \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{locals}}{}[x]\).

  4. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}get}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} & \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{locals}}{}[x] = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}set}}~x\)

  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 \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  4. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{locals}}{}[x] = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}]\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}set}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{locals}}{}[x] = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}] ; \epsilon \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}tee}}~x\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  3. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  4. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  5. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}set}}~x)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}tee}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{local{.}set}}~x) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{global{.}get}}~x\)

  1. Let \(z\) be the current state.

  2. Let \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}{}[x]{.}\href{../exec/runtime.html#syntax-globalinst}{\mathsf{value}}\).

  3. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{global{.}get}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} & \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}{}[x]{.}\href{../exec/runtime.html#syntax-globalinst}{\mathsf{value}} = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{global{.}set}}~x\)

  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 \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  4. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}{}[x]{.}\href{../exec/runtime.html#syntax-globalinst}{\mathsf{value}} = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}]\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-variable}{\mathsf{global{.}set}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}{}[x]{.}\href{../exec/runtime.html#syntax-globalinst}{\mathsf{value}} = {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}] ; \epsilon \\ \end{array}\end{split}\]

Table Instructions

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  4. If \(i\) is greater than or equal to \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. Push the value \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}{}[i]\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i \geq {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}{}[i] & \quad \mbox{if}~ i < {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x\)

  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 \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  4. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  5. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  6. If \(i\) is greater than or equal to \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}{}[i] = {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}]\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i \geq {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}{}[i] = {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}] ; \epsilon & \quad \mbox{if}~ i < {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}size}}~x\)

  1. Let \(z\) be the current state.

  2. Let \(({\mathit{at}}, {\mathit{lim}}, {\mathit{rt}})\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{type}}\).

  3. Let \(n\) be \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}\).

  4. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}size}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} = n \\ {\land}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{type}} = {\mathit{at}}~{\mathit{lim}}~{\mathit{rt}} \\ \end{array} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}grow}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value is on the top of the stack.

  5. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  6. Either:

  1. Let \({\mathit{ti}}\) be \({\href{../exec/modules.html#grow-table}{\mathrm{growtable}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x], n, {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}})\).

  2. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|})\) to the stack.

  3. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x] = {\mathit{ti}}]\).

  1. Or:

  1. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#aux-signed}{\mathrm{signed}}}}_{{|{\mathit{at}}|}}^{{-1}}}}{({-1})})\) to the stack.

Todo

  1. Maybe we want to be more precise than just saying “Either” in the prose, elaborating that it may succeed or fail non-deterministically.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}grow}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x] = {\mathit{ti}}] ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {\mathit{ti}} = {\href{../exec/modules.html#grow-table}{\mathrm{growtable}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x], n, {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}) } \\ & z ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}grow}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#aux-signed}{\mathrm{signed}}}}_{{|{\mathit{at}}|}}^{{-1}}}}{({-1})}) \\ \end{array}\end{split}\]

Note

The \(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}grow}}\) instruction is non-deterministic. It may either succeed, returning the old table size \(\mathit{sz}\), or fail, returning \({-1}\). Failure must occur if the referenced table instance has a maximum size defined that would be exceeded. However, failure can occur in other cases as well. In practice, the choice depends on the resources available to the embedder.

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}fill}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value is on the top of the stack.

  5. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  6. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  7. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  8. If \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else:

  1. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

  2. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  3. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x)\).

  4. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)\) to the stack.

  5. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  6. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  7. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}fill}}~x)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x) \\ ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}fill}}~x) \end{array} & \mbox{otherwise} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}'}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \({\mathit{at}}_2\) is on the top of the stack.

  5. Pop the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)\) from the stack.

  6. Assert: Due to validation, a value of value type \({\mathit{at}}_1\) is on the top of the stack.

  7. Pop the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)\) from the stack.

  8. If \(i_1 + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x_1]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. If \(i_2 + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x_2]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else:

  1. If \(i_1\) is less than or equal to \(i_2\), then:

  1. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)\) to the stack.

  2. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)\) to the stack.

  3. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x_2)\).

  4. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x_1)\).

  5. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + 1)\) to the stack.

  6. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + 1)\) to the stack.

  1. Else:

  1. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + n - 1)\) to the stack.

  2. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + n - 1)\) to the stack.

  3. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x_2)\).

  4. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x_1)\).

  5. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)\) to the stack.

  6. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)\) to the stack.

  1. Push the value \(({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  2. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i_1 + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x_1]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} \lor i_2 + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x_2]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} } \\ & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x_2)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x_1) \\ ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + 1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + 1)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2) \end{array} & \quad \mbox{otherwise, if}~ i_1 \leq i_2 \\ \end{array} } \\ & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + n - 1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + n - 1)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x_2)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x_1) \\ ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}copy}}~x_1~x_2) \end{array} & \mbox{otherwise} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}init}}~x~y\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)\) from the stack.

  6. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  7. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  8. If \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. If \(j + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else if \(j\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|}\), then:

  1. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

  2. Push the value \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}{}[j]\) to the stack.

  3. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x)\).

  4. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)\) to the stack.

  5. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + 1)\) to the stack.

  6. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  7. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}init}}~x~y)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}init}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[x]{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}|} \lor j + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}|} } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}init}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}init}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[y]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}}{}[j]~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}set}}~x) \\ ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}init}}~x~y) \end{array} & \mbox{otherwise} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{elem{.}drop}}~x\)

  1. Let \(z\) be the current state.

  2. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[x]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}} = \epsilon]\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{elem{.}drop}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{elems}}{}[x]{.}\href{../exec/runtime.html#syntax-eleminst}{\mathsf{elem}} = \epsilon] ; \epsilon \\ \end{array}\end{split}\]

Memory Instructions

Note

The alignment \(\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{align}}\) in load and store instructions does not affect the semantics. It is an indication that the offset \(\mathit{ea}\) at which the memory is accessed is intended to satisfy the property \(\mathit{ea} \mathbin{\mathrm{mod}} 2^{\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{align}}} = 0\). A WebAssembly implementation can use this hint to optimize for the intended use. Unaligned access violating that property is still allowed and must succeed regardless of the annotation. However, it may be substantially slower on some hardware.

\({{\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{{{\mathit{loadop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}}~x~{\mathit{ao}}\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  4. If \({{\mathit{loadop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is not defined, then:

  1. Let \({\mathit{nt}}\) be \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \(i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + {|{\mathit{nt}}|} / 8\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. Let \(c\) be the result for which \({{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{nt}}}(c)\) \(=\) \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : {|{\mathit{nt}}|} / 8]\).

  2. Push the value \(({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) to the stack.

  1. If the type of \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is Inn, then:

  1. If \({{\mathit{loadop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is defined, then:

  1. Let \({\mathit{loadop\_{\scriptstyle 0}}}\) be \({{\mathit{loadop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\).

  2. Let \((n, {\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}})\) be \({\mathit{loadop\_{\scriptstyle 0}}}\).

  3. If \(i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + n / 8\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. Let \({\mathsf{i}}{N}\) be \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\).

  2. If \({{\mathit{loadop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is defined, then:

  1. Let \({\mathit{loadop\_{\scriptstyle 0}}}\) be \({{\mathit{loadop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\).

  2. Let \((n, {\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}})\) be \({\mathit{loadop\_{\scriptstyle 0}}}\).

  3. Let \(c\) be the result for which \({{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{n}}(c)\) \(=\) \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : n / 8]\).

  4. Push the value \(({\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{n, {|{\mathsf{i}}{N}|}}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{(c)})\) to the stack.

Todo

Below is the actual prose. (7) Render $inverse_of_nbytes with display hint.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\) exists.

  3. Let \(a\) be the memory address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\) exists.

  5. Let \(\mathit{mem}\) be the memory instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\).

  6. Assert: due to validation, a value of some address type \(\mathit{at}\) is on the top of the stack.

  7. Pop the value \(\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  8. Let \(\mathit{ea}\) be the integer \(i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}}\).

  9. If \(N\) is not part of the instruction, then:

    1. Let \(N\) be the bit width \(|t|\) of number type \(t\).

  10. If \(\mathit{ea} + N/8\) is larger than the length of \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}\), then:

    1. Trap.

  11. Let \(b^\ast\) be the byte sequence \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8]\).

  12. If \(N\) and \(\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}\) are part of the instruction, then:

    1. Let \(n\) be the integer for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(n) = b^\ast\).

    2. Let \(c\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{N,|t|}(n)\).

  13. Else:

    1. Let \(c\) be the constant for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_t(c) = b^\ast\).

  14. Push the value \(t.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + {|{\mathit{nt}}|} / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{nt}}}(c) = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : {|{\mathit{nt}}|} / 8] } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({{\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{n~{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + n / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({{\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{n~{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{n, {|{\mathsf{i}}{N}|}}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{(c)}) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{n}}(c) = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : n / 8] } \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{M}\mathsf{x}N\_\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}\)

Todo

(*) Rule and prose both not spliced.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\) exists.

  3. Let \(a\) be the memory address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\) exists.

  5. Let \(\mathit{mem}\) be the memory instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\).

  6. Assert: due to validation, a value of some address type \(\mathit{at}\) is on the top of the stack.

  7. Pop the value \(\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  8. Let \(\mathit{ea}\) be the integer \(i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}}\).

  9. If \(\mathit{ea} + M \cdot N /8\) is larger than the length of \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}\), then:

    1. Trap.

  10. Let \(b^\ast\) be the byte sequence \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} M \cdot N /8]\).

  11. Let \(m_k\) be the integer for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emM}}(m_k) = b^\ast[k \cdot M/8 \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} M/8]\).

  12. Let \(W\) be the integer \(M \cdot 2\).

  13. Let \(n_k\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{M,W}(m_k)\).

  14. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\mathsf{i}W\mathsf{x}N}(n_0 \dots n_{N-1})\).

  15. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) to the stack.

\[\begin{split}~\\[-1ex] \begin{array}{l} \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{M}\mathsf{x}N\_\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & \mathit{ea} = i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} \\ \wedge & \mathit{ea} + M \cdot N / 8 \leq |S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}| \\ \wedge & \href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emM}}(m_k) = S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} + k \cdot M/8 \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} M/8]) \\ \wedge & W = M \cdot 2 \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\mathsf{i}W\mathsf{x}N}(\href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{M,W}(m_0) \dots \href{../exec/numerics.html#op-ext}{\mathrm{extend}}^{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}_{M,W}(m_{N-1}))) \end{array} \\[1ex] \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{M}\mathsf{x}N\mathsf{\_}\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \end{array} \\ \qquad (\mathrel{\mbox{otherwise}}) \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{{M}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{K}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + M \cdot K / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{{M}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{K}{\mathsf{\_}}{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ ({{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{M}}(j) = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + k \cdot M / 8 : M / 8])^{k<K} \\ {\land}~ c = {{{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{K}}^{{-1}}}}{({{{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{M, N}^{{\href{../syntax/instructions.html#syntax-sx}{\mathit{sx}}}}}}{(j)}^{K}})} \land N = M \cdot 2 \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_splat}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}\)

Todo

(*) Rule and prose both not spliced.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\) exists.

  3. Let \(a\) be the memory address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\) exists.

  5. Let \(\mathit{mem}\) be the memory instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\).

  6. Assert: due to validation, a value of some address type \(\mathit{at}\) is on the top of the stack.

  7. Pop the value \(\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  8. Let \(\mathit{ea}\) be the integer \(i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}}\).

  9. If \(\mathit{ea} + N/8\) is larger than the length of \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}\), then:

    1. Trap.

  10. Let \(b^\ast\) be the byte sequence \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8]\).

  11. Let \(n\) be the integer for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(n) = b^\ast\).

  12. Let \(L\) be the integer \(128 / N\).

  13. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(n^L)\).

  14. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) to the stack.

\[\begin{split}~\\[-1ex] \begin{array}{l} \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_splat}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & \mathit{ea} = i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} \\ \wedge & \mathit{ea} + N/8 \leq |S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}| \\ \wedge & \href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(n) = S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8] \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(n^L)) \end{array} \\[1ex] \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_splat}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \end{array} \\ \qquad (\mathrel{\mbox{otherwise}}) \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{splat}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + N / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{splat}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{N}}(j) = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : N / 8] \\ {\land}~ N = {|{\mathsf{i}}{N}|} \\ {\land}~ M = 128 / N \\ {\land}~ c = {{{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}^{{-1}}}}{({j^{M}})} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_zero}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}\)

Todo

(*) Rule and prose both not spliced.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\) exists.

  3. Let \(a\) be the memory address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\) exists.

  5. Let \(\mathit{mem}\) be the memory instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\).

  6. Assert: due to validation, a value of some address type \(\mathit{at}\) is on the top of the stack.

  7. Pop the value \(\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  8. Let \(\mathit{ea}\) be the integer \(i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}}\).

  9. If \(\mathit{ea} + N/8\) is larger than the length of \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}\), then:

    1. Trap.

  10. Let \(b^\ast\) be the byte sequence \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8]\).

  11. Let \(n\) be the integer for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(n) = b^\ast\).

  12. Let \(c\) be the result of computing \(\href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{u}}}_{N,128}(n)\).

  13. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) to the stack.

\[\begin{split}~\\[-1ex] \begin{array}{l} \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_zero}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & \mathit{ea} = i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} \\ \wedge & \mathit{ea} + N/8 \leq |S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}| \\ \wedge & \href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(n) = S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8]) \\ \wedge & c = \href{../exec/numerics.html#op-ext}{\mathrm{extend}^{\mathsf{u}}}_{N,128}(n) \end{array} \\[1ex] \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_zero}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \end{array} \\ \qquad (\mathrel{\mbox{otherwise}}) \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{zero}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + N / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{zero}}}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{N}}(j) = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : N / 8] \\ {\land}~ c = {{{{\href{../exec/numerics.html#op-ext}{\mathrm{extend}}}}_{N, 128}^{\href{../syntax/instructions.html#syntax-sx}{\mathsf{u}}}}}{(j)} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_lane}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}~y\)

Todo

(*) Rule and prose both not spliced.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\) exists.

  3. Let \(a\) be the memory address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\) exists.

  5. Let \(\mathit{mem}\) be the memory instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\).

  6. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  7. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~v\) from the stack.

  8. Assert: due to validation, a value of some address type \(\mathit{at}\) is on the top of the stack.

  9. Pop the value \(\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  10. Let \(\mathit{ea}\) be the integer \(i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}}\).

  11. If \(\mathit{ea} + N/8\) is larger than the length of \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}\), then:

    1. Trap.

  12. Let \(b^\ast\) be the byte sequence \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8]\).

  13. Let \(r\) be the constant for which \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(r) = b^\ast\).

  14. Let \(L\) be \(128 / N\).

  15. Let \(j^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(v)\).

  16. Let \(c\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(j^\ast \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} [y] = r)\).

  17. Push the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) to the stack.

\[\begin{split}~\\[-1ex] \begin{array}{l} \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~v)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_lane}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}~y) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & \mathit{ea} = i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} \\ \wedge & \mathit{ea} + N/8 \leq |S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}| \\ \wedge & \href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(r) = S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8]) \\ \wedge & L = 128/N \\ \wedge & c = \href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}^{-1}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(v) \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} [y] = r)) \end{array} \\[1ex] \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~v)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}{N}\mathsf{\_lane}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}~y) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \end{array} \\ \qquad (\mathrel{\mbox{otherwise}}) \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{lane}}}~x~{\mathit{ao}}~j) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + N / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c_1)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{lane}}}~x~{\mathit{ao}}~j) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{N}}(k) = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : N / 8] \\ {\land}~ N = {|{\mathsf{i}}{N}|} \\ {\land}~ M = {|\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}|} / N \\ {\land}~ c = {{{{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}^{{-1}}}}{({{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c_1){}[{}[j] = k])} \\ \end{array} } \\ \end{array}\end{split}\]

\({{\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{{{\mathit{storeop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}}~x~{\mathit{ao}}\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 3}}}\) is on the top of the stack.

  3. Pop the value \(({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 3}}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) from the stack.

  4. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  5. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  6. Let \({\mathit{nt}}\) be \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 3}}}\).

  7. If \(i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + {|{\mathit{nt}}|} / 8\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\) and \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is \({\mathit{nt}}\) and \({{\mathit{storeop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is not defined, then:

  1. Trap.

  1. If \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is \({\mathit{nt}}\) and \({{\mathit{storeop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is not defined, then:

  1. Let \({b^\ast}\) be \({{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{nt}}}(c)\).

  2. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : {|{\mathit{nt}}|} / 8] = {b^\ast}]\).

  1. If the type of \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 3}}}\) is Inn, then:

  1. Let \({\mathsf{i}}{N}\) be \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 3}}}\).

  2. If \({\mathit{nt}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}\) is \({\mathsf{i}}{N}\) and \({{\mathit{storeop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\) is defined, then:

  1. Let \(n\) be \({{\mathit{storeop}}_{\mathit{u{\kern-0.1em\scriptstyle 1}}}^?}\).

  2. If \(i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + n / 8\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. Let \({b^\ast}\) be \({{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{n}}({{\href{../exec/numerics.html#op-wrap}{\mathrm{wrap}}}}_{{|{\mathsf{i}}{N}|}, n}(c))\).

  2. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : n / 8] = {b^\ast}]\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + {|{\mathit{nt}}|} / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : {|{\mathit{nt}}|} / 8] = {b^\ast}] ; \epsilon & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {b^\ast} = {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\mathit{nt}}}(c) } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~({{\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{n}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + n / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~({\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~({{\mathsf{i}}{N}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{n}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : n / 8] = {b^\ast}] ; \epsilon & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {b^\ast} = {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{n}}({{\href{../exec/numerics.html#op-wrap}{\mathrm{wrap}}}}_{{|{\mathsf{i}}{N}|}, n}(c)) } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + {|\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}|} / 8 > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}~x~{\mathit{ao}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : {|\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}|} / 8] = {b^\ast}] ; \epsilon & \quad \mbox{if}~ {b^\ast} = {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}}(c) \\ \end{array}\end{split}\]

\(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\mathsf{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}{N}\mathsf{\_lane}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}~y\)

Todo

(*) Rule and prose both not spliced.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\) exists.

  3. Let \(a\) be the memory address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\) exists.

  5. Let \(\mathit{mem}\) be the memory instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a]\).

  6. Assert: due to validation, a value of value type \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}\) is on the top of the stack.

  7. Pop the value \(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c\) from the stack.

  8. Assert: due to validation, a value of some address type \(\mathit{at}\) is on the top of the stack.

  9. Pop the value \(\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  10. Let \(\mathit{ea}\) be the integer \(i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}}\).

  11. If \(\mathit{ea} + N/8\) is larger than the length of \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}\), then:

    1. Trap.

  12. Let \(L\) be \(128/N\).

  13. Let \(j^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(c)\).

  14. Let \(b^\ast\) be the result of computing \(\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(j^\ast[y])\).

  15. Replace the bytes \(\mathit{mem}.\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8]\) with \(b^\ast\).

\[\begin{split}~\\[-1ex] \begin{array}{l} \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}{N}\mathsf{\_lane}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}~y) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S'; F; \epsilon \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & \mathit{ea} = i + \href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} \\ \wedge & \mathit{ea} + N \leq |S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}| \\ \wedge & L = 128/N \\ \wedge & S' = S \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} \href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{mems}}[x]].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[\mathit{ea} \href{../syntax/conventions.html#notation-slice}{\mathrel{\mathbf{:}}} N/8] = \href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}_{\href{../syntax/values.html#syntax-int}{\mathit{i}\scriptstyle\kern-0.1emN}}(\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}_{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}\scriptstyle\kern-0.1emN}\mathsf{x}L}(c)[y])) \end{array} \\[1ex] \begin{array}{lcl@{\qquad}l} S; F; (\mathit{at}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}.\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}{N}\mathsf{\_lane}~x~\href{../syntax/instructions.html#syntax-memarg}{\mathit{memarg}}~y) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; F; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \end{array} \\ \qquad (\mathrel{\mbox{otherwise}}) \\ \end{array}\end{split}\]
\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{lane}}}~x~{\mathit{ao}}~j) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} + N > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~({\href{../syntax/types.html#syntax-vectype}{\mathsf{v\scriptstyle128}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{N}{\mathsf{\_}}{\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{lane}}}~x~{\mathit{ao}}~j) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}{}[i + {\mathit{ao}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{offset}} : N / 8] = {b^\ast}] ; \epsilon & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ N = {|{\mathsf{i}}{N}|} \\ {\land}~ M = 128 / N \\ {\land}~ {b^\ast} = {{\href{../exec/numerics.html#aux-bytes}{\mathrm{bytes}}}}_{{\href{../syntax/types.html#syntax-numtype}{\mathsf{i}}}{N}}({{\href{../exec/numerics.html#aux-lanes}{\mathrm{lanes}}}}_{{{\mathsf{i}}{N}}{\href{../syntax/instructions.html#syntax-shape}{\mathsf{x}}}{M}}(c){}[j]) \\ \end{array} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}size}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{type}}\) is of the case \(\href{../syntax/types.html#syntax-memtype}{\mathsf{page}}\).

  3. Let \(({\mathit{at}}~{\mathit{lim}}~\href{../syntax/types.html#syntax-memtype}{\mathsf{page}})\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{type}}\).

  4. Let \(n \cdot 64 \, {\mathrm{Ki}}\) be \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\).

  5. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) to the stack.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}size}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ n \cdot 64 \, {\mathrm{Ki}} = {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ {\land}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{type}} = {\mathit{at}}~{\mathit{lim}}~\href{../syntax/types.html#syntax-memtype}{\mathsf{page}} \\ \end{array} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}grow}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Either:

  1. Let \({\mathit{mi}}\) be \({\href{../exec/modules.html#grow-mem}{\mathrm{growmem}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x], n)\).

  2. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} / 64 \, {\mathrm{Ki}})\) to the stack.

  3. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x] = {\mathit{mi}}]\).

  1. Or:

  1. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#aux-signed}{\mathrm{signed}}}}_{{|{\mathit{at}}|}}^{{-1}}}}{({-1})})\) to the stack.

Todo

  1. Maybe we want to be more precise than just saying “Either” in the prose, elaborating that it may succeed or fail non-deterministically.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}grow}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x] = {\mathit{mi}}] ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} / 64 \, {\mathrm{Ki}}) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ {\mathit{mi}} = {\href{../exec/modules.html#grow-mem}{\mathrm{growmem}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x], n) } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}grow}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~{{{{\href{../exec/numerics.html#aux-signed}{\mathrm{signed}}}}_{{|{\mathit{at}}|}}^{{-1}}}}{({-1})}) \\ \end{array}\end{split}\]

Note

The \(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}grow}}\) instruction is non-deterministic. It may either succeed, returning the old memory size \(\mathit{sz}\), or fail, returning \({-1}\). Failure must occur if the referenced memory instance has a maximum size defined that would be exceeded. However, failure can occur in other cases as well. In practice, the choice depends on the resources available to the embedder.

\(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}fill}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value is on the top of the stack.

  5. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  6. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  7. Pop the value \(({\href{../syntax/types.html#syntax-numtype}{\mathit{numtype}}}_0{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  8. If \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else:

  1. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

  2. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  3. Execute the instruction \(({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x)\).

  4. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)\) to the stack.

  5. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  6. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  7. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}fill}}~x)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}fill}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x) \\ ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)~{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}fill}}~x) \end{array} & \mbox{otherwise} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \({\mathit{at}'}\) is on the top of the stack.

  3. Pop the value \(({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \({\mathit{at}}_2\) is on the top of the stack.

  5. Pop the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)\) from the stack.

  6. Assert: Due to validation, a value of value type \({\mathit{at}}_1\) is on the top of the stack.

  7. Pop the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)\) from the stack.

  8. If \(i_1 + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x_1]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. If \(i_2 + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x_2]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else:

  1. If \(i_1\) is less than or equal to \(i_2\), then:

  1. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)\) to the stack.

  2. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)\) to the stack.

  3. Execute the instruction \(({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{(8, \href{../syntax/instructions.html#syntax-sx}{\mathsf{u}})}~x_2)\).

  4. Execute the instruction \(({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x_1)\).

  5. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + 1)\) to the stack.

  6. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + 1)\) to the stack.

  1. Else:

  1. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + n - 1)\) to the stack.

  2. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + n - 1)\) to the stack.

  3. Execute the instruction \(({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{(8, \href{../syntax/instructions.html#syntax-sx}{\mathsf{u}})}~x_2)\).

  4. Execute the instruction \(({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x_1)\).

  5. Push the value \(({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)\) to the stack.

  6. Push the value \(({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)\) to the stack.

  1. Push the value \(({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  2. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i_1 + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x_1]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \lor i_2 + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x_2]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} } \\ & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{8~\href{../syntax/instructions.html#syntax-sx}{\mathsf{u}}}~x_2)~({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x_1) \\ ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + 1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + 1)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2) \end{array} & \quad \mbox{otherwise, if}~ i_1 \leq i_2 \\ \end{array} } \\ & z ; ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1 + n - 1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2 + n - 1)~({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{load}}}{8~\href{../syntax/instructions.html#syntax-sx}{\mathsf{u}}}~x_2)~({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x_1) \\ ({\mathit{at}}_1{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_1)~({\mathit{at}}_2{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i_2)~({\mathit{at}'}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}copy}}~x_1~x_2) \end{array} & \mbox{otherwise} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}init}}~x~y\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  3. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)\) from the stack.

  4. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  5. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)\) from the stack.

  6. Assert: Due to validation, a value of value type \({\mathit{at}}\) is on the top of the stack.

  7. Pop the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  8. If \(i + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. If \(j + n\) is greater than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}|}\), then:

  1. Trap.

  1. If \(n\) is \(0\), then:

  1. Do nothing.

  1. Else if \(j\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}|}\), then:

  1. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) to the stack.

  2. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}{}[j])\) to the stack.

  3. Execute the instruction \(({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x)\).

  4. Push the value \(({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)\) to the stack.

  5. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + 1)\) to the stack.

  6. Push the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)\) to the stack.

  7. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}init}}~x~y)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}init}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} & \\ & \multicolumn{4}{@{}l@{}}{\quad \quad \mbox{if}~ i + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[x]{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}|} \lor j + n > {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}|} } \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}init}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{otherwise, if}~ n = 0 \\ & z ; ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}init}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & & \\ & \multicolumn{4}{@{}l@{}}{\quad \begin{array}[t]{@{}l@{}l@{}} \begin{array}[t]{@{}l@{}} ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[y]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}}{}[j])~({\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{store}}}{8}~x) \\ ({\mathit{at}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~j + 1)~(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~n - 1)~(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory{.}init}}~x~y) \end{array} & \mbox{otherwise} \\ \end{array} } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{data{.}drop}}~x\)

  1. Let \(z\) be the current state.

  2. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[x]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}} = \epsilon]\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{data{.}drop}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{datas}}{}[x]{.}\href{../exec/runtime.html#syntax-datainst}{\mathsf{bytes}} = \epsilon] ; \epsilon \\ \end{array}\end{split}\]

Control Instructions

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{block}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}\)

  1. Let \(z\) be the current state.

  2. Let \({t_1^{m}}~\href{../syntax/types.html#syntax-functype}{\rightarrow}~{t_2^{n}}\) be \({{\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}}}_{z}({\mathit{bt}})\).

  3. Assert: Due to validation, there are at least \(m\) values on the top of the stack.

  4. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}\) from the stack.

  5. Enter \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}\) with label \(({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{}~\epsilon~\})\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{block}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{ \epsilon \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \quad \mbox{if}~ {{\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}}}_{z}({\mathit{bt}}) = {t_1^{m}} \href{../syntax/types.html#syntax-functype}{\rightarrow} {t_2^{n}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{loop}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}\)

  1. Let \(z\) be the current state.

  2. Let \({t_1^{m}}~\href{../syntax/types.html#syntax-functype}{\rightarrow}~{t_2^{n}}\) be \({{\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}}}_{z}({\mathit{bt}})\).

  3. Assert: Due to validation, there are at least \(m\) values on the top of the stack.

  4. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}\) from the stack.

  5. Enter \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}\) with label \(({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{m}}{\{}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{loop}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast})~\})\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{loop}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{m}}{\{ \href{../syntax/instructions.html#syntax-instr-control}{\mathsf{loop}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \quad \mbox{if}~ {{\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}}}_{z}({\mathit{bt}}) = {t_1^{m}} \href{../syntax/types.html#syntax-functype}{\rightarrow} {t_2^{n}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{if}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_1^\ast}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_2^\ast}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) from the stack.

  3. If \(c\) is not \(0\), then:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{block}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_1^\ast})\).

  1. Else:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{block}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_2^\ast})\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{if}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_1^\ast}~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{else}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_2^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{block}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_1^\ast}) & \quad \mbox{if}~ c \neq 0 \\ & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{if}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_1^\ast}~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{else}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_2^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{block}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}_2^\ast}) & \quad \mbox{if}~ c = 0 \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l\)

  1. If the first non-value entry of the stack is a \(\href{../exec/runtime.html#syntax-label}{\mathsf{label}}\), then:

  1. Let \(({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast}~\})\) be the current \(\href{../exec/runtime.html#syntax-label}{\mathsf{label}}\) context.

  2. If \(l\) is \(0\), then:

  1. Assert: Due to validation, there are at least \(n\) values on the top of the stack.

  2. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) from the stack.

  3. Pop all values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}'}^\ast}\) from the top of the stack.

  4. Pop the current \(\mathsf{label}\) context from the stack.

  5. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) to the stack.

  6. Execute the instruction \({{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast}\).

  1. Else:

  1. Pop all values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) from the top of the stack.

  2. If \(l\) is greater than \(0\), then:

  1. Pop the current \(\mathsf{label}\) context from the stack.

  2. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) to the stack.

  3. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l - 1)\).

  1. Else if the first non-value entry of the stack is a \(\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}\), then:

  1. Pop all values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) from the top of the stack.

  2. Pop the current \(\mathsf{handler}\) context from the stack.

  3. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) to the stack.

  4. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}'}^\ast}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast} & \quad \mbox{if}~ l = 0 \\ & ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l - 1) & \quad \mbox{if}~ l > 0 \\ & ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_if}}~l\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) from the stack.

  3. If \(c\) is not \(0\), then:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

  1. Else:

  1. Do nothing.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_if}}~l) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) & \quad \mbox{if}~ c \neq 0 \\ & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_if}}~l) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{if}~ c = 0 \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_table}}~{l^\ast}~{l'}\)

  1. Assert: Due to validation, a value of value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  2. Pop the value \((\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)\) from the stack.

  3. If \(i\) is less than \({|{l^\ast}|}\), then:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~{l^\ast}{}[i])\).

  1. Else:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~{l'})\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_table}}~{l^\ast}~{l'}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~{l^\ast}{}[i]) & \quad \mbox{if}~ i < {|{l^\ast}|} \\ & (\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_table}}~{l^\ast}~{l'}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~{l'}) & \quad \mbox{if}~ i \geq {|{l^\ast}|} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_null}}~l\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  3. If \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

  1. Else:

  1. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_null}}~l) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) & \quad \mbox{if}~ {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} = \href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}} \\ & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_null}}~l) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_non\_null}}~l\)

  1. Assert: Due to validation, a value is on the top of the stack.

  2. Pop the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) from the stack.

  3. If \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) is of the case \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}\), then:

  1. Do nothing.

  1. Else:

  1. Push the value \({\href{../exec/runtime.html#syntax-val}{\mathit{val}}}\) to the stack.

  2. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

Todo

  1. Introduce if-let instruction instead of “is of the case”.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_non\_null}}~l) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \epsilon & \quad \mbox{if}~ {\href{../exec/runtime.html#syntax-val}{\mathit{val}}} = \href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}} \\ & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_non\_null}}~l) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-val}{\mathit{val}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_cast}}~l~{\mathit{rt}}_1~{\mathit{rt}}_2\)

  1. Let \(({\mathsf{frame}}_{}\,\{~f~\})\) be the current \(\mathsf{frame}\) context.

  2. Assert: Due to validation, a value is on the top of the stack.

  3. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  4. Let \({\mathit{rt}}\) be \({\mathrm{Ref}}_{\mathit{type}}({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}})\).

  5. Push the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) to the stack.

  6. If \({\mathit{rt}}\) does not match \({{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}}_2)\), then:

  1. Do nothing.

  1. Else:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

Todo

Below is the acutal prose. (9) Need to handle RulePr s |- ref : rt properly in prose instead of $ref_type_of

  1. Let \(F\) be the current frame.

  2. Let \(\mathit{rt}'_2\) be the reference type \(\href{../exec/types.html#type-inst}{\mathrm{clos}}_{F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}(\mathit{rt}_2)\).

  3. Assert: due to validation, \(\mathit{rt}'_2\) is closed.

  4. Assert: due to validation, a reference value is on the top of the stack.

  5. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  6. Assert: due to validation, the reference value is valid with some reference type.

  7. Let \(\mathit{rt}\) be the reference type of \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  8. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) back to the stack.

  9. If the reference type \(\mathit{rt}\) matches \(\mathit{rt}'_2\), then:

    1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_cast}}~l~{\mathit{rt}}_1~{\mathit{rt}}_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ s \vdash {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} : {\mathit{rt}} \\ {\land}~ \{ \begin{array}[t]{@{}l@{}} \}\end{array} \href{../valid/matching.html#match-reftype}{\vdash} {\mathit{rt}} \href{../valid/matching.html#match-reftype}{\leq} {{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}}_2) \\ \end{array} \\ & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_cast}}~l~{\mathit{rt}}_1~{\mathit{rt}}_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_cast\_fail}}~l~{\mathit{rt}}_1~{\mathit{rt}}_2\)

  1. Let \(({\mathsf{frame}}_{}\,\{~f~\})\) be the current \(\mathsf{frame}\) context.

  2. Assert: Due to validation, a value is on the top of the stack.

  3. Pop the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) from the stack.

  4. Let \({\mathit{rt}}\) be \({\mathrm{Ref}}_{\mathit{type}}({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}})\).

  5. Push the value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) to the stack.

  6. If \({\mathit{rt}}\) matches \({{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}}_2)\), then:

  1. Do nothing.

  1. Else:

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

Todo

Below is the actual prose. (9) Need to handle RulePr s |- ref : rt properly in prose instead of $ref_type_of

  1. Let \(F\) be the current frame.

  2. Let \(\mathit{rt}'_2\) be the reference type \(\href{../exec/types.html#type-inst}{\mathrm{clos}}_{F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}(\mathit{rt}_2)\).

  3. Assert: due to validation, \(\mathit{rt}'_2\) is closed.

  4. Assert: due to validation, a reference value is on the top of the stack.

  5. Pop the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  6. Assert: due to validation, the reference value is valid with some reference type.

  7. Let \(\mathit{rt}\) be the reference type of \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  8. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) back to the stack.

  9. If the reference type \(\mathit{rt}\) does not match \(\mathit{rt}'_2\), then:

    1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l)\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_cast\_fail}}~l~{\mathit{rt}}_1~{\mathit{rt}}_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ s \vdash {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}} : {\mathit{rt}} \\ {\land}~ \{ \begin{array}[t]{@{}l@{}} \}\end{array} \href{../valid/matching.html#match-reftype}{\vdash} {\mathit{rt}} \href{../valid/matching.html#match-reftype}{\leq} {{\href{../exec/types.html#type-inst}{\mathrm{clos}}}}_{f{.}\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}}({\mathit{rt}}_2) \\ \end{array} \\ & s ; f ; {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_on\_cast\_fail}}~l~{\mathit{rt}}_1~{\mathit{rt}}_2) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}}\)

  1. If the first non-value entry of the stack is a \(\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}\), then:

  1. Let \(({{\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}}_{n}}{\{}~f~\})\) be the current \(\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}\) context.

  2. Assert: Due to validation, there are at least \(n\) values on the top of the stack.

  3. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) from the stack.

  4. Pop all values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}'}^\ast}\) from the top of the stack.

  5. Pop the current \(\mathsf{frame}\) context from the stack.

  6. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) to the stack.

  1. Else if the first non-value entry of the stack is a \(\href{../exec/runtime.html#syntax-label}{\mathsf{label}}\), then:

  1. Pop all values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) from the top of the stack.

  2. Pop the current \(\mathsf{label}\) context from the stack.

  3. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) to the stack.

  4. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}}\).

  1. Else:

  1. If the first non-value entry of the stack is a \(\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}\), then:

  1. Pop all values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) from the top of the stack.

  2. Pop the current \(\mathsf{handler}\) context from the stack.

  3. Push the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}\) to the stack.

  4. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}}\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({{\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}}_{n}}{\{ f \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}'}^\ast}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}} \\ & ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}} \\ & ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \(x\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}|}\).

  3. Let \(a\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}{}[x]\).

  4. Assert: Due to validation, \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}|}\).

  5. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)\) to the stack.

  6. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}})\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}}) & \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}{}[x] = a \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~x\)

Todo

(*) Prose not spliced, for the prose merges the two cases of null and non-null references.

  1. Assert: due to validation, a null or function reference is on the top of the stack.

  2. Pop the reference value \(r\) from the stack.

  3. If \(r\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\mathit{ht}\), then:

    1. Trap.

  4. Assert: due to validation, \(r\) is a function reference.

  5. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a\) be the reference \(r\).

  6. Invoke the function instance at address \(a\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ \end{array}\end{split}\]

Note

The formal rule for calling a non-null function reference is described below.

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_indirect}}~x~y\)

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x)\).

  2. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}cast}}~(\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~(\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~()~{}^?)~y))\).

  3. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~y)\).

Todo

Below is the actual prose. (11) ref.cast (ref (null ()) y) is rendered differently. Need to handle TERMINAL? case in AL-to-EL-expr phase.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tables}}[x]\) exists.

  3. Let \(\mathit{ta}\) be the table address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tables}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[\mathit{ta}]\) exists.

  5. Let \(\mathit{tab}\) be the table instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[\mathit{ta}]\).

  6. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[y]\) is defined.

  7. Let \(\mathit{dt}_{\mathrm{expect}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[y]\).

  8. Assert: due to validation, a value with value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  9. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  10. If \(i\) is not smaller than the length of \(\mathit{tab}.\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}\), then:

    1. Trap.

  11. Let \(r\) be the reference \(\mathit{tab}.\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}[i]\).

  12. If \(r\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\mathit{ht}\), then:

    1. Trap.

  13. Assert: due to validation of table mutation, \(r\) is a function reference.

  14. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a\) be the function reference \(r\).

  15. Assert: due to validation of table mutation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a]\) exists.

  16. Let \(\mathit{f}\) be the function instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a]\).

  17. Let \(\mathit{dt}_{\mathrm{actual}}\) be the defined type \(\mathit{f}.\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}}\).

  18. If \(\mathit{dt}_{\mathrm{actual}}\) does not match \(\mathit{dt}_{\mathrm{expect}}\), then:

    1. Trap.

  19. Invoke the function instance at address \(a\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_indirect}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x)~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}cast}}~(\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~y))~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~y) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \(x\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}|}\).

  3. Let \(a\) be \(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}{}[x]\).

  4. Assert: Due to validation, \(a\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}|}\).

  5. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)\) to the stack.

  6. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}})\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}}) & \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{module}}{.}\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{funcs}}{}[x] = a \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~x\)

Todo

(*) Prose not spliced, Sphinx cannot build the document with deeply nested ordered list. (mainly caused by spurious conditions that should be assertions)

  1. Assert: due to validation, a function reference is on the top of the stack.

  2. Pop the reference value \(r\) from the stack.

  3. If \(r\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\mathit{ht}\), then:

    1. Trap.

  4. Assert: due to validation, \(r\) is a function reference.

  5. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a\) be the reference \(r\).

  6. Tail-invoke the function instance at address \(a\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{k}}{\{ {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y)~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y) \\ & z ; ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{k}}{\{ {{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y)~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y) \\ & z ; ({{\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}}_{k}}{\{ f \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y)~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\ & z ; ({{\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}}_{k}}{\{ f \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}'}^\ast}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y)~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~y) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}} \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~({t_1^{n}} \href{../syntax/types.html#syntax-functype}{\rightarrow} {t_2^{m}}) } \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_indirect}}~x~y\)

  1. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x)\).

  2. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}cast}}~(\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~(\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~()~{}^?)~y))\).

  3. Execute the instruction \((\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y)\).

Todo

Below is the actual prose. (11) ref.cast (ref (null ()) y) is rendered differently. Need to handle TERMINAL? case in AL-to-EL-expr phase.

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tables}}[x]\) exists.

  3. Let \(\mathit{ta}\) be the table address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tables}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[\mathit{ta}]\) exists.

  5. Let \(\mathit{tab}\) be the table instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[\mathit{ta}]\).

  6. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[y]\) exists.

  7. Let \(\mathit{dt}_{\mathrm{expect}}\) be the defined type \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{types}}[y]\).

  8. Assert: due to validation, a value with value type \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}\) is on the top of the stack.

  9. Pop the value \(\href{../syntax/types.html#syntax-numtype}{\mathsf{i\scriptstyle32}}.\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~i\) from the stack.

  10. If \(i\) is not smaller than the length of \(\mathit{tab}.\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}\), then:

    1. Trap.

  11. If \(\mathit{tab}.\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}[i]\) is uninitialized, then:

    1. Trap.

  12. Let \(a\) be the function address \(\mathit{tab}.\href{../exec/runtime.html#syntax-tableinst}{\mathsf{elem}}[i]\).

  13. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a]\) exists.

  14. Let \(\mathit{f}\) be the function instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a]\).

  15. Let \(\mathit{dt}_{\mathrm{actual}}\) be the defined type \(\mathit{f}.\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}}\).

  16. If \(\mathit{dt}_{\mathrm{actual}}\) does not match \(\mathit{dt}_{\mathrm{expect}}\), then:

    1. Trap.

  17. Tail-invoke the function instance at address \(a\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_indirect}}~x~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table{.}get}}~x)~(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}cast}}~(\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~y))~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return\_call\_ref}}~y) \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw}}~x\)

  1. Let \(z\) be the current state.

  2. Assert: Due to validation, \(x\) is less than \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}|}\).

  3. Assert: Due to validation, \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}{}[x]{.}\href{../exec/runtime.html#syntax-taginst}{\mathsf{type}})\) is of the case \(\href{../syntax/types.html#syntax-comptype}{\mathsf{func}}\).

  4. Let \((\href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~{\href{../syntax/types.html#syntax-functype}{\mathit{functype}}}_0)\) be \({\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}}(z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}{}[x]{.}\href{../exec/runtime.html#syntax-taginst}{\mathsf{type}})\).

  5. Let \({t^{n}}~\href{../syntax/types.html#syntax-functype}{\rightarrow}~{\href{../syntax/types.html#syntax-valtype}{\mathit{valtype}}}_1\) be \({\href{../syntax/types.html#syntax-functype}{\mathit{functype}}}_0\).

  6. Assert: Due to validation, \({\href{../syntax/types.html#syntax-valtype}{\mathit{valtype}}}_1\) is \(\epsilon\).

  7. Let \(a\) be \({|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}|}\).

  8. Assert: Due to validation, there are at least \(n\) values on the top of the stack.

  9. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}\) from the stack.

  10. Let \({\mathit{exn}}\) be \(\{ \begin{array}[t]{@{}l@{}}\href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}{}[x],\; \href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}} \}\end{array}\).

  11. Perform \(z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}} \mathrel{{=}{\oplus}} {\mathit{exn}}]\).

  12. Push the value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)\) to the stack.

  13. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}\).

Todo

check prose

  1. Let \(F\) be the current frame.

  2. Assert: due to validation, \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tags}}[x]\) exists.

  3. Let \(\mathit{ta}\) be the tag address \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tags}}[x]\).

  4. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}[\mathit{ta}]\) exists.

  5. Let \(\mathit{ti}\) be the tag instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}[\mathit{ta}]\).

  6. Let \([t^n] \href{../syntax/types.html#syntax-functype}{\rightarrow} [{t'}^\ast]\) be the tag type \(\mathit{ti}.\href{../exec/runtime.html#syntax-taginst}{\mathsf{type}}\).

  7. Assert: due to validation, there are at least \(n\) values on the top of the stack.

  8. Pop the \(n\) values \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n\) from the stack.

  9. Let \(\mathit{exn}\) be the exception instance \(\{\href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}}~\mathit{ta}, \href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}}~\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n\}\).

  10. Let \(\mathit{ea}\) be the length of \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}\).

  11. Append \(\mathit{exn}\) to \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}\).

  12. Push the value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~\mathit{ea}\) to the stack.

  13. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw}}~x) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & z{}[{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}} \mathrel{{=}{\oplus}} {\mathit{exn}}] ; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}} & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}{}[x]{.}\href{../exec/runtime.html#syntax-taginst}{\mathsf{type}} \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~({t^{n}} \href{../syntax/types.html#syntax-functype}{\rightarrow} \epsilon) \\ {\land}~ a = {|z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}|} \\ {\land}~ {\mathit{exn}} = \{ \begin{array}[t]{@{}l@{}} \href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}}~z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}{}[x],\; \href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}} \}\end{array} \\ \end{array} \\ \end{array}\end{split}\]

Todo

Too deeply nested

  1. Assert: due to validation, a reference is on the top of the stack.

  2. Pop the reference \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) from the stack.

  3. If \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is \(\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~\mathit{ht}\), then:

    1. Trap.

  4. Assert: due to validation, \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\) is an exception reference.

  5. Let \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~\mathit{ea}\) be \(\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}\).

  6. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}[\mathit{ea}]\) exists.

  7. Let \(\mathit{exn}\) be the exception instance \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}[\mathit{ea}]\).

  8. Let \(a\) be the tag address \(\mathit{exn}.\href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}}\).

  9. While the stack is not empty and the top of the stack is not an exception handler, do:

    1. Pop the top element from the stack.

  10. Assert: the stack is now either empty, or there is an exception handler on the top of the stack.

  11. If the stack is empty, then:

  1. Return the exception \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)\) as a result.

  1. Assert: there is an exception handler on the top of the stack.

  2. Pop the exception handler \(\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}_n\{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}^\ast\}\) from the stack.

  3. If \(\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}^\ast\) is empty, then:

    1. Push the exception reference \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~\mathit{ea}\) back to the stack.

    2. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}\) again.

  4. Else:

    1. Let \(F\) be the current frame.

    2. Let \(\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}_1\) be the first catch clause in \(\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}^\ast\) and \({\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast\) the remaining clauses.

    3. If \(\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}_1\) is of the form \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch}}~x~l\) and the tag address \(a\) equals \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tags}}[x]\), then:

      1. Push the values \(\mathit{exn}.\href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}}\) to the stack.

      2. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l\).

    4. Else if \(\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}_1\) is of the form \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch\_ref}}~x~l\) and the tag address \(a\) equals \(F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{tags}}[x]\), then:

      1. Push the values \(\mathit{exn}.\href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}}\) to the stack.

      2. Push the exception reference \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~\mathit{ea}\) to the stack.

      3. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l\).

    5. Else if \(\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}_1\) is of the form \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch\_all}}~l\), then:

      1. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l\).

    6. Else if \(\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}_1\) is of the form \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch\_all\_ref}}~l\), then:

      1. Push the exception reference \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~\mathit{ea}\) to the stack.

      2. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l\).

    7. Else:

      1. Push the modified handler \(\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}_n\{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast\}\) back to the stack.

      2. Push the exception reference \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~\mathit{ea}\) back to the stack.

      3. Execute the instruction \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}\) again.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; (\href{../syntax/instructions.html#syntax-instr-ref}{\mathsf{ref{.}null}}~{\mathit{ht}})~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}} \\[0.8ex] & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}} & \quad \mbox{if}~ {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast} \neq \epsilon \lor {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast} \neq \epsilon \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'}^\ast} \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}} \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}}_{n}}{\{ f \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}} \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ \epsilon \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}} \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch}}~x~l)~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast} \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}{}[a]{.}\href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}} = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}{}[x] \\ {\land}~ {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast} = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}{}[a]{.}\href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}} \\ \end{array} \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch\_ref}}~x~l)~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast} \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) & \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}{}[a]{.}\href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}} = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}{}[x] \\ {\land}~ {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast} = z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}{}[a]{.}\href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}} \\ \end{array} \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch\_all}}~l)~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast} \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ (\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{catch\_all\_ref}}~l)~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast} \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br}}~l) \\[0.8ex] & z ; ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ {\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast} \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}'}^\ast} \}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}}) & \mbox{otherwise} \\ \end{array}\end{split}\]

\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{try\_table}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}\)

  1. Let \(z\) be the current state.

  2. Let \({t_1^{m}}~\href{../syntax/types.html#syntax-functype}{\rightarrow}~{t_2^{n}}\) be \({{\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}}}_{z}({\mathit{bt}})\).

  3. Assert: Due to validation, there are at least \(m\) values on the top of the stack.

  4. Pop the values \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}\) from the stack.

  5. Push the evaluation context \(({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{}~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast}~\})\) to the stack.

  6. Enter \({{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}\) with label \(({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{}~\epsilon~\})\).

Todo

check prose

  1. Assert: due to validation, \(\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}_{S;F}(\href{../syntax/instructions.html#syntax-blocktype}{\mathit{blocktype}})\) is defined.

  2. Let \([t_1^m] \mathrel{\href{../valid/conventions.html#syntax-instrtype}{\rightarrow}} [t_2^n]\) be the instruction type \(\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}_{S;F}(\href{../syntax/instructions.html#syntax-blocktype}{\mathit{blocktype}})\).

  3. Assert: due to validation, there are at least \(m\) values on the top of the stack.

  4. Pop the values \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^m\) from the stack.

  5. Let \(L\) be the label whose arity is \(n\) and whose continuation is the end of the \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{try\_table}}\) instruction.

  6. Enter the block \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^m~\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}_1^\ast\) with label \(L\) and exception handler \(\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}_n\{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}^\ast\}\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{try\_table}}~{\mathit{bt}}~{{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast} \}}~({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{ \epsilon \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{m}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast})) & \quad \mbox{if}~ {{\href{../exec/runtime.html#aux-blocktype}{\mathrm{instrtype}}}}_{z}({\mathit{bt}}) = {t_1^{m}} \href{../syntax/types.html#syntax-functype}{\rightarrow} {t_2^{n}} \\ \end{array}\end{split}\]

Blocks

The following auxiliary rules define the semantics of executing an instruction sequence that forms a block.

Entering \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast\) with label \(L\)

  1. Push \(L\) to the stack.

  2. Jump to the start of the instruction sequence \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast\).

Note

No formal reduction rule is needed for entering an instruction sequence, because the label \(L\) is embedded in the administrative instruction that structured control instructions reduce to directly.

Exiting \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast\) with label \(L\)

When the end of a block is reached without a jump, exception, or trap aborting it, then the following steps are performed.

  1. Pop all values \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\) from the top of the stack.

  2. Assert: due to validation, the label \(L\) is now on the top of the stack.

  3. Pop the label from the stack.

  4. Push \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\) back to the stack.

  5. Jump to the position after the \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{end}}\) of the structured control instruction associated with the label \(L\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast} \\ \end{array}\end{split}\]

Note

This semantics also applies to the instruction sequence contained in a \(\mathsf{loop}\) instruction. Therefore, execution of a loop falls off the end, unless a backwards branch is performed explicitly.

Exception Handling

The following auxiliary rules define the semantics of entering and exiting \(\mathsf{try\_table}\) blocks.

Entering \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast\) with label \(L\) and exception handler \(H\)

  1. Push \(H\) to the stack.

  2. Push \(L\) onto the stack.

  3. Jump to the start of the instruction sequence \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast\).

Note

No formal reduction rule is needed for entering an exception handler because it is an administrative instruction that the \(\mathsf{try\_table}\) instruction reduces to directly.

Exiting an exception handler

When the end of a \(\mathsf{try\_table}\) block is reached without a jump, exception, or trap, then the following steps are performed.

  1. Let \(m\) be the number of values on the top of the stack.

  2. Pop the values \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^m\) from the stack.

  3. Assert: due to 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 \(H\) from the stack.

  6. Push \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^m\) back to the stack.

  7. Jump to the position after the \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{end}}\) of the administrative instruction associated with the handler \(H\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({{\href{../exec/runtime.html#syntax-handler}{\mathsf{handler}}}_{n}}{\{ {{\href{../syntax/instructions.html#syntax-catch}{\mathit{catch}}}^\ast} \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast} \\ \end{array}\end{split}\]

Function Calls

The following auxiliary rules define the semantics of invoking a function instance through one of the call instructions and returning from it.

Invocation of function reference \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)\)

  1. Assert: due to validation, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a]\) exists.

  2. Let \(f\) be the function instance, \(S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a]\).

  3. Let \(\href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~[t_1^n] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^m]\) be the composite type \(\href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}(\mathit{f}.\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}})\).

  4. Let \(\href{../syntax/modules.html#syntax-local}{\mathit{local}}^\ast\) be the list of locals \(f.\href{../exec/runtime.html#syntax-funcinst}{\mathsf{code}}.\href{../syntax/modules.html#syntax-func}{\mathsf{locals}}\).

  5. Let \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{end}}\) be the expression \(f.\href{../exec/runtime.html#syntax-funcinst}{\mathsf{code}}.\href{../syntax/modules.html#syntax-func}{\mathsf{body}}\).

  6. Assert: due to validation, \(n\) values are on the top of the stack.

  7. Pop the values \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n\) from the stack.

  8. Let \(F\) be the frame \(\{ \href{../exec/runtime.html#syntax-frame}{\mathsf{module}}~f.\href{../exec/runtime.html#syntax-funcinst}{\mathsf{module}}, \href{../exec/runtime.html#syntax-frame}{\mathsf{locals}}~\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n~(\href{../exec/runtime.html#default-val}{\mathrm{default}}_t)^\ast \}\).

  9. Push the activation of \(F\) with arity \(m\) to the stack.

  10. Let \(L\) be the label whose arity is \(m\) and whose continuation is the end of the function.

  11. Enter the instruction sequence \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast\) with label \(L\).

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)~(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{call\_ref}}~y) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & ({{\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}}_{m}}{\{ f \}}~({{\href{../exec/runtime.html#syntax-label}{\mathsf{label}}}_{m}}{\{ \epsilon \}}~{{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast})) & \\ &&& \multicolumn{2}{@{}l@{}}{\quad \quad \begin{array}[t]{@{}l@{}} \mbox{if}~ z{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a] = {\mathit{fi}} \\ {\land}~ {\mathit{fi}}{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}} \href{../valid/conventions.html#aux-expand-deftype}{\approx} \href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~({t_1^{n}} \href{../syntax/types.html#syntax-functype}{\rightarrow} {t_2^{m}}) \\ {\land}~ {\mathit{fi}}{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{code}} = \href{../syntax/modules.html#syntax-func}{\mathsf{func}}~x~{(\href{../syntax/modules.html#syntax-local}{\mathsf{local}}~t)^\ast}~({{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast}) \\ {\land}~ f = \{ \begin{array}[t]{@{}l@{}} \href{../exec/runtime.html#syntax-frame}{\mathsf{locals}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}~{({{\href{../exec/runtime.html#default-val}{\mathrm{default}}}}_{t})^\ast},\; \href{../exec/runtime.html#syntax-frame}{\mathsf{module}}~{\mathit{fi}}{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{module}} \}\end{array} \\ \end{array} } \\ \end{array}\end{split}\]

Note

For non-defaultable types, the respective local is left uninitialized by these rules.

Returning from a function

When the end of a function is reached without a jump (including through \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{return}}\)), or an exception or trap aborting it, then the following steps are performed.

  1. Let \(F\) be the current frame.

  2. Let \(n\) be the arity of the activation of \(F\).

  3. Assert: due to validation, there are \(n\) values on the top of the stack.

  4. Pop the results \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n\) from the stack.

  5. Assert: due to validation, the frame \(F\) is now on the top of the stack.

  6. Pop the frame from the stack.

  7. Push \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n\) back to the stack.

  8. Jump to the instruction after the original call.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & ({{\href{../exec/runtime.html#syntax-frame}{\mathsf{frame}}}_{n}}{\{ f \}}~{{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}}) & \href{../exec/conventions.html#exec-notation}{\hookrightarrow} & {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^{n}} \\ \end{array}\end{split}\]

Host Functions

Invoking a host function has non-deterministic behavior. It may either terminate with a trap, an exception, or return regularly. However, in the latter case, it must consume and produce the right number and types of WebAssembly values on the stack, according to its function type.

A host function may also modify the store. However, all store modifications must result in an extension of the original store, i.e., they must only modify mutable contents and must not have instances removed. Furthermore, the resulting store must be valid, i.e., all data and code in it is well-typed.

\[\begin{split}~\\[-1ex] \begin{array}{l} \begin{array}{lcl@{\qquad}l} S; \href{../exec/runtime.html#syntax-val}{\mathit{val}}^n~(\href{../exec/instructions.html#exec-invoke}{\mathsf{invoke}}~a) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S'; \href{../exec/runtime.html#syntax-result}{\mathit{result}} \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a] = \{ \href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}}~\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}, \href{../exec/runtime.html#syntax-funcinst}{\mathsf{hostfunc}}~\mathit{hf} \} \\ \wedge & \href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}) = \href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~[t_1^n] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^m] \\ \wedge & (S'; \href{../exec/runtime.html#syntax-result}{\mathit{result}}) \in \mathit{hf}(S; \href{../exec/runtime.html#syntax-val}{\mathit{val}}^n)) \\ \end{array} \\ \begin{array}{lcl@{\qquad}l} S; \href{../exec/runtime.html#syntax-val}{\mathit{val}}^n~(\href{../exec/instructions.html#exec-invoke}{\mathsf{invoke}}~a) &\href{../exec/conventions.html#exec-notation}{\hookrightarrow}& S; \href{../exec/runtime.html#syntax-val}{\mathit{val}}^n~(\href{../exec/instructions.html#exec-invoke}{\mathsf{invoke}}~a) \end{array} \\ \qquad \begin{array}[t]{@{}r@{~}l@{}} (\mathrel{\mbox{if}} & S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a] = \{ \href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}}~\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}, \href{../exec/runtime.html#syntax-funcinst}{\mathsf{hostfunc}}~\mathit{hf} \} \\ \wedge & \href{../valid/conventions.html#aux-expand-deftype}{\mathrm{expand}}(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}) = \href{../syntax/types.html#syntax-comptype}{\mathsf{func}}~[t_1^n] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^m] \\ \wedge & \bot \in \mathit{hf}(S; \href{../exec/runtime.html#syntax-val}{\mathit{val}}^n)) \\ \end{array} \\ \end{array}\end{split}\]

Here, \(\mathit{hf}(S; \href{../exec/runtime.html#syntax-val}{\mathit{val}}^n)\) denotes the implementation-defined execution of host function \(\mathit{hf}\) in current store \(S\) with arguments \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n\). It yields a set of possible outcomes, where each element is either a pair of a modified store \(S'\) and a result or the special value \(\bot\) indicating divergence. A host function is non-deterministic if there is at least one argument for which the set of outcomes is not singular.

For a WebAssembly implementation to be sound in the presence of host functions, every host function instance must be valid, which means that it adheres to suitable pre- and post-conditions: under a valid store \(S\), and given arguments \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}^n\) matching the ascribed parameter types \(t_1^n\), executing the host function must yield a non-empty set of possible outcomes each of which is either divergence or consists of a valid store \(S'\) that is an extension of \(S\) and a result matching the ascribed return types \(t_2^m\). All these notions are made precise in the Appendix.

Note

A host function can call back into WebAssembly by invoking a function exported from a module. However, the effects of any such call are subsumed by the non-deterministic behavior allowed for the host function.

Expressions

An expression is evaluated relative to a current frame pointing to its containing module instance.

  1. Jump to the start of the instruction sequence \(\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast\) of the expression.

  2. Execute the instruction sequence.

  3. Assert: due to validation, the top of the stack contains a value.

  4. Pop the value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) from the stack.

The value \(\href{../exec/runtime.html#syntax-val}{\mathit{val}}\) is the result of the evaluation.

\[\begin{split}\begin{array}[t]{@{}l@{}rcl@{}l@{}} & z ; {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast} & \href{../exec/conventions.html#exec-notation}{\hookrightarrow^\ast} & {z'} ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast} & \quad \mbox{if}~ z ; {{\href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}}^\ast} \href{../exec/conventions.html#exec-notation}{\hookrightarrow^\ast} {z'} ; {{\href{../exec/runtime.html#syntax-val}{\mathit{val}}}^\ast} \\ \end{array}\end{split}\]
\[S; F; \href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast \href{../exec/conventions.html#exec-notation}{\hookrightarrow} S'; F'; \href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'^\ast \qquad (\mathrel{\mbox{if}} S; F; \href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}^\ast~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{end}} \href{../exec/conventions.html#exec-notation}{\hookrightarrow} S'; F'; \href{../syntax/instructions.html#syntax-instr}{\mathit{instr}}'^\ast~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{end}})\]

Note

Evaluation iterates this reduction rule until reaching a value. Expressions constituting function bodies are executed during function invocation.