Introducing VMEntryScope to update the VM stack limit.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Nov 2013 05:29:42 +0000 (05:29 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Nov 2013 05:29:42 +0000 (05:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124634.

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

1. Introduced USE(SEPARATE_C_AND_JS_STACK) (defined in Platform.h).
   Currently, it is hardcoded to use separate C and JS stacks. Once we
   switch to using the C stack for JS frames, we'll need to fix this to
   only be enabled when ENABLE(LLINT_C_LOOP).

2. Stack limits are now tracked in the VM.

   Logically, there are 2 stack limits:
   a. m_stackLimit for the native C stack, and
   b. m_jsStackLimit for the JS stack.

   If USE(SEPARATE_C_AND_JS_STACK), then the 2 limits are the same
   value, and are implemented as 2 fields in a union.

3. The VM native stackLimit is set as follows:
   a. Initially, the VM sets it to the limit of the stack of the thread that
      instantiated the VM. This allows the parser and bytecode generator to
      run before we enter the VM to execute JS code.

   b. Upon entry into the VM to execute JS code (via one of the
      Interpreter::execute...() functions), we instantiate a VMEntryScope
      that sets the VM's stackLimit to the limit of the current thread's
      stack. The VMEntryScope will automatically restore the previous
      entryScope and stack limit upon destruction.

   If USE(SEPARATE_C_AND_JS_STACK), the JSStack's methods will set the VM's
   jsStackLimit whenever it grows or shrinks.

4. The VM now provides a isSafeToRecurse() function that compares the
   current stack pointer against its native stackLimit. This subsumes and
   obsoletes the VMStackBounds class.

5. The VMEntryScope class also subsumes DynamicGlobalObjectScope for
   tracking the JSGlobalObject that we last entered the VM with.

6. Renamed dynamicGlobalObject() to vmEntryGlobalObject() since that is
   the value that the function retrieves.

7. Changed JIT and LLINT code to do stack checks against the jsStackLimit
   in the VM class instead of the JSStack.

* API/JSBase.cpp:
(JSEvaluateScript):
(JSCheckScriptSyntax):
* API/JSContextRef.cpp:
(JSGlobalContextRetain):
(JSGlobalContextRelease):
* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::emitNode):
(JSC::BytecodeGenerator::emitNodeInConditionContext):
* debugger/Debugger.cpp:
(JSC::Debugger::detach):
(JSC::Debugger::recompileAllJSFunctions):
(JSC::Debugger::pauseIfNeeded):
* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::vmEntryGlobalObject):
* debugger/DebuggerCallFrame.h:
* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::compileFunction):
* dfg/DFGOSREntry.cpp:
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLOSREntry.cpp:
* heap/Heap.cpp:
(JSC::Heap::lastChanceToFinalize):
(JSC::Heap::deleteAllCompiledCode):
* interpreter/CachedCall.h:
(JSC::CachedCall::CachedCall):
* interpreter/CallFrame.cpp:
(JSC::CallFrame::vmEntryGlobalObject):
* interpreter/CallFrame.h:
* interpreter/Interpreter.cpp:
(JSC::unwindCallFrame):
(JSC::Interpreter::unwind):
(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::debug):
* interpreter/JSStack.cpp:
(JSC::JSStack::JSStack):
(JSC::JSStack::growSlowCase):
* interpreter/JSStack.h:
* interpreter/JSStackInlines.h:
(JSC::JSStack::shrink):
(JSC::JSStack::grow):
- Moved these inlined functions here from JSStack.h. It reduces some
  #include dependencies of JSSTack.h which had previously resulted
  in some EWS bots' unhappiness with this patch.
(JSC::JSStack::updateStackLimit):
* jit/JIT.cpp:
(JSC::JIT::privateCompile):
* jit/JITCall.cpp:
(JSC::JIT::compileLoadVarargs):
* jit/JITCall32_64.cpp:
(JSC::JIT::compileLoadVarargs):
* jit/JITOperations.cpp:
* llint/LLIntSlowPaths.cpp:
* llint/LowLevelInterpreter.asm:
* parser/Parser.cpp:
(JSC::::Parser):
* parser/Parser.h:
(JSC::Parser::canRecurse):
* runtime/CommonSlowPaths.h:
* runtime/Completion.cpp:
(JSC::evaluate):
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/StringRecursionChecker.h:
(JSC::StringRecursionChecker::performCheck):
* runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::releaseExecutableMemory):
(JSC::VM::throwException):
* runtime/VM.h:
(JSC::VM::addressOfJSStackLimit):
(JSC::VM::jsStackLimit):
(JSC::VM::setJSStackLimit):
(JSC::VM::stackLimit):
(JSC::VM::setStackLimit):
(JSC::VM::isSafeToRecurse):
* runtime/VMEntryScope.cpp: Added.
(JSC::VMEntryScope::VMEntryScope):
(JSC::VMEntryScope::~VMEntryScope):
(JSC::VMEntryScope::requiredCapacity):
* runtime/VMEntryScope.h: Added.
(JSC::VMEntryScope::globalObject):
* runtime/VMStackBounds.h: Removed.

Source/WebCore:

No new tests.

Renamed dynamicGlobalObject() to vmEntryGlobalObject().
Replaced uses of DynamicGlobalObjectScope with VMEntryScope.

* ForwardingHeaders/runtime/VMEntryScope.h: Added.
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* bindings/js/JSCryptoAlgorithmBuilder.cpp:
(WebCore::JSCryptoAlgorithmBuilder::add):
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::create):
* bindings/js/JSDOMBinding.cpp:
(WebCore::firstDOMWindow):
* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JavaScriptCallFrame.h:
(WebCore::JavaScriptCallFrame::vmEntryGlobalObject):
* bindings/js/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::recompileAllJSFunctions):
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::evaluateBreakpointAction):
(WebCore::ScriptDebugServer::handlePause):
* bindings/js/WorkerScriptDebugServer.cpp:
(WebCore::WorkerScriptDebugServer::recompileAllJSFunctions):
* bindings/objc/WebScriptObject.mm:
(WebCore::addExceptionToConsole):
* bridge/c/c_utility.cpp:
(JSC::Bindings::convertValueToNPVariant):
* bridge/objc/objc_instance.mm:
(ObjcInstance::moveGlobalExceptionToExecState):
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::convertValueToObjcObject):
* bridge/objc/objc_utility.mm:
(JSC::Bindings::convertValueToObjcValue):

Source/WebKit/mac:

* WebView/WebScriptDebugger.mm:
(WebScriptDebugger::sourceParsed):

Source/WTF:

* wtf/Platform.h:
* wtf/StackBounds.h:
(WTF::StackBounds::StackBounds):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159605 268f45cc-cd09-0410-ab3c-d52691b4dbfc

66 files changed:
Source/JavaScriptCore/API/JSBase.cpp
Source/JavaScriptCore/API/JSContextRef.cpp
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/debugger/Debugger.cpp
Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
Source/JavaScriptCore/debugger/DebuggerCallFrame.h
Source/JavaScriptCore/dfg/DFGJITCompiler.cpp
Source/JavaScriptCore/dfg/DFGOSREntry.cpp
Source/JavaScriptCore/ftl/FTLLink.cpp
Source/JavaScriptCore/ftl/FTLOSREntry.cpp
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/interpreter/CachedCall.h
Source/JavaScriptCore/interpreter/CallFrame.cpp
Source/JavaScriptCore/interpreter/CallFrame.h
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/interpreter/JSStack.cpp
Source/JavaScriptCore/interpreter/JSStack.h
Source/JavaScriptCore/interpreter/JSStackInlines.h
Source/JavaScriptCore/jit/JIT.cpp
Source/JavaScriptCore/jit/JITCall.cpp
Source/JavaScriptCore/jit/JITCall32_64.cpp
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/Parser.h
Source/JavaScriptCore/runtime/CommonSlowPaths.h
Source/JavaScriptCore/runtime/Completion.cpp
Source/JavaScriptCore/runtime/FunctionConstructor.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/runtime/StringRecursionChecker.h
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/JavaScriptCore/runtime/VMEntryScope.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/VMEntryScope.h [moved from Source/JavaScriptCore/runtime/VMStackBounds.h with 54% similarity]
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WTF/wtf/StackBounds.h
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/runtime/VMEntryScope.h [new file with mode: 0644]
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp
Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSErrorHandler.cpp
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/JavaScriptCallFrame.h
Source/WebCore/bindings/js/PageScriptDebugServer.cpp
Source/WebCore/bindings/js/ScriptDebugServer.cpp
Source/WebCore/bindings/js/WorkerScriptDebugServer.cpp
Source/WebCore/bindings/objc/WebScriptObject.mm
Source/WebCore/bridge/c/c_utility.cpp
Source/WebCore/bridge/objc/objc_instance.mm
Source/WebCore/bridge/objc/objc_runtime.mm
Source/WebCore/bridge/objc/objc_utility.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebScriptDebugger.mm

index 4a77da2..c0930a4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -54,7 +54,7 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
     JSObject* jsThisObject = toJS(thisObject);
 
     // evaluate sets "this" to the global object if it is NULL
-    JSGlobalObject* globalObject = exec->dynamicGlobalObject();
+    JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
     SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
 
     JSValue evaluationException;
@@ -85,7 +85,7 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc
     SourceCode source = makeSource(script->string(), sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
     
     JSValue syntaxException;
-    bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException);
+    bool isValidSyntax = checkSyntax(exec->vmEntryGlobalObject()->globalExec(), source, &syntaxException);
 
     if (!isValidSyntax) {
         if (exception)
index 2ed8241..f0a435c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -155,7 +155,7 @@ JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
     APIEntryShim entryShim(exec);
 
     VM& vm = exec->vm();
-    gcProtect(exec->dynamicGlobalObject());
+    gcProtect(exec->vmEntryGlobalObject());
     vm.ref();
     return ctx;
 }
@@ -170,7 +170,7 @@ void JSGlobalContextRelease(JSGlobalContextRef ctx)
         VM& vm = exec->vm();
         savedIdentifierTable = wtfThreadData().setCurrentIdentifierTable(vm.identifierTable);
 
-        bool protectCountIsZero = Heap::heap(exec->dynamicGlobalObject())->unprotect(exec->dynamicGlobalObject());
+        bool protectCountIsZero = Heap::heap(exec->vmEntryGlobalObject())->unprotect(exec->vmEntryGlobalObject());
         if (protectCountIsZero)
             vm.heap.reportAbandonedObjectGraph();
         vm.deref();
