Debian Codegraph @

js/src/jit-test/tests/wasm/branch-hinting/complex_control_flow.js

raw
1 // Test branch hinting with nested if.
2
3 var imports = { "":{inc() { counter++ }} };
4 counter = 0;
5
6 let module = new WebAssembly.Module(wasmTextToBinary(`(module
7 (import "" "inc" (func (result i32)))
8 (func
9 (result i32)
10 (@metadata.code.branch_hint "\\00") (if (result i32)
11 (i32.const 1)
12 (then
13 (@metadata.code.branch_hint "\\00") (if (result i32)
14 (i32.const 2)
15 (then
16 (@metadata.code.branch_hint "\\00") (if (result i32)
17 (i32.const 3)
18 (then
19 (@metadata.code.branch_hint "\\00") (if (result i32)
20 (i32.const 0)
21 (then (call 0))
22 (else (i32.const 42))
23 )
24 )
25 (else (call 0))
26 )
27 )
28 (else (call 0))
29 )
30 )
31 (else (call 0))
32 )
33 )
34 (export "run" (func 1))
35 )`, 42, imports));
36
37 assertEq(counter, 0);
38 assertEq(wasmParsedBranchHints(module), true);