Skip to content

Commit

Permalink
Fix memory index in data instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Jul 31, 2024
1 parent 2fcf26d commit 4d503df
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions document/core/exec/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -674,19 +674,17 @@ It is up to the :ref:`embedder <embedder>` to define how such conditions are rep

16. For each :ref:`data segment <syntax-data>` :math:`\data_i` in :math:`\module.\MDATAS` whose :ref:`mode <syntax-datamode>` is of the form :math:`\DACTIVE~\{ \DMEM~\memidx_i, \DOFFSET~\X{dinstr}^\ast_i~\END \}`, do:

a. Assert: :math:`\memidx_i` is :math:`0`.
a. Let :math:`n` be the length of the vector :math:`\data_i.\DINIT`.

b. Let :math:`n` be the length of the vector :math:`\data_i.\DINIT`.
b. :ref:`Execute <exec-instr-seq>` the instruction sequence :math:`\X{dinstr}^\ast_i`.

c. :ref:`Execute <exec-instr-seq>` the instruction sequence :math:`\X{dinstr}^\ast_i`.

d. :ref:`Execute <exec-const>` the instruction :math:`\I32.\CONST~0`.
c. :ref:`Execute <exec-const>` the instruction :math:`\I32.\CONST~0`.

e. :ref:`Execute <exec-const>` the instruction :math:`\I32.\CONST~n`.
d. :ref:`Execute <exec-const>` the instruction :math:`\I32.\CONST~n`.

f. :ref:`Execute <exec-memory.init>` the instruction :math:`\MEMORYINIT~i`.
e. :ref:`Execute <exec-memory.init>` the instruction :math:`\MEMORYINIT~i`.

g. :ref:`Execute <exec-data.drop>` the instruction :math:`\DATADROP~i`.
f. :ref:`Execute <exec-data.drop>` the instruction :math:`\DATADROP~i`.

17. If the :ref:`start function <syntax-start>` :math:`\module.\MSTART` is not empty, then:

Expand Down Expand Up @@ -737,8 +735,8 @@ where:
\F{runelem}_i(\{\ETYPE~\X{et}, \EINIT~\reff^n, \EMODE~\EDECLARATIVE\}) \quad=\\ \qquad
(\ELEMDROP~i) \\[1ex]
\F{rundata}_i(\{\DINIT~b^n, \DMODE~\DPASSIVE\}) \quad=\quad \epsilon \\
\F{rundata}_i(\{\DINIT~b^n, \DMODE~\DACTIVE \{\DMEM~0, \DOFFSET~\instr^\ast~\END\}\}) \quad=\\ \qquad
\instr^\ast~(\I32.\CONST~0)~(\I32.\CONST~n)~(\MEMORYINIT~i)~(\DATADROP~i) \\
\F{rundata}_i(\{\DINIT~b^n, \DMODE~\DACTIVE \{\DMEM~x, \DOFFSET~\instr^\ast~\END\}\}) \quad=\\ \qquad
\instr^\ast~(\I32.\CONST~0)~(\I32.\CONST~n)~(\MEMORYINIT~x~i)~(\DATADROP~i) \\
\end{array}
.. note::
Expand Down

0 comments on commit 4d503df

Please sign in to comment.