tor-browser

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

testJumpRange.js (897B)


      1 load(libdir + "asm.js");
      2 load(libdir + "asserts.js");
      3 
      4 var fatFunc = USE_ASM + '\n';
      5 // Recursion depth reduced to allow PBL with debug build (hence larger
      6 // frames) to work.
      7 for (var i = 0; i < 75; i++)
      8    fatFunc += "function f" + i + "() { return ((f" + (i+1) + "()|0)+1)|0 }\n";
      9 fatFunc += "function f75() { return 42 }\n";
     10 fatFunc += "return f0";
     11 
     12 for (let threshold of [0, 50, 100, 5000, -1]) {
     13    setJitCompilerOption("jump-threshold", threshold);
     14 
     15    assertEq(asmCompile(
     16        USE_ASM + `
     17            function h() { return ((g()|0)+2)|0 }
     18            function g() { return ((f()|0)+1)|0 }
     19            function f() { return 42 }
     20            return h
     21        `)()(), 45);
     22 
     23    enableGeckoProfiling();
     24    asmLink(asmCompile(USE_ASM + 'function f() {} function g() { f() } function h() { g() } return h'))();
     25    disableGeckoProfiling();
     26 
     27    assertEq(asmCompile(fatFunc)()(), 117);
     28 }