index e622a00..5b2cdfe 100644 (file)
@@ -422,6 +422,7 @@ set(JavaScriptCore_SOURCES
     runtime/TypedArrayController.cpp
     runtime/TypedArrayType.cpp
     runtime/VM.cpp
+    runtime/VMEntryScope.cpp
     runtime/Watchdog.cpp
     runtime/WatchdogNone.cpp
     runtime/WeakMapConstructor.cpp
index 2fbccb4..7d0fb5a 100644 (file)
@@ -1,3 +1,148 @@
+2013-11-20  Mark Lam  <mark.lam@apple.com>
+
+        Introducing VMEntryScope to update the VM stack limit.
+        https://bugs.webkit.org/show_bug.cgi?id=124634.
+
+        Reviewed by Geoffrey Garen.
+
+        1. Introduced USE(SEPARATE_C_AND_JS_STACK) (defined in Platform.h).
+           Currently, it is hardcoded to use separate C and JS stacks. Once we
+           switch to using the C stack for JS frames, we'll need to fix this to
+           only be enabled when ENABLE(LLINT_C_LOOP).
+
+        2. Stack limits are now tracked in the VM.
+
+           Logically, there are 2 stack limits:
+           a. m_stackLimit for the native C stack, and
+           b. m_jsStackLimit for the JS stack.
+
+           If USE(SEPARATE_C_AND_JS_STACK), then the 2 limits are the same
+           value, and are implemented as 2 fields in a union.
+
+        3. The VM native stackLimit is set as follows:
+           a. Initially, the VM sets it to the limit of the stack of the thread that
+              instantiated the VM. This allows the parser and bytecode generator to
+              run before we enter the VM to execute JS code.
+
+           b. Upon entry into the VM to execute JS code (via one of the
+              Interpreter::execute...() functions), we instantiate a VMEntryScope
+              that sets the VM's stackLimit to the limit of the current thread's
+              stack. The VMEntryScope will automatically restore the previous
+              entryScope and stack limit upon destruction.
+
+           If USE(SEPARATE_C_AND_JS_STACK), the JSStack's methods will set the VM's
+           jsStackLimit whenever it grows or shrinks.
+
+        4. The VM now provides a isSafeToRecurse() function that compares the
+           current stack pointer against its native stackLimit. This subsumes and
+           obsoletes the VMStackBounds class.
+
+        5. The VMEntryScope class also subsumes DynamicGlobalObjectScope for
+           tracking the JSGlobalObject that we last entered the VM with.
+
+        6. Renamed dynamicGlobalObject() to vmEntryGlobalObject() since that is
+           the value that the function retrieves.
+
+        7. Changed JIT and LLINT code to do stack checks against the jsStackLimit
+           in the VM class instead of the JSStack.
+
+        * API/JSBase.cpp:
+        (JSEvaluateScript):
+        (JSCheckScriptSyntax):
+        * API/JSContextRef.cpp:
+        (JSGlobalContextRetain):
+        (JSGlobalContextRelease):
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::BytecodeGenerator):
+        * bytecompiler/BytecodeGenerator.h:
+        (JSC::BytecodeGenerator::emitNode):
+        (JSC::BytecodeGenerator::emitNodeInConditionContext):
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::detach):
+        (JSC::Debugger::recompileAllJSFunctions):
+        (JSC::Debugger::pauseIfNeeded):
+        * debugger/DebuggerCallFrame.cpp:
+        (JSC::DebuggerCallFrame::vmEntryGlobalObject):
+        * debugger/DebuggerCallFrame.h:
+        * dfg/DFGJITCompiler.cpp:
+        (JSC::DFG::JITCompiler::compileFunction):
+        * dfg/DFGOSREntry.cpp:
+        * ftl/FTLLink.cpp:
+        (JSC::FTL::link):
+        * ftl/FTLOSREntry.cpp:
+        * heap/Heap.cpp:
+        (JSC::Heap::lastChanceToFinalize):
+        (JSC::Heap::deleteAllCompiledCode):
+        * interpreter/CachedCall.h:
+        (JSC::CachedCall::CachedCall):
+        * interpreter/CallFrame.cpp:
+        (JSC::CallFrame::vmEntryGlobalObject):
+        * interpreter/CallFrame.h:
+        * interpreter/Interpreter.cpp:
+        (JSC::unwindCallFrame):
+        (JSC::Interpreter::unwind):
+        (JSC::Interpreter::execute):
+        (JSC::Interpreter::executeCall):
+        (JSC::Interpreter::executeConstruct):
+        (JSC::Interpreter::prepareForRepeatCall):
+        (JSC::Interpreter::debug):
+        * interpreter/JSStack.cpp:
+        (JSC::JSStack::JSStack):
+        (JSC::JSStack::growSlowCase):
+        * interpreter/JSStack.h:
+        * interpreter/JSStackInlines.h:
+        (JSC::JSStack::shrink):
+        (JSC::JSStack::grow):
+        - Moved these inlined functions here from JSStack.h. It reduces some
+          #include dependencies of JSSTack.h which had previously resulted
+          in some EWS bots' unhappiness with this patch.
+        (JSC::JSStack::updateStackLimit):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompile):
+        * jit/JITCall.cpp:
+        (JSC::JIT::compileLoadVarargs):
+        * jit/JITCall32_64.cpp:
+        (JSC::JIT::compileLoadVarargs):
+        * jit/JITOperations.cpp:
+        * llint/LLIntSlowPaths.cpp:
+        * llint/LowLevelInterpreter.asm:
+        * parser/Parser.cpp:
+        (JSC::::Parser):
+        * parser/Parser.h:
+        (JSC::Parser::canRecurse):
+        * runtime/CommonSlowPaths.h:
+        * runtime/Completion.cpp:
+        (JSC::evaluate):
+        * runtime/FunctionConstructor.cpp:
+        (JSC::constructFunctionSkippingEvalEnabledCheck):
+        * runtime/JSGlobalObject.cpp:
+        * runtime/JSGlobalObject.h:
+        * runtime/StringRecursionChecker.h:
+        (JSC::StringRecursionChecker::performCheck):
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        (JSC::VM::releaseExecutableMemory):
+        (JSC::VM::throwException):
+        * runtime/VM.h:
+        (JSC::VM::addressOfJSStackLimit):
+        (JSC::VM::jsStackLimit):
+        (JSC::VM::setJSStackLimit):
+        (JSC::VM::stackLimit):
+        (JSC::VM::setStackLimit):
+        (JSC::VM::isSafeToRecurse):
+        * runtime/VMEntryScope.cpp: Added.
+        (JSC::VMEntryScope::VMEntryScope):
+        (JSC::VMEntryScope::~VMEntryScope):
+        (JSC::VMEntryScope::requiredCapacity):
+        * runtime/VMEntryScope.h: Added.
+        (JSC::VMEntryScope::globalObject):
+        * runtime/VMStackBounds.h: Removed.
+
 2013-11-20  Michael Saboff  <msaboff@apple.com>
 
         [Win] JavaScript JIT crash (with DFG enabled).
index b142b46..6123764 100644 (file)
@@ -913,6 +913,8 @@ javascriptcore_sources += \
        Source/JavaScriptCore/runtime/JSExportMacros.h \
        Source/JavaScriptCore/runtime/VM.cpp \
        Source/JavaScriptCore/runtime/VM.h \
+       Source/JavaScriptCore/runtime/VMEntryScope.cpp \
+       Source/JavaScriptCore/runtime/VMEntryScope.h \
        Source/JavaScriptCore/runtime/JSFunctionInlines.h \
        Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h \
        Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.h \
@@ -1127,7 +1129,6 @@ javascriptcore_sources += \
        Source/JavaScriptCore/runtime/Uint32Array.h \
        Source/JavaScriptCore/runtime/Uint8Array.h \
        Source/JavaScriptCore/runtime/Uint8ClampedArray.h \
-       Source/JavaScriptCore/runtime/VMStackBounds.h \
        Source/JavaScriptCore/runtime/Watchdog.cpp \
        Source/JavaScriptCore/runtime/Watchdog.h \
        Source/JavaScriptCore/runtime/WatchdogNone.cpp \
index 7037cf2..9f8c974 100644 (file)
     <ClCompile Include="..\runtime\TypedArrayController.cpp" />
     <ClCompile Include="..\runtime\TypedArrayType.cpp" />
     <ClCompile Include="..\runtime\VM.cpp" />
+    <ClCompile Include="..\runtime\VMEntryScope.cpp" />
     <ClCompile Include="..\runtime\Watchdog.cpp" />
     <ClCompile Include="..\runtime\WatchdogNone.cpp" />
     <ClCompile Include="..\runtime\WeakMapConstructor.cpp" />
     <ClInclude Include="..\runtime\Uint32Array.h" />
     <ClInclude Include="..\runtime\Uint8Array.h" />
     <ClInclude Include="..\runtime\VM.h" />
+    <ClInclude Include="..\runtime\VMEntryScope.h" />
     <ClInclude Include="..\runtime\Watchdog.h" />
     <ClInclude Include="..\runtime\WeakGCMap.h" />
     <ClInclude Include="..\runtime\WeakMapConstructor.h" />
index 337fab9..80132f2 100644 (file)
     <ClCompile Include="..\runtime\VM.cpp">
       <Filter>runtime</Filter>
     </ClCompile>
+    <ClCompile Include="..\runtime\VMEntryScope.cpp">
+      <Filter>runtime</Filter>
+    </ClCompile>
     <ClCompile Include="..\parser\SourceCode.cpp">
       <Filter>parser</Filter>
     </ClCompile>
     <ClInclude Include="..\runtime\VM.h">
       <Filter>runtime</Filter>
     </ClInclude>
+    <ClInclude Include="..\runtime\VMEntryScope.h">
+      <Filter>runtime</Filter>
+    </ClInclude>
     <ClInclude Include="..\assembler\MacroAssemblerX86Common.cpp">
       <Filter>assembler</Filter>
     </ClInclude>
index c0cdd49..a3fb0da 100644 (file)
                FE20CE9E15F04A9500DF3430 /* LLIntCLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */; };
                FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4A331E15BD2E07006F54F3 /* VMInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               FE6617281774E03500495B00 /* VMStackBounds.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6617271774E03500495B00 /* VMStackBounds.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */; };
