Skip to content

Commit 8b73d00

Browse files
authored
[spec] Adjust oversight in reversal of br_table validation (#1305)
1 parent b9668b9 commit 8b73d00

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

document/core/valid/instructions.rst

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and the provided output stack with result values of types :math:`t_2^\ast` that
2121
Stack types are akin to :ref:`function types <syntax-functype>`,
2222
except that they allow individual operands to be classified as :math:`\bot` (*bottom*), indicating that the type is unconstrained.
2323
As an auxiliary notion, an operand type :math:`t_1` *matches* another operand type :math:`t_2`, if :math:`t_1` is either :math:`\bot` or equal to :math:`t_2`.
24+
This is extended to stack types in a point-wise manner.
2425

2526
.. _match-opdtype:
2627

@@ -35,6 +36,13 @@ As an auxiliary notion, an operand type :math:`t_1` *matches* another operand ty
3536
\vdash \bot \leq t
3637
}
3738
39+
.. math::
40+
\frac{
41+
(\vdash t \leq t')^\ast
42+
}{
43+
\vdash [t^\ast] \leq [{t'}^\ast]
44+
}
45+
3846
.. note::
3947
For example, the instruction :math:`\I32.\ADD` has type :math:`[\I32~\I32] \to [\I32]`,
4048
consuming two |I32| values and producing one.
@@ -949,23 +957,28 @@ Control Instructions
949957
:math:`\BRTABLE~l^\ast~l_N`
950958
...........................
951959

960+
952961
* The label :math:`C.\CLABELS[l_N]` must be defined in the context.
953962

954963
* Let :math:`[t^\ast]` be the :ref:`result type <syntax-resulttype>` :math:`C.\CLABELS[l_N]`.
955964

956965
* For all :math:`l_i` in :math:`l^\ast`,
957966
the label :math:`C.\CLABELS[l_i]` must be defined in the context.
958967

959-
* For all :math:`l_i` in :math:`l^\ast`,
960-
:math:`C.\CLABELS[l_i]` must be :math:`[t^\ast]`.
968+
* There must be a :ref:`result type <syntax-resulttype>` :math:`[t^\ast]`, such that:
969+
970+
* For each :ref:`operand type <syntax-opdtype>` :math:`t_j` in :math:`t^\ast` and corresponding type :math:`t'_{Nj}` in :math:`C.\CLABELS[l_N]`, :math:`t_j` :ref:`matches <match-opdtype>` :math:`t'_{Nj}`.
971+
972+
* For all :math:`l_i` in :math:`l^\ast`,
973+
and for each :ref:`operand type <syntax-opdtype>` :math:`t_j` in :math:`t^\ast` and corresponding type :math:`t'_{ij}` in :math:`C.\CLABELS[l_i]`, :math:`t_j` :ref:`matches <match-opdtype>` :math:`t'_{ij}`.
961974

962975
* Then the instruction is valid with type :math:`[t_1^\ast~t^\ast~\I32] \to [t_2^\ast]`, for any sequences of :ref:`value types <syntax-valtype>` :math:`t_1^\ast` and :math:`t_2^\ast`.
963976

964977
.. math::
965978
\frac{
966-
(C.\CLABELS[l] = [t^\ast])^\ast
979+
(\vdash [t^\ast] \leq C.\CLABELS[l])^\ast
967980
\qquad
968-
C.\CLABELS[l_N] = [t^\ast]
981+
\vdash [t^\ast] \leq C.\CLABELS[l_N]
969982
}{
970983
C \vdashinstr \BRTABLE~l^\ast~l_N : [t_1^\ast~t^\ast~\I32] \to [t_2^\ast]
971984
}
@@ -1088,7 +1101,7 @@ Non-empty Instruction Sequence: :math:`\instr^\ast~\instr_N`
10881101
\frac{
10891102
C \vdashinstrseq \instr^\ast : [t_1^\ast] \to [t_0^\ast~{t'}^\ast]
10901103
\qquad
1091-
(\vdash t' \leq t)^\ast
1104+
\vdash [{t'}^\ast] \leq [t^\ast]
10921105
\qquad
10931106
C \vdashinstr \instr_N : [t^\ast] \to [t_3^\ast]
10941107
}{
@@ -1121,7 +1134,7 @@ Expressions :math:`\expr` are classified by :ref:`result types <syntax-resulttyp
11211134
\frac{
11221135
C \vdashinstrseq \instr^\ast : [] \to [{t'}^\ast]
11231136
\qquad
1124-
(\vdash t' \leq t)^\ast
1137+
\vdash [{t'}^\ast] \leq [t^\ast]
11251138
}{
11261139
C \vdashexpr \instr^\ast~\END : [t^\ast]
11271140
}

0 commit comments

Comments
 (0)