Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 7ef87ae

Browse files
authored
[spec] Changes for multiple memories (#3)
2 parents 4477d04 + 6f50abe commit 7ef87ae

File tree

7 files changed

+142
-125
lines changed

7 files changed

+142
-125
lines changed

document/core/binary/instructions.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Variable Instructions
117117
Memory Instructions
118118
~~~~~~~~~~~~~~~~~~~
119119

120-
Each variant of :ref:`memory instruction <syntax-instr-memory>` is encoded with a different byte code. Loads and stores are followed by the encoding of their |memarg| immediate.
120+
Each variant of :ref:`memory instruction <syntax-instr-memory>` is encoded with a different byte code. Loads and stores are followed by the encoding of their |memarg| immediate, which includes the :ref:`memory index <binary-memidx>` if bit 6 of the flags field containing alignment is set; the memory index defaults to 0 otherwise.
121121

122122
.. _binary-memarg:
123123
.. _binary-load:
@@ -128,9 +128,12 @@ Each variant of :ref:`memory instruction <syntax-instr-memory>` is encoded with
128128
.. _binary-memory.grow:
129129

130130
.. math::
131-
\begin{array}{llclll}
131+
\begin{array}{llcllll}
132132
\production{memory argument} & \Bmemarg &::=&
133-
a{:}\Bu32~~o{:}\Bu32 &\Rightarrow& \{ \ALIGN~a,~\OFFSET~o \} \\
133+
a{:}\Bu32~~o{:}\Bu32 &\Rightarrow& 0~\{ \ALIGN~a,~\OFFSET~o \}
134+
& (\iff a < 2^6) \\ &&|&
135+
a{:}\Bu32~~o{:}\Bu32~~x{:}\memidx &\Rightarrow& x~\{ \ALIGN~(a - 2^6),~\OFFSET~o \}
136+
& (\otherwise) \\
134137
\production{instruction} & \Binstr &::=& \dots \\ &&|&
135138
\hex{28}~~m{:}\Bmemarg &\Rightarrow& \I32.\LOAD~m \\ &&|&
136139
\hex{29}~~m{:}\Bmemarg &\Rightarrow& \I64.\LOAD~m \\ &&|&
@@ -155,13 +158,10 @@ Each variant of :ref:`memory instruction <syntax-instr-memory>` is encoded with
155158
\hex{3C}~~m{:}\Bmemarg &\Rightarrow& \I64.\STORE\K{8}~m \\ &&|&
156159
\hex{3D}~~m{:}\Bmemarg &\Rightarrow& \I64.\STORE\K{16}~m \\ &&|&
157160
\hex{3E}~~m{:}\Bmemarg &\Rightarrow& \I64.\STORE\K{32}~m \\ &&|&
158-
\hex{3F}~~\hex{00} &\Rightarrow& \MEMORYSIZE \\ &&|&
159-
\hex{40}~~\hex{00} &\Rightarrow& \MEMORYGROW \\
161+
\hex{3F}~~x{:}\Bmemidx &\Rightarrow& \MEMORYSIZE~x \\ &&|&
162+
\hex{40}~~x{:}\Bmemidx &\Rightarrow& \MEMORYGROW~x \\
160163
\end{array}
161164
162-
.. note::
163-
In future versions of WebAssembly, the additional zero bytes occurring in the encoding of the |MEMORYSIZE| and |MEMORYGROW| instructions may be used to index additional memories.
164-
165165
166166
.. index:: numeric instruction
167167
pair: binary format; instruction

document/core/exec/instructions.rst

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,14 @@ Memory Instructions
391391
.. _exec-load:
392392
.. _exec-loadn:
393393

394-
:math:`t\K{.}\LOAD~\memarg` and :math:`t\K{.}\LOAD{N}\K{\_}\sx~\memarg`
395-
.......................................................................
394+
:math:`t\K{.}\LOAD~x~\memarg` and :math:`t\K{.}\LOAD{N}\K{\_}\sx~x~\memarg`
395+
...........................................................................
396396

397397
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
398398

399-
2. Assert: due to :ref:`validation <valid-loadn>`, :math:`F.\AMODULE.\MIMEMS[0]` exists.
399+
2. Assert: due to :ref:`validation <valid-loadn>`, :math:`F.\AMODULE.\MIMEMS[x]` exists.
400400

401-
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[0]`.
401+
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[x]`.
402402

403403
4. Assert: due to :ref:`validation <valid-loadn>`, :math:`S.\SMEMS[a]` exists.
404404

@@ -436,28 +436,28 @@ Memory Instructions
436436
~\\[-1ex]
437437
\begin{array}{l}
438438
\begin{array}{lcl@{\qquad}l}
439-
S; F; (\I32.\CONST~i)~(t.\LOAD~\memarg) &\stepto& S; F; (t.\CONST~c)
439+
S; F; (\I32.\CONST~i)~(t.\LOAD~x~\memarg) &\stepto& S; F; (t.\CONST~c)
440440
\end{array}
441441
\\ \qquad
442442
\begin{array}[t]{@{}r@{~}l@{}}
443443
(\iff & \X{ea} = i + \memarg.\OFFSET \\
444-
\wedge & \X{ea} + |t|/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA| \\
445-
\wedge & \bytes_t(c) = S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA[\X{ea} \slice |t|/8])
444+
\wedge & \X{ea} + |t|/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA| \\
445+
\wedge & \bytes_t(c) = S.\SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA[\X{ea} \slice |t|/8])
446446
\end{array}
447447
\\[1ex]
448448
\begin{array}{lcl@{\qquad}l}
449-
S; F; (\I32.\CONST~i)~(t.\LOAD{N}\K{\_}\sx~\memarg) &\stepto&
449+
S; F; (\I32.\CONST~i)~(t.\LOAD{N}\K{\_}\sx~x~\memarg) &\stepto&
450450
S; F; (t.\CONST~\extend\F{\_}\sx_{N,|t|}(n))
451451
\end{array}
452452
\\ \qquad
453453
\begin{array}[t]{@{}r@{~}l@{}}
454454
(\iff & \X{ea} = i + \memarg.\OFFSET \\
455-
\wedge & \X{ea} + N/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA| \\
456-
\wedge & \bytes_{\iN}(n) = S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA[\X{ea} \slice N/8])
455+
\wedge & \X{ea} + N/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA| \\
456+
\wedge & \bytes_{\iN}(n) = S.\SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA[\X{ea} \slice N/8])
457457
\end{array}
458458
\\[1ex]
459459
\begin{array}{lcl@{\qquad}l}
460-
S; F; (\I32.\CONST~k)~(t.\LOAD({N}\K{\_}\sx)^?~\memarg) &\stepto& S; F; \TRAP
460+
S; F; (\I32.\CONST~k)~(t.\LOAD({N}\K{\_}\sx)^?~x~\memarg) &\stepto& S; F; \TRAP
461461
\end{array}
462462
\\ \qquad
463463
(\otherwise) \\
@@ -467,14 +467,14 @@ Memory Instructions
467467
.. _exec-store:
468468
.. _exec-storen:
469469

