Skip to content

Commit 7ed8f19

Browse files
authored
Add a .wast test to exercise v128 and GC const expression evaluation (#13285)
Not all paths related to both GC and v128 were covered by our existing tests.
1 parent 689eae7 commit 7ed8f19

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
;;! gc = true
2+
;;! simd = true
3+
4+
;; Tests for GC const-expression evaluation with SIMD types.
5+
6+
;; Simple v128.const global
7+
(module
8+
(global $g v128 (v128.const i32x4 1 2 3 4))
9+
10+
(func (export "v128-simple") (result v128)
11+
(global.get $g)
12+
)
13+
)
14+
(assert_return (invoke "v128-simple") (v128.const i32x4 1 2 3 4))
15+
16+
;; struct.new_default with a v128 field
17+
(module
18+
(type $s (struct (field v128)))
19+
20+
(global $g anyref (struct.new_default $s))
21+
22+
(func (export "v128-struct-default") (result v128)
23+
(struct.get $s 0 (ref.cast (ref $s) (global.get $g)))
24+
)
25+
)
26+
(assert_return (invoke "v128-struct-default") (v128.const i32x4 0 0 0 0))
27+
28+
;; array.new_fixed with v128.const elements
29+
(module
30+
(type $arr (array v128))
31+
32+
(global $g anyref (array.new_fixed $arr 2
33+
(v128.const i32x4 1 2 3 4)
34+
(v128.const i32x4 5 6 7 8)
35+
))
36+
37+
(func (export "v128-array-len") (result i32)
38+
(array.len (ref.cast (ref $arr) (global.get $g)))
39+
)
40+
(func (export "v128-array-elem0") (result v128)
41+
(array.get $arr (ref.cast (ref $arr) (global.get $g)) (i32.const 0))
42+
)
43+
(func (export "v128-array-elem1") (result v128)
44+
(array.get $arr (ref.cast (ref $arr) (global.get $g)) (i32.const 1))
45+
)
46+
)
47+
(assert_return (invoke "v128-array-len") (i32.const 2))
48+
(assert_return (invoke "v128-array-elem0") (v128.const i32x4 1 2 3 4))
49+
(assert_return (invoke "v128-array-elem1") (v128.const i32x4 5 6 7 8))

0 commit comments

Comments
 (0)