[JSC] Remove wasmAwareLexicalGlobalObject
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2019 05:34:21 +0000 (05:34 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2019 05:34:21 +0000 (05:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203351

Reviewed by Mark Lam.

Source/JavaScriptCore:

CallFrame::lexicalGlobalObject() is no longer called frequently. We can just make the current wasmAwareLexicalGlobalObject as CallFrame::lexicalGlobalObject,
and remove wasmAwareLexicalGlobalObject function.

* debugger/Debugger.cpp:
(JSC::Debugger::hasBreakpoint):
(JSC::Debugger::breakProgram):
(JSC::lexicalGlobalObjectForCallFrame):
* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::deprecatedVMEntryGlobalObject const):
(JSC::DebuggerCallFrame::scope):
(JSC::DebuggerCallFrame::thisValue const):
(JSC::DebuggerCallFrame::evaluateWithScopeExtension):
* debugger/DebuggerCallFrame.h:
* inspector/JSJavaScriptCallFrame.cpp:
(Inspector::JSJavaScriptCallFrame::thisObject const):
* inspector/JavaScriptCallFrame.h:
(Inspector::JavaScriptCallFrame::thisValue const):
* interpreter/CallFrame.cpp:
(JSC::CallFrame::lexicalGlobalObjectFromWasmCallee const):
(JSC::CallFrame::wasmAwareLexicalGlobalObject): Deleted.
* interpreter/CallFrame.h:
* interpreter/Interpreter.cpp:
(JSC::notifyDebuggerOfUnwinding):
(JSC::Interpreter::debug):
* interpreter/StackVisitor.cpp:
(JSC::StackVisitor::Frame::createArguments):
* interpreter/StackVisitor.h:
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::llint_throw_stack_overflow_error):
* runtime/JSFunction.cpp:
(JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor):
(JSC::RetrieveArgumentsFunctor::operator() const):
(JSC::retrieveArguments):
* runtime/JSScope.h:
(JSC::CallFrame::lexicalGlobalObject const):
* runtime/RegExpInlines.h:
(JSC::RegExp::matchInline):
* wasm/js/WasmToJS.cpp:
(JSC::Wasm::wasmToJS):

Source/WebCore:

* bindings/js/CommonVM.cpp:
(WebCore::lexicalFrameFromCommonVM):
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::responsibleDocument):
* bindings/js/StructuredClone.cpp:
(WebCore::cloneArrayBufferImpl):
* dom/Document.cpp:
(WebCore::Document::shouldBypassMainWorldContentSecurityPolicy const):
* testing/Internals.cpp:
(WebCore::Internals::parserMetaData):
(WebCore::Internals::isFromCurrentWorld const):

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

22 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/debugger/Debugger.cpp
Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
Source/JavaScriptCore/debugger/DebuggerCallFrame.h
Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp
Source/JavaScriptCore/inspector/JavaScriptCallFrame.h
Source/JavaScriptCore/interpreter/CallFrame.cpp
Source/JavaScriptCore/interpreter/CallFrame.h
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/interpreter/StackVisitor.cpp
Source/JavaScriptCore/interpreter/StackVisitor.h
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/JSScope.h
Source/JavaScriptCore/runtime/RegExpInlines.h
Source/JavaScriptCore/wasm/js/WasmToJS.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/CommonVM.cpp
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/StructuredClone.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/testing/Internals.cpp

