Ignore:
Timestamp:
Apr 13, 2022, 2:01:19 PM (3 years ago)
Author:
[email protected]
Message:

[JSC] Remove DeprecatedCallFrameForDebugger
https://bugs.webkit.org/show_bug.cgi?id=239045

Reviewed by Devin Rousso.

We should not enlarge sizeof(JSGlobalObject) by having DeprecatedCallFrameForDebugger which is only used for Debugger, and it is used
only when we have an error when evaluating top-level SyntaxError. This patch removes it: we introduce EmptyTopLevelCallFrameForDebugger
which can be constructed on stack and we use it instead of DeprecatedCallFrameForDebugger.

  • Source/JavaScriptCore/debugger/Debugger.cpp:

(JSC::Debugger::updateCallFrame):
(JSC::EmptyTopLevelCallFrameForDebugger::EmptyTopLevelCallFrameForDebugger):
(JSC::EmptyTopLevelCallFrameForDebugger::asCallFrame):
(JSC::Debugger::exception):

  • Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::create):
(JSC::DebuggerCallFrame::positionForCallFrame):

  • Source/JavaScriptCore/interpreter/CallFrame.cpp:

(JSC::CallFrame::convertToStackOverflowFrame):
(JSC::CallFrame::initDeprecatedCallFrameForDebugger): Deleted.

  • Source/JavaScriptCore/interpreter/CallFrame.h:

(JSC::CallFrame::isEmptyTopLevelCallFrameForDebugger const):
(JSC::CallFrame::isDeprecatedCallFrameForDebugger const): Deleted.

  • Source/JavaScriptCore/interpreter/Interpreter.cpp:

(JSC::Interpreter::notifyDebuggerOfExceptionToBeThrown):

  • Source/JavaScriptCore/runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::deprecatedCallFrameForDebugger): Deleted.

  • Source/JavaScriptCore/runtime/JSGlobalObject.h:
  • Source/JavaScriptCore/runtime/VM.cpp:

(JSC::VM::throwException):

Canonical link: https://commits.webkit.org/249603@main

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r292075 r292830  
    10361036}
    10371037
     1038class EmptyTopLevelCallFrameForDebugger {
     1039public:
     1040    EmptyTopLevelCallFrameForDebugger(JSGlobalObject* globalObject)
     1041    {
     1042        CallFrame* callFrame = asCallFrame();
     1043        callFrame->setCodeBlock(nullptr);
     1044        callFrame->setCallerFrame(CallFrame::noCaller());
     1045        callFrame->setReturnPC(nullptr);
     1046        callFrame->setArgumentCountIncludingThis(1);
     1047        callFrame->setThisValue(globalObject->globalThis());
     1048        callFrame->setCallee(globalObject->globalCallee());
     1049        ASSERT(callFrame->isEmptyTopLevelCallFrameForDebugger());
     1050    }
     1051
     1052    CallFrame* asCallFrame() { return CallFrame::create(m_values); }
     1053
     1054private:
     1055    Register m_values[CallFrame::headerSizeInRegisters + /* thisValue */ 1] { };
     1056};
     1057
    10381058void Debugger::exception(JSGlobalObject* globalObject, CallFrame* callFrame, JSValue exception, bool hasCatchHandler)
    10391059{
     
    10571077    }
    10581078
     1079    // When callFrame is nullptr, we are throwing an error without JS call frames.
     1080    // This can happen when program throws SyntaxError without evaluation.
     1081    EmptyTopLevelCallFrameForDebugger emptyCallFrame(globalObject);
     1082    bool callFrameWasNull = !callFrame;
     1083    if (callFrameWasNull)
     1084        callFrame = emptyCallFrame.asCallFrame();
     1085
    10591086    m_hasHandlerForExceptionCallback = true;
    10601087    m_currentException = exception;
     
    10621089    m_currentException = JSValue();
    10631090    m_hasHandlerForExceptionCallback = false;
     1091
     1092    if (callFrameWasNull)
     1093        m_currentCallFrame = nullptr;
    10641094}
    10651095
Note: See TracChangeset for help on using the changeset viewer.