470-
:math:`t\K{.}\STORE~\memarg` and :math:`t\K{.}\STORE{N}~\memarg`
471-
................................................................
470+
:math:`t\K{.}\STORE~x~\memarg` and :math:`t\K{.}\STORE{N}~x~\memarg`
471+
....................................................................
472472

473473
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
474474

475-
2. Assert: due to :ref:`validation <valid-storen>`, :math:`F.\AMODULE.\MIMEMS[0]` exists.
475+
2. Assert: due to :ref:`validation <valid-storen>`, :math:`F.\AMODULE.\MIMEMS[x]` exists.
476476

477-
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[0]`.
477+
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[x]`.
478478

479479
4. Assert: due to :ref:`validation <valid-storen>`, :math:`S.\SMEMS[a]` exists.
480480

@@ -514,27 +514,27 @@ Memory Instructions
514514
~\\[-1ex]
515515
\begin{array}{l}
516516
\begin{array}{lcl@{\qquad}l}
517-
S; F; (\I32.\CONST~i)~(t.\CONST~c)~(t.\STORE~\memarg) &\stepto& S'; F; \epsilon
517+
S; F; (\I32.\CONST~i)~(t.\CONST~c)~(t.\STORE~x~\memarg) &\stepto& S'; F; \epsilon
518518
\end{array}
519519
\\ \qquad
520520
\begin{array}[t]{@{}r@{~}l@{}}
521521
(\iff & \X{ea} = i + \memarg.\OFFSET \\
522-
\wedge & \X{ea} + |t|/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA| \\
523-
\wedge & S' = S \with \SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA[\X{ea} \slice |t|/8] = \bytes_t(c)
522+
\wedge & \X{ea} + |t|/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA| \\
523+
\wedge & S' = S \with \SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA[\X{ea} \slice |t|/8] = \bytes_t(c)
524524
\end{array}
525525
\\[1ex]
526526
\begin{array}{lcl@{\qquad}l}
527-
S; F; (\I32.\CONST~i)~(t.\CONST~c)~(t.\STORE{N}~\memarg) &\stepto& S'; F; \epsilon
527+
S; F; (\I32.\CONST~i)~(t.\CONST~c)~(t.\STORE{N}~x~\memarg) &\stepto& S'; F; \epsilon
528528
\end{array}
529529
\\ \qquad
530530
\begin{array}[t]{@{}r@{~}l@{}}
531531
(\iff & \X{ea} = i + \memarg.\OFFSET \\
532-
\wedge & \X{ea} + N/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA| \\
533-
\wedge & S' = S \with \SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA[\X{ea} \slice N/8] = \bytes_{\iN}(\wrap_{|t|,N}(c))
532+
\wedge & \X{ea} + N/8 \leq |S.\SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA| \\
533+
\wedge & S' = S \with \SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA[\X{ea} \slice N/8] = \bytes_{\iN}(\wrap_{|t|,N}(c))
534534
\end{array}
535535
\\[1ex]
536536
\begin{array}{lcl@{\qquad}l}
537-
S; F; (\I32.\CONST~k)~(t.\CONST~c)~(t.\STORE{N}^?~\memarg) &\stepto& S; F; \TRAP
537+
S; F; (\I32.\CONST~k)~(t.\CONST~c)~(t.\STORE{N}^?~x~\memarg) &\stepto& S; F; \TRAP
538538
\end{array}
539539
\\ \qquad
540540
(\otherwise) \\
@@ -543,14 +543,14 @@ Memory Instructions
543543
544544
.. _exec-memory.size:
545545

546-
:math:`\MEMORYSIZE`
547-
...................
546+
:math:`\MEMORYSIZE~x`
547+
.....................
548548

549549
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
550550

551-
2. Assert: due to :ref:`validation <valid-memory.size>`, :math:`F.\AMODULE.\MIMEMS[0]` exists.
551+
2. Assert: due to :ref:`validation <valid-memory.size>`, :math:`F.\AMODULE.\MIMEMS[x]` exists.
552552

553-
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[0]`.
553+
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[x]`.
554554

555555
4. Assert: due to :ref:`validation <valid-memory.size>`, :math:`S.\SMEMS[a]` exists.
556556

@@ -563,23 +563,23 @@ Memory Instructions
563563
.. math::
564564
\begin{array}{l}
565565
\begin{array}{lcl@{\qquad}l}
566-
S; F; \MEMORYSIZE &\stepto& S; F; (\I32.\CONST~\X{sz})
566+
S; F; (\MEMORYSIZE~x) &\stepto& S; F; (\I32.\CONST~\X{sz})
567567
\end{array}
568568
\\ \qquad
569-
(\iff |S.\SMEMS[F.\AMODULE.\MIMEMS[0]].\MIDATA| = \X{sz}\cdot64\,\F{Ki}) \\
569+
(\iff |S.\SMEMS[F.\AMODULE.\MIMEMS[x]].\MIDATA| = \X{sz}\cdot64\,\F{Ki}) \\
570570
\end{array}
571571
572572
573573
.. _exec-memory.grow:
574574

575-
:math:`\MEMORYGROW`
576-
...................
575+
:math:`\MEMORYGROW~x`
576+
.....................
577577

578578
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
579579

580-
2. Assert: due to :ref:`validation <valid-memory.grow>`, :math:`F.\AMODULE.\MIMEMS[0]` exists.
580+
2. Assert: due to :ref:`validation <valid-memory.grow>`, :math:`F.\AMODULE.\MIMEMS[x]` exists.
581581

582-
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[0]`.
582+
3. Let :math:`a` be the :ref:`memory address <syntax-memaddr>` :math:`F.\AMODULE.\MIMEMS[x]`.
583583

584584
4. Assert: due to :ref:`validation <valid-memory.grow>`, :math:`S.\SMEMS[a]` exists.
585585

@@ -603,17 +603,17 @@ Memory Instructions
603603
~\\[-1ex]
604604
\begin{array}{l}
605605
\begin{array}{lcl@{\qquad}l}
606-
S; F; (\I32.\CONST~n)~\MEMORYGROW &\stepto& S'; F; (\I32.\CONST~\X{sz})
606+
S; F; (\I32.\CONST~n)~(\MEMORYGROW~x) &\stepto& S'; F; (\I32.\CONST~\X{sz})
607607
\end{array}
608608
\\ \qquad
609609
\begin{array}[t]{@{}r@{~}l@{}}
610-
(\iff & F.\AMODULE.\MIMEMS[0] = a \\
610+
(\iff & F.\AMODULE.\MIMEMS[x] = a \\
611611
\wedge & \X{sz} = |S.\SMEMS[a].\MIDATA|/64\,\F{Ki} \\
612612
\wedge & S' = S \with \SMEMS[a] = \growmem(S.\SMEMS[a], n)) \\
613613
\end{array}
614614
\\[1ex]
615615
\begin{array}{lcl@{\qquad}l}
616-
S; F; (\I32.\CONST~n)~\MEMORYGROW &\stepto& S; F; (\I32.\CONST~{-1})
616+
S; F; (\I32.\CONST~n)~(\MEMORYGROW~x) &\stepto& S; F; (\I32.\CONST~{-1})
617617
\end{array}
618618
\end{array}
619619

document/core/syntax/instructions.rst

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,22 @@ Instructions in this group are concerned with linear :ref:`memory <syntax-mem>`.
231231
\{ \OFFSET~\u32, \ALIGN~\u32 \} \\
232232
\production{instruction} & \instr &::=&
233233
\dots \\&&|&
234-
\K{i}\X{nn}\K{.}\LOAD~\memarg ~|~
235-
\K{f}\X{nn}\K{.}\LOAD~\memarg \\&&|&
236-
\K{i}\X{nn}\K{.}\STORE~\memarg ~|~
237-
\K{f}\X{nn}\K{.}\STORE~\memarg \\&&|&
238-
\K{i}\X{nn}\K{.}\LOAD\K{8\_}\sx~\memarg ~|~
239-
\K{i}\X{nn}\K{.}\LOAD\K{16\_}\sx~\memarg ~|~
240-
\K{i64.}\LOAD\K{32\_}\sx~\memarg \\&&|&
241-
\K{i}\X{nn}\K{.}\STORE\K{8}~\memarg ~|~
242-
\K{i}\X{nn}\K{.}\STORE\K{16}~\memarg ~|~
243-
\K{i64.}\STORE\K{32}~\memarg \\&&|&
244-
\MEMORYSIZE \\&&|&
245-
\MEMORYGROW \\
234+
\K{i}\X{nn}\K{.}\LOAD~\memidx~\memarg ~|~
235+
\K{f}\X{nn}\K{.}\LOAD~\memidx~\memarg \\&&|&
236+
\K{i}\X{nn}\K{.}\STORE~\memidx~\memarg ~|~
237+
\K{f}\X{nn}\K{.}\STORE~\memidx~\memarg \\&&|&
238+
\K{i}\X{nn}\K{.}\LOAD\K{8\_}\sx~\memidx~\memarg ~|~
239+
\K{i}\X{nn}\K{.}\LOAD\K{16\_}\sx~\memidx~\memarg ~|~
240+
\K{i64.}\LOAD\K{32\_}\sx~\memidx~\memarg \\&&|&
241+
\K{i}\X{nn}\K{.}\STORE\K{8}~\memidx~\memarg ~|~
242+
\K{i}\X{nn}\K{.}\STORE\K{16}~\memidx~\memarg ~|~
243+
\K{i64.}\STORE\K{32}~\memidx~\memarg \\&&|&
244+
\MEMORYSIZE~\memidx \\&&|&
245+
\MEMORYGROW~\memidx \\
246246
\end{array}
247247
248248
Memory is accessed with |LOAD| and |STORE| instructions for the different :ref:`value types <syntax-valtype>`.
249-
They all take a *memory immediate* |memarg| that contains an address *offset* and the expected *alignment* (expressed as the exponent of a power of 2).
249+
They all take a :ref:`memory index <syntax-memidx>` and a *memory immediate* |memarg| that contains an address *offset* and the expected *alignment* (expressed as the exponent of a power of 2).
250250
Integer loads and stores can optionally specify a *storage size* that is smaller than the :ref:`bit width <syntax-valtype>` of the respective value type.
251251
In the case of loads, a sign extension mode |sx| is then required to select appropriate behavior.
252252

@@ -258,14 +258,9 @@ A :ref:`trap <trap>` results if any of the accessed memory bytes lies outside th
258258
Future version of WebAssembly might provide memory instructions with 64 bit address ranges.
259259

260260
The |MEMORYSIZE| instruction returns the current size of a memory.
261-
The |MEMORYGROW| instruction grows memory by a given delta and returns the previous size, or :math:`-1` if enough memory cannot be allocated.
261+
The |MEMORYGROW| instruction grows a memory by a given delta and returns the previous size, or :math:`-1` if enough memory cannot be allocated.
262262
Both instructions operate in units of :ref:`page size <page-size>`.
263263

264-
.. note::
265-
In the current version of WebAssembly,
266-
all memory instructions implicitly operate on :ref:`memory <syntax-mem>` :ref:`index <syntax-memidx>` :math:`0`.
267-
This restriction may be lifted in future versions.
268-
269264

270265
.. index:: ! control instruction, ! structured control, ! label, ! block, ! branch, ! unwinding, result type, label index, function index, type index, vector, trap, function, table, function type
271266
pair: abstract syntax; instruction

document/core/syntax/modules.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ Memories are referenced through :ref:`memory indices <syntax-memidx>`,
187187
starting with the smallest index not referencing a memory :ref:`import <syntax-import>`.
188188
Most constructs implicitly reference memory index :math:`0`.
189189

190-
.. note::
191-
In the current version of WebAssembly, at most one memory may be defined or imported in a single module,
192-
and *all* constructs implicitly reference this memory :math:`0`.
193-
This restriction may be lifted in future versions.
194-
195190

196191
.. index:: ! global, global index, global type, mutability, expression, constant, value, import
197192
pair: abstract syntax; global

document/core/text/instructions.rst

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,60 @@ Lexically, an |Toffset| or |Talign| phrase is considered a single :ref:`keyword
191191
\text{align{=}}a{:}\Tu32 &\Rightarrow& a \\ &&|&
192192
\epsilon &\Rightarrow& N \\
193193
\production{instruction} & \Tplaininstr_I &::=& \dots \\ &&|&
194-
\text{i32.load}~~m{:}\Tmemarg_4 &\Rightarrow& \I32.\LOAD~m \\ &&|&
195-
\text{i64.load}~~m{:}\Tmemarg_8 &\Rightarrow& \I64.\LOAD~m \\ &&|&
196-
\text{f32.load}~~m{:}\Tmemarg_4 &\Rightarrow& \F32.\LOAD~m \\ &&|&
197-
\text{f64.load}~~m{:}\Tmemarg_8 &\Rightarrow& \F64.\LOAD~m \\ &&|&
198-
\text{i32.load8\_s}~~m{:}\Tmemarg_1 &\Rightarrow& \I32.\LOAD\K{8\_s}~m \\ &&|&
199-
\text{i32.load8\_u}~~m{:}\Tmemarg_1 &\Rightarrow& \I32.\LOAD\K{8\_u}~m \\ &&|&
200-
\text{i32.load16\_s}~~m{:}\Tmemarg_2 &\Rightarrow& \I32.\LOAD\K{16\_s}~m \\ &&|&
201-
\text{i32.load16\_u}~~m{:}\Tmemarg_2 &\Rightarrow& \I32.\LOAD\K{16\_u}~m \\ &&|&
202-
\text{i64.load8\_s}~~m{:}\Tmemarg_1 &\Rightarrow& \I64.\LOAD\K{8\_s}~m \\ &&|&
203-
\text{i64.load8\_u}~~m{:}\Tmemarg_1 &\Rightarrow& \I64.\LOAD\K{8\_u}~m \\ &&|&
204-
\text{i64.load16\_s}~~m{:}\Tmemarg_2 &\Rightarrow& \I64.\LOAD\K{16\_s}~m \\ &&|&
205-
\text{i64.load16\_u}~~m{:}\Tmemarg_2 &\Rightarrow& \I64.\LOAD\K{16\_u}~m \\ &&|&
206-
\text{i64.load32\_s}~~m{:}\Tmemarg_4 &\Rightarrow& \I64.\LOAD\K{32\_s}~m \\ &&|&
207-
\text{i64.load32\_u}~~m{:}\Tmemarg_4 &\Rightarrow& \I64.\LOAD\K{32\_u}~m \\ &&|&
208-
\text{i32.store}~~m{:}\Tmemarg_4 &\Rightarrow& \I32.\STORE~m \\ &&|&
209-
\text{i64.store}~~m{:}\Tmemarg_8 &\Rightarrow& \I64.\STORE~m \\ &&|&
210-
\text{f32.store}~~m{:}\Tmemarg_4 &\Rightarrow& \F32.\STORE~m \\ &&|&
211-
\text{f64.store}~~m{:}\Tmemarg_8 &\Rightarrow& \F64.\STORE~m \\ &&|&
212-
\text{i32.store8}~~m{:}\Tmemarg_1 &\Rightarrow& \I32.\STORE\K{8}~m \\ &&|&
213-
\text{i32.store16}~~m{:}\Tmemarg_2 &\Rightarrow& \I32.\STORE\K{16}~m \\ &&|&
214-
\text{i64.store8}~~m{:}\Tmemarg_1 &\Rightarrow& \I64.\STORE\K{8}~m \\ &&|&
215-
\text{i64.store16}~~m{:}\Tmemarg_2 &\Rightarrow& \I64.\STORE\K{16}~m \\ &&|&
216-
\text{i64.store32}~~m{:}\Tmemarg_4 &\Rightarrow& \I64.\STORE\K{32}~m \\ &&|&
217-
\text{memory.size} &\Rightarrow& \MEMORYSIZE \\ &&|&
218-
\text{memory.grow} &\Rightarrow& \MEMORYGROW \\
194+
\text{i32.load}~~x{:}\Tmemidx~~m{:}\Tmemarg_4 &\Rightarrow& \I32.\LOAD~x~m \\ &&|&
195+
\text{i64.load}~~x{:}\Tmemidx~~m{:}\Tmemarg_8 &\Rightarrow& \I64.\LOAD~x~m \\ &&|&
196+
\text{f32.load}~~x{:}\Tmemidx~~m{:}\Tmemarg_4 &\Rightarrow& \F32.\LOAD~x~m \\ &&|&
197+
\text{f64.load}~~x{:}\Tmemidx~~m{:}\Tmemarg_8 &\Rightarrow& \F64.\LOAD~x~m \\ &&|&
198+
\text{i32.load8\_s}~~x{:}\Tmemidx~~m{:}\Tmemarg_1 &\Rightarrow& \I32.\LOAD\K{8\_s}~x~m \\ &&|&
199+
\text{i32.load8\_u}~~x{:}\Tmemidx~~m{:}\Tmemarg_1 &\Rightarrow& \I32.\LOAD\K{8\_u}~x~m \\ &&|&
200+
\text{i32.load16\_s}~~x{:}\Tmemidx~~m{:}\Tmemarg_2 &\Rightarrow& \I32.\LOAD\K{16\_s}~x~m \\ &&|&
201+
\text{i32.load16\_u}~~x{:}\Tmemidx~~m{:}\Tmemarg_2 &\Rightarrow& \I32.\LOAD\K{16\_u}~x~m \\ &&|&
202+
\text{i64.load8\_s}~~x{:}\Tmemidx~~m{:}\Tmemarg_1 &\Rightarrow& \I64.\LOAD\K{8\_s}~x~m \\ &&|&
203+
\text{i64.load8\_u}~~x{:}\Tmemidx~~m{:}\Tmemarg_1 &\Rightarrow& \I64.\LOAD\K{8\_u}~x~m \\ &&|&
204+
\text{i64.load16\_s}~~x{:}\Tmemidx~~m{:}\Tmemarg_2 &\Rightarrow& \I64.\LOAD\K{16\_s}~x~m \\ &&|&
205+
\text{i64.load16\_u}~~x{:}\Tmemidx~~m{:}\Tmemarg_2 &\Rightarrow& \I64.\LOAD\K{16\_u}~x~m \\ &&|&
206+
\text{i64.load32\_s}~~x{:}\Tmemidx~~m{:}\Tmemarg_4 &\Rightarrow& \I64.\LOAD\K{32\_s}~x~m \\ &&|&
207+
\text{i64.load32\_u}~~x{:}\Tmemidx~~m{:}\Tmemarg_4 &\Rightarrow& \I64.\LOAD\K{32\_u}~x~m \\ &&|&
208+
\text{i32.store}~~x{:}\Tmemidx~~m{:}\Tmemarg_4 &\Rightarrow& \I32.\STORE~x~m \\ &&|&
209+
\text{i64.store}~~x{:}\Tmemidx~~m{:}\Tmemarg_8 &\Rightarrow& \I64.\STORE~x~m \\ &&|&
210+
\text{f32.store}~~x{:}\Tmemidx~~m{:}\Tmemarg_4 &\Rightarrow& \F32.\STORE~x~m \\ &&|&
211+
\text{f64.store}~~x{:}\Tmemidx~~m{:}\Tmemarg_8 &\Rightarrow& \F64.\STORE~x~m \\ &&|&
212+
\text{i32.store8}~~x{:}\Tmemidx~~m{:}\Tmemarg_1 &\Rightarrow& \I32.\STORE\K{8}~x~m \\ &&|&
213+
\text{i32.store16}~~x{:}\Tmemidx~~m{:}\Tmemarg_2 &\Rightarrow& \I32.\STORE\K{16}~x~m \\ &&|&
214+
\text{i64.store8}~~x{:}\Tmemidx~~m{:}\Tmemarg_1 &\Rightarrow& \I64.\STORE\K{8}~x~m \\ &&|&
215+
\text{i64.store16}~~x{:}\Tmemidx~~m{:}\Tmemarg_2 &\Rightarrow& \I64.\STORE\K{16}~x~m \\ &&|&
216+
\text{i64.store32}~~x{:}\Tmemidx~~m{:}\Tmemarg_4 &\Rightarrow& \I64.\STORE\K{32}~x~m \\ &&|&
217+
\text{memory.size}~~x{:}\Tmemidx &\Rightarrow& \MEMORYSIZE~x \\ &&|&
218+
\text{memory.grow}~~x{:}\Tmemidx &\Rightarrow& \MEMORYGROW~x \\
219+
\end{array}
220+
221+
222+
Abbreviations
223+
.............
224+
225+
As an abbreviation, the memory index can be omitted in all memory instructions, defaulting to :math:`\T{0}`.
226+
227+
.. math::
228+
\begin{array}{llclll}
229+
\production{instruction} &
230+
\Tvaltype\text{.load}~~\Tmemarg
231+
&\equiv&
232+
\Tvaltype\text{.load}~~\text{0}~~\Tmemarg \\&
233+
\Tvaltype\text{.load}N\text{\_}\sx~~\Tmemarg
234+
&\equiv&
235+
\Tvaltype\text{.load}N\text{\_}\sx~~\text{0}~~\Tmemarg \\&
236+
\Tvaltype\text{.store}~~\Tmemarg
237+
&\equiv&
238+
\Tvaltype\text{.store}~~\text{0}~~\Tmemarg \\&
239+
\Tvaltype\text{.store}N~~\Tmemarg
240+
&\equiv&
241+
\Tvaltype\text{.store}N~~\text{0}~~\Tmemarg \\&
242+
\text{memory.size}
243+
&\equiv&
244+
\text{memory.size}~~\text{0} \\&
245+
\text{memory.grow}
246+
&\equiv&
247+
\text{memory.grow}~~\text{0} \\
219248
\end{array}
220249
221250

0 commit comments

Comments
 (0)