test_bug732665_meta.js 890 B

123456789101112131415161718192021222324252627
  1. var bottom = stackPointerInfo();
  2. var top = bottom;
  3. function nearNativeStackLimit() {
  4. function inner() {
  5. try {
  6. with ({}) { // keep things predictable -- stay in the interpreter
  7. top = stackPointerInfo();
  8. var stepsFromLimit = eval("inner()"); // Use eval to force a number of native stackframes to be created.
  9. }
  10. return stepsFromLimit + 1;
  11. } catch(e) {
  12. // It would be nice to check here that the exception is actually an
  13. // over-recursion here. But doing so would require toString()ing the
  14. // exception, which we may not have the stack space to do.
  15. return 1;
  16. }
  17. }
  18. return inner();
  19. }
  20. var nbFrames = nearNativeStackLimit();
  21. var frameSize = bottom - top;
  22. print("Max stack size:", frameSize, "bytes",
  23. "\nMaximum number of frames:", nbFrames,
  24. "\nAverage frame size:", Math.ceil(frameSize / nbFrames), "bytes");