+               FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861E182B7A0400F6D851 /* Breakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FE20CE9C15F04A9500DF3430 /* LLIntCLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntCLoop.h; path = llint/LLIntCLoop.h; sourceTree = "<group>"; };
                FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMInspector.cpp; sourceTree = "<group>"; };
                FE4A331E15BD2E07006F54F3 /* VMInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInspector.h; sourceTree = "<group>"; };
-               FE6617271774E03500495B00 /* VMStackBounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMStackBounds.h; sourceTree = "<group>"; };
+               FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMEntryScope.cpp; sourceTree = "<group>"; };
+               FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMEntryScope.h; sourceTree = "<group>"; };
                FEA0861E182B7A0400F6D851 /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpoint.h; sourceTree = "<group>"; };
                FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebuggerPrimitives.h; sourceTree = "<group>"; };
                FED287B115EC9A5700DA8161 /* LLIntOpcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntOpcode.h; path = llint/LLIntOpcode.h; sourceTree = "<group>"; };
                7EF6E0BB0EB7A1EC0079AFAF /* runtime */ = {
                        isa = PBXGroup;
                        children = (
+                               FE5932A5183C5A2600A1ECCC /* VMEntryScope.cpp */,
+                               FE5932A6183C5A2600A1ECCC /* VMEntryScope.h */,
                                BCF605110E203EF800B9A64D /* ArgList.cpp */,
                                BCF605120E203EF800B9A64D /* ArgList.h */,
                                BC257DE50E1F51C50016B6C9 /* Arguments.cpp */,
                                A7A8AF3117ADB5F3005AB174 /* Uint8ClampedArray.h */,
                                E18E3A570DF9278C00D90B34 /* VM.cpp */,
                                E18E3A560DF9278C00D90B34 /* VM.h */,
-                               FE6617271774E03500495B00 /* VMStackBounds.h */,
                                FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */,
                                FED94F2C171E3E2300BE77A4 /* Watchdog.h */,
                                FED94F2D171E3E2300BE77A4 /* WatchdogMac.cpp */,
                                86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
                                86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
                                65C0285D1717966800351E35 /* ARMv7DOpcode.h in Headers */,
+                               FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */,
                                0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */,
                                A7BFF3C0179868940002F462 /* DFGFiltrationResult.h in Headers */,
                                C2FCAE1117A9C24E0034C735 /* BytecodeBasicBlock.h in Headers */,
                                0F426A491460CBB700131F8F /* VirtualRegister.h in Headers */,
                                BC18C4200E16F5CD00B34460 /* VM.h in Headers */,
                                FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */,
-                               FE6617281774E03500495B00 /* VMStackBounds.h in Headers */,
                                FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */,
                                0F919D2615853CE3004A4E7D /* Watchpoint.h in Headers */,
                                142E313C134FF0A600AFADB5 /* Weak.h in Headers */,
                                14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */,
                                147F39D7107EC37600427A48 /* JSVariableObject.cpp in Sources */,
                                86E3C61C167BABEE006D760A /* JSVirtualMachine.mm in Sources */,
+                               FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */,
                                A7CA3AE717DA41AE006538AF /* JSWeakMap.cpp in Sources */,
                                A7482B9411671147003B0712 /* JSWeakObjectMapRefPrivate.cpp in Sources */,
                                1442566115EDE98D0066A49B /* JSWithScope.cpp in Sources */,
index cf9e7f3..da80f78 100644 (file)
@@ -159,7 +159,6 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, ProgramNode* programNode, UnlinkedP
 #ifndef NDEBUG
     , m_lastOpcodePosition(0)
 #endif
-    , m_stack(vm, wtfThreadData().stack())
     , m_usesExceptions(false)
     , m_expressionTooDeep(false)
 {
@@ -207,7 +206,6 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, FunctionBodyNode* functionBody, Unl
 #ifndef NDEBUG
     , m_lastOpcodePosition(0)
 #endif
-    , m_stack(vm, wtfThreadData().stack())
     , m_usesExceptions(false)
     , m_expressionTooDeep(false)
 {
@@ -421,7 +419,6 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, EvalNode* evalNode, UnlinkedEvalCod
 #ifndef NDEBUG
     , m_lastOpcodePosition(0)
 #endif
-    , m_stack(vm, wtfThreadData().stack())
     , m_usesExceptions(false)
     , m_expressionTooDeep(false)
 {
index cadc51a..e5ca332 100644 (file)
@@ -44,7 +44,6 @@
 #include "Nodes.h"
 #include "StaticPropertyAnalyzer.h"
 #include "UnlinkedCodeBlock.h"
-#include "VMStackBounds.h"
 
 #include <functional>
 
@@ -233,7 +232,7 @@ namespace JSC {
         {
             // Node::emitCode assumes that dst, if provided, is either a local or a referenced temporary.
             ASSERT(!dst || dst == ignoredResult() || !dst->isTemporary() || dst->refCount());
-            if (!m_stack.isSafeToRecurse()) {
+            if (!m_vm->isSafeToRecurse()) {
                 emitThrowExpressionTooDeepException();
                 return;
             }
@@ -249,7 +248,7 @@ namespace JSC {
         {
             // Node::emitCode assumes that dst, if provided, is either a local or a referenced temporary.
             ASSERT(!dst || dst == ignoredResult() || !dst->isTemporary() || dst->refCount());
-            if (!m_stack.isSafeToRecurse())
+            if (!m_vm->isSafeToRecurse())
                 return emitThrowExpressionTooDeepException();
             return n->emitBytecode(*this, dst);
         }
@@ -261,7 +260,7 @@ namespace JSC {
 
         void emitNodeInConditionContext(ExpressionNode* n, Label* trueTarget, Label* falseTarget, FallThroughMode fallThroughMode)
         {
-            if (!m_stack.isSafeToRecurse()) {
+            if (!m_vm->isSafeToRecurse()) {
                 emitThrowExpressionTooDeepException();
                 return;
             }
@@ -639,8 +638,6 @@ namespace JSC {
         size_t m_lastOpcodePosition;
 #endif
 
-        VMStackBounds m_stack;
-
         bool m_usesExceptions;
         bool m_expressionTooDeep;
     };
index 06e68d1..de5e8a8 100644 (file)
@@ -32,6 +32,7 @@
 #include "Operations.h"
 #include "Parser.h"
 #include "Protect.h"
+#include "VMEntryScope.h"
 
 namespace {
 
@@ -172,7 +173,7 @@ void Debugger::detach(JSGlobalObject* globalObject)
     // If we're detaching from the currently executing global object, manually tear down our
     // stack, since we won't get further debugger callbacks to do so. Also, resume execution,
     // since there's no point in staying paused once a window closes.
-    if (m_currentCallFrame && m_currentCallFrame->dynamicGlobalObject() == globalObject) {
+    if (m_currentCallFrame && m_currentCallFrame->vmEntryGlobalObject() == globalObject) {
         m_currentCallFrame = 0;
         m_pauseOnCallFrame = 0;
         continueProgram();
@@ -193,8 +194,8 @@ void Debugger::recompileAllJSFunctions(VM* vm)
 {
     // If JavaScript is running, it's not safe to recompile, since we'll end
     // up throwing away code that is live on the stack.
-    ASSERT(!vm->dynamicGlobalObject);
-    if (vm->dynamicGlobalObject)
+    ASSERT(!vm->entryScope);
+    if (vm->entryScope)
         return;
     
     vm->prepareToDiscardCode();
@@ -438,8 +439,8 @@ void Debugger::pauseIfNeeded(CallFrame* callFrame)
     if (m_isPaused)
         return;
 
-    JSGlobalObject* dynamicGlobalObject = callFrame->dynamicGlobalObject();
-    if (!needPauseHandling(dynamicGlobalObject))
+    JSGlobalObject* vmEntryGlobalObject = callFrame->vmEntryGlobalObject();
+    if (!needPauseHandling(vmEntryGlobalObject))
         return;
 
     Breakpoint breakpoint;
@@ -470,7 +471,7 @@ void Debugger::pauseIfNeeded(CallFrame* callFrame)
             return;
     }
 
-    handlePause(m_reasonForPause, dynamicGlobalObject);
+    handlePause(m_reasonForPause, vmEntryGlobalObject);
 
     if (!m_pauseOnNextStatement && !m_pauseOnCallFrame) {
         setShouldPause(false);
index d3623b3..8587078 100644 (file)
@@ -35,6 +35,7 @@
 #include "Operations.h"
 #include "Parser.h"
 #include "StackVisitor.h"
+#include "VMEntryScope.h"
 
 namespace JSC {
 
@@ -77,12 +78,12 @@ PassRefPtr<DebuggerCallFrame> DebuggerCallFrame::callerFrame()
     return m_caller;
 }
 
-JSC::JSGlobalObject* DebuggerCallFrame::dynamicGlobalObject() const
+JSC::JSGlobalObject* DebuggerCallFrame::vmEntryGlobalObject() const
 {
     ASSERT(isValid());
     if (!isValid())
         return 0;
-    return m_callFrame->dynamicGlobalObject();
+    return m_callFrame->vmEntryGlobalObject();
 }
 
 SourceID DebuggerCallFrame::sourceID() const
index 240f570..c58dc68 100644 (file)
@@ -58,7 +58,7 @@ public:
     int column() const { return m_position.m_column.zeroBasedInt(); }
     JS_EXPORT_PRIVATE const TextPosition& position() const { return m_position; }
 
-    JS_EXPORT_PRIVATE JSGlobalObject* dynamicGlobalObject() const;
+    JS_EXPORT_PRIVATE JSGlobalObject* vmEntryGlobalObject() const;
     JS_EXPORT_PRIVATE JSScope* scope() const;
     JS_EXPORT_PRIVATE String functionName() const;
     JS_EXPORT_PRIVATE Type type() const;
index 1552647..5499d7e 100644 (file)
@@ -331,9 +331,8 @@ void JITCompiler::compileFunction()
     // so enter after this.
     Label fromArityCheck(this);
     // Plant a check that sufficient space is available in the JSStack.
-    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56291
     addPtr(TrustedImm32(virtualRegisterForLocal(m_codeBlock->m_numCalleeRegisters).offset() * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1);
-    Jump stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), GPRInfo::regT1);
+    Jump stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), GPRInfo::regT1);
     // Return here after stack check.
     Label fromStackCheck = label();
 
index a82ac35..ff483e4 100644 (file)
@@ -33,6 +33,7 @@
 #include "DFGJITCode.h"
 #include "DFGNode.h"
 #include "JIT.h"
+#include "JSStackInlines.h"
 #include "Operations.h"
 
 namespace JSC { namespace DFG {
index 3c095bd..bf52c56 100644 (file)
@@ -84,7 +84,7 @@ void link(State& state)
             GPRInfo::callFrameRegister, GPRInfo::regT1);
         CCallHelpers::Jump stackCheck = jit.branchPtr(
             CCallHelpers::Above,
-            CCallHelpers::AbsoluteAddress(state.graph.m_vm.interpreter->stack().addressOfEnd()),
+            CCallHelpers::AbsoluteAddress(state.graph.m_vm.addressOfJSStackLimit()),
             GPRInfo::regT1);
         CCallHelpers::Label fromStackCheck = jit.label();
         
index 0910624..2f24508 100644 (file)
@@ -30,6 +30,7 @@
 #include "CodeBlock.h"
 #include "DFGJITCode.h"
 #include "FTLForOSREntryJITCode.h"
+#include "JSStackInlines.h"
 
 #if ENABLE(FTL_JIT)
 
index 354427e..d4b4302 100644 (file)
@@ -291,7 +291,7 @@ bool Heap::isPagedOut(double deadline)
 // Run all pending finalizers now because we won't get another chance.
 void Heap::lastChanceToFinalize()
 {
-    RELEASE_ASSERT(!m_vm->dynamicGlobalObject);
+    RELEASE_ASSERT(!m_vm->entryScope);
     RELEASE_ASSERT(m_operationInProgress == NoOperation);
 
     m_objectSpace.lastChanceToFinalize();
@@ -689,7 +689,7 @@ void Heap::deleteAllCompiledCode()
 {
     // If JavaScript is running, it's not safe to delete code, since we'll end
     // up deleting code that is live on the stack.
-    if (m_vm->dynamicGlobalObject)
+    if (m_vm->entryScope)
         return;
 
     for (ExecutableBase* current = m_compiledCode.head(); current; current = current->next()) {
index ddf9a40..b6d52db 100644 (file)
 #define CachedCall_h
 
 #include "CallFrameClosure.h"
+#include "ExceptionHelpers.h"
 #include "JSFunction.h"
 #include "JSGlobalObject.h"
 #include "Interpreter.h"
+#include "VMEntryScope.h"
 
 namespace JSC {
     class CachedCall {
@@ -38,10 +40,13 @@ namespace JSC {
         CachedCall(CallFrame* callFrame, JSFunction* function, int argumentCount)
             : m_valid(false)
             , m_interpreter(callFrame->interpreter())
-            , m_globalObjectScope(callFrame->vm(), function->scope()->globalObject())
+            , m_entryScope(callFrame->vm(), function->scope()->globalObject())
         {
             ASSERT(!function->isHostFunction());
-            m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argumentCount + 1, function->scope());
+            if (callFrame->vm().isSafeToRecurse())
+                m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argumentCount + 1, function->scope());
+            else
+                throwStackOverflowError(callFrame);
             m_valid = !callFrame->hadException();
         }
         
@@ -69,7 +74,7 @@ namespace JSC {
     private:
         bool m_valid;
         Interpreter* m_interpreter;
-        DynamicGlobalObjectScope m_globalObjectScope;
+        VMEntryScope m_entryScope;
         CallFrameClosure m_closure;
     };
 }
index ef36160..7ccc812 100644 (file)
@@ -30,6 +30,7 @@
 #include "CodeBlock.h"
 #include "Interpreter.h"
 #include "Operations.h"
+#include "VMEntryScope.h"
 
 namespace JSC {
 
@@ -122,4 +123,15 @@ Register* CallFrame::frameExtentInternal()
     return registers() + virtualRegisterForLocal(codeBlock->m_numCalleeRegisters).offset();
 }
 
+JSGlobalObject* CallFrame::vmEntryGlobalObject()
+{
+    if (this == lexicalGlobalObject()->globalExec())
+        return lexicalGlobalObject();
+
+    // For any ExecState that's not a globalExec, the 
+    // dynamic global object must be set since code is running
+    ASSERT(vm().entryScope);
+    return vm().entryScope->globalObject();
+}
+
 } // namespace JSC
index 91806bb..1cb21eb 100644 (file)
@@ -51,7 +51,7 @@ namespace JSC  {
         }
 
         // Global object in which execution began.
-        JSGlobalObject* dynamicGlobalObject();
+        JS_EXPORT_PRIVATE JSGlobalObject* vmEntryGlobalObject();
 
         // Global object in which the currently executing code was defined.
         // Differs from dynamicGlobalObject() during function calls across web browser frames.
index 7783a9b..833a0a5 100644 (file)
@@ -66,7 +66,7 @@
 #include "StackVisitor.h"
 #include "StrictEvalActivation.h"
 #include "StrongInlines.h"
-#include "VMStackBounds.h"
+#include "VMEntryScope.h"
 #include "VirtualRegister.h"
 
 #include <limits.h>
@@ -395,7 +395,7 @@ static bool unwindCallFrame(StackVisitor& visitor)
     CodeBlock* oldCodeBlock = codeBlock;
     JSScope* scope = callFrame->scope();
 
-    if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
+    if (Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger()) {
         if (callFrame->callee())
             debugger->returnEvent(callFrame);
         else
@@ -650,7 +650,7 @@ NEVER_INLINE HandlerInfo* Interpreter::unwind(CallFrame*& callFrame, JSValue& ex
     ASSERT(callFrame->vm().exceptionStack().size());
     ASSERT(!exceptionValue.isObject() || asObject(exceptionValue)->hasProperty(callFrame, callFrame->vm().propertyNames->stack));
 
-    Debugger* debugger = callFrame->dynamicGlobalObject()->debugger();
+    Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger();
     if (debugger && debugger->needsExceptionCallbacks()) {
         // We need to clear the exception and the exception stack here in order to see if a new exception happens.
         // Afterwards, the values are put back to continue processing this error.
@@ -739,15 +739,14 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, J
     if (vm.isCollectorBusy())
         return jsNull();
 
-    StackStats::CheckPoint stackCheckPoint;
-    const VMStackBounds vmStackBounds(vm, wtfThreadData().stack());
-    if (!vmStackBounds.isSafeToRecurse())
+    VMEntryScope entryScope(vm, scope->globalObject());
+    if (!vm.isSafeToRecurse())
         return checkedReturn(throwStackOverflowError(callFrame));
 
     // First check if the "program" is actually just a JSON object. If so,
     // we'll handle the JSON object here. Else, we'll handle real JS code
     // below at failedJSONP.
-    DynamicGlobalObjectScope globalObjectScope(vm, scope->globalObject());
+
     Vector<JSONPData> JSONPData;
     bool parseResult;
     const String programSource = program->source().toString();
@@ -900,11 +899,6 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT
     if (vm.isCollectorBusy())
         return jsNull();
 
-    StackStats::CheckPoint stackCheckPoint;
-    const VMStackBounds vmStackBounds(vm, wtfThreadData().stack());
-    if (!vmStackBounds.isSafeToRecurse())
-        return checkedReturn(throwStackOverflowError(callFrame));
-
     bool isJSCall = (callType == CallTypeJS);
     JSScope* scope;
     CodeBlock* newCodeBlock;
@@ -916,7 +910,10 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT
         ASSERT(callType == CallTypeHost);
         scope = callFrame->scope();
     }
-    DynamicGlobalObjectScope globalObjectScope(vm, scope->globalObject());
+
+    VMEntryScope entryScope(vm, scope->globalObject());
+    if (!vm.isSafeToRecurse())
+        return checkedReturn(throwStackOverflowError(callFrame));
 
     if (isJSCall) {
         // Compile the callee:
@@ -978,11 +975,6 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc
     if (vm.isCollectorBusy())
         return checkedReturn(throwStackOverflowError(callFrame));
 
-    StackStats::CheckPoint stackCheckPoint;
-    const VMStackBounds vmStackBounds(vm, wtfThreadData().stack());
-    if (!vmStackBounds.isSafeToRecurse())
-        return checkedReturn(throwStackOverflowError(callFrame));
-
     bool isJSConstruct = (constructType == ConstructTypeJS);
     JSScope* scope;
     CodeBlock* newCodeBlock;
@@ -995,7 +987,9 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc
         scope = callFrame->scope();
     }
 
-    DynamicGlobalObjectScope globalObjectScope(vm, scope->globalObject());
+    VMEntryScope entryScope(vm, scope->globalObject());
+    if (!vm.isSafeToRecurse())
+        return checkedReturn(throwStackOverflowError(callFrame));
 
     if (isJSConstruct) {
         // Compile the callee:
@@ -1065,13 +1059,6 @@ CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionE
     if (vm.isCollectorBusy())
         return CallFrameClosure();
 
-    StackStats::CheckPoint stackCheckPoint;
-    const VMStackBounds vmStackBounds(vm, wtfThreadData().stack());
-    if (!vmStackBounds.isSafeToRecurse()) {
-        throwStackOverflowError(callFrame);
-        return CallFrameClosure();
-    }
-
     // Compile the callee:
     JSObject* error = functionExecutable->prepareForExecution(callFrame, scope, CodeForCall);
     if (error) {
@@ -1165,12 +1152,9 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
     if (vm.isCollectorBusy())
         return jsNull();
 
-    DynamicGlobalObjectScope globalObjectScope(vm, scope->globalObject());
-
-    StackStats::CheckPoint stackCheckPoint;
-    const VMStackBounds vmStackBounds(vm, wtfThreadData().stack());
-    if (!vmStackBounds.isSafeToRecurse())
-        return checkedReturn(throwStackOverflowError(callFrame));
+    VMEntryScope entryScope(vm, scope->globalObject());
+    if (!vm.isSafeToRecurse())
+        return checkedReturn(throwStackOverflowError(callFrame));        
 
     unsigned numVariables = eval->numVariables();
     int numFunctions = eval->numberOfFunctionDecls();
@@ -1251,7 +1235,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
 
 NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookID debugHookID)
 {
-    Debugger* debugger = callFrame->dynamicGlobalObject()->debugger();
+    Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger();
     if (!debugger || !debugger->needsOpDebugCallbacks())
         return;
 
index da3d07d..722e1bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,7 +27,6 @@
  */
 
 #include "config.h"
-#include "JSStack.h"
 #include "JSStackInlines.h"
 
 #include "ConservativeRoots.h"
@@ -44,13 +43,14 @@ static Mutex& stackStatisticsMutex()
 }    
 
 JSStack::JSStack(VM& vm, size_t capacity)
-    : m_end(0)
+    : m_vm(vm)
+    , m_end(0)
     , m_topCallFrame(vm.topCallFrame)
 {
     ASSERT(capacity && isPageAligned(capacity));
 
     m_reservation = PageReservation::reserve(roundUpAllocationSize(capacity * sizeof(Register), commitSize), OSAllocator::JSVMStackPages);
-    m_end = highAddress();
+    updateStackLimit(highAddress());
     m_commitEnd = highAddress();
 
     disableErrorStackReserve();
@@ -71,7 +71,7 @@ bool JSStack::growSlowCase(Register* newEnd)
     // If we have already committed enough memory to satisfy this request,
     // just update the end pointer and return.
     if (newEnd >= m_commitEnd) {
-        m_end = newEnd;
+        updateStackLimit(newEnd);
         return true;
     }
 
@@ -87,7 +87,7 @@ bool JSStack::growSlowCase(Register* newEnd)
     m_reservation.commit(reinterpret_cast<char*>(m_commitEnd) - delta, delta);
     addToCommittedByteCount(delta);
     m_commitEnd = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(m_commitEnd) - delta);
-    m_end = newEnd;
+    updateStackLimit(newEnd);
     return true;
 }
 
index 10463e4..a4fef94 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -87,7 +87,6 @@ namespace JSC {
             return highAddress() - 1;
         }
 
-        Register* getLimitOfStack() const { return m_end; }
         size_t size() const { return highAddress() - lowAddress(); }
 
         bool grow(Register*);
@@ -95,15 +94,9 @@ namespace JSC {
         static size_t committedByteCount();
         static void initializeThreading();
 
-        Register* const * addressOfEnd() const
-        {
-            return &m_end;
-        }
-
         Register* getTopOfFrame(CallFrame*);
         Register* getStartOfFrame(CallFrame*);
         Register* getTopOfStack();
-        Register* end() const { return m_end; }
 
         CallFrame* pushFrame(CallFrame* callerFrame, class CodeBlock*,
             JSScope*, int argsCount, JSObject* callee);
@@ -153,6 +146,9 @@ namespace JSC {
         void releaseExcessCapacity();
         void addToCommittedByteCount(long);
 
+        void updateStackLimit(Register* newEnd);
+
+        VM& m_vm;
         Register* m_end;
         Register* m_commitEnd;
         Register* m_useableEnd;
@@ -162,22 +158,6 @@ namespace JSC {
         friend class LLIntOffsetsExtractor;
     };
 
-    inline void JSStack::shrink(Register* newEnd)
-    {
-        if (newEnd >= m_end)
-            return;
-        m_end = newEnd;
-        if (m_end == getBaseOfStack() && (m_commitEnd - getBaseOfStack()) >= maxExcessCapacity)
-            releaseExcessCapacity();
-    }
-
-    inline bool JSStack::grow(Register* newEnd)
-    {
-        if (newEnd >= m_end)
-            return true;
-        return growSlowCase(newEnd);
-    }
-
 } // namespace JSC
 
 #endif // JSStack_h
index 216d8f3..199926c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
 #include "CallFrame.h"
 #include "CodeBlock.h"
 #include "JSStack.h"
+#include "VM.h"
 
 namespace JSC {
 
@@ -135,6 +136,29 @@ inline void JSStack::popFrame(CallFrame* frame)
     installTrapsAfterFrame(callerFrame);
 }
 
+inline void JSStack::shrink(Register* newEnd)
+{
+    if (newEnd >= m_end)
+        return;
+    updateStackLimit(newEnd);
+    if (m_end == getBaseOfStack() && (m_commitEnd - getBaseOfStack()) >= maxExcessCapacity)
+        releaseExcessCapacity();
+}
+
+inline bool JSStack::grow(Register* newEnd)
+{
+    if (newEnd >= m_end)
+        return true;
+    return growSlowCase(newEnd);
+}
+
+inline void JSStack::updateStackLimit(Register* newEnd)
+{
+    m_end = newEnd;
+#if USE(SEPARATE_C_AND_JS_STACK)
+    m_vm.setJSStackLimit(newEnd);
+#endif
+}
 
 #if ENABLE(DEBUG_JSSTACK)
 inline JSValue JSStack::generateFenceValue(size_t argIndex)
index 2d3a1df..62ab90f 100644 (file)
@@ -568,7 +568,7 @@ CompilationResult JIT::privateCompile(JITCompilationEffort effort)
 #endif
 
         addPtr(TrustedImm32(virtualRegisterForLocal(m_codeBlock->m_numCalleeRegisters).offset() * sizeof(Register)), callFrameRegister, regT1);
-        stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT1);
+        stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT1);
     }
 
     Label functionBody = label();
index 731710f..cb496b3 100644 (file)
@@ -84,7 +84,7 @@ void JIT::compileLoadVarargs(Instruction* instruction)
         addPtr(callFrameRegister, regT1);
         // regT1: newCallFrame
 
-        slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT1));
+        slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT1));
 
         // Initialize ArgumentCount.
         store32(regT0, Address(regT1, JSStack::ArgumentCount * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
index 9f63492..d0e0dad 100644 (file)
@@ -162,7 +162,7 @@ void JIT::compileLoadVarargs(Instruction* instruction)
         addPtr(callFrameRegister, regT3);
         // regT3: newCallFrame
 
-        slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT3));
+        slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT3));
 
         // Initialize ArgumentCount.
         store32(regT2, payloadFor(JSStack::ArgumentCount, regT3));
index 74efe0f..2c45b3a 100644 (file)
@@ -44,6 +44,7 @@
 #include "JSGlobalObjectFunctions.h"
 #include "JSNameScope.h"
 #include "JSPropertyNameIterator.h"
+#include "JSStackInlines.h"
 #include "JSWithScope.h"
 #include "ObjectConstructor.h"
 #include "Operations.h"
index 10b77a6..dd4fc74 100644 (file)
@@ -43,6 +43,7 @@
 #include "JSGlobalObjectFunctions.h"
 #include "JSNameScope.h"
 #include "JSPropertyNameIterator.h"
+#include "JSStackInlines.h"
 #include "JSString.h"
 #include "JSWithScope.h"
 #include "LLIntCommon.h"
index e502359..1040186 100644 (file)
@@ -383,10 +383,9 @@ macro functionInitialization(profileArgSkip)
     loadi CodeBlock::m_numCalleeRegisters[t1], t0
     addi 1, t0 # Account that local0 goes at slot -1
     loadp CodeBlock::m_vm[t1], t2
-    loadp VM::interpreter[t2], t2
     lshiftp 3, t0
     subp cfr, t0, t0
-    bpbeq Interpreter::m_stack + JSStack::m_end[t2], t0, .stackHeightOK
+    bpbeq VM::m_jsStackLimit[t2], t0, .stackHeightOK
 
     # Stack height check failed - need to call a slow_path.
     callSlowPath(_llint_stack_check)
index 4952592..3fddcc3 100644 (file)
@@ -193,7 +193,6 @@ template <typename LexerType>
 Parser<LexerType>::Parser(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode)
     : m_vm(vm)
     , m_source(&source)
-    , m_stack(*vm, wtfThreadData().stack())
     , m_hasStackOverflow(false)
     , m_allowsIn(true)
     , m_assignmentCount(0)
index 4a5ad85..b091f76 100644 (file)
@@ -35,7 +35,6 @@
 #include "SourceProvider.h"
 #include "SourceProviderCache.h"
 #include "SourceProviderCacheItem.h"
-#include "VMStackBounds.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/OwnPtr.h>
@@ -758,7 +757,7 @@ private:
     
     bool canRecurse()
     {
-        return m_stack.isSafeToRecurse();
+        return m_vm->isSafeToRecurse();
     }
     
     const JSTextPosition& lastTokenEndPosition() const
@@ -827,7 +826,6 @@ private:
     ParserArena* m_arena;
     OwnPtr<LexerType> m_lexer;
     
-    VMStackBounds m_stack;
     bool m_hasStackOverflow;
     String m_errorMessage;
     JSToken m_token;
index 8f92a8e..6df9afd 100644 (file)
@@ -29,6 +29,7 @@
 #include "CodeBlock.h"
 #include "CodeSpecializationKind.h"
 #include "ExceptionHelpers.h"
+#include "JSStackInlines.h"
 #include "NameInstance.h"
 #include <wtf/Platform.h>
 
index eec95e1..d8c7b2f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
- *  Copyright (C) 2003, 2007 Apple Inc.
+ *  Copyright (C) 2003, 2007, 2013 Apple Inc.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Library General Public
@@ -78,7 +78,7 @@ JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, J
     }
 
     if (!thisValue || thisValue.isUndefinedOrNull())
-        thisValue = exec->dynamicGlobalObject();
+        thisValue = exec->vmEntryGlobalObject();
     JSObject* thisObj = jsCast<JSObject*>(thisValue.toThis(exec, NotStrictMode));
     JSValue result = exec->interpreter()->execute(program, exec, thisObj);
 
index 87c3ab6..53de632 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
- *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -112,7 +112,7 @@ JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState* exec, JSGlobalObj
 
     SourceCode source = makeSource(program, sourceURL, position);
     JSObject* exception = 0;
-    FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, exec, exec->dynamicGlobalObject()->debugger(), source, &exception);
+    FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, exec, exec->vmEntryGlobalObject()->debugger(), source, &exception);
     if (!function) {
         ASSERT(exception);
         return exec->vm().throwException(exec, exception);
index d431887..f05166a 100644 (file)
@@ -716,26 +716,6 @@ void JSGlobalObject::clearRareData(JSCell* cell)
     jsCast<JSGlobalObject*>(cell)->m_rareData.clear();
 }
 
-DynamicGlobalObjectScope::DynamicGlobalObjectScope(VM& vm, JSGlobalObject* dynamicGlobalObject)
-    : m_dynamicGlobalObjectSlot(vm.dynamicGlobalObject)
-    , m_savedDynamicGlobalObject(m_dynamicGlobalObjectSlot)
-{
-    if (!m_dynamicGlobalObjectSlot) {
-#if ENABLE(ASSEMBLER)
-        if (ExecutableAllocator::underMemoryPressure())
-            vm.heap.deleteAllCompiledCode();
-#endif
-
-        m_dynamicGlobalObjectSlot = dynamicGlobalObject;
-
-        // Reset the date cache between JS invocations to force the VM
-        // to observe time zone changes.
-        vm.resetDateCache();
-    }
-    // Clear the exception stack between entries
-    vm.clearExceptionStack();
-}
-
 void slowValidateCell(JSGlobalObject* globalObject)
 {
     RELEASE_ASSERT(globalObject->isGlobalObject());
index cc829ac..b0feb5d 100644 (file)
@@ -584,17 +584,6 @@ inline bool JSGlobalObject::symbolTableHasProperty(PropertyName propertyName)
     return !entry.isNull();
 }
 
-inline JSGlobalObject* ExecState::dynamicGlobalObject()
-{
-    if (this == lexicalGlobalObject()->globalExec())
-        return lexicalGlobalObject();
-
-    // For any ExecState that's not a globalExec, the 
-    // dynamic global object must be set since code is running
-    ASSERT(vm().dynamicGlobalObject);
-    return vm().dynamicGlobalObject;
-}
-
 inline JSArray* constructEmptyArray(ExecState* exec, ArrayAllocationProfile* profile, JSGlobalObject* globalObject, unsigned initialLength = 0)
 {
     return ArrayAllocationProfile::updateLastAllocationFor(profile, JSArray::create(exec->vm(), initialLength >= MIN_SPARSE_ARRAY_INDEX ? globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithArrayStorage) : globalObject->arrayStructureForProfileDuringAllocation(profile), initialLength));
@@ -635,21 +624,6 @@ inline JSArray* constructArrayNegativeIndexed(ExecState* exec, ArrayAllocationPr
     return constructArrayNegativeIndexed(exec, profile, exec->lexicalGlobalObject(), values, length);
 }
 
-class DynamicGlobalObjectScope {
-    WTF_MAKE_NONCOPYABLE(DynamicGlobalObjectScope);
-public:
-    JS_EXPORT_PRIVATE DynamicGlobalObjectScope(VM&, JSGlobalObject*);
-
-    ~DynamicGlobalObjectScope()
-    {
-        m_dynamicGlobalObjectSlot = m_savedDynamicGlobalObject;
-    }
-
-private:
-    JSGlobalObject*& m_dynamicGlobalObjectSlot;
-    JSGlobalObject* m_savedDynamicGlobalObject;
-};
-
 inline JSObject* JSScope::globalThis()
 { 
     return globalObject()->globalThis();
index 6f236f1..c99dd4f 100644 (file)
@@ -21,7 +21,6 @@
 #define StringRecursionChecker_h
 
 #include "Interpreter.h"
-#include "VMStackBounds.h"
 #include <wtf/StackStats.h>
 #include <wtf/WTFThreadData.h>
 
@@ -51,8 +50,7 @@ private:
 inline JSValue StringRecursionChecker::performCheck()
 {
     VM& vm = m_exec->vm();
-    const VMStackBounds nativeStack(vm, wtfThreadData().stack());
-    if (!nativeStack.isSafeToRecurse())
+    if (!vm.isSafeToRecurse())
         return throwStackOverflowError();
     bool alreadyVisited = !vm.stringRecursionCheckVisitedObjects.add(m_thisObject).isNewEntry;
     if (alreadyVisited)
index 566aa28..cee1ceb 100644 (file)
@@ -195,7 +195,7 @@ VM::VM(VMType vmType, HeapType heapType)
     , jsArrayClassInfo(JSArray::info())
     , jsFinalObjectClassInfo(JSFinalObject::info())
     , sizeOfLastScratchBuffer(0)
-    , dynamicGlobalObject(0)
+    , entryScope(0)
     , m_enabledProfiler(0)
     , m_regExpCache(new RegExpCache(this))
 #if ENABLE(REGEXP_TRACING)
@@ -215,10 +215,16 @@ VM::VM(VMType vmType, HeapType heapType)
 #if ENABLE(GC_VALIDATION)
     , m_initializingObjectClass(0)
 #endif
+    , m_stackLimit(0)
+#if USE(SEPARATE_C_AND_JS_STACK)
+    , m_jsStackLimit(0)
+#endif
     , m_inDefineOwnProperty(false)
     , m_codeCache(CodeCache::create())
 {
     interpreter = new Interpreter(*this);
+    StackBounds stack = wtfThreadData().stack();
+    setStackLimit(stack.recursionLimit());
 
     // Need to be careful to keep everything consistent here
     JSLockHolder lock(this);
@@ -532,7 +538,7 @@ void VM::releaseExecutableMemory()
 {
     prepareToDiscardCode();
     
-    if (dynamicGlobalObject) {
+    if (entryScope) {
         StackPreservingRecompiler recompiler;
         HeapIterationScope iterationScope(heap);
         HashSet<JSCell*> roots;
@@ -618,7 +624,7 @@ static void appendSourceToError(CallFrame* callFrame, ErrorInstance* exception,
     
 JSValue VM::throwException(ExecState* exec, JSValue error)
 {
-    ASSERT(exec == topCallFrame || exec == exec->lexicalGlobalObject()->globalExec() || exec == exec->dynamicGlobalObject()->globalExec());
+    ASSERT(exec == topCallFrame || exec == exec->lexicalGlobalObject()->globalExec() || exec == exec->vmEntryGlobalObject()->globalExec());
     
     Vector<StackFrame> stackTrace;
     interpreter->getStackTrace(stackTrace);
index f1ed6cf..c823bc4 100644 (file)
@@ -54,6 +54,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/RefCountedArray.h>
 #include <wtf/SimpleStats.h>
+#include <wtf/StackBounds.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/ThreadSpecific.h>
 #include <wtf/WTFThreadData.h>
@@ -90,6 +91,7 @@ namespace JSC {
     class UnlinkedEvalCodeBlock;
     class UnlinkedFunctionExecutable;
     class UnlinkedProgramCodeBlock;
+    class VMEntryScope;
 
 #if ENABLE(DFG_JIT)
     namespace DFG {
@@ -361,6 +363,19 @@ namespace JSC {
         JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
         JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
         
+        void** addressOfJSStackLimit() { return &m_jsStackLimit; }
+        void* jsStackLimit() { return m_jsStackLimit; }
+        void setJSStackLimit(void* limit) { m_jsStackLimit = limit; }
+
+        void* stackLimit() { return m_stackLimit; }
+        void setStackLimit(void* limit) { m_stackLimit = limit; }
+        bool isSafeToRecurse() const
+        {
+            ASSERT(wtfThreadData().stack().isGrowingDownward());
+            void* curr;
+            return &curr >= m_stackLimit;
+        }
+
         const ClassInfo* const jsArrayClassInfo;
         const ClassInfo* const jsFinalObjectClassInfo;
 
@@ -396,7 +411,7 @@ namespace JSC {
 
         void gatherConservativeRoots(ConservativeRoots&);
 
-        JSGlobalObject* dynamicGlobalObject;
+        VMEntryScope* entryScope;
 
         HashSet<JSObject*> stringRecursionCheckVisitedObjects;
 
@@ -475,6 +490,18 @@ namespace JSC {
 #if ENABLE(GC_VALIDATION)
         const ClassInfo* m_initializingObjectClass;
 #endif
+
+#if USE(SEPARATE_C_AND_JS_STACK)
+        struct {
+            void* m_stackLimit;
+            void* m_jsStackLimit;
+        };
+#else
+        union {
+            void* m_stackLimit;
+            void* m_jsStackLimit;
+        };
+#endif
         JSValue m_exception;
         bool m_inDefineOwnProperty;
         OwnPtr<CodeCache> m_codeCache;
diff --git a/Source/JavaScriptCore/runtime/VMEntryScope.cpp b/Source/JavaScriptCore/runtime/VMEntryScope.cpp
new file mode 100644 (file)
index 0000000..26b0028
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "VMEntryScope.h"
+
+#include "VM.h"
+#include <wtf/StackBounds.h>
+
+namespace JSC {
+
+VMEntryScope::VMEntryScope(VM& vm, JSGlobalObject* globalObject)
+    : m_vm(vm)
+    , m_stack(wtfThreadData().stack())
+    , m_globalObject(globalObject)
+    , m_prev(vm.entryScope)
+    , m_prevStackLimit(vm.stackLimit())
+{
+    if (!vm.entryScope) {
+#if ENABLE(ASSEMBLER)
+        if (ExecutableAllocator::underMemoryPressure())
+            vm.heap.deleteAllCompiledCode();
+#endif
+        vm.entryScope = this;
+
+        // Reset the date cache between JS invocations to force the VM to
+        // observe time xone changes.
+        vm.resetDateCache();
+    }
+    // Clear the exception stack between entries
+    vm.clearExceptionStack();
+
+    void* limit = m_stack.recursionLimit(requiredCapacity());
+    vm.setStackLimit(limit);
+}
+
+VMEntryScope::~VMEntryScope()
+{
+    m_vm.entryScope = m_prev;
+    m_vm.setStackLimit(m_prevStackLimit);
+}
+
+size_t VMEntryScope::requiredCapacity() const
+{
+    Interpreter* interpreter = m_vm.interpreter;
+
+    // We require a smaller stack budget for the error stack. This is to allow
+    // some minimal JS execution to proceed and do the work of throwing a stack
+    // overflow error if needed. In contrast, arbitrary JS code will require the
+    // more generous stack budget in order to proceed.
+    //
+    // These sizes were derived from the stack usage of a number of sites when
+    // layout occurs when we've already consumed most of the C stack.
+    const size_t requiredStack = 128 * KB;
+    const size_t errorModeRequiredStack = 64 * KB;
+
+    size_t requiredCapacity = interpreter->isInErrorHandlingMode() ? errorModeRequiredStack : requiredStack;
+    RELEASE_ASSERT(m_stack.size() >= requiredCapacity);
+    return requiredCapacity; 
+}
+
+} // namespace JSC
+
similarity index 54%
rename from Source/JavaScriptCore/runtime/VMStackBounds.h
rename to Source/JavaScriptCore/runtime/VMEntryScope.h
index 76a3ebd..8e1c44a 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef VMStackBounds_h
-#define VMStackBounds_h
+#ifndef VMEntryScope_h
+#define VMEntryScope_h
 
-#include "VM.h"
+#include "Interpreter.h"
 #include <wtf/StackBounds.h>
+#include <wtf/StackStats.h>
 
 namespace JSC {
 
-class VMStackBounds {
+class JSGlobalObject;
+class VM;
+
+class VMEntryScope {
 public:
-    VMStackBounds(VM& vm, const StackBounds& bounds)
-        : m_vm(vm)
-        , m_bounds(bounds)
-    {
-    }
+    JS_EXPORT_PRIVATE VMEntryScope(VM&, JSGlobalObject*);
+    JS_EXPORT_PRIVATE ~VMEntryScope();
 
-    bool isSafeToRecurse() const { return m_bounds.isSafeToRecurse(requiredCapacity()); }
+    JSGlobalObject* globalObject() const { return m_globalObject; }
 
 private:
-    inline size_t requiredCapacity() const
-    {
-        Interpreter* interpreter = m_vm.interpreter;
-
-        // We have two separate stack limits, one for regular JS execution, and one
-        // for when we're handling errors. We need the error stack to be smaller
-        // otherwise there would obviously not be any stack left to execute JS in when
-        // there's a stack overflow.
-        //
-        // These sizes were derived from the stack usage of a number of sites when
-        // layout occurs when we've already consumed most of the C stack.
-        const size_t requiredStack = 128 * KB;
-        const size_t errorModeRequiredStack = 64 * KB;
-
-        size_t requiredCapacity = interpreter->isInErrorHandlingMode() ? errorModeRequiredStack : requiredStack;
-        RELEASE_ASSERT(m_bounds.size() >= requiredCapacity);
-        return requiredCapacity; 
-    }
+    size_t requiredCapacity() const;
 
     VM& m_vm;
-    const StackBounds& m_bounds;
+    StackStats::CheckPoint m_stackCheckPoint;
+    StackBounds m_stack;
+    JSGlobalObject* m_globalObject;
+
+    // m_prev and m_prevStackLimit may belong to a different thread's stack.
+    VMEntryScope* m_prev;
+    void* m_prevStackLimit;
 };
 
 } // namespace JSC
 
-#endif // VMStackBounds_h
+#endif // VMEntryScope_h
 
index 2fc112e..2063147 100644 (file)
@@ -1,3 +1,14 @@
+2013-11-20  Mark Lam  <mark.lam@apple.com>
+
+        Introducing VMEntryScope to update the VM stack limit.
+        https://bugs.webkit.org/show_bug.cgi?id=124634.
+
+        Reviewed by Geoffrey Garen.
+
+        * wtf/Platform.h:
+        * wtf/StackBounds.h:
+        (WTF::StackBounds::StackBounds):
+
 2013-11-18  Filip Pizlo  <fpizlo@apple.com>
 
         Allow the FTL debug dumps to include the new size field
index b2b2479..2e01d36 100644 (file)
 #endif
 #endif
 
+/* FIXME: We currently unconditionally use spearate stacks. When we switch to using the
+   C stack for JS frames, we'll need to make the following conditional on ENABLE(LLINT_CLOOP)
+   only.
+*/
+#if ENABLE(LLINT_CLOOP) || 1
+#define WTF_USE_SEPARATE_C_AND_JS_STACK 1
+#endif
+
 /* Pick which allocator to use; we only need an executable allocator if the assembler is compiled in.
    On x86-64 we use a single fixed mmap, on other platforms we mmap on demand. */
 #if ENABLE(ASSEMBLER)
index a595c1b..ca39749 100644 (file)
@@ -30,9 +30,6 @@
 namespace WTF {
 
 class StackBounds {
-    // isSafeToRecurse() / recursionLimit() tests (by default)
-    // that we are at least this far from the end of the stack.
-    //
     // This 64k number was picked because a sampling of stack usage differences
     // between consecutive entries into one of the Interpreter::execute...()
     // functions was seen to be as high as 27k. Hence, 64k is chosen as a
@@ -49,14 +46,6 @@ public:
         return bounds;
     }
 
-    bool isSafeToRecurse(size_t minAvailableDelta = s_defaultAvailabilityDelta) const
-    {
-        checkConsistency();
-        if (isGrowingDownward())
-            return current() >= recursionLimit(minAvailableDelta);
-        return current() <= recursionLimit(minAvailableDelta);
-    }
-
     void* origin() const
     {
         ASSERT(m_origin);
@@ -70,22 +59,6 @@ public:
         return static_cast<char*>(m_bound) - static_cast<char*>(m_origin);
     }
 
-private:
-    StackBounds()
-        : m_origin(0)
-        , m_bound(0)
-    {
-    }
-
-    WTF_EXPORT_PRIVATE void initialize();
-
-    void* current() const
-    {
-        checkConsistency();
-        void* currentPosition = &currentPosition;
-        return currentPosition;
-    }
-
     void* recursionLimit(size_t minAvailableDelta = s_defaultAvailabilityDelta) const
     {
         checkConsistency();
@@ -104,6 +77,15 @@ private:
 #endif
     }
 
+private:
+    StackBounds()
+        : m_origin(0)
+        , m_bound(0)
+    {
+    }
+
+    WTF_EXPORT_PRIVATE void initialize();
+
     void checkConsistency() const
     {
 #if !ASSERT_DISABLED
index e911776..7c03c65 100644 (file)
@@ -1,3 +1,48 @@
+2013-11-20  Mark Lam  <mark.lam@apple.com>
+
+        Introducing VMEntryScope to update the VM stack limit.
+        https://bugs.webkit.org/show_bug.cgi?id=124634.
+
+        Reviewed by Geoffrey Garen.
+
+        No new tests.
+
+        Renamed dynamicGlobalObject() to vmEntryGlobalObject().
+        Replaced uses of DynamicGlobalObjectScope with VMEntryScope.
+
+        * ForwardingHeaders/runtime/VMEntryScope.h: Added.
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * bindings/js/JSCryptoAlgorithmBuilder.cpp:
+        (WebCore::JSCryptoAlgorithmBuilder::add):
+        * bindings/js/JSCustomXPathNSResolver.cpp:
+        (WebCore::JSCustomXPathNSResolver::create):
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::firstDOMWindow):
+        * bindings/js/JSErrorHandler.cpp:
+        (WebCore::JSErrorHandler::handleEvent):
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSEventListener::handleEvent):
+        * bindings/js/JavaScriptCallFrame.h:
+        (WebCore::JavaScriptCallFrame::vmEntryGlobalObject):
+        * bindings/js/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::recompileAllJSFunctions):
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::evaluateBreakpointAction):
+        (WebCore::ScriptDebugServer::handlePause):
+        * bindings/js/WorkerScriptDebugServer.cpp:
+        (WebCore::WorkerScriptDebugServer::recompileAllJSFunctions):
+        * bindings/objc/WebScriptObject.mm:
+        (WebCore::addExceptionToConsole):
+        * bridge/c/c_utility.cpp:
+        (JSC::Bindings::convertValueToNPVariant):
+        * bridge/objc/objc_instance.mm:
+        (ObjcInstance::moveGlobalExceptionToExecState):
+        * bridge/objc/objc_runtime.mm:
+        (JSC::Bindings::convertValueToObjcObject):
+        * bridge/objc/objc_utility.mm:
+        (JSC::Bindings::convertValueToObjcValue):
+
 2013-11-20  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Generate toHTMLFooElement() to clean up static_cast<>
diff --git a/Source/WebCore/ForwardingHeaders/runtime/VMEntryScope.h b/Source/WebCore/ForwardingHeaders/runtime/VMEntryScope.h
new file mode 100644 (file)
index 0000000..ff784cc
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_VMEntryScope_h
+#define WebCore_FWD_VMEntryScope_h
+#include <JavaScriptCore/VMEntryScope.h>
+#endif
index 0446b78..76cd34d 100644 (file)
     <ClInclude Include="..\ForwardingHeaders\runtime\JSExportMacros.h" />
     <ClInclude Include="..\ForwardingHeaders\runtime\JSFunction.h" />
     <ClInclude Include="..\ForwardingHeaders\runtime\VM.h" />
+    <ClInclude Include="..\ForwardingHeaders\runtime\VMEntryScope.h" />
     <ClInclude Include="..\ForwardingHeaders\runtime\JSGlobalObject.h" />
     <ClInclude Include="..\ForwardingHeaders\runtime\JSProxy.h" />
     <ClInclude Include="..\ForwardingHeaders\runtime\JSWithScope.h" />
index 954d583..0c6bc5c 100644 (file)
     <ClInclude Include="..\ForwardingHeaders\runtime\VM.h">
       <Filter>ForwardingHeaders\runtime</Filter>
     </ClInclude>
+    <ClInclude Include="..\ForwardingHeaders\runtime\VMEntryScope.h">
+      <Filter>ForwardingHeaders\runtime</Filter>
+    </ClInclude>
     <ClInclude Include="..\ForwardingHeaders\runtime\JSGlobalObject.h">
       <Filter>ForwardingHeaders\runtime</Filter>
     </ClInclude>
index 13c063b..d03f6b9 100644 (file)
@@ -71,7 +71,7 @@ void JSCryptoAlgorithmBuilder::add(const char* key, const Vector<uint8_t>& buffe
     VM& vm = m_exec->vm();
     Identifier identifier(&vm, key);
     RefPtr<Uint8Array> arrayView = Uint8Array::create(buffer.data(), buffer.size());
-    m_dictionary->putDirect(vm, identifier, arrayView->wrap(m_exec, vm.dynamicGlobalObject));
+    m_dictionary->putDirect(vm, identifier, arrayView->wrap(m_exec, vm.entryScope->globalObject()));
 }
 
 void JSCryptoAlgorithmBuilder::add(const char* key, const CryptoAlgorithmDescriptionBuilder& nestedBuilder)
index 9a52427..f1b63f8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Alexey Proskuryakov (ap@nypop.com)
+ * Copyright (C) 2007, 2013 Alexey Proskuryakov (ap@nypop.com)
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -52,7 +52,7 @@ PassRefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(ExecState* e
         return 0;
     }
 
-    return adoptRef(new JSCustomXPathNSResolver(exec, resolverObject, asJSDOMWindow(exec->dynamicGlobalObject())));
+    return adoptRef(new JSCustomXPathNSResolver(exec, resolverObject, asJSDOMWindow(exec->vmEntryGlobalObject())));
 }
 
 JSCustomXPathNSResolver::JSCustomXPathNSResolver(ExecState* exec, JSObject* customResolver, JSDOMWindow* globalObject)
index 6e3fc2c..e6a9eea 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
- *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.
  *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
  *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
  *
@@ -494,7 +494,7 @@ DOMWindow& activeDOMWindow(ExecState* exec)
 
 DOMWindow& firstDOMWindow(ExecState* exec)
 {
-    return asJSDOMWindow(exec->dynamicGlobalObject())->impl();
+    return asJSDOMWindow(exec->vmEntryGlobalObject())->impl();
 }
 
 static inline bool canAccessDocument(JSC::ExecState* state, Document* targetDocument, SecurityReportingOption reportingOption = ReportSecurityError)
index a50747b..f72c334 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -39,6 +40,7 @@
 #include "JSEvent.h"
 #include "JSMainThreadExecState.h"
 #include <runtime/JSLock.h>
+#include <runtime/VMEntryScope.h>
 #include <wtf/Ref.h>
 
 using namespace JSC;
@@ -94,7 +96,7 @@ void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext,
         args.append(jsNumber(errorEvent->colno()));
 
         VM& vm = globalObject->vm();
-        DynamicGlobalObjectScope globalObjectScope(vm, vm.dynamicGlobalObject ? vm.dynamicGlobalObject : globalObject);
+        VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);
 
         JSValue returnValue = scriptExecutionContext->isDocument()
             ? JSMainThreadExecState::call(exec, jsFunction, callType, callData, globalObject, args)
index 1dee60f..703c2ab 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
- *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All Rights Reserved.
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All Rights Reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,7 @@
 #include "WorkerGlobalScope.h"
 #include <runtime/ExceptionHelpers.h>
 #include <runtime/JSLock.h>
+#include <runtime/VMEntryScope.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCountedLeakCounter.h>
 
@@ -123,7 +124,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
         globalObject->setCurrentEvent(event);
 
         VM& vm = globalObject->vm();
-        DynamicGlobalObjectScope globalObjectScope(vm, vm.dynamicGlobalObject ? vm.dynamicGlobalObject : globalObject);
+        VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);
 
         InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(scriptExecutionContext, callType, callData);
 
index 152599c..4696eb5 100644 (file)
@@ -53,7 +53,7 @@ public:
     String functionName() const { return m_debuggerCallFrame->functionName(); }
     JSC::DebuggerCallFrame::Type type() const { return m_debuggerCallFrame->type(); }
     JSC::JSScope* scopeChain() const { return m_debuggerCallFrame->scope(); }
-    JSC::JSGlobalObject* dynamicGlobalObject() const { return m_debuggerCallFrame->dynamicGlobalObject(); }
+    JSC::JSGlobalObject* vmEntryGlobalObject() const { return m_debuggerCallFrame->vmEntryGlobalObject(); }
 
     JSC::JSValue thisValue() const { return m_debuggerCallFrame->thisValue(); }
     JSC::JSValue evaluate(const String& script, JSC::JSValue& exception) const  { return m_debuggerCallFrame->evaluate(script, exception); }
index 8dae951..215577d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -115,7 +116,7 @@ void PageScriptDebugServer::recompileAllJSFunctions(Timer<ScriptDebugServer>*)
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
     // If JavaScript stack is not empty postpone recompilation.
-    if (JSDOMWindow::commonVM()->dynamicGlobalObject)
+    if (JSDOMWindow::commonVM()->entryScope)
         recompileAllJSFunctionsSoon();
     else
         Debugger::recompileAllJSFunctions(JSDOMWindow::commonVM());
index e260e6e..adb5778 100644 (file)
@@ -99,7 +99,7 @@ bool ScriptDebugServer::evaluateBreakpointAction(const ScriptBreakpointAction& b
     DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
     switch (breakpointAction.type) {
     case ScriptBreakpointActionTypeLog: {
-        DOMWindow& window = asJSDOMWindow(debuggerCallFrame->dynamicGlobalObject())->impl();
+        DOMWindow& window = asJSDOMWindow(debuggerCallFrame->vmEntryGlobalObject())->impl();
         if (PageConsole* console = window.pageConsole())
             console->addMessage(JSMessageSource, LogMessageLevel, breakpointAction.data);
         break;
@@ -288,10 +288,10 @@ void ScriptDebugServer::handleExceptionInBreakpointCondition(JSC::ExecState* exe
     reportException(exec, exception);
 }
 
-void ScriptDebugServer::handlePause(Debugger::ReasonForPause, JSGlobalObject* dynamicGlobalObject)
+void ScriptDebugServer::handlePause(Debugger::ReasonForPause, JSGlobalObject* vmEntryGlobalObject)
 {
-    dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause, dynamicGlobalObject);
-    didPause(dynamicGlobalObject);
+    dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause, vmEntryGlobalObject);
+    didPause(vmEntryGlobalObject);
 
     TimerBase::fireTimersInNestedEventLoop();
 
@@ -300,9 +300,10 @@ void ScriptDebugServer::handlePause(Debugger::ReasonForPause, JSGlobalObject* dy
     runEventLoopWhilePaused();
     m_runningNestedMessageLoop = false;
 
-    didContinue(dynamicGlobalObject);
-    dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue, dynamicGlobalObject);
+    didContinue(vmEntryGlobalObject);
+    dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue, vmEntryGlobalObject);
 }
+
 void ScriptDebugServer::recompileAllJSFunctionsSoon()
 {
     m_recompileTimer.startOneShot(0);
index 5c3a74c..b417f43 100644 (file)
@@ -67,7 +67,7 @@ void WorkerScriptDebugServer::recompileAllJSFunctions(Timer<ScriptDebugServer>*)
 
     JSC::JSLockHolder lock(vm);
     // If JavaScript stack is not empty postpone recompilation.
-    if (vm->dynamicGlobalObject)
+    if (vm->entryScope)
         recompileAllJSFunctionsSoon();
     else
         JSC::Debugger::recompileAllJSFunctions(vm);
index fb58e94..e324c63 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -124,7 +124,7 @@ id createJSWrapper(JSC::JSObject* object, PassRefPtr<JSC::Bindings::RootObject>
 
 static void addExceptionToConsole(ExecState* exec)
 {
-    JSDOMWindow* window = asJSDOMWindow(exec->dynamicGlobalObject());
+    JSDOMWindow* window = asJSDOMWindow(exec->vmEntryGlobalObject());
     if (!window || !exec->hadException())
         return;
     reportCurrentException(exec);
index eba1102..8c5f473 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2006, 2013 Apple Computer, Inc.  All rights reserved.
  * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -94,7 +94,7 @@ void convertValueToNPVariant(ExecState* exec, JSValue value, NPVariant* result)
                 OBJECT_TO_NPVARIANT(obj, *result);
             }
         } else {
-            JSGlobalObject* globalObject = exec->dynamicGlobalObject();
+            JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
 
             RootObject* rootObject = findRootObject(globalObject);
             if (rootObject) {
index d44e92b..d1d37f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2008, 2009, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -92,7 +92,7 @@ void ObjcInstance::moveGlobalExceptionToExecState(ExecState* exec)
         return;
     }
 
-    if (!s_exceptionEnvironment || s_exceptionEnvironment == exec->dynamicGlobalObject()) {
+    if (!s_exceptionEnvironment || s_exceptionEnvironment == exec->vmEntryGlobalObject()) {
         JSLockHolder lock(exec);
         throwError(exec, s_exception);
     }
index 7dd12c2..1cde373 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2008, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -113,7 +113,7 @@ JSValue ObjcField::valueFromInstance(ExecState* exec, const Instance* instance)
 
 static id convertValueToObjcObject(ExecState* exec, JSValue value)
 {
-    RefPtr<RootObject> rootObject = findRootObject(exec->dynamicGlobalObject());
+    RefPtr<RootObject> rootObject = findRootObject(exec->vmEntryGlobalObject());
     if (!rootObject)
         return nil;
     return [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:rootObject.get() rootObject:rootObject.get()];
index 2c4fb1e..e48c39a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004, 2013 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -88,7 +88,7 @@ ObjcValue convertValueToObjcValue(ExecState* exec, JSValue value, ObjcValueType
         case ObjcObjectType: {
             JSLockHolder lock(exec);
             
-            JSGlobalObject *originGlobalObject = exec->dynamicGlobalObject();
+            JSGlobalObject *originGlobalObject = exec->vmEntryGlobalObject();
             RootObject* originRootObject = findRootObject(originGlobalObject);
 
             JSGlobalObject* globalObject = 0;
index 2fdfa2b..993dff4 100644 (file)
@@ -1,3 +1,13 @@
+2013-11-20  Mark Lam  <mark.lam@apple.com>
+
+        Introducing VMEntryScope to update the VM stack limit.
+        https://bugs.webkit.org/show_bug.cgi?id=124634.
+
+        Reviewed by Geoffrey Garen.
+
+        * WebView/WebScriptDebugger.mm:
+        (WebScriptDebugger::sourceParsed):
+
 2013-11-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         Enable HTMLTemplateElement on Mac port
index be5a5d5..295d00d 100644 (file)
@@ -92,7 +92,7 @@ void WebScriptDebugger::sourceParsed(ExecState* exec, SourceProvider* sourceProv
     NSURL *nsURL = toNSURL(sourceProvider->url());
     int firstLine = sourceProvider->startPosition().m_line.oneBasedInt();
 
-    WebFrame *webFrame = toWebFrame(exec->dynamicGlobalObject());
+    WebFrame *webFrame = toWebFrame(exec->vmEntryGlobalObject());
     WebView *webView = [webFrame webView];
     WebScriptDebugDelegateImplementationCache* implementations = WebViewGetScriptDebugDelegateImplementations(webView);