summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/regress/bug1856733.js
blob: 0f3e59dcfefed89b991734980f53b6194e9bad97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// |jit-test| --wasm-gc; skip-if: !wasmGcEnabled()

// Validates if imported globals are accounted for in init expressions.

var ins = wasmEvalText(`(module
    (import "" "d" (global $g0 i32))
    (global $g i32 (i32.const 1))
    (global $g2 (mut i32) (global.get $g))
    (global $g3 (mut i32) (global.get $g0))
    (func (export "test1") (result i32) global.get $g2)
    (func (export "test2") (result i32) global.get $g3)
)`, {"": {d: 2},});
assertEq(ins.exports.test1(), 1);
assertEq(ins.exports.test2(), 2);

wasmFailValidateText(`(module
    (import "" "d" (global $g0 (mut i32)))
    (global $g (mut i32)  (global.get $g0))
)`, /must reference a global immutable import/);

wasmFailValidateText(`(module
    (import "" "d" (global $g0 i32))
    (global $g i32 (global.get $g))
)`, /global\.get index out of range/);

// Other tests from the bug.

wasmValidateText(`(module
    (import "xx" "d" (global $g0 i32))
    (global $int i32 (i32.const 251))
    (global $tbl2 (ref i31) (ref.i31
      (global.get $int)
    ))
)`);
wasmValidateText(`(module
    (import "xx" "d" (global $g0 i32))
    (type $block (array (ref eq)))
    (global $len i32 (i32.const 256))
    (global $tbl (ref $block) (array.new $block
     (ref.i31
      (i32.const 0)
     )
     (global.get $len)
    ))
)`);