Change stack recursion checks to be based on stack availability.
https://bugs.webkit.org/show_bug.cgi?id=99872.
Reviewed by Filip Pizlo and Geoffrey Garen.
Source/JavaScriptCore:
- Remove m_reentryDepth, ThreadStackType which are now obsolete.
- Replaced the reentryDepth checks with a StackBounds check.
- Added the Interpreter::StackPolicy class to compute a reasonable
stack capacity requirement given the native stack that the
interpreter is executing on at that time.
- Reserved an amount of JSStack space for the use of error handling
and enable its use (using Interpreter::ErrorHandlingMode) when
we're about to throw or report an exception.
- Interpreter::StackPolicy also allows more native stack space
to be used when in ErrorHandlingMode. This is needed in the case
of native stack overflows.
- Fixed the parser so that it throws a StackOverflowError instead of
a SyntaxError when it encounters a stack overflow.
(JSContextGroupCreate):
(JSGlobalContextCreateInGroup):
(JSC::Interpreter::ErrorHandlingMode::ErrorHandlingMode):
(JSC):
(JSC::Interpreter::ErrorHandlingMode::~ErrorHandlingMode):
(JSC::Interpreter::StackPolicy::StackPolicy):
(JSC::Interpreter::Interpreter):
(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
- interpreter/Interpreter.h:
(JSC):
(Interpreter):
(ErrorHandlingMode):
(StackPolicy):
(JSC::Interpreter::StackPolicy::requiredCapacity):
(JSC):
(JSC::JSStack::JSStack):
(JSC::JSStack::growSlowCase):
(JSC::JSStack::enableErrorStackReserve):
(JSC::JSStack::disableErrorStackReserve):
(JSStack):
(JSC::JSStack::reservationEnd):
(JSC):
(jscmain):
(JSC::::Parser):
(Parser):
(JSC::::parse):
- runtime/ExceptionHelpers.cpp:
(JSC::throwStackOverflowError):
- runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::createContextGroup):
(JSC::JSGlobalData::create):
(JSC::JSGlobalData::createLeaked):
(JSC::JSGlobalData::sharedInstance):
(JSC):
(JSGlobalData):
- runtime/StringRecursionChecker.h:
(JSC::StringRecursionChecker::performCheck):
(realMain):
Source/WebCore:
Removed the use of ThreadStackType. Enabled the reserved JSStack space
for error processing before doing work in reportException().
- bindings/js/JSDOMBinding.cpp:
(WebCore::reportException):
- bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::commonJSGlobalData):
- bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::WorkerScriptController):
LayoutTests:
Updated test baseline.
- fast/js/global-recursion-on-full-stack-expected.txt:
- fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt: