summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/branch-hinting/complex_control_flow.js
blob: 727a3156fb279e3158d6c3d3a06b0460007cd57a (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
// Test branch hinting with nested if.

var imports = { "":{inc() { counter++ }} };
counter = 0;

let module = new WebAssembly.Module(wasmTextToBinary(`(module
  (import "" "inc" (func (result i32)))
  (func
      (result i32)
      (@metadata.code.branch_hint "\\00") (if (result i32)
          (i32.const 1)
          (then
              (@metadata.code.branch_hint "\\00") (if (result i32)
                  (i32.const 2)
                  (then
                      (@metadata.code.branch_hint "\\00") (if (result i32)
                          (i32.const 3)
                          (then
                              (@metadata.code.branch_hint "\\00") (if (result i32)
                                  (i32.const 0)
                                  (then (call 0))
                                  (else (i32.const 42))
                              )
                          )
                          (else (call 0))
                      )
                  )
                  (else (call 0))
              )
          )
          (else (call 0))
      )
  )
  (export "run" (func 1))
)`, 42, imports));

assertEq(counter, 0);
assertEq(wasmParsedBranchHints(module), true);