tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ion-loop-phi.js (1304B)


      1 // Finishing a loop will try to minimize phi nodes. We must properly replace
      2 // phi nodes that escape a loop via catch block control flow patches.
      3 wasmEvalText(`(module
      4  (func)
      5  (func (local i32)
      6    try
      7      loop
      8        call 0
      9        i32.const 0
     10        br_if 0
     11      end
     12    catch_all
     13    end
     14  )
     15 )`);
     16 
     17 // Same as above, but ensure that we check every enclosing try block for
     18 // control flow patches, as delegate can tunnel outwards.
     19 wasmEvalText(`(module
     20  (func)
     21  (func (local i32)
     22    try
     23      try
     24        loop
     25          call 0
     26          i32.const 0
     27          br_if 0
     28        end
     29      delegate 0
     30    catch_all
     31    end
     32  )
     33 )`);
     34 
     35 // Ensure that we check the body block as delegate can target that.
     36 wasmEvalText(`(module
     37  (func)
     38  (func (local i32)
     39    loop
     40      try
     41        (; catch patch to try block is added ;)
     42        call 0
     43        (; br_if ensures we will need a backedge ;)
     44        i32.const 0
     45        br_if 1
     46      (; catch patches are relocated to body ;)
     47      delegate 1
     48    (; finishing loop backedge must fixup patches stored in body ;)
     49    end
     50 
     51    (; add another catch patch to body so that the landing pad will be a
     52       join point between two edges, forcing a use of the dangling phi,
     53       hitting the debug assertion
     54    ;)
     55    try
     56      call 0
     57    delegate 0
     58  )
     59 )`);