Skip to content

Commit e9dccd9

Browse files
authored
[spec] Simplify exec rule for if (#1517)
1 parent 9de7805 commit e9dccd9

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

document/core/exec/instructions.rst

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,37 +2587,27 @@ Control Instructions
25872587
:math:`\IF~\blocktype~\instr_1^\ast~\ELSE~\instr_2^\ast~\END`
25882588
.............................................................
25892589

2590-
1. Assert: due to :ref:`validation <valid-blocktype>`, :math:`\expand_F(\blocktype)` is defined.
2591-
2592-
2. Let :math:`[t_1^m] \to [t_2^n]` be the :ref:`function type <syntax-functype>` :math:`\expand_F(\blocktype)`.
2593-
2594-
3. Let :math:`L` be the label whose arity is :math:`n` and whose continuation is the end of the |IF| instruction.
2595-
2596-
4. Assert: due to :ref:`validation <valid-if>`, a value of :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
2597-
2598-
5. Pop the value :math:`\I32.\CONST~c` from the stack.
2599-
2600-
6. Assert: due to :ref:`validation <valid-if>`, there are at least :math:`m` values on the top of the stack.
2590+
1. Assert: due to :ref:`validation <valid-if>`, a value of :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
26012591

2602-
7. Pop the values :math:`\val^m` from the stack.
2592+
2. Pop the value :math:`\I32.\CONST~c` from the stack.
26032593

2604-
8. If :math:`c` is non-zero, then:
2594+
3. If :math:`c` is non-zero, then:
26052595

2606-
a. :ref:`Enter <exec-instr-seq-enter>` the block :math:`\val^m~\instr_1^\ast` with label :math:`L`.
2596+
a. Execute the block instruction :math:`\BLOCK~\X{bt}~\instr_1^\ast~\END`.
26072597

2608-
9. Else:
2598+
4. Else:
26092599

2610-
a. :ref:`Enter <exec-instr-seq-enter>` the block :math:`\val^m~\instr_2^\ast` with label :math:`L`.
2600+
a. Execute the block instruction :math:`\BLOCK~\X{bt}~\instr_2^\ast~\END`.
26112601

26122602
.. math::
26132603
~\\[-1ex]
26142604
\begin{array}{lcl}
2615-
F; \val^m~(\I32.\CONST~c)~\IF~\X{bt}~\instr_1^\ast~\ELSE~\instr_2^\ast~\END &\stepto&
2616-
F; \LABEL_n\{\epsilon\}~\val^m~\instr_1^\ast~\END
2617-
\\&&\quad (\iff c \neq 0 \wedge \expand_F(\X{bt}) = [t_1^m] \to [t_2^n]) \\
2618-
F; \val^m~(\I32.\CONST~c)~\IF~\X{bt}~\instr_1^\ast~\ELSE~\instr_2^\ast~\END &\stepto&
2619-
F; \LABEL_n\{\epsilon\}~\val^m~\instr_2^\ast~\END
2620-
\\&&\quad (\iff c = 0 \wedge \expand_F(\X{bt}) = [t_1^m] \to [t_2^n]) \\
2605+
F; (\I32.\CONST~c)~\IF~\X{bt}~\instr_1^\ast~\ELSE~\instr_2^\ast~\END &\stepto&
2606+
F; \BLOCK~\X{bt}~\instr_1^\ast~\END
2607+
\\&&\quad (\iff c \neq 0) \\
2608+
F; (\I32.\CONST~c)~\IF~\X{bt}~\instr_1^\ast~\ELSE~\instr_2^\ast~\END &\stepto&
2609+
F; \BLOCK~\X{bt}~\instr_2^\ast~\END
2610+
\\&&\quad (\iff c = 0) \\
26212611
\end{array}
26222612
26232613

0 commit comments

Comments
 (0)