tor-browser

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

test_bug732665_meta.js (917B)


      1 /* globals stackPointerInfo */
      2 
      3 var stackBottom = stackPointerInfo();
      4 var stackTop = stackBottom;
      5 
      6 function nearNativeStackLimit() {
      7  function inner() {
      8    try {
      9      stackTop = stackPointerInfo();
     10      // eslint-disable-next-line no-eval
     11      var stepsFromLimit = eval("inner()"); // Use eval to force a number of native stackframes to be created.
     12      return stepsFromLimit + 1;
     13    } catch (e) {
     14      // It would be nice to check here that the exception is actually an
     15      // over-recursion here. But doing so would require toString()ing the
     16      // exception, which we may not have the stack space to do.
     17      return 1;
     18    }
     19  }
     20  return inner();
     21 }
     22 
     23 var nbFrames = nearNativeStackLimit();
     24 var frameSize = stackBottom - stackTop;
     25 print(
     26  "Max stack size:",
     27  frameSize,
     28  "bytes",
     29  "\nMaximum number of frames:",
     30  nbFrames,
     31  "\nAverage frame size:",
     32  Math.ceil(frameSize / nbFrames),
     33  "bytes"
     34 );