Skip to content

Commit

Permalink
Merge pull request #382 from WebAssembly/spec.valid-types
Browse files Browse the repository at this point in the history
Spec type and module validation, subtyping, and module instantiation.
  • Loading branch information
rossberg authored Jul 20, 2023
2 parents 2dcdf17 + fd15280 commit f58ae60
Show file tree
Hide file tree
Showing 15 changed files with 944 additions and 316 deletions.
2 changes: 1 addition & 1 deletion document/core/appendix/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Added managed reference types [#proposal-gc]_.

* New :ref:`reference instructions <syntax-instr-ref>` for :ref:`array types <syntax-structtype>`: |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |ARRAYNEWDATA|, |ARRAYNEWELEM|, :math:`\ARRAYGET\K{\_}\sx^?`, |ARRAYSET|, |ARRAYLEN|, |ARRAYFILL|, |ARRAYCOPY|, |ARRAYINITDATA|, |ARRAYINITELEM|

* New :ref:`reference instructions <syntax-instr-ref>` for converting :ref:`host types <syntax-extern>`: |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|
* New :ref:`reference instructions <syntax-instr-ref>` for converting :ref:`host types <syntax-externtype>`: |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|

* Extended set of :ref:`constant instructions <valid-const>` with |I31NEW|, |STRUCTNEW|, |STRUCTNEWDEFAULT|, |ARRAYNEW|, |ARRAYNEWDEFAULT|, |ARRAYNEWFIXED|, |EXTERNINTERNALIZE|, |EXTERNEXTERNALIZE|, and |GLOBALGET| for any previously declared immutable :ref:`global <syntax-global>`

Expand Down
18 changes: 18 additions & 0 deletions document/core/appendix/properties.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ The typing rules defining WebAssembly :ref:`validation <valid>` only cover the *
In order to state and prove soundness precisely, the typing rules must be extended to the *dynamic* components of the abstract :ref:`runtime <syntax-runtime>`, that is, the :ref:`store <syntax-store>`, :ref:`configurations <syntax-config>`, and :ref:`administrative instructions <syntax-instr-admin>`. [#cite-pldi2017]_


.. index:: context, recursive types, recursive type indices
.. context-rec:
Contexts
~~~~~~~~

.. todo:: maybe move elsewhere?

In order to check :ref:`rolled up <aux-roll-rectype>` recursive types,
the :ref:`context <context>` is locally extended with an additional component that records the :ref:`supertypes <syntax-subtype>` of each :ref:`recursive type index <syntax-rectypeidx>`, represented as :ref:`defined types <syntax-deftype>`:

.. math::
\begin{array}{llll}
\production{context} & C &::=&
\{~ \dots, \CRECS ~ (\deftype^\ast)^\ast ~\} \\
\end{array}
.. index:: value, value type, result, result type, trap
.. _valid-result:

Expand Down
48 changes: 24 additions & 24 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,12 @@ Reference Instructions
\end{array}
.. _exec-i31.get_s:
.. _exec-i31.get_sx:

:math:`\I31GET\K{\_}\sx`
........................

1. Assert: due to :ref:`validation <valid-i31.get_s>`, a :ref:`value <syntax-val>` of :ref:`type <syntax-valtype>` :math:`(\REF~\NULL~\I31)` is on the top of the stack.
1. Assert: due to :ref:`validation <valid-i31.get_sx>`, a :ref:`value <syntax-val>` of :ref:`type <syntax-valtype>` :math:`(\REF~\NULL~\I31)` is on the top of the stack.

2. Pop the value :math:`\reff` from the stack.

Expand Down Expand Up @@ -462,7 +462,7 @@ Reference Instructions
S; F; \val^n~(\STRUCTNEW~x) &\stepto& S'; F; (\REFSTRUCTADDR~|S.\SSTRUCTS|)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
\land & \X{si} = \{\SITYPE~F.\AMODULE.\MITYPES[x], \SIFIELDS~(\packval_{\X{ft}}(\val))^n\} \\
\land & S' = S \with \SSTRUCTS = S.\SSTRUCTS~\X{si})
\end{array} \\
Expand Down Expand Up @@ -501,7 +501,7 @@ Reference Instructions
F; (\STRUCTNEWDEFAULT~x) &\stepto& (\default_{\unpacktype(\X{ft})}))^n~(\STRUCTNEW~x)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n)
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n)
\end{array} \\
\end{array}
Expand All @@ -511,7 +511,7 @@ Reference Instructions
S; F; (\STRUCTNEWDEFAULT~x) &\stepto& S'; F; (\REFSTRUCTADDR~|S.\SSTRUCTS|)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
\land & \X{si} = \{\SITYPE~F.\AMODULE.\MITYPES[x], \SIFIELDS~(\packval_{\X{ft}}(\default_{\unpacktype(\X{ft})}))^n\} \\
\land & S' = S \with \SSTRUCTS = S.\SSTRUCTS~\X{si})
\end{array} \\
Expand Down Expand Up @@ -561,7 +561,7 @@ Reference Instructions
S; F; (\REFSTRUCTADDR~a)~(\STRUCTGET\K{\_}\sx^?~x~i) &\stepto& \val
&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
\land & \val = \unpackval^{\sx^?}_{\X{ft}^\ast[i]}(S.\SSTRUCTS[a].\SIFIELDS[i]))
\end{array} \\
S; F; (\REFNULL~t)~(\STRUCTGET\K{\_}\sx^?~x~i) &\stepto& \TRAP
Expand Down Expand Up @@ -612,7 +612,7 @@ Reference Instructions
S; F; (\REFSTRUCTADDR~a)~\val~(\STRUCTSET~x~i) &\stepto& S'; \epsilon
&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
\land & S' = S \with \SSTRUCTS[a].\SIFIELDS[i] = \packval_{\X{ft}^\ast[i]}(\val))
\end{array} \\
S; F; (\REFNULL~t)~\val~(\STRUCTSET~x~i) &\stepto& \TRAP
Expand Down Expand Up @@ -657,7 +657,7 @@ Reference Instructions
S; F; \val~(\I32.\CONST~n)~(\ARRAYNEW~x) &\stepto& S'; F; (\REFARRAYADDR~|S.\SARRAYS|)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
\land & \X{ai} = \{\AITYPE~F.\AMODULE.\MITYPES[x], \AIFIELDS~(\packval_{\X{ft}}(\val))^n\} \\
\land & S' = S \with \SARRAYS = S.\SARRAYS~\X{ai})
\end{array} \\
Expand Down Expand Up @@ -696,7 +696,7 @@ Reference Instructions
F; (\I32.\CONST~n)~(\ARRAYNEWDEFAULT~x) &\stepto& (\default_{\unpacktype(\X{ft}}))^n~(\ARRAYNEWFIXED~x~n)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft})
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft})
\end{array} \\
\end{array}
Expand All @@ -706,7 +706,7 @@ Reference Instructions
S; F; (\I32.\CONST~n)~(\ARRAYNEWDEFAULT~x) &\stepto& S'; F; (\REFARRAYADDR~|S.\SARRAYS|)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
\land & \X{ai} = \{\AITYPE~F.\AMODULE.\MITYPES[x], \AIFIELDS~(\packval_{\X{ft}}(\default_{\unpacktype(\X{ft}}))^n\} \\
\land & S' = S \with \SARRAYS = S.\SARRAYS~\X{ai})
\end{array} \\
Expand All @@ -728,7 +728,7 @@ Reference Instructions

4. Let :math:`\TARRAY~\X{ft}` be the :ref:`array type <syntax-arraytype>` :math:`\deftype`. (todo: unroll)

5. Assert: due to :ref:`validation <valid-struct.new_fixed>`, :math:`n` :ref:`values <syntax-val>` are on the top of the stack.
5. Assert: due to :ref:`validation <valid-array.new_fixed>`, :math:`n` :ref:`values <syntax-val>` are on the top of the stack.

6. Pop the :math:`n` values :math:`\val^\ast` from the stack.

Expand All @@ -751,7 +751,7 @@ Reference Instructions
S; F; \val^n~(\ARRAYNEWFIXED~x~n) &\stepto& S'; F; (\REFARRAYADDR~|S.\SARRAYS|)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
\land & \X{ai} = \{\AITYPE~F.\AMODULE.\MITYPES[x], \AIFIELDS~(\packval_{\X{ft}}(\val))^n\} \\
\land & S' = S \with \SARRAYS = S.\SARRAYS~\X{ai})
\end{array} \\
Expand Down Expand Up @@ -788,9 +788,9 @@ Reference Instructions

11. Pop the value :math:`(\I32.\CONST~s)` from the stack.

12. Assert: due to :ref:`validation <valid-array.new_data>`, the :ref:`field type <syntax-fieldtype>` :math:`\X{ft}` has a defined :ref:`size <aux-size-fieldtype>`.
12. Assert: due to :ref:`validation <valid-array.new_data>`, the :ref:`field type <syntax-fieldtype>` :math:`\X{ft}` has a defined :ref:`bit width <bitwidth-fieldtype>`.

13. Let :math:`z` be the :ref:`size <aux-size-fieldtype>` of :ref:`field type <syntax-fieldtype>` :math:`\X{ft}`.
13. Let :math:`z` be the :ref:`bit width <bitwidth-fieldtype>` of :ref:`field type <syntax-fieldtype>` :math:`\X{ft}`.

14. If the sum of :math:`s` and :math:`n` times :math:`z` is larger than the length of :math:`\datainst.\DIDATA`, then:

Expand All @@ -814,14 +814,14 @@ Reference Instructions
S; F; (\I32.\CONST~s)~(\I32.\CONST~n)~(\ARRAYNEWDATA~x~y) &\stepto& \TRAP
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
\land & s + n\cdot|\X{ft}| > |S.\SDATAS[F.\AMODULE.\MIDATAS[y]].\DIDATA|)
\end{array} \\
\\[1ex]
S; F; (\I32.\CONST~s)~(\I32.\CONST~n)~(\ARRAYNEWDATA~x~y) &\stepto& (t.\CONST~c)^n~(\ARRAYNEWFIXED~x~n)
\\&&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
\land & t = \unpacktype(\X{ft}) \\
\land & (\bytes_{\X{ft}}(c))^n = S.\SDATAS[F.\AMODULE.\MIDATAS[y]].\DIDATA[s \slice n\cdot|\X{ft}|] \\
\end{array} \\
Expand Down Expand Up @@ -931,7 +931,7 @@ Reference Instructions
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~i)~(\ARRAYGET\K{\_}\sx^?~x) &\stepto& \val
&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
\land & \val = \unpackval^{\sx^?}_{\X{ft}}(S.\SARRAYS[a].\AIFIELDS[i]))
\end{array} \\
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~i)~(\ARRAYGET\K{\_}\sx^?~x) &\stepto& \val
Expand Down Expand Up @@ -990,7 +990,7 @@ Reference Instructions
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~i)~\val~(\ARRAYSET~x) &\stepto& S'; \epsilon
&
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
(\iff & \expanddt(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
\land & S' = S \with \SARRAYS[a].\AIFIELDS[i] = \packval_{\X{ft}}(\val))
\end{array} \\
S; F; (\REFNULL~t)~(\I32.\CONST~i)~\val~(\ARRAYSET~x) &\stepto& \TRAP
Expand Down Expand Up @@ -4210,7 +4210,7 @@ Invocation of :ref:`function address <syntax-funcaddr>` :math:`a`

2. Let :math:`f` be the :ref:`function instance <syntax-funcinst>`, :math:`S.\SFUNCS[a]`.

3. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`structured type <syntax-strtype>` :math:`\expand(\X{f}.\FITYPE)`.
3. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`compound type <syntax-comptype>` :math:`\expanddt(\X{f}.\FITYPE)`.

4. Let :math:`\local^\ast` be the list of :ref:`locals <syntax-local>` :math:`f.\FICODE.\FLOCALS`.

Expand All @@ -4237,7 +4237,7 @@ Invocation of :ref:`function address <syntax-funcaddr>` :math:`a`
\\ \qquad
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & S.\SFUNCS[a] = f \\
\wedge & \expand(S.f.\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m] \\
\wedge & \expanddt(S.f.\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m] \\
\wedge & f.\FICODE = \{ \FTYPE~x, \FLOCALS~\{\LTYPE~t\}^k, \FBODY~\instr^\ast~\END \} \\
\wedge & F = \{ \AMODULE~f.\FIMODULE, ~\ALOCALS~\val^n~(\default_t)^k \})
\end{array} \\
Expand All @@ -4254,7 +4254,7 @@ Tail-invocation of :ref:`function address <syntax-funcaddr>` :math:`a`

1. Assert: due to :ref:`validation <valid-call>`, :math:`S.\SFUNCS[a]` exists.

2. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`structured type <syntax-strtype>` :math:`\expand(S.\SFUNCS[a].\FITYPE)`.
2. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`compound type <syntax-comptype>` :math:`\expanddt(S.\SFUNCS[a].\FITYPE)`.

3. Assert: due to :ref:`validation <valid-return_call>`, there are at least :math:`n` values on the top of the stack.

Expand All @@ -4279,7 +4279,7 @@ Tail-invocation of :ref:`function address <syntax-funcaddr>` :math:`a`
\begin{array}{lcl@{\qquad}l}
S; \FRAME_m\{F\}~B^\ast[\val^n~(\RETURNINVOKE~a)]~\END &\stepto&
\val^n~(\INVOKE~a)
& (\iff \expand(S.\SFUNCS[a].\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m])
& (\iff \expanddt(S.\SFUNCS[a].\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m])
\end{array}
Expand Down Expand Up @@ -4337,7 +4337,7 @@ Furthermore, the resulting store must be :ref:`valid <valid-store>`, i.e., all d
\\ \qquad
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & S.\SFUNCS[a] = \{ \FITYPE~\deftype, \FIHOSTCODE~\X{hf} \} \\
\wedge & \expand(\deftype) = \TFUNC~[t_1^n] \toF [t_2^m] \\
\wedge & \expanddt(\deftype) = \TFUNC~[t_1^n] \toF [t_2^m] \\
\wedge & (S'; \result) \in \X{hf}(S; \val^n)) \\
\end{array} \\
\begin{array}{lcl@{\qquad}l}
Expand All @@ -4346,7 +4346,7 @@ Furthermore, the resulting store must be :ref:`valid <valid-store>`, i.e., all d
\\ \qquad
\begin{array}[t]{@{}r@{~}l@{}}
(\iff & S.\SFUNCS[a] = \{ \FITYPE~\deftype, \FIHOSTCODE~\X{hf} \} \\
\wedge & \expand(\deftype) = \TFUNC~[t_1^n] \toF [t_2^m] \\
\wedge & \expanddt(\deftype) = \TFUNC~[t_1^n] \toF [t_2^m] \\
\wedge & \bot \in \X{hf}(S; \val^n)) \\
\end{array} \\
\end{array}
Expand Down
35 changes: 29 additions & 6 deletions document/core/exec/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ Growing :ref:`memories <syntax-meminst>`
:ref:`Modules <syntax-moduleinst>`
..................................

.. todo:: update prose for types
.. todo:: change semantics for globals

The allocation function for :ref:`modules <syntax-module>` requires a suitable list of :ref:`external values <syntax-externval>` that are assumed to :ref:`match <match-externtype>` the :ref:`import <syntax-import>` vector of the module,
a list of initialization :ref:`values <syntax-val>` for the module's :ref:`globals <syntax-global>`,
and list of :ref:`reference <syntax-ref>` vectors for the module's :ref:`element segments <syntax-elem>`.
Expand Down Expand Up @@ -381,8 +384,6 @@ and list of :ref:`reference <syntax-ref>` vectors for the module's :ref:`element
where:

.. todo:: adjust deftypes

.. math::
\begin{array}{@{}rlll@{}}
\table^\ast &=& \module.\MTABLES \\
Expand All @@ -403,7 +404,7 @@ where:
\MIEXPORTS~\exportinst^\ast ~\}
\end{array} \\[1ex]
\deftype^\ast &=&
\insttype_{\moduleinst}(\module.\MTYPES) \\
\alloctype^\ast(\module.\MTYPES) \\
S_1, \funcaddr^\ast &=&
\allocfunc^\ast(S, \module.\MFUNCS, \moduleinst) \\
S_2, \tableaddr^\ast &=&
Expand Down Expand Up @@ -450,8 +451,30 @@ Here, the notation :math:`\F{allocx}^\ast` is shorthand for multiple :ref:`alloc
Moreover, if the dots :math:`\dots` are a sequence :math:`A^n` (as for globals or tables), then the elements of this sequence are passed to the allocation function pointwise.

For types, however, allocation is defined in terms of :ref:`rolling <aux-roll-rectype>`:

.. math::
\begin{array}{rlll}
\alloctype^\ast(\rectype^n) = \deftype^\ast \\[1ex]
\mbox{where for all $i < n$:} \hfill \\
\deftype^\ast[x_i \slice m_i] &=& \rolldt{x_i}(\rectype^n[i])[\subst \deftype^\ast[0 : \slice x_i]) \\
x_{i+1} &=& x_i + m_i \land x_n = |\deftype^\ast| \\
\end{array}
.. todo:: unify with type closure somehow?


.. scratch
\begin{array}{rlll}
\alloctype^\ast(\epsilon) = \epsilon \\
\alloctype^\ast(\rectype^\ast~\rectype') = \deftype^\ast~{\deftype'}^\ast \\[1ex]
\mbox{where:} \hfill \\
\deftype^\ast &=& \alloctype^\ast(\reftype^\ast) \\
{\deftype'}^\ast &=& \rolldt{|\deftype^\ast|}(\rectype)[\subst \deftype^\ast) \\
\end{array}
.. note::
The definition of module allocation is mutually recursive with the allocation of its associated types and functions, because the resulting module instance :math:`\moduleinst` is passed to the allocators as an argument, in order to form the necessary closures.
The definition of module allocation is mutually recursive with the allocation of its associated functions, because the resulting module instance :math:`\moduleinst` is passed to the allocators as an argument, in order to form the necessary closures.
In an implementation, this recursion is easily unraveled by mutating one or the other in a secondary step.


Expand Down Expand Up @@ -665,7 +688,7 @@ The following steps are performed:

2. Let :math:`\funcinst` be the :ref:`function instance <syntax-funcinst>` :math:`S.\SFUNCS[\funcaddr]`.

3. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`structured type <syntax-strtype>` :math:`\expand(\funcinst.\FITYPE)`.
3. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`compound type <syntax-comptype>` :math:`\expanddt(\funcinst.\FITYPE)`.

4. If the length :math:`|\val^\ast|` of the provided argument values is different from the number :math:`n` of expected arguments, then:

Expand Down Expand Up @@ -697,7 +720,7 @@ The values :math:`\val_{\F{res}}^m` are returned as the results of the invocatio
~\\[-1ex]
\begin{array}{@{}lcl}
\invoke(S, \funcaddr, \val^n) &=& S; F; \val^n~(\INVOKE~\funcaddr) \\
&(\iff & \expand(S.\SFUNCS[\funcaddr].\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m] \\
&(\iff & \expanddt(S.\SFUNCS[\funcaddr].\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m] \\
&\wedge& (S \vdashval \val : t_1)^n \\
&\wedge& F = \{ \AMODULE~\{\}, \ALOCALS~\epsilon \}) \\
\end{array}
2 changes: 1 addition & 1 deletion document/core/exec/runtime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ Conventions

.. math::
\begin{array}{llll}
\fblocktype_{S;F}(\typeidx) &=& \functype & (\iff \expand(F.\AMODULE.\MITYPES[\typeidx]) = \TFUNC~\functype) \\
\fblocktype_{S;F}(\typeidx) &=& \functype & (\iff \expanddt(F.\AMODULE.\MITYPES[\typeidx]) = \TFUNC~\functype) \\
\fblocktype_{S;F}([\valtype^?]) &=& [] \to [\valtype^?] \\
\end{array}
Expand Down
3 changes: 3 additions & 0 deletions document/core/exec/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ Any form of :ref:`type <syntax-type>` can be *instantiated* into a :ref:`closed

.. math::
\insttype_{\moduleinst}(t) = t[\subst \moduleinst.\MITYPES]
.. note::
This is the runtime equivalent to :ref:`type closure <type-closure>`.
12 changes: 6 additions & 6 deletions document/core/exec/values.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ The following auxiliary typing rules specify this typing relation relative to a

* Let :math:`\deftype` be the :ref:`defined type <syntax-deftype>` :math:`\structinst.\SITYPE`.

* The :ref:`expansion <aux-expand>` of :math:`\deftype` must be a :ref:`struct type <syntax-structtype>`.
* The :ref:`expansion <aux-expand-deftype>` of :math:`\deftype` must be a :ref:`struct type <syntax-structtype>`.

* Then the value is valid with :ref:`reference type <syntax-reftype>` :math:`(\REF~\deftype)`.

.. math::
\frac{
\deftype = S.\SSTRUCTS[a].\SITYPE
\qquad
\expand(\deftype) = \TSTRUCT~\structtype
\expanddt(\deftype) = \TSTRUCT~\structtype
}{
S \vdashval \REFSTRUCTADDR~a : \REF~\deftype
}
Expand All @@ -116,15 +116,15 @@ The following auxiliary typing rules specify this typing relation relative to a

* Let :math:`\deftype` be the :ref:`defined type <syntax-deftype>` :math:`\arrayinst.\AITYPE`.

* The :ref:`expansion <aux-expand>` of :math:`\deftype` must be an :ref:`array type <syntax-arraytype>`.
* The :ref:`expansion <aux-expand-deftype>` of :math:`\deftype` must be an :ref:`array type <syntax-arraytype>`.

* Then the value is valid with :ref:`reference type <syntax-reftype>` :math:`(\REF~\arraytype)`.

.. math::
\frac{
\deftype = S.\SARRAYS[a].\AITYPE
\qquad
\expand(\deftype) = \TARRAY~\arraytype
\expanddt(\deftype) = \TARRAY~\arraytype
}{
S \vdashval \REFARRAYADDR~a : \REF~\deftype
}
Expand All @@ -139,15 +139,15 @@ The following auxiliary typing rules specify this typing relation relative to a

* Let :math:`\deftype` be the :ref:`defined type <syntax-deftype>` :math:`\funcinst.\FITYPE`.

* The :ref:`expansion <aux-expand>` of :math:`\deftype` must be a :ref:`function type <syntax-functype>`.
* The :ref:`expansion <aux-expand-deftype>` of :math:`\deftype` must be a :ref:`function type <syntax-functype>`.

* Then the value is valid with :ref:`reference type <syntax-reftype>` :math:`(\REF~\functype)`.

.. math::
\frac{
\deftype = S.\SFUNCS[a].\FITYPE
\qquad
\expand(\deftype) = \TFUNC~\functype
\expanddt(\deftype) = \TFUNC~\functype
}{
S \vdashval \REFFUNCADDR~a : \REF~\deftype
}
Expand Down
Loading

0 comments on commit f58ae60

Please sign in to comment.