Debian Codegraph @

js/src/jit-test/tests/wasm/regress/bug1856733.js

raw
1 // Validates if imported globals are accounted for in init expressions.
2
3 var ins = wasmEvalText(`(module
4 (import "" "d" (global $g0 i32))
5 (global $g i32 (i32.const 1))
6 (global $g2 (mut i32) (global.get $g))
7 (global $g3 (mut i32) (global.get $g0))
8 (func (export "test1") (result i32) global.get $g2)
9 (func (export "test2") (result i32) global.get $g3)
10 )`, {"": {d: 2},});
11 assertEq(ins.exports.test1(), 1);
12 assertEq(ins.exports.test2(), 2);
13
14 wasmFailValidateText(`(module
15 (import "" "d" (global $g0 (mut i32)))
16 (global $g (mut i32) (global.get $g0))
17 )`, /must reference a previously-defined immutable global/);
18
19 wasmFailValidateText(`(module
20 (import "" "d" (global $g0 i32))
21 (global $g i32 (global.get $g))
22 )`, /global\.get index out of range/);
23
24 // Other tests from the bug.
25
26 wasmValidateText(`(module
27 (import "xx" "d" (global $g0 i32))
28 (global $int i32 (i32.const 251))
29 (global $tbl2 (ref i31) (ref.i31
30 (global.get $int)
31 ))
32 )`);
33 wasmValidateText(`(module
34 (import "xx" "d" (global $g0 i32))
35 (type $block (array (ref eq)))
36 (global $len i32 (i32.const 256))
37 (global $tbl (ref $block) (array.new $block
38 (ref.i31
39 (i32.const 0)
40 )
41 (global.get $len)
42 ))
43 )`);