You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: proposals/bulk-memory-operations/Overview.md
+15-15
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ when profiling some WebAssembly benchmarks. Some examples:
19
19
20
20
## Prototype
21
21
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
23
23
to v8's [`MemMove` function](https://cs.chromium.org/chromium/src/v8/src/utils.h?l=446). I compared
24
24
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`.
25
25
@@ -39,7 +39,7 @@ This is the core loop:
39
39
```
40
40
41
41
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
43
43
hacked a version of v8 to replace any exported function called `memcpy` or `memmove` with a new function with
44
44
the following contents:
45
45
@@ -48,7 +48,7 @@ the following contents:
48
48
get_local $dst
49
49
get_local $src
50
50
get_local $size
51
-
move_memory
51
+
mem.copy
52
52
get_local $dst)
53
53
```
54
54
@@ -78,7 +78,7 @@ Here are the results on my machine (x86_64, 2.9GHz, L1 32k, L2 256k, L3 256k):
78
78
79
79
This proposal introduces 2 new instructions:
80
80
81
-
`move_memory`:
81
+
`mem.copy`:
82
82
83
83
Copy data from a source memory region to destination region;
84
84
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
91
91
- top-1: source address
92
92
- top-0: size of memory region in bytes
93
93
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.
95
95
96
96
The instruction has the signature `[i32 i32 i32] -> []`. The parameters are, in order:
97
97
@@ -106,25 +106,25 @@ immediate.
106
106
107
107
```
108
108
instr ::== ...
109
-
| move_memory
110
-
| set_memory
109
+
| mem.copy
110
+
| mem.set
111
111
```
112
112
113
113
## Validation
114
114
115
-
`move_memory`
115
+
`mem.copy`
116
116
117
117
* The memory `C.mems[0]` must be defined in the context.
118
118
* Then the instruction is valid with type `[i32 i32 i32] -> []`.
119
119
120
-
`set_memory`
120
+
`mem.set`
121
121
122
122
* The memory `C.mems[0]` must be defined in the context.
123
123
* Then the instruction is valid with type `[i32 i32 i32] -> []`.
124
124
125
125
## Execution
126
126
127
-
`move_memory`
127
+
`mem.copy`
128
128
129
129
1. Let `F` be the current frame.
130
130
1. Assert: due to validation, `F.module.memaddrs[0]` exists.
@@ -144,7 +144,7 @@ instr ::== ...
144
144
1. Let `b*` be the byte sequence `mem.data[s:n]`.
145
145
1. Replace the bytes `mem.data[d:n]` with `b*`.
146
146
147
-
`set_memory`
147
+
`mem.set`
148
148
149
149
1. Let `F` be the current frame.
150
150
1. Assert: due to validation, `F.module.memaddrs[0]` exists.
@@ -167,8 +167,8 @@ instr ::== ...
167
167
168
168
```
169
169
instr ::= ...
170
-
| 0xC5 0x00 => move_memory
171
-
| 0xC6 0x00 => set_memory
170
+
| 0xC5 0x00 => mem.copy
171
+
| 0xC6 0x00 => mem.set
172
172
```
173
173
174
174
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.
0 commit comments