index 46768bc..cc8459e 100644 (file)
@@ -1,3 +1,50 @@
+2019-10-23  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        [JSC] Remove wasmAwareLexicalGlobalObject
+        https://bugs.webkit.org/show_bug.cgi?id=203351
+
+        Reviewed by Mark Lam.
+
+        CallFrame::lexicalGlobalObject() is no longer called frequently. We can just make the current wasmAwareLexicalGlobalObject as CallFrame::lexicalGlobalObject,
+        and remove wasmAwareLexicalGlobalObject function.
+
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::hasBreakpoint):
+        (JSC::Debugger::breakProgram):
+        (JSC::lexicalGlobalObjectForCallFrame):
+        * debugger/DebuggerCallFrame.cpp:
+        (JSC::DebuggerCallFrame::deprecatedVMEntryGlobalObject const):
+        (JSC::DebuggerCallFrame::scope):
+        (JSC::DebuggerCallFrame::thisValue const):
+        (JSC::DebuggerCallFrame::evaluateWithScopeExtension):
+        * debugger/DebuggerCallFrame.h:
+        * inspector/JSJavaScriptCallFrame.cpp:
+        (Inspector::JSJavaScriptCallFrame::thisObject const):
+        * inspector/JavaScriptCallFrame.h:
+        (Inspector::JavaScriptCallFrame::thisValue const):
+        * interpreter/CallFrame.cpp:
+        (JSC::CallFrame::lexicalGlobalObjectFromWasmCallee const):
+        (JSC::CallFrame::wasmAwareLexicalGlobalObject): Deleted.
+        * interpreter/CallFrame.h:
+        * interpreter/Interpreter.cpp:
+        (JSC::notifyDebuggerOfUnwinding):
+        (JSC::Interpreter::debug):
+        * interpreter/StackVisitor.cpp:
+        (JSC::StackVisitor::Frame::createArguments):
+        * interpreter/StackVisitor.h:
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::llint_throw_stack_overflow_error):
+        * runtime/JSFunction.cpp:
+        (JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor):
+        (JSC::RetrieveArgumentsFunctor::operator() const):
+        (JSC::retrieveArguments):
+        * runtime/JSScope.h:
+        (JSC::CallFrame::lexicalGlobalObject const):
+        * runtime/RegExpInlines.h:
+        (JSC::RegExp::matchInline):
+        * wasm/js/WasmToJS.cpp:
+        (JSC::Wasm::wasmToJS):
+
 2019-10-23  Keith Miller  <keith_miller@apple.com>
 
         Undo incidental change from BytecodeIndex class patch
index cdd195f..dda6d05 100644 (file)
@@ -525,7 +525,7 @@ bool Debugger::hasBreakpoint(SourceID sourceID, const TextPosition& position, Br
     if (!m_currentCallFrame)
         return false;
 
-    JSGlobalObject* globalObject = m_currentCallFrame->lexicalGlobalObject();
+    JSGlobalObject* globalObject = m_currentCallFrame->lexicalGlobalObject(m_vm);
     if (exception) {
         // An erroneous condition counts as "false".
         handleExceptionInBreakpointCondition(globalObject, exception);
@@ -626,7 +626,7 @@ void Debugger::breakProgram()
     m_pauseAtNextOpportunity = true;
     setSteppingMode(SteppingModeEnabled);
     m_currentCallFrame = m_vm.topCallFrame;
-    pauseIfNeeded(m_currentCallFrame->lexicalGlobalObject());
+    pauseIfNeeded(m_currentCallFrame->lexicalGlobalObject(m_vm));
 }
 
 void Debugger::continueProgram()
@@ -675,7 +675,7 @@ static inline JSGlobalObject* lexicalGlobalObjectForCallFrame(VM& vm, CallFrame*
 {
     if (!callFrame)
         return nullptr;
-    return callFrame->wasmAwareLexicalGlobalObject(vm);
+    return callFrame->lexicalGlobalObject(vm);
 }
 
 void Debugger::updateCallFrame(JSGlobalObject* globalObject, CallFrame* callFrame, CallFrameUpdateAction action)
index 2ce72e8..015d19e 100644 (file)
@@ -125,7 +125,7 @@ JSC::JSGlobalObject* DebuggerCallFrame::deprecatedVMEntryGlobalObject() const
     if (!isValid())
         return nullptr;
     VM& vm = m_validMachineFrame->deprecatedVM();
-    return vm.deprecatedVMEntryGlobalObject(m_validMachineFrame->wasmAwareLexicalGlobalObject(vm));
+    return vm.deprecatedVMEntryGlobalObject(m_validMachineFrame->lexicalGlobalObject(vm));
 }
 
 SourceID DebuggerCallFrame::sourceID() const
@@ -171,7 +171,7 @@ DebuggerScope* DebuggerCallFrame::scope()
         else if (JSCallee* callee = jsDynamicCast<JSCallee*>(vm, m_validMachineFrame->jsCallee()))
             scope = callee->scope();
         else
-            scope = m_validMachineFrame->lexicalGlobalObject()->globalLexicalEnvironment();
+            scope = m_validMachineFrame->lexicalGlobalObject(vm)->globalLexicalEnvironment();
 
         m_scope.set(vm, DebuggerScope::create(vm, scope));
     }
