Ignore:
Timestamp:
Oct 22, 2019, 2:23:26 PM (6 years ago)
Author:
[email protected]
Message:

[JSC] Remove non-LargeAllocation restriction for JSCallee
https://bugs.webkit.org/show_bug.cgi?id=203260

Reviewed by Saam Barati.

Source/JavaScriptCore:

We now pass JSGlobalObject* instead of ExecState*. And we are getting VM& from JSGlobalObject*.
Because now accessing ExecState::vm() becomes less frequent, we can remove the restriction that
callee is only allocated in non-LargeAllocation, which restriction made ExecState::vm fast.

This patch renames CallFrame::vm to CallFrame::deprecatedVM. And we avoid using it as much as possible.
And we also remove the restriction that callee needs to be in non-LargeAllocation.

  • API/JSContextRef.cpp:

(JSContextCreateBacktrace):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::noticeIncomingCall):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::deprecatedVMEntryGlobalObject const):
(JSC::DebuggerCallFrame::functionName const):
(JSC::DebuggerCallFrame::scope):
(JSC::DebuggerCallFrame::type const):
(JSC::DebuggerCallFrame::evaluateWithScopeExtension):
(JSC::DebuggerCallFrame::positionForCallFrame):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::executeOSRExit):
(JSC::DFG::OSRExit::compileOSRExit):
(JSC::DFG::OSRExit::debugOperationPrintSpeculationFailure):

  • dfg/DFGOperations.cpp:
  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileFTLOSRExit):

  • ftl/FTLOperations.cpp:

(JSC::FTL::compileFTLLazySlowPath):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):

  • inspector/ScriptCallStackFactory.cpp:

(Inspector::createScriptCallStack):
(Inspector::createScriptCallStackForConsole):

  • interpreter/CallFrame.cpp:

(JSC::CallFrame::callerSourceOrigin):
(JSC::CallFrame::friendlyFunctionName):

  • interpreter/CallFrame.h:

(JSC::CallFrame::iterate):

  • interpreter/Interpreter.cpp:

(JSC::sizeOfVarargs):
(JSC::sizeFrameForVarargs):
(JSC::Interpreter::getStackTrace):
(JSC::Interpreter::unwind):
(JSC::Interpreter::notifyDebuggerOfExceptionToBeThrown):
(JSC::Interpreter::debug):

  • interpreter/Interpreter.h:
  • interpreter/ShadowChicken.cpp:

(JSC::ShadowChicken::update):

  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::StackVisitor):
(JSC::StackVisitor::Frame::functionName const):

  • interpreter/StackVisitor.h:

(JSC::StackVisitor::visit):

  • jit/HostCallReturnValue.cpp:

(JSC::getHostCallReturnValueWithExecState):

  • jit/JITOperations.cpp:
  • jit/Repatch.cpp:

(JSC::linkFor):
(JSC::linkPolymorphicCall):

  • jit/Repatch.h:
  • jsc.cpp:

(functionJSCStack):
(functionRunString):
(functionLoadString):
(functionCallerSourceOrigin):
(functionCallerIsOMGCompiled):
(functionDollarEvalScript):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/Error.cpp:

(JSC::getBytecodeOffset):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

  • runtime/JSCellInlines.h:

(JSC::CallFrame::deprecatedVM const):
(JSC::CallFrame::vm const): Deleted.

  • runtime/JSFunction.cpp:

(JSC::retrieveArguments):
(JSC::JSFunction::argumentsGetter):
(JSC::retrieveCallerFunction):
(JSC::JSFunction::callerGetter):
(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGlobalObject.cpp:

(JSC::assertCall):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):
(JSC::globalFuncImportModule):

  • runtime/NullSetterFunction.cpp:

(JSC::callerIsStrict):
(JSC::NullSetterFunctionInternal::callReturnUndefined):

  • tools/JSDollarVM.cpp:

(IGNORE_WARNINGS_BEGIN):
(JSC::functionLLintTrue):
(JSC::functionJITTrue):
(JSC::functionDumpRegisters):
(JSC::functionShadowChickenFunctionsOnStack):

  • tools/VMInspector.cpp:

(JSC::VMInspector::codeBlockForFrame):
(JSC::VMInspector::dumpCallFrame):
(JSC::VMInspector::dumpRegisters):
(JSC::VMInspector::dumpStack):

  • wasm/js/WasmToJS.cpp:

(JSC::Wasm::wasmToJS):

Source/WebCore:

Passing VM& instead of calling CallFrame::vm.

  • bindings/js/JSDOMGlobalObject.cpp:

(WebCore::callerGlobalObject):

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::responsibleDocument):

  • bindings/js/JSDOMWindowBase.h:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateCallWith):

  • testing/Internals.cpp:

(WebCore::Internals::parserMetaData):

