Debian Codegraph @

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

raw
1
2 // A bug in Ion's alias analysis was causing the two `global.get 0`s
3 // to be GVNd together, despite the fact that the call inside the try
4 // block changes the value. In this case, this caused the returned
5 // value to be 7 rather than the correct value 5.
6
7 const wasm = wasmTextToBinary(`(module
8 (global $g (mut i32) (i32.const 0))
9 (func $f0
10 i32.const 1
11 global.set 0
12 )
13 (func $f1 (param i32) (param i32) (result i32)
14 global.get 0
15
16 i32.eqz
17 if
18 local.get 0
19 i32.const 1
20 i32.or
21 local.set 0
22 end
23
24 try
25 call $f0
26
27 global.get 0
28 i32.eqz
29 if
30 local.get 0
31 i32.const 2
32 i32.or
33 local.set 0
34 end
35 catch_all
36 i32.const 15
37 local.set 0
38 end
39 local.get 0
40 )
41 (func (export "test") (result i32)
42 i32.const 4
43 i32.const 0
44 call $f1
45 )
46 )`);
47
48 const mod = new WebAssembly.Module(wasm);
49 const ins = new WebAssembly.Instance(mod);
50 assertEq(ins.exports.test(), 5);