tor-browser

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

inlining-stack-trace.js (1974B)


      1 // |jit-test| -P wasm_lazy_tiering; -P wasm_lazy_tiering_synchronous; -P wasm_lazy_tiering_level=9; -P wasm_inlining_level=9; skip-if: wasmCompileMode() != "baseline+ion" || !getPrefValue("wasm_lazy_tiering")
      2 
      3 let {assertStackTrace} = WasmHelpers;
      4 
      5 let exports = wasmEvalText(`(module
      6  (func $throw3 (import "" "throw3"))
      7 
      8  (memory 1 1)
      9  (type $s (struct (field i32)))
     10 
     11 
     12  (func $throw2
     13    call $throw3
     14  )
     15  (func $throw1 (export "throw1")
     16    call $throw2
     17  )
     18 
     19  (func $unreachable2
     20    unreachable
     21  )
     22  (func $unreachable1 (export "unreachable1")
     23    call $unreachable2
     24  )
     25 
     26  (func $oob2
     27    i32.const -1
     28    i32.load
     29    drop
     30  )
     31  (func $oob1 (export "oob1")
     32    call $oob2
     33  )
     34 
     35  (func $null2
     36    ref.null $s
     37    struct.get $s 0
     38    drop
     39  )
     40  (func $null1 (export "null1")
     41    call $null2
     42  )
     43 
     44  (func $div2
     45    i32.const 1
     46    i32.const 0
     47    i32.div_u
     48    drop
     49  )
     50  (func $div1 (export "div1")
     51    call $div2
     52  )
     53 
     54  (func $mod2
     55    i32.const 1
     56    i32.const 0
     57    i32.rem_u
     58    drop
     59  )
     60  (func $mod1 (export "mod1")
     61    call $mod2
     62  )
     63 )`, {"": {throw3: () => { throw new Error() }}}).exports;
     64 
     65 let tests = [
     66  {func: exports.throw1, stack: ['throw3', 'throw2', 'throw1', '']},
     67  {func: exports.unreachable1, stack: ['unreachable2', 'unreachable1', '']},
     68  {func: exports.oob1, stack: ['oob2', 'oob1', '']},
     69  {func: exports.null1, stack: ['null2', 'null1', '']},
     70  {func: exports.div1, stack: ['div2', 'div1', '']},
     71  {func: exports.mod1, stack: ['mod2', 'mod1', '']},
     72 ];
     73 
     74 // Run this two times. The first time should trigger a synchronous compile,
     75 // and the second time should have inlining.
     76 for (let i = 1; i <= 2; i++) {
     77  for (let {func, stack} of tests) {
     78    if (i === 2) {
     79      assertEq(wasmFunctionTier(func), "optimized");
     80    }
     81 
     82    let success = false;
     83    try {
     84      func();
     85      success = true;
     86    } catch (e) {
     87      assertStackTrace(e, stack);
     88    }
     89 
     90    // The above should always throw an exception
     91    assertEq(success, false);
     92  }
     93 }