From 4d503df4692bde9f3cbf402aa728fe684a36953f Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Wed, 31 Jul 2024 09:39:55 +0200 Subject: [PATCH] Fix memory index in data instantiation --- document/core/exec/modules.rst | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/document/core/exec/modules.rst b/document/core/exec/modules.rst index 578acfa2..d3a158e7 100644 --- a/document/core/exec/modules.rst +++ b/document/core/exec/modules.rst @@ -674,19 +674,17 @@ It is up to the :ref:`embedder ` to define how such conditions are rep 16. For each :ref:`data segment ` :math:`\data_i` in :math:`\module.\MDATAS` whose :ref:`mode ` 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 ` the instruction sequence :math:`\X{dinstr}^\ast_i`. - c. :ref:`Execute ` the instruction sequence :math:`\X{dinstr}^\ast_i`. - - d. :ref:`Execute ` the instruction :math:`\I32.\CONST~0`. + c. :ref:`Execute ` the instruction :math:`\I32.\CONST~0`. - e. :ref:`Execute ` the instruction :math:`\I32.\CONST~n`. + d. :ref:`Execute ` the instruction :math:`\I32.\CONST~n`. - f. :ref:`Execute ` the instruction :math:`\MEMORYINIT~i`. + e. :ref:`Execute ` the instruction :math:`\MEMORYINIT~i`. - g. :ref:`Execute ` the instruction :math:`\DATADROP~i`. + f. :ref:`Execute ` the instruction :math:`\DATADROP~i`. 17. If the :ref:`start function ` :math:`\module.\MSTART` is not empty, then: @@ -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::