Skip to content

Commit b1f7d24

Browse files
committed
Rename current_memory/grow_memory to mem.size/mem.grow.
See WebAssembly/spec#627.
1 parent 81d2cd0 commit b1f7d24

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

WebAssembly.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ A *linear memory* is a contiguous, [byte]-addressable, readable and writable
130130
range of memory spanning from offset `0` and extending up to a *linear-memory
131131
size*, allocated as part of a WebAssembly instance. The size of a linear memory
132132
is always a multiple of the [page] size and may be increased dynamically (with
133-
the [`grow_memory`](#grow-memory) instruction) up to an optional declared
133+
the [`mem.grow`](#grow-memory) instruction) up to an optional declared
134134
*maximum length*. Linear memories are sandboxed, so they don't overlap with each
135135
other or with other parts of a WebAssembly instance, including the call stack,
136136
globals, and tables, and their bounds are enforced.
@@ -2823,17 +2823,17 @@ the name "wrap".
28232823

28242824
#### Grow Linear-Memory Size
28252825

2826-
| Mnemonic | Opcode | Immediates | Signature | Families |
2827-
| ------------- | ------ | ----------------------- | ------------------------- | -------- |
2828-
| `grow_memory` | 0x40 | `$reserved`: [varuint1] | `($delta: iPTR) : (iPTR)` | [Z] |
2826+
| Mnemonic | Opcode | Immediates | Signature | Families |
2827+
| ----------- | ------ | ----------------------- | ------------------------- | -------- |
2828+
| `mem.grow` | 0x40 | `$reserved`: [varuint1] | `($delta: iPTR) : (iPTR)` | [Z] |
28292829

2830-
The `grow_memory` instruction increases the size of the [default linear memory]
2831-
by `$delta`, in units of unsigned [pages]. If the index of any byte of the
2830+
The `mem.grow` instruction increases the size of the [default linear memory] by
2831+
`$delta`, in units of unsigned [pages]. If the index of any byte of the
28322832
referenced linear memory would be unrepresentable as unsigned in an `iPTR`, if
28332833
allocation fails due to insufficient dynamic resources, or if the linear memory
28342834
has a `maximum` length and the actual size would exceed the `maximum` length, it
28352835
returns `-1` and the linear-memory size is not increased; otherwise the
2836-
linear-memory size is increased, and `grow_memory` returns the previous
2836+
linear-memory size is increased, and `mem.grow` returns the previous
28372837
linear-memory size, also as an unsigned value in units of [pages]. Newly
28382838
allocated bytes are initialized to all zeros.
28392839

@@ -2851,21 +2851,25 @@ valid returns.
28512851

28522852
> `$reserved` is intended for future use.
28532853
2854+
> This instruction was previously named `grow_memory`.
2855+
28542856
#### Current Linear-Memory Size
28552857

2856-
| Mnemonic | Opcode | Immediates | Signature | Families |
2857-
| ---------------- | ------ | ----------------------- | ---------------------- | -------- |
2858-
| `current_memory` | 0x3f | `$reserved`: [varuint1] | `() : (iPTR)` | [Z] |
2858+
| Mnemonic | Opcode | Immediates | Signature | Families |
2859+
| ----------- | ------ | ----------------------- | ---------------------- | -------- |
2860+
| `mem.size` | 0x3f | `$reserved`: [varuint1] | `() : (iPTR)` | [Z] |
28592861

2860-
The `current_memory` instruction returns the size of the [default linear
2861-
memory], as an unsigned value in units of [pages].
2862+
The `mem.size` instruction returns the size of the [default linear memory], as
2863+
an unsigned value in units of [pages].
28622864

28632865
**Validation**:
28642866
- [Linear-memory size validation](#linear-memory-size-validation) is required.
28652867
- `$reserved` is required to be `0`.
28662868

28672869
> `$reserved` is intended for future use.
28682870
2871+
> This instruction was previously named `current_memory`.
2872+
28692873

28702874
Instantiation
28712875
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)