Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Commit 83b7620

Browse files
committed
Rename {set,move}_memory to mem.{set,copy}
This aligns with current interest in using `mem.` prefix for memory operations, see WebAssembly/spec#627 and WebAssembly/threads#62 (comment).
1 parent 096ac5b commit 83b7620

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

proposals/bulk-memory-operations/Overview.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ when profiling some WebAssembly benchmarks. Some examples:
1919

2020
## Prototype
2121

22-
I implemented a prototype implementation of a `move_memory` instruction in v8 which just calls out
22+
I implemented a prototype implementation of a `mem.copy` instruction in v8 which just calls out
2323
to v8's [`MemMove` function](https://cs.chromium.org/chromium/src/v8/src/utils.h?l=446). I compared
2424
this to an implementation [generated by emscripten](https://gist.github.com/binji/c57dc945bba60985439ef8e5b574eee0) and currently used in the Unity demo. This implementation aligns then performs copies using `i32.load` and `i32.store`. I've also included performance achieved by unrolling this loop manually and increasing the size to `i64`.
2525

@@ -39,7 +39,7 @@ This is the core loop:
3939
```
4040

4141
The code for the benchmark can be found [here](https://gist.github.com/binji/b8e8bc0c0121235d9f1668bc447c7f8c).
42-
Note that this will not run properly without a WebAssembly implementation of `move_memory`. For my tests, I
42+
Note that this will not run properly without a WebAssembly implementation of `mem.copy`. For my tests, I
4343
hacked a version of v8 to replace any exported function called `memcpy` or `memmove` with a new function with
4444
the following contents:
4545

@@ -48,7 +48,7 @@ the following contents:
4848
get_local $dst
4949
get_local $src
5050
get_local $size
51-
move_memory
51+
mem.copy
5252
get_local $dst)
5353
```
5454

@@ -78,7 +78,7 @@ Here are the results on my machine (x86_64, 2.9GHz, L1 32k, L2 256k, L3 256k):
7878

7979
This proposal introduces 2 new instructions:
8080

81-
`move_memory`:
81+
`mem.copy`:
8282

8383
Copy data from a source memory region to destination region;
8484
these regions may overlap: the copy is performed as if the source region was
@@ -91,7 +91,7 @@ The instruction has the signature `[i32 i32 i32] -> []`. The parameters are, in
9191
- top-1: source address
9292
- top-0: size of memory region in bytes
9393

94-
`set_memory`: Set all bytes in a memory region to a given byte.
94+
`mem.set`: Set all bytes in a memory region to a given byte.
9595

9696
The instruction has the signature `[i32 i32 i32] -> []`. The parameters are, in order:
9797

@@ -106,25 +106,25 @@ immediate.
106106

107107
```
108108
instr ::== ...
109-
| move_memory
110-
| set_memory
109+
| mem.copy
110+
| mem.set
111111
```
112112

113113
## Validation
114114

115-
`move_memory`
115+
`mem.copy`
116116

117117
* The memory `C.mems[0]` must be defined in the context.
118118
* Then the instruction is valid with type `[i32 i32 i32] -> []`.
119119

120-
`set_memory`
120+
`mem.set`
121121

122122
* The memory `C.mems[0]` must be defined in the context.
123123
* Then the instruction is valid with type `[i32 i32 i32] -> []`.
124124

125125
## Execution
126126

127-
`move_memory`
127+
`mem.copy`
128128

129129
1. Let `F` be the current frame.
130130
1. Assert: due to validation, `F.module.memaddrs[0]` exists.
@@ -144,7 +144,7 @@ instr ::== ...
144144
1. Let `b*` be the byte sequence `mem.data[s:n]`.
145145
1. Replace the bytes `mem.data[d:n]` with `b*`.
146146

147-
`set_memory`
147+
`mem.set`
148148

149149
1. Let `F` be the current frame.
150150
1. Assert: due to validation, `F.module.memaddrs[0]` exists.
@@ -167,8 +167,8 @@ instr ::== ...
167167

168168
```
169169
instr ::= ...
170-
| 0xC5 0x00 => move_memory
171-
| 0xC6 0x00 => set_memory
170+
| 0xC5 0x00 => mem.copy
171+
| 0xC6 0x00 => mem.set
172172
```
173173

174174
Note that this skips `0xC0..0xC4` because those are currently proposed to be used for the
@@ -180,6 +180,6 @@ An immediate byte is included for future extensions. It currently must be zero.
180180

181181
```
182182
plaininstr_I ::= ...
183-
| `move_memory` => move_memory
184-
| `set_memory` => set_memory
183+
| `mem.copy` => mem.copy
184+
| `mem.set` => mem.set
185185
```

0 commit comments

Comments
 (0)