Skip to content

Commit 16ef0ec

Browse files
committed
[spec/interpreter/test] Land bulk instructions & reference types proposals (WebAssembly#1287)
1 parent 5ed9d56 commit 16ef0ec

File tree

8 files changed

+938
-229
lines changed

8 files changed

+938
-229
lines changed

test/core/binary.wast

Lines changed: 668 additions & 59 deletions
Large diffs are not rendered by default.

test/core/data.wast

Lines changed: 69 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@
88
(data (i32.const 1) "a" "" "bcd")
99
(data (offset (i32.const 0)))
1010
(data (offset (i32.const 0)) "" "a" "bc" "")
11-
(data 0 (i32.const 0))
12-
(data 0x0 (i32.const 1) "a" "" "bcd")
13-
(data 0x000 (offset (i32.const 0)))
14-
(data 0 (offset (i32.const 0)) "" "a" "bc" "")
15-
(data $m (i32.const 0))
16-
(data $m (i32.const 1) "a" "" "bcd")
17-
(data $m (offset (i32.const 0)))
18-
(data $m (offset (i32.const 0)) "" "a" "bc" "")
11+
(data (memory 0) (i32.const 0))
12+
(data (memory 0x0) (i32.const 1) "a" "" "bcd")
13+
(data (memory 0x000) (offset (i32.const 0)))
14+
(data (memory 0) (offset (i32.const 0)) "" "a" "bc" "")
15+
(data (memory $m) (i32.const 0))
16+
(data (memory $m) (i32.const 1) "a" "" "bcd")
17+
(data (memory $m) (offset (i32.const 0)))
18+
(data (memory $m) (offset (i32.const 0)) "" "a" "bc" "")
19+
(data $d1 (i32.const 0))
20+
(data $d2 (i32.const 1) "a" "" "bcd")
21+
(data $d3 (offset (i32.const 0)))
22+
(data $d4 (offset (i32.const 0)) "" "a" "bc" "")
23+
(data $d5 (memory 0) (i32.const 0))
24+
(data $d6 (memory 0x0) (i32.const 1) "a" "" "bcd")
25+
(data $d7 (memory 0x000) (offset (i32.const 0)))
26+
(data $d8 (memory 0) (offset (i32.const 0)) "" "a" "bc" "")
27+
(data $d9 (memory $m) (i32.const 0))
28+
(data $d10 (memory $m) (i32.const 1) "a" "" "bcd")
29+
(data $d11 (memory $m) (offset (i32.const 0)))
30+
(data $d12 (memory $m) (offset (i32.const 0)) "" "a" "bc" "")
1931
)
2032

2133
;; Basic use
@@ -158,44 +170,42 @@
158170

159171
;; Invalid bounds for data
160172

161-
(assert_unlinkable
173+
(assert_trap
162174
(module
163175
(memory 0)
164176
(data (i32.const 0) "a")
165177
)
166-
"data segment does not fit"
178+
"out of bounds memory access"
167179
)
168180

169-
(assert_unlinkable
181+
(assert_trap
170182
(module
171183
(memory 0 0)
172184
(data (i32.const 0) "a")
173185
)
174-
"data segment does not fit"
186+
"out of bounds memory access"
175187
)
176188

177-
(assert_unlinkable
189+
(assert_trap
178190
(module
179191
(memory 0 1)
180192
(data (i32.const 0) "a")
181193
)
182-
"data segment does not fit"
194+
"out of bounds memory access"
183195
)
184-
185-
(assert_unlinkable
196+
(assert_trap
186197
(module
187198
(memory 0)
188199
(data (i32.const 1))
189200
)
190-
"data segment does not fit"
201+
"out of bounds memory access"
191202
)
192-
193-
(assert_unlinkable
203+
(assert_trap
194204
(module
195205
(memory 0 1)
196206
(data (i32.const 1))
197207
)
198-
"data segment does not fit"
208+
"out of bounds memory access"
199209
)
200210

201211
;; This seems to cause a time-out on Travis.
@@ -204,77 +214,77 @@
204214
(memory 0x10000)
205215
(data (i32.const 0xffffffff) "ab")
206216
)
207-
"" ;; either out of memory or segment does not fit
217+
"" ;; either out of memory or out of bounds
208218
;)
209219

210-
(assert_unlinkable
220+
(assert_trap
211221
(module
212222
(global (import "spectest" "global_i32") i32)
213223
(memory 0)
214224
(data (global.get 0) "a")
215225
)
216-
"data segment does not fit"
226+
"out of bounds memory access"
217227
)
218228

219-
(assert_unlinkable
229+
(assert_trap
220230
(module
221231
(memory 1 2)
222232
(data (i32.const 0x1_0000) "a")
223233
)
224-
"data segment does not fit"
234+
"out of bounds memory access"
225235
)
226-
(assert_unlinkable
236+
(assert_trap
227237
(module
228238
(import "spectest" "memory" (memory 1))
229239
(data (i32.const 0x1_0000) "a")
230240
)
231-
"data segment does not fit"
241+
"out of bounds memory access"
232242
)
233243

234-
(assert_unlinkable
244+
(assert_trap
235245
(module
236246
(memory 2)
237247
(data (i32.const 0x2_0000) "a")
238248
)
239-
"data segment does not fit"
249+
"out of bounds memory access"
240250
)
241251

242-
(assert_unlinkable
252+
(assert_trap
243253
(module
244254
(memory 2 3)
245255
(data (i32.const 0x2_0000) "a")
246256
)
247-
"data segment does not fit"
257+
"out of bounds memory access"
248258
)
249259

250-
(assert_unlinkable
260+
(assert_trap
251261
(module
252262
(memory 1)
253263
(data (i32.const -1) "a")
254264
)
255-
"data segment does not fit"
265+
"out of bounds memory access"
256266
)
257-
(assert_unlinkable
267+
(assert_trap
258268
(module
259269
(import "spectest" "memory" (memory 1))
260270
(data (i32.const -1) "a")
261271
)
262-
"data segment does not fit"
272+
"out of bounds memory access"
263273
)
264274

265-
(assert_unlinkable
275+
(assert_trap
266276
(module
267277
(memory 2)
268278
(data (i32.const -100) "a")
269279
)
270-
"data segment does not fit"
280+
"out of bounds memory access"
271281
)
272-
(assert_unlinkable
282+
(assert_trap
273283
(module
274284
(import "spectest" "memory" (memory 1))
275285
(data (i32.const -100) "a")
276286
)
277-
"data segment does not fit"
287+
"out of bounds memory access"
278288
)
279289

280290
;; Data without memory
@@ -292,19 +302,30 @@
292302
"\00asm" "\01\00\00\00"
293303
"\05\03\01" ;; memory section
294304
"\00\00" ;; memory 0
295-
"\0b\06\01" ;; data section
296-
"\01\41\00\0b" ;; data segment 0 for memory 1
305+
"\0b\07\01" ;; data section
306+
"\02\01\41\00\0b" ;; active data segment 0 for memory 1
297307
"\00" ;; empty vec(byte)
298308
)
299309
"unknown memory 1"
300310
)
301311

302-
;; Data segment with memory index 1 (no memory section)
312+
;; Data segment with memory index 0 (no memory section)
303313
(assert_invalid
304314
(module binary
305315
"\00asm" "\01\00\00\00"
306316
"\0b\06\01" ;; data section
307-
"\01\41\00\0b" ;; data segment 0 for memory 1
317+
"\00\41\00\0b" ;; active data segment 0 for memory 0
318+
"\00" ;; empty vec(byte)
319+
)
320+
"unknown memory 0"
321+
)
322+
323+
;; Data segment with memory index 1 (no memory section)
324+
(assert_invalid
325+
(module binary
326+
"\00asm" "\01\00\00\00"
327+
"\0b\07\01" ;; data section
328+
"\02\01\41\00\0b" ;; active data segment 0 for memory 1
308329
"\00" ;; empty vec(byte)
309330
)
310331
"unknown memory 1"
@@ -317,7 +338,8 @@
317338
"\00asm" "\01\00\00\00"
318339
"\05\03\01" ;; memory section
319340
"\00\00" ;; memory 0
320-
"\0b\44\01" ;; data section
341+
"\0b\45\01" ;; data section
342+
"\02" ;; active segment
321343
"\01" ;; memory index
322344
"\41\00\0b" ;; offset constant expression
323345
"\3e" ;; vec(byte) length
@@ -336,7 +358,8 @@
336358
(assert_invalid
337359
(module binary
338360
"\00asm" "\01\00\00\00"
339-
"\0b\44\01" ;; data section
361+
"\0b\45\01" ;; data section
362+
"\02" ;; active segment
340363
"\01" ;; memory index
341364
"\41\00\0b" ;; offset constant expression
342365
"\3e" ;; vec(byte) length
@@ -455,4 +478,4 @@
455478
(data (global.get 0))
456479
)
457480
"constant expression required"
458-
)
481+
)

test/core/elem.wast

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -139,107 +139,106 @@
139139

140140
;; Invalid bounds for elements
141141

142-
(assert_unlinkable
142+
(assert_trap
143143
(module
144144
(table 0 funcref)
145145
(func $f)
146146
(elem (i32.const 0) $f)
147147
)
148-
"elements segment does not fit"
148+
"out of bounds table access"
149149
)
150150

151-
(assert_unlinkable
151+
(assert_trap
152152
(module
153153
(table 0 0 funcref)
154154
(func $f)
155155
(elem (i32.const 0) $f)
156156
)
157-
"elements segment does not fit"
157+
"out of bounds table access"
158158
)
159159

160-
(assert_unlinkable
160+
(assert_trap
161161
(module
162162
(table 0 1 funcref)
163163
(func $f)
164164
(elem (i32.const 0) $f)
165165
)
166-
"elements segment does not fit"
166+
"out of bounds table access"
167167
)
168168

169-
(assert_unlinkable
169+
(assert_trap
170170
(module
171171
(table 0 funcref)
172172
(elem (i32.const 1))
173173
)
174-
"elements segment does not fit"
174+
"out of bounds table access"
175175
)
176-
177-
(assert_unlinkable
176+
(assert_trap
178177
(module
179178
(table 10 funcref)
180179
(func $f)
181180
(elem (i32.const 10) $f)
182181
)
183-
"elements segment does not fit"
182+
"out of bounds table access"
184183
)
185-
(assert_unlinkable
184+
(assert_trap
186185
(module
187186
(import "spectest" "table" (table 10 funcref))
188187
(func $f)
189188
(elem (i32.const 10) $f)
190189
)
191-
"elements segment does not fit"
190+
"out of bounds table access"
192191
)
193192

194-
(assert_unlinkable
193+
(assert_trap
195194
(module
196195
(table 10 20 funcref)
197196
(func $f)
198197
(elem (i32.const 10) $f)
199198
)
200-
"elements segment does not fit"
199+
"out of bounds table access"
201200
)
202-
(assert_unlinkable
201+
(assert_trap
203202
(module
204203
(import "spectest" "table" (table 10 funcref))
205204
(func $f)
206205
(elem (i32.const 10) $f)
207206
)
208-
"elements segment does not fit"
207+
"out of bounds table access"
209208
)
210209

211-
(assert_unlinkable
210+
(assert_trap
212211
(module
213212
(table 10 funcref)
214213
(func $f)
215214
(elem (i32.const -1) $f)
216215
)
217-
"elements segment does not fit"
216+
"out of bounds table access"
218217
)
219-
(assert_unlinkable
218+
(assert_trap
220219
(module
221220
(import "spectest" "table" (table 10 funcref))
222221
(func $f)
223222
(elem (i32.const -1) $f)
224223
)
225-
"elements segment does not fit"
224+
"out of bounds table access"
226225
)
227226

228-
(assert_unlinkable
227+
(assert_trap
229228
(module
230229
(table 10 funcref)
231230
(func $f)
232231
(elem (i32.const -10) $f)
233232
)
234-
"elements segment does not fit"
233+
"out of bounds table access"
235234
)
236-
(assert_unlinkable
235+
(assert_trap
237236
(module
238237
(import "spectest" "table" (table 10 funcref))
239238
(func $f)
240239
(elem (i32.const -10) $f)
241240
)
242-
"elements segment does not fit"
241+
"out of bounds table access"
243242
)
244243

245244
;; Element without table

test/core/global.wast

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@
200200

201201
(assert_return (invoke "set-x" (i32.const 6)))
202202
(assert_return (invoke "set-y" (i64.const 7)))
203+
204+
(assert_return (invoke "set-7" (f32.const 8)))
205+
(assert_return (invoke "set-8" (f64.const 9)))
206+
207+
(assert_return (invoke "get-x") (i32.const 6))
208+
(assert_return (invoke "get-y") (i64.const 7))
209+
(assert_return (invoke "get-7") (f32.const 8))
210+
(assert_return (invoke "get-8") (f64.const 9))
211+
203212
(assert_return (invoke "set-7" (f32.const 8)))
204213
(assert_return (invoke "set-8" (f64.const 9)))
205214

0 commit comments

Comments
 (0)