tor-browser

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

compiler-frame-depth.js (643B)


      1 // Ensures that the postorder allows us to have very deep expression trees.
      2 
      3 var expr = '(local.get 0)';
      4 
      5 for (var i = 1000; i --> 0; ) {
      6    expr = `(f32.neg ${expr})`;
      7 }
      8 
      9 var code = `(module
     10 (func
     11  (param f32)
     12  (result f32)
     13  ${expr}
     14 )
     15 (export "run" (func 0))
     16 )`;
     17 
     18 try {
     19    wasmFullPass(code, Math.fround(13.37), {}, 13.37);
     20 } catch (e) {
     21    // Some configurations, like e.g. ASAN, will fail these tests because its
     22    // stack frames are much bigger than usual ones and the parser will bail
     23    // out during its recursive descent.
     24    // Ignore those errors specifically.
     25    assertEq(e.message.includes('out of memory'), true);
     26 }