summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/exceptions/ion-loop-phi.js
blob: bdf49ca97b00548039ff15b1a1c982c0c7e18fb3 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Finishing a loop will try to minimize phi nodes. We must properly replace
// phi nodes that escape a loop via catch block control flow patches.
wasmEvalText(`(module
  (func)
  (func (local i32)
    try
      loop
        call 0
        i32.const 0
        br_if 0
      end
    catch_all
    end
  )
)`);

// Same as above, but ensure that we check every enclosing try block for
// control flow patches, as delegate can tunnel outwards.
wasmEvalText(`(module
  (func)
  (func (local i32)
    try
      try
        loop
          call 0
          i32.const 0
          br_if 0
        end
      delegate 0
    catch_all
    end
  )
)`);

// Ensure that we check the body block as delegate can target that.
wasmEvalText(`(module
  (func)
  (func (local i32)
    loop
      try
        (; catch patch to try block is added ;)
        call 0
        (; br_if ensures we will need a backedge ;)
        i32.const 0
        br_if 1
      (; catch patches are relocated to body ;)
      delegate 1
    (; finishing loop backedge must fixup patches stored in body ;)
    end

    (; add another catch patch to body so that the landing pad will be a
       join point between two edges, forcing a use of the dangling phi,
       hitting the debug assertion
    ;)
    try
      call 0
    delegate 0
  )
)`);