Location:
trunk/Source/JavaScriptCore/interpreter
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r251425 r251457  
    234234}
    235235
    236 SourceOrigin CallFrame::callerSourceOrigin()
     236SourceOrigin CallFrame::callerSourceOrigin(VM& vm)
    237237{
    238238    RELEASE_ASSERT(callee().isCell());
    239     VM* vm = &this->vm();
    240239    SourceOrigin sourceOrigin;
    241240    bool haveSkippedFirstFrame = false;
     
    293292    case FunctionCode:
    294293        if (jsCallee())
    295             return getCalculatedDisplayName(vm(), jsCallee());
     294            return getCalculatedDisplayName(codeBlock->vm(), jsCallee());
    296295        return emptyString();
    297296    }
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r251425 r251457  
    137137        JSGlobalObject* lexicalGlobalObject() const;
    138138
    139         VM& vm() const;
     139        // FIXME: Remove this function
     140        // https://bugs.webkit.org/show_bug.cgi?id=203272
     141        VM& deprecatedVM() const;
    140142
    141143        static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); }
     
    152154        JS_EXPORT_PRIVATE CallFrame* callerFrame(EntryFrame*&) const;
    153155
    154         JS_EXPORT_PRIVATE SourceOrigin callerSourceOrigin();
     156        JS_EXPORT_PRIVATE SourceOrigin callerSourceOrigin(VM&);
    155157
    156158        static ptrdiff_t callerFrameOffset() { return OBJECT_OFFSETOF(CallerFrameAndPC, callerFrame); }
     
    281283        // receiver. We should always be using StackVisitor directly.
    282284        // It's only valid to call this from a non-wasm top frame.
    283         template <StackVisitor::EmptyEntryFrameAction action = StackVisitor::ContinueIfTopEntryFrameIsEmpty, typename Functor> void iterate(const Functor& functor)
    284         {
    285             VM* vm;
     285        template <StackVisitor::EmptyEntryFrameAction action = StackVisitor::ContinueIfTopEntryFrameIsEmpty, typename Functor> void iterate(VM& vm, const Functor& functor)
     286        {
    286287            void* rawThis = this;
    287             if (!!rawThis) {
     288            if (!!rawThis)
    288289                RELEASE_ASSERT(callee().isCell());
    289                 vm = &this->vm();
    290             } else
    291                 vm = nullptr;
    292290            StackVisitor::visit<action, Functor>(this, vm, functor);
    293291        }
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r251425 r251457  
    177177}
    178178
    179 unsigned sizeOfVarargs(JSGlobalObject* globalObject, CallFrame* callFrame, JSValue arguments, uint32_t firstVarArgOffset)
    180 {
    181     VM& vm = callFrame->vm();
     179unsigned sizeOfVarargs(JSGlobalObject* globalObject, JSValue arguments, uint32_t firstVarArgOffset)
     180{
     181    VM& vm = globalObject->vm();
    182182    auto scope = DECLARE_THROW_SCOPE(vm);
    183183
     
    242242    auto scope = DECLARE_THROW_SCOPE(vm);
    243243
    244     unsigned length = sizeOfVarargs(globalObject, callFrame, arguments, firstVarArgOffset);
     244    unsigned length = sizeOfVarargs(globalObject, arguments, firstVarArgOffset);
    245245    RETURN_IF_EXCEPTION(scope, 0);
    246246
     
    441441    size_t framesCount = 0;
    442442    size_t maxFramesCountNeeded = maxStackSize + framesToSkip;
    443     StackVisitor::visit(callFrame, &vm, [&] (StackVisitor&) -> StackVisitor::Status {
     443    StackVisitor::visit(callFrame, vm, [&] (StackVisitor&) -> StackVisitor::Status {
    444444        if (++framesCount < maxFramesCountNeeded)
    445445            return StackVisitor::Continue;
     
    453453
    454454    GetStackTraceFunctor functor(vm, owner, results, framesToSkip, framesCount);
    455     StackVisitor::visit(callFrame, &vm, functor);
     455    StackVisitor::visit(callFrame, vm, functor);
    456456    ASSERT(results.size() == results.capacity());
    457457}
     
    628628    HandlerInfo* handler = nullptr;
    629629    UnwindFunctor functor(vm, callFrame, isTerminatedExecutionException(vm, exception), codeBlock, handler);
    630     StackVisitor::visit<StackVisitor::TerminateIfTopEntryFrameIsEmpty>(callFrame, &vm, functor);
     630    StackVisitor::visit<StackVisitor::TerminateIfTopEntryFrameIsEmpty>(callFrame, vm, functor);
    631631    if (!handler)
    632632        return nullptr;
     
    650650        else {
    651651            GetCatchHandlerFunctor functor;
    652             StackVisitor::visit(callFrame, &vm, functor);
     652            StackVisitor::visit(callFrame, vm, functor);
    653653            HandlerInfo* handler = functor.handler();
    654654            ASSERT(!handler || handler->isCatchHandler());
     
    12151215NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookType debugHookType)
    12161216{
    1217     VM& vm = callFrame->vm();
     1217    VM& vm = callFrame->deprecatedVM();
    12181218    auto scope = DECLARE_CATCH_SCOPE(vm);
    12191219    Debugger* debugger = callFrame->lexicalGlobalObject()->debugger();
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.h

    r251425 r251457  
    168168    }
    169169
    170     unsigned sizeOfVarargs(JSGlobalObject*, CallFrame*, JSValue arguments, uint32_t firstVarArgOffset);
     170    unsigned sizeOfVarargs(JSGlobalObject*, JSValue arguments, uint32_t firstVarArgOffset);
    171171    static constexpr unsigned maxArguments = 0x10000;
    172172    unsigned sizeFrameForVarargs(JSGlobalObject*, CallFrame*, VM&, JSValue arguments, unsigned numUsedStackSlots, uint32_t firstVarArgOffset);
  • trunk/Source/JavaScriptCore/interpreter/ShadowChicken.cpp

    r251425 r251457  
    174174        Vector<Frame> stackRightNow;
    175175        StackVisitor::visit(
    176             callFrame, &vm, [&] (StackVisitor& visitor) -> StackVisitor::Status {
     176            callFrame, vm, [&] (StackVisitor& visitor) -> StackVisitor::Status {
    177177                if (visitor->isInlinedFrame())
    178178                    return StackVisitor::Continue;
     
    295295    Vector<Frame> toPush;
    296296    StackVisitor::visit(
    297         callFrame, &vm, [&] (StackVisitor& visitor) -> StackVisitor::Status {
     297        callFrame, vm, [&] (StackVisitor& visitor) -> StackVisitor::Status {
    298298            if (visitor->isInlinedFrame()) {
    299299                // FIXME: Handle inlining.
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r251425 r251457  
    4040namespace JSC {
    4141
    42 StackVisitor::StackVisitor(CallFrame* startFrame, VM* vm)
     42StackVisitor::StackVisitor(CallFrame* startFrame, VM& vm)
    4343{
    4444    m_frame.m_index = 0;
     
    4646    CallFrame* topFrame;
    4747    if (startFrame) {
    48         ASSERT(vm);
    49         ASSERT(!vm->topCallFrame || reinterpret_cast<void*>(vm->topCallFrame) != vm->topEntryFrame);
    50 
    51         m_frame.m_entryFrame = vm->topEntryFrame;
    52         topFrame = vm->topCallFrame;
     48        ASSERT(!vm.topCallFrame || reinterpret_cast<void*>(vm.topCallFrame) != vm.topEntryFrame);
     49
     50        m_frame.m_entryFrame = vm.topEntryFrame;
     51        topFrame = vm.topCallFrame;
    5352
    5453        if (topFrame && topFrame->isStackOverflowFrame()) {
    5554            topFrame = topFrame->callerFrame(m_frame.m_entryFrame);
    56             m_topEntryFrameIsEmpty = (m_frame.m_entryFrame != vm->topEntryFrame);
    57             if (startFrame == vm->topCallFrame)
     55            m_topEntryFrameIsEmpty = (m_frame.m_entryFrame != vm.topEntryFrame);
     56            if (startFrame == vm.topCallFrame)
    5857                startFrame = topFrame;
    5958        }
     
    304303        JSCell* callee = this->callee().asCell();
    305304        if (callee)
    306             traceLine = getCalculatedDisplayName(callFrame()->vm(), jsCast<JSObject*>(callee)).impl();
     305            traceLine = getCalculatedDisplayName(callFrame()->deprecatedVM(), jsCast<JSObject*>(callee)).impl();
    307306        break;
    308307    }
    309308    case CodeType::Function:
    310         traceLine = getCalculatedDisplayName(callFrame()->vm(), jsCast<JSObject*>(this->callee().asCell())).impl();
     309        traceLine = getCalculatedDisplayName(callFrame()->deprecatedVM(), jsCast<JSObject*>(this->callee().asCell())).impl();
    311310        break;
    312311    case CodeType::Global:
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.h

    r251425 r251457  
    143143
    144144    template <EmptyEntryFrameAction action = ContinueIfTopEntryFrameIsEmpty, typename Functor>
    145     static void visit(CallFrame* startFrame, VM* vm, const Functor& functor)
     145    static void visit(CallFrame* startFrame, VM& vm, const Functor& functor)
    146146    {
    147147        StackVisitor visitor(startFrame, vm);
     
    163163
    164164private:
    165     JS_EXPORT_PRIVATE StackVisitor(CallFrame* startFrame, VM*);
     165    JS_EXPORT_PRIVATE StackVisitor(CallFrame* startFrame, VM&);
    166166
    167167    JS_EXPORT_PRIVATE void gotoNextFrame();
Note: See TracChangeset for help on using the changeset viewer.