GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing webassembly.github.io — Embedding — WebAssembly 3.0 (2026-11-04) Embedding¶A WebAssembly implementation will typically be embedded into a host environment. An embedder implements the connection between such a host environment and the WebAssembly semantics as defined in the main body of this specification. An embedder is expected to interact with the semantics in well-defined ways. This section defines a suitable interface to the WebAssembly semantics in the form of entry points through which an embedder can access it. The interface is intended to be complete, in the sense that an embedder does not need to reference other functional parts of the WebAssembly specification directly. Note On the other hand, an embedder does not need to provide the host environment with access to all functionality defined in this interface. For example, an implementation may not support parsing of the text format. Types¶In the description of the embedder interface, syntactic classes from the abstract syntax and the runtime’s abstract machine are used as names for variables that range over the possible objects from that class. Hence, these syntactic classes can also be interpreted as types. For numeric parameters, notation like \(i:\href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}\) is used to specify a symbolic name in addition to the respective value range. Booleans¶Interface operation that are predicates return Boolean values:
\[\begin{split}\begin{array}{llll}
\def\mathdef139#1{{}}\mathdef139{Boolean} & \href{../appendix/embedding.html#embed-bool}{\mathit{bool}} &::=& \href{../appendix/embedding.html#embed-bool}{\mathit{false}} ~|~ \href{../appendix/embedding.html#embed-bool}{\mathit{true}} \\
\end{array}\end{split}\]
Exceptions and Errors¶Invoking an exported function may throw or propagate exceptions, expressed by an auxiliary syntactic class:
\[\begin{split}\begin{array}{llll}
\def\mathdef139#1{{}}\mathdef139{exception} & \href{../appendix/embedding.html#embed-error}{\mathit{exception}} &::=& \href{../appendix/embedding.html#embed-error}{\mathsf{exception}}~\href{../exec/runtime.html#syntax-exnaddr}{\mathit{exnaddr}} \\
\end{array}\end{split}\]
The exception address \(exnaddr\) identifies the exception thrown. Failure of an interface operation is also indicated by an auxiliary syntactic class:
\[\begin{split}\begin{array}{llll}
\def\mathdef139#1{{}}\mathdef139{error} & \href{../appendix/embedding.html#embed-error}{\mathit{error}} &::=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} \\
\end{array}\end{split}\]
In addition to the error conditions specified explicitly in this section, such as invalid arguments or exceptions and traps resulting from execution, implementations may also return errors when specific implementation limitations are reached. Note Errors are abstract and unspecific with this definition. Implementations can refine it to carry suitable classifications and diagnostic messages. Pre- and Post-Conditions¶Some operations state pre-conditions about their arguments or post-conditions about their results. It is the embedder’s responsibility to meet the pre-conditions. If it does, the post conditions are guaranteed by the semantics. In addition to pre- and post-conditions explicitly stated with each operation, the specification adopts the following conventions for runtime objects (\(\href{../exec/runtime.html#syntax-store}{\mathit{store}}\), \(\href{../exec/runtime.html#syntax-moduleinst}{\mathit{moduleinst}}\), addresses):
Note As long as an embedder treats runtime objects as abstract and only creates and manipulates them through the interface defined here, all implicit pre-conditions are automatically met. Store¶\(\mathrm{store\_init}() : \href{../exec/runtime.html#syntax-store}{\mathit{store}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{store\_init}() &=& \{ \} \\
\end{array}\end{split}\]
Modules¶\(\mathrm{module\_decode}(\href{../syntax/values.html#syntax-byte}{\mathit{byte}}^\ast) : \href{../syntax/modules.html#syntax-module}{\mathit{module}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{module\_decode}(b^\ast) &=& m && (\mathrel{\mbox{if}} \href{../binary/modules.html#binary-module}{\mathtt{module}} \stackrel\ast\Longrightarrow m{:}b^\ast) \\
\mathrm{module\_decode}(b^\ast) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{module\_parse}(\href{../syntax/values.html#syntax-name}{\mathit{char}}^\ast) : \href{../syntax/modules.html#syntax-module}{\mathit{module}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{module\_parse}(c^\ast) &=& m && (\mathrel{\mbox{if}} \href{../text/modules.html#text-module}{\mathtt{module}} \stackrel\ast\Longrightarrow m{:}c^\ast) \\
\mathrm{module\_parse}(c^\ast) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{module\_validate}(\href{../syntax/modules.html#syntax-module}{\mathit{module}}) : \href{../appendix/embedding.html#embed-error}{\mathit{error}}^?\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{module\_validate}(m) &=& \epsilon && (\mathrel{\mbox{if}} {} \href{../valid/modules.html#valid-module}{\vdash} m : \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}^\ast \rightarrow {\href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}'}^\ast) \\
\mathrm{module\_validate}(m) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{module\_instantiate}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../syntax/modules.html#syntax-module}{\mathit{module}}, \href{../exec/runtime.html#syntax-externaddr}{\mathit{externaddr}}^\ast) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-moduleinst}{\mathit{moduleinst}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{exception}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}})\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{module\_instantiate}(S, m, \mathit{ev}^\ast) &=& (S', F.\href{../exec/runtime.html#syntax-frame}{\mathsf{module}}) && (\mathrel{\mbox{if}} \href{../exec/modules.html#exec-instantiation}{\mathrm{instantiate}}(S, m, \mathit{ev}^\ast) \href{../exec/conventions.html#exec-notation}{\hookrightarrow}^\ast S'; F; \epsilon) \\
\mathrm{module\_instantiate}(S, m, \mathit{ev}^\ast) &=& (S', \href{../appendix/embedding.html#embed-error}{\mathsf{error}}) && (\mathrel{\mbox{otherwise}}, \mathrel{\mbox{if}} \href{../exec/modules.html#exec-instantiation}{\mathrm{instantiate}}(S, m, \mathit{ev}^\ast) \href{../exec/conventions.html#exec-notation}{\hookrightarrow}^\ast S'; F; \href{../exec/runtime.html#syntax-result}{\mathit{result}}) \\
\end{array}\end{split}\]
Note The store may be modified even in case of an error. \(\mathrm{module\_imports}(\href{../syntax/modules.html#syntax-module}{\mathit{module}}) : (\href{../syntax/values.html#syntax-name}{\mathit{name}}, \href{../syntax/values.html#syntax-name}{\mathit{name}}, \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}})^\ast\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{module\_imports}(m) &=& (\mathit{nm}_1, \mathit{nm}_2, \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}})^\ast \\
&& \qquad (\mathrel{\mbox{if}} (\href{../syntax/modules.html#syntax-import}{\mathsf{import}}~\mathit{nm}_1~\mathit{nm}_2~\mathit{xt}^\ast)^\ast \in m \wedge {} \href{../valid/modules.html#valid-module}{\vdash} m : \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}^\ast \rightarrow {\href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}'}^\ast) \\
\end{array}\end{split}\]
\(\mathrm{module\_exports}(\href{../syntax/modules.html#syntax-module}{\mathit{module}}) : (\href{../syntax/values.html#syntax-name}{\mathit{name}}, \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}})^\ast\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{module\_exports}(m) &=& (\\mathit{nm}, \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}')^\ast \\
&& \qquad (\mathrel{\mbox{if}} (\href{../syntax/modules.html#syntax-export}{\mathsf{export}}~\mathit{nm}~\mathit{xt}^\ast)^\ast \in m \wedge {} \href{../valid/modules.html#valid-module}{\vdash} m : \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}^\ast \rightarrow {\href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}'}^\ast) \\
\end{array}\end{split}\]
Module Instances¶\(\mathrm{instance\_export}(\href{../exec/runtime.html#syntax-moduleinst}{\mathit{moduleinst}}, \href{../syntax/values.html#syntax-name}{\mathit{name}}) : \href{../exec/runtime.html#syntax-externaddr}{\mathit{externaddr}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{instance\_export}(m, \href{../syntax/values.html#syntax-name}{\mathit{name}}) &=& m.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{exports}}[i].\href{../exec/runtime.html#syntax-exportinst}{\mathsf{addr}} && (\mathrel{\mbox{if}} m.\href{../exec/runtime.html#syntax-moduleinst}{\mathsf{exports}}[i].\href{../exec/runtime.html#syntax-exportinst}{\mathsf{name}} = \href{../syntax/values.html#syntax-name}{\mathit{name}}) \\
\mathrm{instance\_export}(m, \href{../syntax/values.html#syntax-name}{\mathit{name}}) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
Functions¶\(\mathrm{func\_alloc}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}, \href{../exec/runtime.html#syntax-hostfunc}{\mathit{hostfunc}}) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-funcaddr}{\mathit{funcaddr}})\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{func\_alloc}(S, \mathit{dt}, \mathit{code}) &=& (S', \mathit{a})
&& (\begin{array}{@{}l@{}}
\mathrel{\mbox{if}} \href{../exec/modules.html#alloc-func}{\mathrm{allocfunc}}(S, \mathit{dt}, \mathit{code}, \{\}) = S', \mathit{a}) \\
\end{array} \\
\end{array}\end{split}\]
Note This operation assumes that \(\href{../exec/runtime.html#syntax-hostfunc}{\mathit{hostfunc}}\) satisfies the pre- and post-conditions required for a function instance with type \(\href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\). Regular (non-host) function instances can only be created indirectly through module instantiation. \(\mathrm{func\_type}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-funcaddr}{\mathit{funcaddr}}) : \href{../valid/conventions.html#syntax-deftype}{\mathit{deftype}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{func\_type}(S, a) &=& S.\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}[a].\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}} \\
\end{array}\end{split}\]
\(\mathrm{func\_invoke}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-funcaddr}{\mathit{funcaddr}}, \href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{exception}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}})\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{func\_invoke}(S, a, v^\ast) &=& (S', {v'}^\ast) && (\mathrel{\mbox{if}} \href{../exec/modules.html#exec-invocation}{\mathrm{invoke}}(S, a, v^\ast) \href{../exec/conventions.html#exec-notation}{\hookrightarrow}^\ast S'; F; {v'}^\ast) \\
\mathrm{func\_invoke}(S, a, v^\ast) &=& (S', \href{../appendix/embedding.html#embed-error}{\mathsf{exception}}~a') && (\mathrel{\mbox{if}} \href{../exec/modules.html#exec-invocation}{\mathrm{invoke}}(S, a, v^\ast) \href{../exec/conventions.html#exec-notation}{\hookrightarrow}^\ast S'; F; (\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a')~\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{throw\_ref}} \\
\mathrm{func\_invoke}(S, a, v^\ast) &=& (S', \href{../appendix/embedding.html#embed-error}{\mathsf{error}}) && (\mathrel{\mbox{if}} \href{../exec/modules.html#exec-invocation}{\mathrm{invoke}}(S, a, v^\ast) \href{../exec/conventions.html#exec-notation}{\hookrightarrow}^\ast S'; F; \href{../exec/runtime.html#syntax-trap}{\mathsf{trap}}) \\
\end{array}\end{split}\]
Note The store may be modified even in case of an error. Tables¶\(\mathrm{table\_alloc}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../syntax/types.html#syntax-tabletype}{\mathit{tabletype}}, \href{../exec/runtime.html#syntax-ref}{\mathit{ref}}) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tableaddr}{\mathit{tableaddr}})\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{table\_alloc}(S, \mathit{tt}, r) &=& (S', \mathit{a}) && (\mathrel{\mbox{if}} \href{../exec/modules.html#alloc-table}{\mathrm{alloctable}}(S, \mathit{tt}, r) = S', \mathit{a}) \\
\end{array}\end{split}\]
\(\mathrm{table\_type}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tableaddr}{\mathit{tableaddr}}) : \href{../syntax/types.html#syntax-tabletype}{\mathit{tabletype}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{table\_type}(S, a) &=& S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[a].\href{../exec/runtime.html#syntax-tableinst}{\mathsf{type}} \\
\end{array}\end{split}\]
\(\mathrm{table\_read}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tableaddr}{\mathit{tableaddr}}, i:\href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}) : \href{../exec/runtime.html#syntax-ref}{\mathit{ref}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{table\_read}(S, a, i) &=& r && (\mathrel{\mbox{if}} S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[a].\href{../exec/runtime.html#syntax-tableinst}{\mathsf{refs}}[i] = r) \\
\mathrm{table\_read}(S, a, i) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{table\_write}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tableaddr}{\mathit{tableaddr}}, i:\href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}, \href{../exec/runtime.html#syntax-ref}{\mathit{ref}}) : \href{../exec/runtime.html#syntax-store}{\mathit{store}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{table\_write}(S, a, i, r) &=& S' && (\mathrel{\mbox{if}} S' = S \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} \href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[a].\href{../exec/runtime.html#syntax-tableinst}{\mathsf{refs}}[i] = r) \\
\mathrm{table\_write}(S, a, i, r) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{table\_size}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tableaddr}{\mathit{tableaddr}}) : \href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{table\_size}(S, a) &=& n &&
(\mathrel{\mbox{if}} |S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[a].\href{../exec/runtime.html#syntax-tableinst}{\mathsf{refs}}| = n) \\
\end{array}\end{split}\]
\(\mathrm{table\_grow}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tableaddr}{\mathit{tableaddr}}, n:\href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}, \href{../exec/runtime.html#syntax-ref}{\mathit{ref}}) : \href{../exec/runtime.html#syntax-store}{\mathit{store}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{table\_grow}(S, a, n, r) &=& S' &&
(\mathrel{\mbox{if}} S' = S \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} \href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[a] = \href{../exec/modules.html#grow-table}{\mathrm{growtable}}(S.\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}[a], n, r)) \\
\mathrm{table\_grow}(S, a, n, r) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
Memories¶\(\mathrm{mem\_alloc}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../syntax/types.html#syntax-memtype}{\mathit{memtype}}) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-memaddr}{\mathit{memaddr}})\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{mem\_alloc}(S, \mathit{mt}) &=& (S', \mathit{a}) && (\mathrel{\mbox{if}} \href{../exec/modules.html#alloc-mem}{\mathrm{allocmem}}(S, \mathit{mt}) = S', \mathit{a}) \\
\end{array}\end{split}\]
\(\mathrm{mem\_type}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-memaddr}{\mathit{memaddr}}) : \href{../syntax/types.html#syntax-memtype}{\mathit{memtype}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{mem\_type}(S, a) &=& S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a].\href{../exec/runtime.html#syntax-meminst}{\mathsf{type}} \\
\end{array}\end{split}\]
\(\mathrm{mem\_read}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-memaddr}{\mathit{memaddr}}, i:\href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}) : \href{../syntax/values.html#syntax-byte}{\mathit{byte}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{mem\_read}(S, a, i) &=& b && (\mathrel{\mbox{if}} S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[i] = b) \\
\mathrm{mem\_read}(S, a, i) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{mem\_write}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-memaddr}{\mathit{memaddr}}, i:\href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}, \href{../syntax/values.html#syntax-byte}{\mathit{byte}}) : \href{../exec/runtime.html#syntax-store}{\mathit{store}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{mem\_write}(S, a, i, b) &=& S' && (\mathrel{\mbox{if}} S' = S \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} \href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}[i] = b) \\
\mathrm{mem\_write}(S, a, i, b) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{mem\_size}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-memaddr}{\mathit{memaddr}}) : \href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{mem\_size}(S, a) &=& n &&
(\mathrel{\mbox{if}} |S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a].\href{../exec/runtime.html#syntax-meminst}{\mathsf{bytes}}| = n \cdot 64\,\mathrm{Ki}) \\
\end{array}\end{split}\]
\(\mathrm{mem\_grow}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-memaddr}{\mathit{memaddr}}, n:\href{../syntax/values.html#syntax-int}{\mathit{u\scriptstyle\kern-0.1em64}}) : \href{../exec/runtime.html#syntax-store}{\mathit{store}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{mem\_grow}(S, a, n) &=& S' &&
(\mathrel{\mbox{if}} S' = S \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} \href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a] = \href{../exec/modules.html#grow-mem}{\mathrm{growmem}}(S.\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}[a], n)) \\
\mathrm{mem\_grow}(S, a, n) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
Tags¶\(\mathrm{tag\_alloc}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../syntax/types.html#syntax-tagtype}{\mathit{tagtype}}) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tagaddr}{\mathit{tagaddr}})\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{tag\_alloc}(S, \mathit{tt}) &=& (S', \mathit{a}) && (\mathrel{\mbox{if}} \href{../exec/modules.html#alloc-tag}{\mathrm{alloctag}}(S, \mathit{tt}) = S', \mathit{a}) \\
\end{array}\end{split}\]
\(\mathrm{tag\_type}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tagaddr}{\mathit{tagaddr}}) : \href{../syntax/types.html#syntax-tagtype}{\mathit{tagtype}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{tag\_type}(S, a) &=& S.\href{../exec/runtime.html#syntax-store}{\mathsf{tags}}[a].\href{../exec/runtime.html#syntax-taginst}{\mathsf{type}} \\
\end{array}\end{split}\]
Exceptions¶\(\mathrm{exn\_alloc}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-tagaddr}{\mathit{tagaddr}}, \href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-exnaddr}{\mathit{exnaddr}})\)¶
\[\begin{split}\begin{array}{lcll}
\mathrm{exn\_alloc}(S, \href{../exec/runtime.html#syntax-tagaddr}{\mathit{tagaddr}}, \href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast) &=& (S \href{../syntax/conventions.html#notation-compose}{\oplus} \{\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}~\href{../exec/runtime.html#syntax-exninst}{\mathit{exninst}}\}, |S.\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}|) &
(\mathrel{\mbox{if}} \href{../exec/runtime.html#syntax-exninst}{\mathit{exninst}} = \{\href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}}~\href{../exec/runtime.html#syntax-tagaddr}{\mathit{tagaddr}}, \href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}}~\href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\} \\
\end{array}\end{split}\]
\(\mathrm{exn\_tag}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-exnaddr}{\mathit{exnaddr}}) : \href{../exec/runtime.html#syntax-tagaddr}{\mathit{tagaddr}}\)¶
\[\begin{split}\begin{array}{lcll}
\mathrm{exn\_tag}(S, a) &=& \href{../exec/runtime.html#syntax-exninst}{\mathit{exninst}}.\href{../exec/runtime.html#syntax-exninst}{\mathsf{tag}} &
(\mathrel{\mbox{if}} \href{../exec/runtime.html#syntax-exninst}{\mathit{exninst}} = S.\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}[a]) \\
\end{array}\end{split}\]
\(\mathrm{exn\_read}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-exnaddr}{\mathit{exnaddr}}) : \href{../exec/runtime.html#syntax-val}{\mathit{val}}^\ast\)¶
\[\begin{split}\begin{array}{lcll}
\mathrm{exn\_read}(S, a) &=& \href{../exec/runtime.html#syntax-exninst}{\mathit{exninst}}.\href{../exec/runtime.html#syntax-exninst}{\mathsf{fields}} &
(\mathrel{\mbox{if}} \href{../exec/runtime.html#syntax-exninst}{\mathit{exninst}} = S.\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}[a]) \\
\end{array}\end{split}\]
Globals¶\(\mathrm{global\_alloc}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../syntax/types.html#syntax-globaltype}{\mathit{globaltype}}, \href{../exec/runtime.html#syntax-val}{\mathit{val}}) : (\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-globaladdr}{\mathit{globaladdr}})\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{global\_alloc}(S, \mathit{gt}, v) &=& (S', \mathit{a}) && (\mathrel{\mbox{if}} \href{../exec/modules.html#alloc-global}{\mathrm{allocglobal}}(S, \mathit{gt}, v) = S', \mathit{a}) \\
\end{array}\end{split}\]
\(\mathrm{global\_type}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-globaladdr}{\mathit{globaladdr}}) : \href{../syntax/types.html#syntax-globaltype}{\mathit{globaltype}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{global\_type}(S, a) &=& S.\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}[a].\href{../exec/runtime.html#syntax-globalinst}{\mathsf{type}} \\
\end{array}\end{split}\]
\(\mathrm{global\_read}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-globaladdr}{\mathit{globaladdr}}) : \href{../exec/runtime.html#syntax-val}{\mathit{val}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{global\_read}(S, a) &=& v && (\mathrel{\mbox{if}} S.\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}[a].\href{../exec/runtime.html#syntax-globalinst}{\mathsf{value}} = v) \\
\end{array}\end{split}\]
\(\mathrm{global\_write}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-globaladdr}{\mathit{globaladdr}}, \href{../exec/runtime.html#syntax-val}{\mathit{val}}) : \href{../exec/runtime.html#syntax-store}{\mathit{store}} ~|~ \href{../appendix/embedding.html#embed-error}{\mathit{error}}\)¶
\[\begin{split}~ \\
\begin{array}{lclll}
\mathrm{global\_write}(S, a, v) &=& S' && (\mathrel{\mbox{if}} S.\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}[a].\href{../exec/runtime.html#syntax-globalinst}{\mathsf{type}} = \href{../syntax/types.html#syntax-mut}{\mathsf{mut}}~t \wedge S' = S \href{../syntax/conventions.html#notation-replace}{\mathrel{\mbox{with}}} \href{../exec/runtime.html#syntax-store}{\mathsf{globals}}[a].\href{../exec/runtime.html#syntax-globalinst}{\mathsf{value}} = v) \\
\mathrm{global\_write}(S, a, v) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
Values¶\(\mathrm{ref\_type}(\href{../exec/runtime.html#syntax-store}{\mathit{store}}, \href{../exec/runtime.html#syntax-ref}{\mathit{ref}}) : \href{../syntax/types.html#syntax-reftype}{\mathit{reftype}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{ref\_type}(S, r) &=& t && (\mathrel{\mbox{if}} S \href{../exec/values.html#valid-val}{\vdash} r : t) \\
\end{array}\end{split}\]
Note In future versions of WebAssembly, not all references may carry precise type information at run time. In such cases, this function may return a less precise supertype. \(\mathrm{val\_default}(\href{../syntax/types.html#syntax-valtype}{\mathit{valtype}}) : \href{../exec/runtime.html#syntax-val}{\mathit{val}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{val\_default}(t) &=& v && (\mathrel{\mbox{if}} \href{../exec/runtime.html#aux-default}{\mathrm{default}}_t = v) \\
\mathrm{val\_default}(t) &=& \href{../appendix/embedding.html#embed-error}{\mathsf{error}} && (\mathrel{\mbox{if}} \href{../exec/runtime.html#aux-default}{\mathrm{default}}_t = \epsilon) \\
\end{array}\end{split}\]
Matching¶\(\mathrm{match\_valtype}(\href{../syntax/types.html#syntax-valtype}{\mathit{valtype}}_1, \href{../syntax/types.html#syntax-valtype}{\mathit{valtype}}_2) : \href{../appendix/embedding.html#embed-bool}{\mathit{bool}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{match\_reftype}(t_1, t_2) &=& \href{../appendix/embedding.html#embed-bool}{\mathit{true}} && (\mathrel{\mbox{if}} {} \href{../valid/matching.html#match-valtype}{\vdash} t_1 \href{../valid/matching.html#match-valtype}{\leq} t_2) \\
\mathrm{match\_reftype}(t_1, t_2) &=& \href{../appendix/embedding.html#embed-bool}{\mathit{false}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
\(\mathrm{match\_externtype}(\href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}_1, \href{../syntax/types.html#syntax-externtype}{\mathit{externtype}}_2) : \href{../appendix/embedding.html#embed-bool}{\mathit{bool}}\)¶
\[\begin{split}\begin{array}{lclll}
\mathrm{match\_externtype}(\mathit{et}_1, \mathit{et}_2) &=& \href{../appendix/embedding.html#embed-bool}{\mathit{true}} && (\mathrel{\mbox{if}} {} \href{../valid/matching.html#match-externtype}{\vdash} \mathit{et}_1 \href{../valid/matching.html#match-externtype}{\leq} \mathit{et}_2) \\
\mathrm{match\_externtype}(\mathit{et}_1, \mathit{et}_2) &=& \href{../appendix/embedding.html#embed-bool}{\mathit{false}} && (\mathrel{\mbox{otherwise}}) \\
\end{array}\end{split}\]
©2017-2025, WebAssembly Community Group.
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |