Skip to content

Commit e923de4

Browse files
committed
update repos
spec: c90bc9686f1a90b76fb2ec782256d26323164c91
1 parent 5fd7a87 commit e923de4

14 files changed

+1178
-22
lines changed

binary.wast

+246
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@
114114
"\0b" ;; end
115115
)
116116

117+
;; Data segment memory index can have non-minimal length
118+
(module binary
119+
"\00asm" "\01\00\00\00"
120+
"\05\03\01" ;; Memory section with 1 entry
121+
"\00\00" ;; no max, minimum 0
122+
"\0b\07\01" ;; Data section with 1 entry
123+
"\80\00" ;; Memory index 0, encoded with 2 bytes
124+
"\41\00\0b\00" ;; (i32.const 0) with contents ""
125+
)
126+
127+
;; Element segment table index can have non-minimal length
128+
(module binary
129+
"\00asm" "\01\00\00\00"
130+
"\04\04\01" ;; Table section with 1 entry
131+
"\70\00\00" ;; no max, minimum 0, anyfunc
132+
"\09\07\01" ;; Element section with 1 entry
133+
"\80\00" ;; Table index 0, encoded with 2 bytes
134+
"\41\00\0b\00" ;; (i32.const 0) with no elements
135+
)
136+
117137
;; Unsigned LEB128 must not be overlong
118138
(assert_malformed
119139
(module binary
@@ -287,6 +307,80 @@
287307
"zero flag expected"
288308
)
289309

310+
;; call_indirect reserved byte should not be a "long" LEB128 zero.
311+
(assert_malformed
312+
(module binary
313+
"\00asm" "\01\00\00\00"
314+
"\01\04\01\60\00\00" ;; Type section
315+
"\03\02\01\00" ;; Function section
316+
"\04\04\01\70\00\00" ;; Table section
317+
"\0a\0a\01" ;; Code section
318+
319+
;; function 0
320+
"\07\00"
321+
"\41\00" ;; i32.const 0
322+
"\11\00" ;; call_indirect (type 0)
323+
"\80\00" ;; call_indirect reserved byte
324+
"\0b" ;; end
325+
)
326+
"zero flag expected"
327+
)
328+
329+
;; Same as above for 3, 4, and 5-byte zero encodings.
330+
(assert_malformed
331+
(module binary
332+
"\00asm" "\01\00\00\00"
333+
"\01\04\01\60\00\00" ;; Type section
334+
"\03\02\01\00" ;; Function section
335+
"\04\04\01\70\00\00" ;; Table section
336+
"\0a\0b\01" ;; Code section
337+
338+
;; function 0
339+
"\08\00"
340+
"\41\00" ;; i32.const 0
341+
"\11\00" ;; call_indirect (type 0)
342+
"\80\80\00" ;; call_indirect reserved byte
343+
"\0b" ;; end
344+
)
345+
"zero flag expected"
346+
)
347+
348+
(assert_malformed
349+
(module binary
350+
"\00asm" "\01\00\00\00"
351+
"\01\04\01\60\00\00" ;; Type section
352+
"\03\02\01\00" ;; Function section
353+
"\04\04\01\70\00\00" ;; Table section
354+
"\0a\0c\01" ;; Code section
355+
356+
;; function 0
357+
"\09\00"
358+
"\41\00" ;; i32.const 0
359+
"\11\00" ;; call_indirect (type 0)
360+
"\80\80\80\00" ;; call_indirect reserved byte
361+
"\0b" ;; end
362+
)
363+
"zero flag expected"
364+
)
365+
366+
(assert_malformed
367+
(module binary
368+
"\00asm" "\01\00\00\00"
369+
"\01\04\01\60\00\00" ;; Type section
370+
"\03\02\01\00" ;; Function section
371+
"\04\04\01\70\00\00" ;; Table section
372+
"\0a\0d\01" ;; Code section
373+
374+
;; function 0
375+
"\0a\00"
376+
"\41\00" ;; i32.const 0
377+
"\11\00" ;; call_indirect (type 0)
378+
"\80\80\80\80\00" ;; call_indirect reserved byte
379+
"\0b" ;; end
380+
)
381+
"zero flag expected"
382+
)
383+
290384
;; memory.grow reserved byte equal to zero.
291385
(assert_malformed
292386
(module binary
@@ -307,6 +401,84 @@
307401
"zero flag expected"
308402
)
309403

404+
;; memory.grow reserved byte should not be a "long" LEB128 zero.
405+
(assert_malformed
406+
(module binary
407+
"\00asm" "\01\00\00\00"
408+
"\01\04\01\60\00\00" ;; Type section
409+
"\03\02\01\00" ;; Function section
410+
"\05\03\01\00\00" ;; Memory section
411+
"\0a\0a\01" ;; Code section
412+
413+
;; function 0
414+
"\08\00"
415+
"\41\00" ;; i32.const 0
416+
"\40" ;; memory.grow
417+
"\80\00" ;; memory.grow reserved byte
418+
"\1a" ;; drop
419+
"\0b" ;; end
420+
)
421+
"zero flag expected"
422+
)
423+
424+
;; Same as above for 3, 4, and 5-byte zero encodings.
425+
(assert_malformed
426+
(module binary
427+
"\00asm" "\01\00\00\00"
428+
"\01\04\01\60\00\00" ;; Type section
429+
"\03\02\01\00" ;; Function section
430+
"\05\03\01\00\00" ;; Memory section
431+
"\0a\0b\01" ;; Code section
432+
433+
;; function 0
434+
"\09\00"
435+
"\41\00" ;; i32.const 0
436+
"\40" ;; memory.grow
437+
"\80\80\00" ;; memory.grow reserved byte
438+
"\1a" ;; drop
439+
"\0b" ;; end
440+
)
441+
"zero flag expected"
442+
)
443+
444+
(assert_malformed
445+
(module binary
446+
"\00asm" "\01\00\00\00"
447+
"\01\04\01\60\00\00" ;; Type section
448+
"\03\02\01\00" ;; Function section
449+
"\05\03\01\00\00" ;; Memory section
450+
"\0a\0c\01" ;; Code section
451+
452+
;; function 0
453+
"\0a\00"
454+
"\41\00" ;; i32.const 0
455+
"\40" ;; memory.grow
456+
"\80\80\80\00" ;; memory.grow reserved byte
457+
"\1a" ;; drop
458+
"\0b" ;; end
459+
)
460+
"zero flag expected"
461+
)
462+
463+
(assert_malformed
464+
(module binary
465+
"\00asm" "\01\00\00\00"
466+
"\01\04\01\60\00\00" ;; Type section
467+
"\03\02\01\00" ;; Function section
468+
"\05\03\01\00\00" ;; Memory section
469+
"\0a\0d\01" ;; Code section
470+
471+
;; function 0
472+
"\0b\00"
473+
"\41\00" ;; i32.const 0
474+
"\40" ;; memory.grow
475+
"\80\80\80\80\00" ;; memory.grow reserved byte
476+
"\1a" ;; drop
477+
"\0b" ;; end
478+
)
479+
"zero flag expected"
480+
)
481+
310482
;; memory.size reserved byte equal to zero.
311483
(assert_malformed
312484
(module binary
@@ -326,6 +498,80 @@
326498
"zero flag expected"
327499
)
328500

501+
;; memory.size reserved byte should not be a "long" LEB128 zero.
502+
(assert_malformed
503+
(module binary
504+
"\00asm" "\01\00\00\00"
505+
"\01\04\01\60\00\00" ;; Type section
506+
"\03\02\01\00" ;; Function section
507+
"\05\03\01\00\00" ;; Memory section
508+
"\0a\08\01" ;; Code section
509+
510+
;; function 0
511+
"\06\00"
512+
"\3f" ;; memory.size
513+
"\80\00" ;; memory.size reserved byte
514+
"\1a" ;; drop
515+
"\0b" ;; end
516+
)
517+
"zero flag expected"
518+
)
519+
520+
;; Same as above for 3, 4, and 5-byte zero encodings.
521+
(assert_malformed
522+
(module binary
523+
"\00asm" "\01\00\00\00"
524+
"\01\04\01\60\00\00" ;; Type section
525+
"\03\02\01\00" ;; Function section
526+
"\05\03\01\00\00" ;; Memory section
527+
"\0a\09\01" ;; Code section
528+
529+
;; function 0
530+
"\07\00"
531+
"\3f" ;; memory.size
532+
"\80\80\00" ;; memory.size reserved byte
533+
"\1a" ;; drop
534+
"\0b" ;; end
535+
)
536+
"zero flag expected"
537+
)
538+
539+
(assert_malformed
540+
(module binary
541+
"\00asm" "\01\00\00\00"
542+
"\01\04\01\60\00\00" ;; Type section
543+
"\03\02\01\00" ;; Function section
544+
"\05\03\01\00\00" ;; Memory section
545+
"\0a\0a\01" ;; Code section
546+
547+
;; function 0
548+
"\08\00"
549+
"\3f" ;; memory.size
550+
"\80\80\80\00" ;; memory.size reserved byte
551+
"\1a" ;; drop
552+
"\0b" ;; end
553+
)
554+
"zero flag expected"
555+
)
556+
557+
(assert_malformed
558+
(module binary
559+
"\00asm" "\01\00\00\00"
560+
"\01\04\01\60\00\00" ;; Type section
561+
"\03\02\01\00" ;; Function section
562+
"\05\03\01\00\00" ;; Memory section
563+
"\0a\0b\01" ;; Code section
564+
565+
;; function 0
566+
"\09\00"
567+
"\3f" ;; memory.size
568+
"\80\80\80\80\00" ;; memory.size reserved byte
569+
"\1a" ;; drop
570+
"\0b" ;; end
571+
)
572+
"zero flag expected"
573+
)
574+
329575
;; No more than 2^32 locals.
330576
(assert_malformed
331577
(module binary

block.wast

+11
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@
167167
(func (export "as-set_local-value") (result i32)
168168
(local i32) (set_local 0 (block (result i32) (i32.const 1))) (get_local 0)
169169
)
170+
(func (export "as-tee_local-value") (result i32)
171+
(local i32) (tee_local 0 (block (result i32) (i32.const 1)))
172+
)
173+
(global $a (mut i32) (i32.const 10))
174+
(func (export "as-set_global-value") (result i32)
175+
(set_global $a (block (result i32) (i32.const 1)))
176+
(get_global $a)
177+
)
178+
170179
(func (export "as-load-operand") (result i32)
171180
(i32.load (block (result i32) (i32.const 1)))
172181
)
@@ -277,6 +286,8 @@
277286
(assert_return (invoke "as-drop-operand"))
278287
(assert_return (invoke "as-br-value") (i32.const 1))
279288
(assert_return (invoke "as-set_local-value") (i32.const 1))
289+
(assert_return (invoke "as-tee_local-value") (i32.const 1))
290+
(assert_return (invoke "as-set_global-value") (i32.const 1))
280291
(assert_return (invoke "as-load-operand") (i32.const 1))
281292

282293
(assert_return (invoke "as-unary-operand") (i32.const 0))

br.wast

+9
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@
181181
(func (export "as-set_local-value") (result i32) (local f32)
182182
(block (result i32) (set_local 0 (br 0 (i32.const 17))) (i32.const -1))
183183
)
184+
(func (export "as-tee_local-value") (result i32) (local i32)
185+
(block (result i32) (tee_local 0 (br 0 (i32.const 1))))
186+
)
187+
(global $a (mut i32) (i32.const 10))
188+
(func (export "as-set_global-value") (result i32)
189+
(block (result i32) (set_global $a (br 0 (i32.const 1))))
190+
)
184191

185192
(memory 1)
186193
(func (export "as-load-address") (result f32)
@@ -377,6 +384,8 @@
377384
(assert_return (invoke "as-call_indirect-last") (i32.const 23))
378385

379386
(assert_return (invoke "as-set_local-value") (i32.const 17))
387+
(assert_return (invoke "as-tee_local-value") (i32.const 1))
388+
(assert_return (invoke "as-set_global-value") (i32.const 1))
380389

381390
(assert_return (invoke "as-load-address") (f32.const 1.7))
382391
(assert_return (invoke "as-loadN-address") (i64.const 30))

br_if.wast

+19
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,19 @@
205205
(i32.const -1)
206206
)
207207
)
208+
(func (export "as-tee_local-value") (param i32) (result i32)
209+
(block (result i32)
210+
(tee_local 0 (br_if 0 (i32.const 1) (get_local 0)))
211+
(return (i32.const -1))
212+
)
213+
)
214+
(global $a (mut i32) (i32.const 10))
215+
(func (export "as-set_global-value") (param i32) (result i32)
216+
(block (result i32)
217+
(set_global $a (br_if 0 (i32.const 1) (get_local 0)))
218+
(return (i32.const -1))
219+
)
220+
)
208221

209222
(func (export "as-unary-operand") (result f64)
210223
(block (result f64) (f64.neg (br_if 0 (f64.const 1.0) (i32.const 1))))
@@ -391,6 +404,12 @@
391404
(assert_return (invoke "as-set_local-value" (i32.const 0)) (i32.const -1))
392405
(assert_return (invoke "as-set_local-value" (i32.const 1)) (i32.const 17))
393406

407+
(assert_return (invoke "as-tee_local-value" (i32.const 0)) (i32.const -1))
408+
(assert_return (invoke "as-tee_local-value" (i32.const 1)) (i32.const 1))
409+
410+
(assert_return (invoke "as-set_global-value" (i32.const 0)) (i32.const -1))
411+
(assert_return (invoke "as-set_global-value" (i32.const 1)) (i32.const 1))
412+
394413
(assert_return (invoke "as-unary-operand") (f64.const 1.0))
395414
(assert_return (invoke "as-binary-left") (i32.const 1))
396415
(assert_return (invoke "as-binary-right") (i32.const 1))

br_table.wast

+16
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,20 @@
10271027
(i32.const -1)
10281028
)
10291029
)
1030+
(func (export "as-tee_local-value") (result i32)
1031+
(local i32)
1032+
(block (result i32)
1033+
(set_local 0 (br_table 0 (i32.const 1) (i32.const 1)))
1034+
(i32.const -1)
1035+
)
1036+
)
1037+
(global $a (mut i32) (i32.const 10))
1038+
(func (export "as-set_global-value") (result i32)
1039+
(block (result i32)
1040+
(set_global $a (br_table 0 (i32.const 1) (i32.const 1)))
1041+
(i32.const -1)
1042+
)
1043+
)
10301044

10311045
(memory 1)
10321046
(func (export "as-load-address") (result f32)
@@ -1342,6 +1356,8 @@
13421356
(assert_return (invoke "as-call_indirect-func") (i32.const 23))
13431357

13441358
(assert_return (invoke "as-set_local-value") (i32.const 17))
1359+
(assert_return (invoke "as-tee_local-value") (i32.const 1))
1360+
(assert_return (invoke "as-set_global-value") (i32.const 1))
13451361

13461362
(assert_return (invoke "as-load-address") (f32.const 1.7))
13471363
(assert_return (invoke "as-loadN-address") (i64.const 30))

0 commit comments

Comments
 (0)