@@ -193,7 +193,7 @@ DebuggerCallFrame::Type DebuggerCallFrame::type() const
     return ProgramType;
 }
 
-JSValue DebuggerCallFrame::thisValue() const
+JSValue DebuggerCallFrame::thisValue(VM& vm) const
 {
     ASSERT(isValid());
     if (!isValid())
@@ -215,7 +215,7 @@ JSValue DebuggerCallFrame::thisValue() const
     ECMAMode ecmaMode = NotStrictMode;
     if (codeBlock && codeBlock->isStrictMode())
         ecmaMode = StrictMode;
-    return thisValue.toThis(m_validMachineFrame->lexicalGlobalObject(), ecmaMode);
+    return thisValue.toThis(m_validMachineFrame->lexicalGlobalObject(vm), ecmaMode);
 }
 
 // Evaluate some JavaScript code in the scope of this frame.
@@ -265,7 +265,7 @@ JSValue DebuggerCallFrame::evaluateWithScopeExtension(const String& script, JSOb
         globalObject->setGlobalScopeExtension(JSWithScope::create(vm, globalObject, ignoredPreviousScope, scopeExtensionObject));
     }
 
-    JSValue thisValue = this->thisValue();
+    JSValue thisValue = this->thisValue(vm);
     JSValue result = vm.interpreter->execute(eval, globalObject, thisValue, scope()->jsScope());
     if (UNLIKELY(catchScope.exception())) {
         exception = catchScope.exception();
index 10fe318..ac6ecd3 100644 (file)
@@ -60,7 +60,7 @@ public:
     JS_EXPORT_PRIVATE DebuggerScope* scope();
     JS_EXPORT_PRIVATE String functionName() const;
     JS_EXPORT_PRIVATE Type type() const;
-    JS_EXPORT_PRIVATE JSValue thisValue() const;
+    JS_EXPORT_PRIVATE JSValue thisValue(VM&) const;
     JSValue evaluateWithScopeExtension(const String&, JSObject* scopeExtensionObject, NakedPtr<Exception>&);
 
     bool isValid() const { return !!m_validMachineFrame || isTailDeleted(); }
index 042d79b..5fefe98 100644 (file)
@@ -206,9 +206,9 @@ JSValue JSJavaScriptCallFrame::scopeChain(JSGlobalObject* globalObject) const
     return constructArray(this->globalObject(vm), static_cast<ArrayAllocationProfile*>(nullptr), list);
 }
 
-JSValue JSJavaScriptCallFrame::thisObject(JSGlobalObject*) const
+JSValue JSJavaScriptCallFrame::thisObject(JSGlobalObject* globalObject) const
 {
-    return impl().thisValue();
+    return impl().thisValue(globalObject->vm());
 }
 
 JSValue JSJavaScriptCallFrame::isTailDeleted(JSC::JSGlobalObject*) const
index 5334d21..ac8d368 100644 (file)
@@ -52,7 +52,7 @@ public:
     JSC::JSGlobalObject* deprecatedVMEntryGlobalObject() const { return m_debuggerCallFrame->deprecatedVMEntryGlobalObject(); }
     bool isTailDeleted() const { return m_debuggerCallFrame->isTailDeleted(); }
 
-    JSC::JSValue thisValue() const { return m_debuggerCallFrame->thisValue(); }
+    JSC::JSValue thisValue(VM& vm) const { return m_debuggerCallFrame->thisValue(vm); }
     JSC::JSValue evaluateWithScopeExtension(const String& script, JSC::JSObject* scopeExtension, NakedPtr<JSC::Exception>& exception) const { return m_debuggerCallFrame->evaluateWithScopeExtension(script, scopeExtension, exception); }
 
 private:
index 672b268..be098a1 100644 (file)
@@ -190,18 +190,6 @@ Register* CallFrame::topOfFrameInternal()
     return registers() + codeBlock->stackPointerOffset();
 }
 
-JSGlobalObject* CallFrame::wasmAwareLexicalGlobalObject(VM& vm)
-{
-#if ENABLE(WEBASSEMBLY)
-    if (!callee().isWasm())
-        return lexicalGlobalObject();
-    return vm.wasmContext.load()->owner<JSWebAssemblyInstance>()->globalObject();
-#else
-    UNUSED_PARAM(vm);
-    return lexicalGlobalObject();
-#endif
-}
-
 bool CallFrame::isAnyWasmCallee()
 {
     CalleeBits callee = this->callee();
@@ -357,6 +345,13 @@ void CallFrame::convertToStackOverflowFrame(VM& vm, CodeBlock* codeBlockToKeepAl
     setArgumentCountIncludingThis(0);
 }
 
+#if ENABLE(WEBASSEMBLY)
+JSGlobalObject* CallFrame::lexicalGlobalObjectFromWasmCallee(VM& vm) const
+{
+    return vm.wasmContext.load()->owner<JSWebAssemblyInstance>()->globalObject();
+}
+#endif
+
 bool isFromJSCode(void* returnAddress)
 {
     UNUSED_PARAM(returnAddress);
index 10edfb0..31c9bff 100644 (file)
@@ -125,13 +125,11 @@ namespace JSC  {
             return this[scopeRegisterOffset].Register::scope();
         }
 
-        JSGlobalObject* wasmAwareLexicalGlobalObject(VM&);
-
         JS_EXPORT_PRIVATE bool isAnyWasmCallee();
 
         // Global object in which the currently executing code was defined.
         // Differs from VM::deprecatedVMEntryGlobalObject() during function calls across web browser frames.
-        JSGlobalObject* lexicalGlobalObject() const;
+        JSGlobalObject* lexicalGlobalObject(VM&) const;
 
         // FIXME: Remove this function
         // https://bugs.webkit.org/show_bug.cgi?id=203272
@@ -169,6 +167,9 @@ namespace JSC  {
         CallSiteIndex unsafeCallSiteIndex() const;
     private:
         unsigned callSiteBitsAsBytecodeOffset() const;
+#if ENABLE(WEBASSEMBLY)
+        JS_EXPORT_PRIVATE JSGlobalObject* lexicalGlobalObjectFromWasmCallee(VM&) const;
+#endif
     public:
 
         // This will try to get you the bytecode offset, but you should be aware that
index ff81597..e8673bf 100644 (file)
@@ -515,7 +515,7 @@ private:
 
 ALWAYS_INLINE static void notifyDebuggerOfUnwinding(VM& vm, CallFrame* callFrame)
 {
-    JSGlobalObject* globalObject = callFrame->wasmAwareLexicalGlobalObject(vm);
+    JSGlobalObject* globalObject = callFrame->lexicalGlobalObject(vm);
     auto catchScope = DECLARE_CATCH_SCOPE(vm);
     if (Debugger* debugger = globalObject->debugger()) {
         SuspendExceptionScope scope(&vm);
@@ -1216,7 +1216,7 @@ NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookType debugHo
 {
     VM& vm = callFrame->deprecatedVM();
     auto scope = DECLARE_CATCH_SCOPE(vm);
-    Debugger* debugger = callFrame->lexicalGlobalObject()->debugger();
+    Debugger* debugger = callFrame->lexicalGlobalObject(vm)->debugger();
     if (!debugger)
         return;
 
index c3172f7..a583b48 100644 (file)
@@ -369,13 +369,13 @@ intptr_t StackVisitor::Frame::sourceID()
     return noSourceID;
 }
 
-ClonedArguments* StackVisitor::Frame::createArguments()
+ClonedArguments* StackVisitor::Frame::createArguments(VM& vm)
 {
     ASSERT(m_callFrame);
     CallFrame* physicalFrame = m_callFrame;
     // FIXME: Revisit JSGlobalObject.
     // https://bugs.webkit.org/show_bug.cgi?id=203204
-    JSGlobalObject* globalObject = physicalFrame->lexicalGlobalObject();
+    JSGlobalObject* globalObject = physicalFrame->lexicalGlobalObject(vm);
     ClonedArguments* arguments;
     ArgumentsMode mode;
     if (Options::useFunctionDotArguments())
index d35761f..0c81d1b 100644 (file)
@@ -97,7 +97,7 @@ public:
         Optional<RegisterAtOffsetList> calleeSaveRegistersForUnwinding();
 #endif
 
-        ClonedArguments* createArguments();
+        ClonedArguments* createArguments(VM&);
         CallFrame* callFrame() const { return m_callFrame; }
         
         void dump(PrintStream&, Indenter = Indenter()) const;
index 5798d30..4bd8fae 100644 (file)
@@ -1943,7 +1943,7 @@ extern "C" SlowPathReturnType llint_throw_stack_overflow_error(VM* vm, ProtoCall
 
     JSGlobalObject* globalObject = nullptr;
     if (callFrame)
-        globalObject = callFrame->lexicalGlobalObject();
+        globalObject = callFrame->lexicalGlobalObject(*vm);
     else
         globalObject = protoFrame->callee()->globalObject(*vm);
     throwStackOverflowError(globalObject, scope);
index 04b871e..40a7354 100644 (file)
@@ -271,8 +271,9 @@ CallType JSFunction::getCallData(JSCell* cell, CallData& callData)
 
 class RetrieveArgumentsFunctor {
 public:
-    RetrieveArgumentsFunctor(JSFunction* functionObj)
-        : m_targetCallee(functionObj)
+    RetrieveArgumentsFunctor(VM& vm, JSFunction* functionObj)
+        : m_vm(vm)
+        , m_targetCallee(functionObj)
         , m_result(jsNull())
     {
     }
@@ -288,18 +289,19 @@ public:
         if (callee != m_targetCallee)
             return StackVisitor::Continue;
 
-        m_result = JSValue(visitor->createArguments());
+        m_result = JSValue(visitor->createArguments(m_vm));
         return StackVisitor::Done;
     }
 
 private:
+    VM& m_vm;
     JSObject* m_targetCallee;
     mutable JSValue m_result;
 };
 
 static JSValue retrieveArguments(VM& vm, CallFrame* callFrame, JSFunction* functionObj)
 {
-    RetrieveArgumentsFunctor functor(functionObj);
+    RetrieveArgumentsFunctor functor(vm, functionObj);
     if (callFrame)
         callFrame->iterate(vm, functor);
     return functor.result();
index a9a3efe..090ed75 100644 (file)
@@ -140,8 +140,13 @@ inline JSScope* Register::scope() const
     return jsCast<JSScope*>(unboxedCell());
 }
 
-inline JSGlobalObject* CallFrame::lexicalGlobalObject() const
+inline JSGlobalObject* CallFrame::lexicalGlobalObject(VM& vm) const
 {
+    UNUSED_PARAM(vm);
+#if ENABLE(WEBASSEMBLY)
+    if (callee().isWasm())
+        return lexicalGlobalObjectFromWasmCallee(vm);
+#endif
     return jsCallee()->globalObject();
 }
 
index 8436dec..f7d9190 100644 (file)
@@ -143,7 +143,7 @@ ALWAYS_INLINE int RegExp::matchInline(VM& vm, const String& s, unsigned startOff
         auto throwScope = DECLARE_THROW_SCOPE(vm);
         // FIXME: Revisit JSGlobalObject.
         // https://bugs.webkit.org/show_bug.cgi?id=203204
-        JSGlobalObject* globalObject = vm.topCallFrame->lexicalGlobalObject();
+        JSGlobalObject* globalObject = vm.topCallFrame->lexicalGlobalObject(vm);
         throwScope.throwException(globalObject, errorToThrow(globalObject));
         if (!hasHardError(m_constructionErrorCode))
             reset();
@@ -273,7 +273,7 @@ ALWAYS_INLINE MatchResult RegExp::matchInline(VM& vm, const String& s, unsigned
         auto throwScope = DECLARE_THROW_SCOPE(vm);
         // FIXME: Revisit JSGlobalObject.
         // https://bugs.webkit.org/show_bug.cgi?id=203204
-        JSGlobalObject* globalObject = vm.topCallFrame->lexicalGlobalObject();
+        JSGlobalObject* globalObject = vm.topCallFrame->lexicalGlobalObject(vm);
         throwScope.throwException(globalObject, errorToThrow(globalObject));
         if (!hasHardError(m_constructionErrorCode))
             reset();
index 8674627..98a7874 100644 (file)
@@ -306,7 +306,7 @@ Expected<MacroAssemblerCodeRef<WasmEntryPtrTag>, BindingFailure> wasmToJS(VM& vm
                 // https://bugs.webkit.org/show_bug.cgi?id=203206
                 VM& vm = callFrame->deprecatedVM();
                 NativeCallFrameTracer tracer(vm, callFrame);
-                return v.toInt32(callFrame->lexicalGlobalObject());
+                return v.toInt32(callFrame->lexicalGlobalObject(vm));
             };
 
             slowPath.append(jit.branchIfNotNumber(GPRInfo::returnValueGPR, DoNotHaveTagRegisters));
@@ -340,7 +340,7 @@ Expected<MacroAssemblerCodeRef<WasmEntryPtrTag>, BindingFailure> wasmToJS(VM& vm
                 // https://bugs.webkit.org/show_bug.cgi?id=203206
                 VM& vm = callFrame->deprecatedVM();
                 NativeCallFrameTracer tracer(vm, callFrame);
-                return static_cast<float>(v.toNumber(callFrame->lexicalGlobalObject()));
+                return static_cast<float>(v.toNumber(callFrame->lexicalGlobalObject(vm)));
             };
 
             auto notANumber = jit.branchIfNotNumber(GPRInfo::returnValueGPR, DoNotHaveTagRegisters);
@@ -379,7 +379,7 @@ Expected<MacroAssemblerCodeRef<WasmEntryPtrTag>, BindingFailure> wasmToJS(VM& vm
                 // https://bugs.webkit.org/show_bug.cgi?id=203206
                 VM& vm = callFrame->deprecatedVM();
                 NativeCallFrameTracer tracer(vm, callFrame);
-                return v.toNumber(callFrame->lexicalGlobalObject());
+                return v.toNumber(callFrame->lexicalGlobalObject(vm));
             };
 
             auto notANumber = jit.branchIfNotNumber(GPRInfo::returnValueGPR, DoNotHaveTagRegisters);
index 4990743..b84a948 100644 (file)
@@ -1,3 +1,22 @@
+2019-10-23  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        [JSC] Remove wasmAwareLexicalGlobalObject
+        https://bugs.webkit.org/show_bug.cgi?id=203351
+
+        Reviewed by Mark Lam.
+
+        * bindings/js/CommonVM.cpp:
+        (WebCore::lexicalFrameFromCommonVM):
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::responsibleDocument):
+        * bindings/js/StructuredClone.cpp:
+        (WebCore::cloneArrayBufferImpl):
+        * dom/Document.cpp:
+        (WebCore::Document::shouldBypassMainWorldContentSecurityPolicy const):
+        * testing/Internals.cpp:
+        (WebCore::Internals::parserMetaData):
+        (WebCore::Internals::isFromCurrentWorld const):
+
 2019-10-23  Chris Dumez  <cdumez@apple.com>
 
         Notification should not prevent entering the back/forward cache
index 09b784f..cbf3d0b 100644 (file)
@@ -74,9 +74,10 @@ JSC::VM& commonVMSlow()
 
 Frame* lexicalFrameFromCommonVM()
 {
-    if (auto* topCallFrame = commonVM().topCallFrame) {
-        if (auto* globalObject = JSC::jsCast<JSDOMGlobalObject*>(topCallFrame->lexicalGlobalObject())) {
-            if (auto* window = JSC::jsDynamicCast<JSDOMWindow*>(commonVM(), globalObject)) {
+    JSC::VM& vm = commonVM();
+    if (auto* topCallFrame = vm.topCallFrame) {
+        if (auto* globalObject = JSC::jsCast<JSDOMGlobalObject*>(topCallFrame->lexicalGlobalObject(vm))) {
+            if (auto* window = JSC::jsDynamicCast<JSDOMWindow*>(vm, globalObject)) {
                 if (auto* frame = window->wrapped().frame())
                     return frame;
             }
index 406bab3..dc387d5 100644 (file)
@@ -280,7 +280,7 @@ Document* responsibleDocument(VM& vm, CallFrame& callFrame)
     auto* callerFrame = functor.callerFrame();
     if (!callerFrame)
         return nullptr;
-    return asJSDOMWindow(callerFrame->lexicalGlobalObject())->wrapped().document();
+    return asJSDOMWindow(callerFrame->lexicalGlobalObject(vm))->wrapped().document();
 }
 
 void JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(DOMWindow* window)
index 675f217..985b3db 100644 (file)
@@ -41,11 +41,12 @@ enum class CloneMode {
 
 static EncodedJSValue cloneArrayBufferImpl(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame, CloneMode mode)
 {
+    VM& vm = lexicalGlobalObject->vm();
+
     ASSERT(lexicalGlobalObject);
     ASSERT(callFrame->argumentCount());
-    ASSERT(callFrame->lexicalGlobalObject() == lexicalGlobalObject);
+    ASSERT(callFrame->lexicalGlobalObject(vm) == lexicalGlobalObject);
 
-    VM& vm = lexicalGlobalObject->vm();
     auto* buffer = toUnsharedArrayBuffer(vm, callFrame->uncheckedArgument(0));
     if (!buffer) {
         auto scope = DECLARE_THROW_SCOPE(vm);
index 954aa29..7d00f22 100644 (file)
@@ -2618,8 +2618,9 @@ void Document::resumeDeviceMotionAndOrientationUpdates()
 bool Document::shouldBypassMainWorldContentSecurityPolicy() const
 {
     // Bypass this policy when the world is known, and it not the normal world.
-    auto& callFrame = *commonVM().topCallFrame;
-    return &callFrame != JSC::CallFrame::noCaller() && !currentWorld(*callFrame.lexicalGlobalObject()).isNormal();
+    JSC::VM& vm = commonVM();
+    auto& callFrame = *vm.topCallFrame;
+    return &callFrame != JSC::CallFrame::noCaller() && !currentWorld(*callFrame.lexicalGlobalObject(vm)).isNormal();
 }
 
 void Document::platformSuspendOrStopActiveDOMObjects()
index e4e7ac9..fa5bf61 100644 (file)
@@ -2206,7 +2206,7 @@ String Internals::parserMetaData(JSC::JSValue code)
 {
     JSC::VM& vm = contextDocument()->vm();
     JSC::CallFrame* callFrame = vm.topCallFrame;
-    JSC::JSGlobalObject* globalObject = callFrame->lexicalGlobalObject();
+    JSC::JSGlobalObject* globalObject = callFrame->lexicalGlobalObject(vm);
     ScriptExecutable* executable;
 
     if (!code || code.isNull() || code.isUndefined()) {
@@ -3480,7 +3480,8 @@ Ref<SerializedScriptValue> Internals::deserializeBuffer(ArrayBuffer& buffer) con
 
 bool Internals::isFromCurrentWorld(JSC::JSValue value) const
 {
-    return isWorldCompatible(*contextDocument()->vm().topCallFrame->lexicalGlobalObject(), value);
+    JSC::VM& vm = contextDocument()->vm();
+    return isWorldCompatible(*vm.topCallFrame->lexicalGlobalObject(vm), value);
 }
 
 void Internals::setUsesOverlayScrollbars(bool enabled)