Skip to content

Commit 8c6ea22

Browse files
authored
[spec] Update text for zero-byte OOB case (WebAssembly#101)
Also fix some typos from previous CL (see macros.def)
1 parent d976981 commit 8c6ea22

File tree

2 files changed

+14
-57
lines changed

2 files changed

+14
-57
lines changed

document/core/exec/instructions.rst

+12-55
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,7 @@ Memory Instructions
645645

646646
11. Pop the value :math:`\I32.\CONST~i` from the stack.
647647

648-
12. If :math:`n` is :math:`0`, then:
649-
650-
a. If :math:`i` is larger than the length of :math:`\X{mem}.\MIDATA`, then:
651-
652-
i. Trap.
653-
654-
13. Else:
648+
12. Else:
655649

656650
a. Push the value :math:`\I32.\CONST~i` to the stack.
657651

@@ -678,14 +672,7 @@ Memory Instructions
678672
\end{array} \\
679673
\begin{array}{lcl@{\qquad}l}
680674
S; F; (\I32.\CONST~i)~\val~(\I32.\CONST~0)~(\MEMORYFILL) &\stepto& S; F; \epsilon
681-
\end{array}
682-
\\ \qquad
683-
(\iff i \leq |\SMEMS[F.\AMODULE.\MIMEMS[0]]|) \\
684-
\begin{array}{lcl@{\qquad}l}
685-
S; F; (\I32.\CONST~i)~\val~(\I32.\CONST~0)~(\MEMORYFILL) &\stepto& S; F; \TRAP
686-
\end{array}
687-
\\ \qquad
688-
(\otherwise) \\
675+
\end{array} \\
689676
\end{array}
690677
691678
@@ -728,17 +715,7 @@ Memory Instructions
728715

729716
16. Pop the value :math:`\I32.\CONST~d` from the stack.
730717

731-
17. If :math:`n` is :math:`0`, then:
732-
733-
a. If :math:`d` is larger than the length of :math:`\X{mem}.\MIDATA`, then:
734-
735-
i. Trap.
736-
737-
b. If :math:`s` is larger than the length of :math:`\X{data}.\DIINIT`, then:
738-
739-
i. Trap.
740-
741-
18. Else:
718+
17. Else:
742719

743720
a. Push the value :math:`\I32.\CONST~d` to the stack.
744721

@@ -760,6 +737,10 @@ Memory Instructions
760737
~\\[-1ex]
761738
\begin{array}{l}
762739
\begin{array}{lcl@{\qquad}l}
740+
S; F; (\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~0)~(\MEMORYINIT~x) &\stepto& S; F; \epsilon
741+
\end{array}
742+
\\[1ex]
743+
\begin{array}{lcl@{\qquad}l}
763744
S; F; (\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~(n+1))~(\MEMORYINIT~x) &\stepto& S; F;
764745
\begin{array}[t]{@{}l@{}}
765746
(\I32.\CONST~d)~(\I32.\CONST~b)~(\I32\K{.}\STORE\K{8}~\{ \OFFSET~0, \ALIGN~0 \}) \\
@@ -773,15 +754,6 @@ Memory Instructions
773754
\end{array}
774755
\\[1ex]
775756
\begin{array}{lcl@{\qquad}l}
776-
S; F; (\I32.\CONST~d)~(\I32.\CONST~(s)~(\I32.\CONST~0)~(\MEMORYINIT~x) &\stepto& S; F; \epsilon
777-
\end{array}
778-
\\ \qquad
779-
\begin{array}[t]{@{}r@{~}l@{}}
780-
(\iff & d \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA| \\
781-
\wedge & s \leq |S.\SDATA[F.\AMODULE.\MIDATAS[x]].\DIINIT|) \\
782-
\end{array}
783-
\\[1ex]
784-
\begin{array}{lcl@{\qquad}l}
785757
S; F; (\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~n)~(\MEMORYINIT~x) &\stepto& S; F; \TRAP
786758
\end{array}
787759
\\ \qquad
@@ -877,17 +849,7 @@ Table Instructions
877849

878850
16. Pop the value :math:`\I32.\CONST~d` from the stack.
879851

880-
17. If :math:`n` is :math:`0`, then:
881-
882-
a. If :math:`d` is larger than the length of :math:`\X{table}.\TIELEM`, then:
883-
884-
i. Trap.
885-
886-
b. If :math:`s` is larger than the length of :math:`\X{elem}.\EIINIT`, then:
887-
888-
i. Trap.
889-
890-
18. Else:
852+
17. Else:
891853

892854
a. Push the value :math:`\I32.\CONST~d` to the stack.
893855

@@ -907,6 +869,10 @@ Table Instructions
907869
~\\[-1ex]
908870
\begin{array}{l}
909871
\begin{array}{lcl@{\qquad}l}
872+
S; F; (\I32.\CONST~d)~(\I32.\CONST~(s)~(\I32.\CONST~0)~(\TABLEINIT~x) &\stepto& S; F; \epsilon
873+
\end{array}
874+
\\[1ex]
875+
\begin{array}{lcl@{\qquad}l}
910876
S; F; (\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~(n+1))~(\TABLEINIT~x) &\stepto& S; F;
911877
\begin{array}[t]{@{}l@{}}
912878
(\I32.\CONST~d)~\funcelem~\TABLESET \\
@@ -920,15 +886,6 @@ Table Instructions
920886
\end{array}
921887
\\[1ex]
922888
\begin{array}{lcl@{\qquad}l}
923-
S; F; (\I32.\CONST~d)~(\I32.\CONST~(s)~(\I32.\CONST~0)~(\TABLEINIT~x) &\stepto& S; F; \epsilon
924-
\end{array}
925-
\\ \qquad
926-
\begin{array}[t]{@{}r@{~}l@{}}
927-
(\iff & d \leq |S.\STABLES[F.\AMODULE.\MITABLES[0]].\TIELEM| \\
928-
\wedge & s \leq |S.\SELEM[F.\AMODULE.\MIELEMS[x]].\EIINIT|) \\
929-
\end{array}
930-
\\[1ex]
931-
\begin{array}{lcl@{\qquad}l}
932889
S; F; (\I32.\CONST~d)~(\I32.\CONST~s)~(\I32.\CONST~n)~(\TABLEINIT~x) &\stepto& S; F; \TRAP
933890
\end{array}
934891
\\ \qquad

document/core/util/macros.def

+2-2
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,8 @@
922922
.. |INVOKE| mathdef:: \xref{exec/runtime}{syntax-invoke}{\K{invoke}}
923923
.. |INITELEM| mathdef:: \xref{exec/runtime}{syntax-init_elem}{\K{init\_elem}}
924924
.. |INITDATA| mathdef:: \xref{exec/runtime}{syntax-init_data}{\K{init\_data}}
925-
.. |TABLEGET| mathdef:: \xref{exec/runtime}{syntax-table_get}{\K{table.get}
926-
.. |TABLESET| mathdef:: \xref{exec/runtime}{syntax-table_set}{\K{table.set}
925+
.. |TABLEGET| mathdef:: \xref{exec/runtime}{syntax-table_get}{\K{table.get}}
926+
.. |TABLESET| mathdef:: \xref{exec/runtime}{syntax-table_set}{\K{table.set}}
927927

928928

929929
.. Values & Results, non-terminals

0 commit comments

Comments
 (0)