⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 292891 in webkit


Ignore:
Timestamp:
Apr 14, 2022, 2:56:27 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Reduce use of CallFrame::deprecatedVM
https://bugs.webkit.org/show_bug.cgi?id=239326

Reviewed by Devin Rousso.

Reduce use of CallFrame::deprecatedVM, mainly in inspector related code to eventually remove CallFrame::deprecatedVM.

  • Source/JavaScriptCore/debugger/Debugger.cpp:

(JSC::Debugger::evaluateBreakpointCondition):
(JSC::Debugger::evaluateBreakpointActions):
(JSC::Debugger::exceptionOrCaughtValue):

  • Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::globalObject):
(JSC::DebuggerCallFrame::functionName const):
(JSC::DebuggerCallFrame::scope):
(JSC::DebuggerCallFrame::type const):
(JSC::DebuggerCallFrame::evaluateWithScopeExtension):
(JSC::DebuggerCallFrame::deprecatedVMEntryGlobalObject const): Deleted.

  • Source/JavaScriptCore/debugger/DebuggerCallFrame.h:
  • Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp:

(Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):
(Inspector::JSJavaScriptCallFrame::scopeDescriptions):
(Inspector::JSJavaScriptCallFrame::functionName const):
(Inspector::JSJavaScriptCallFrame::scopeChain const):
(Inspector::JSJavaScriptCallFrame::type const):

  • Source/JavaScriptCore/inspector/JavaScriptCallFrame.h:

(Inspector::JavaScriptCallFrame::functionName const):
(Inspector::JavaScriptCallFrame::type const):
(Inspector::JavaScriptCallFrame::scopeChain const):
(Inspector::JavaScriptCallFrame::evaluateWithScopeExtension const):
(Inspector::JavaScriptCallFrame::deprecatedVMEntryGlobalObject const): Deleted.

  • Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp:

(Inspector::InspectorDebuggerAgent::debuggerScopeExtensionObject):
(Inspector::InspectorDebuggerAgent::didPause):

  • Source/JavaScriptCore/interpreter/Interpreter.cpp:

(JSC::Interpreter::debug):

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

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r292886 r292891  
     12022-04-14  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Reduce use of CallFrame::deprecatedVM
     4        https://bugs.webkit.org/show_bug.cgi?id=239326
     5
     6        Reviewed by Devin Rousso.
     7
     8        Reduce use of CallFrame::deprecatedVM, mainly in inspector related code to eventually remove CallFrame::deprecatedVM.
     9
     10        * debugger/Debugger.cpp:
     11        (JSC::Debugger::evaluateBreakpointCondition):
     12        (JSC::Debugger::evaluateBreakpointActions):
     13        (JSC::Debugger::exceptionOrCaughtValue):
     14        * debugger/DebuggerCallFrame.cpp:
     15        (JSC::DebuggerCallFrame::globalObject):
     16        (JSC::DebuggerCallFrame::functionName const):
     17        (JSC::DebuggerCallFrame::scope):
     18        (JSC::DebuggerCallFrame::type const):
     19        (JSC::DebuggerCallFrame::evaluateWithScopeExtension):
     20        (JSC::DebuggerCallFrame::deprecatedVMEntryGlobalObject const): Deleted.
     21        * debugger/DebuggerCallFrame.h:
     22        * inspector/JSJavaScriptCallFrame.cpp:
     23        (Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):
     24        (Inspector::JSJavaScriptCallFrame::scopeDescriptions):
     25        (Inspector::JSJavaScriptCallFrame::functionName const):
     26        (Inspector::JSJavaScriptCallFrame::scopeChain const):
     27        (Inspector::JSJavaScriptCallFrame::type const):
     28        * inspector/JavaScriptCallFrame.h:
     29        (Inspector::JavaScriptCallFrame::functionName const):
     30        (Inspector::JavaScriptCallFrame::type const):
     31        (Inspector::JavaScriptCallFrame::scopeChain const):
     32        (Inspector::JavaScriptCallFrame::evaluateWithScopeExtension const):
     33        (Inspector::JavaScriptCallFrame::deprecatedVMEntryGlobalObject const): Deleted.
     34        * inspector/agents/InspectorDebuggerAgent.cpp:
     35        (Inspector::InspectorDebuggerAgent::debuggerScopeExtensionObject):
     36        (Inspector::InspectorDebuggerAgent::didPause):
     37        * interpreter/Interpreter.cpp:
     38        (JSC::Interpreter::debug):
     39
    1402022-04-14  Alexey Shvayka  <ashvayka@apple.com>
    241
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r292830 r292891  
    608608    ASSERT(isAttached(globalObject));
    609609
     610    VM& vm = globalObject->vm();
    610611    const String& condition = breakpoint.condition();
    611612    if (condition.isEmpty())
     
    615616    DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
    616617    JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    617     JSValue result = debuggerCallFrame.evaluateWithScopeExtension(condition, scopeExtensionObject, exception);
     618    JSValue result = debuggerCallFrame.evaluateWithScopeExtension(vm, condition, scopeExtensionObject, exception);
    618619
    619620    // We can lose the debugger while executing JavaScript.
     
    634635    ASSERT(isAttached(globalObject));
    635636
     637    VM& vm = globalObject->vm();
     638
    636639    m_currentProbeBatchId++;
    637640
     
    645648        case Breakpoint::Action::Type::Log:
    646649            dispatchFunctionToObservers([&] (Observer& observer) {
    647                 observer.breakpointActionLog(debuggerCallFrame.globalObject(), action.data);
     650                observer.breakpointActionLog(debuggerCallFrame.globalObject(vm), action.data);
    648651            });
    649652            break;
     
    652655            NakedPtr<Exception> exception;
    653656            JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    654             debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
     657            debuggerCallFrame.evaluateWithScopeExtension(vm, action.data, scopeExtensionObject, exception);
    655658            if (exception)
    656                 reportException(debuggerCallFrame.globalObject(), exception);
     659                reportException(debuggerCallFrame.globalObject(vm), exception);
    657660            break;
    658661        }
     
    667670            NakedPtr<Exception> exception;
    668671            JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
    669             JSValue result = debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
    670             JSC::JSGlobalObject* debuggerGlobalObject = debuggerCallFrame.globalObject();
     672            JSValue result = debuggerCallFrame.evaluateWithScopeExtension(vm, action.data, scopeExtensionObject, exception);
     673            JSC::JSGlobalObject* debuggerGlobalObject = debuggerCallFrame.globalObject(vm);
    671674            if (exception)
    672675                reportException(debuggerGlobalObject, exception);
     
    10271030        return currentException();
    10281031
     1032    VM& vm = globalObject->vm();
    10291033    for (RefPtr<DebuggerCallFrame> frame = &currentDebuggerCallFrame(); frame; frame = frame->callerFrame()) {
    1030         DebuggerScope& scope = *frame->scope();
     1034        DebuggerScope& scope = *frame->scope(vm);
    10311035        if (scope.isCatchScope())
    10321036            return scope.caughtValue(globalObject);
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp

    r292830 r292891  
    112112}
    113113
    114 JSGlobalObject* DebuggerCallFrame::globalObject()
    115 {
    116     return scope()->globalObject();
    117 }
    118 
    119 JSC::JSGlobalObject* DebuggerCallFrame::deprecatedVMEntryGlobalObject() const
    120 {
    121     ASSERT(isValid());
    122     if (!isValid())
    123         return nullptr;
    124     VM& vm = m_validMachineFrame->deprecatedVM();
    125     return vm.deprecatedVMEntryGlobalObject(m_validMachineFrame->lexicalGlobalObject(vm));
     114JSGlobalObject* DebuggerCallFrame::globalObject(VM& vm)
     115{
     116    return scope(vm)->globalObject();
    126117}
    127118
     
    136127}
    137128
    138 String DebuggerCallFrame::functionName() const
     129String DebuggerCallFrame::functionName(VM& vm) const
    139130{
    140131    ASSERT(isValid());
     
    142133        return String();
    143134
    144     VM& vm = m_validMachineFrame->deprecatedVM();
    145135    if (isTailDeleted()) {
    146136        if (JSFunction* func = jsDynamicCast<JSFunction*>(vm, m_shadowChickenFrame.callee))
     
    152142}
    153143
    154 DebuggerScope* DebuggerCallFrame::scope()
     144DebuggerScope* DebuggerCallFrame::scope(VM& vm)
    155145{
    156146    ASSERT(isValid());
     
    159149
    160150    if (!m_scope) {
    161         VM& vm = m_validMachineFrame->deprecatedVM();
    162151        JSScope* scope;
    163152        CodeBlock* codeBlock = m_validMachineFrame->codeBlock();
     
    176165}
    177166
    178 DebuggerCallFrame::Type DebuggerCallFrame::type() const
     167DebuggerCallFrame::Type DebuggerCallFrame::type(VM& vm) const
    179168{
    180169    ASSERT(isValid());
     
    185174        return FunctionType;
    186175
    187     if (jsDynamicCast<JSFunction*>(m_validMachineFrame->deprecatedVM(), m_validMachineFrame->jsCallee()))
     176    if (jsDynamicCast<JSFunction*>(vm, m_validMachineFrame->jsCallee()))
    188177        return FunctionType;
    189178
     
    217206
    218207// Evaluate some JavaScript code in the scope of this frame.
    219 JSValue DebuggerCallFrame::evaluateWithScopeExtension(const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception)
     208JSValue DebuggerCallFrame::evaluateWithScopeExtension(VM& vm, const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception)
    220209{
    221210    CallFrame* callFrame = nullptr;
     
    243232        return jsUndefined();
    244233
    245     VM& vm = callFrame->deprecatedVM();
    246234    JSLockHolder lock(vm);
    247235    auto catchScope = DECLARE_CATCH_SCOPE(vm);
     
    261249    TDZEnvironment variablesUnderTDZ;
    262250    PrivateNameEnvironment privateNameEnvironment;
    263     JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ, privateNameEnvironment);
     251    JSScope::collectClosureVariablesUnderTDZ(scope(vm)->jsScope(), variablesUnderTDZ, privateNameEnvironment);
    264252
    265253    ECMAMode ecmaMode = codeBlock->ownerExecutable()->isInStrictContext() ? ECMAMode::strict() : ECMAMode::sloppy();
     
    276264    }
    277265
    278     JSValue result = vm.interpreter->execute(eval, globalObject, debuggerCallFrame->thisValue(vm), debuggerCallFrame->scope()->jsScope());
     266    JSValue result = vm.interpreter->execute(eval, globalObject, debuggerCallFrame->thisValue(vm), debuggerCallFrame->scope(vm)->jsScope());
    279267    if (UNLIKELY(catchScope.exception())) {
    280268        exception = catchScope.exception();
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.h

    r266534 r292891  
    4949
    5050    JS_EXPORT_PRIVATE RefPtr<DebuggerCallFrame> callerFrame();
    51     JSGlobalObject* globalObject();
     51    JSGlobalObject* globalObject(VM&);
    5252    JS_EXPORT_PRIVATE SourceID sourceID() const;
    5353
     
    5757    JS_EXPORT_PRIVATE const TextPosition& position() const { return m_position; }
    5858
    59     JS_EXPORT_PRIVATE JSGlobalObject* deprecatedVMEntryGlobalObject() const;
    60     JS_EXPORT_PRIVATE DebuggerScope* scope();
    61     JS_EXPORT_PRIVATE String functionName() const;
    62     JS_EXPORT_PRIVATE Type type() const;
     59    JS_EXPORT_PRIVATE DebuggerScope* scope(VM&);
     60    JS_EXPORT_PRIVATE String functionName(VM&) const;
     61    JS_EXPORT_PRIVATE Type type(VM&) const;
    6362    JS_EXPORT_PRIVATE JSValue thisValue(VM&) const;
    6463
    65     JSValue evaluateWithScopeExtension(const String&, JSObject* scopeExtensionObject, NakedPtr<Exception>&);
     64    JSValue evaluateWithScopeExtension(VM&, const String&, JSObject* scopeExtensionObject, NakedPtr<Exception>&);
    6665
    6766    bool isValid() const { return !!m_validMachineFrame || isTailDeleted(); }
  • trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp

    r292118 r292891  
    8686    NakedPtr<Exception> exception;
    8787    JSObject* scopeExtension = callFrame->argument(1).getObject();
    88     JSValue result = impl().evaluateWithScopeExtension(script, scopeExtension, exception);
     88    JSValue result = impl().evaluateWithScopeExtension(vm, script, scopeExtension, exception);
    8989    if (exception)
    9090        throwException(globalObject, scope, exception);
     
    131131    auto throwScope = DECLARE_THROW_SCOPE(vm);
    132132
    133     DebuggerScope* scopeChain = impl().scopeChain();
     133    DebuggerScope* scopeChain = impl().scopeChain(vm);
    134134    if (!scopeChain)
    135135        return jsUndefined();
     
    174174JSValue JSJavaScriptCallFrame::functionName(JSGlobalObject* globalObject) const
    175175{
    176     return jsString(globalObject->vm(), impl().functionName());
     176    VM& vm = globalObject->vm();
     177    return jsString(vm, impl().functionName(vm));
    177178}
    178179
     
    182183    auto scope = DECLARE_THROW_SCOPE(vm);
    183184
    184     if (!impl().scopeChain())
     185    if (!impl().scopeChain(vm))
    185186        return jsNull();
    186187
    187     DebuggerScope* scopeChain = impl().scopeChain();
     188    DebuggerScope* scopeChain = impl().scopeChain(vm);
    188189    DebuggerScope::iterator iter = scopeChain->begin();
    189190    DebuggerScope::iterator end = scopeChain->end();
     
    218219{
    219220    VM& vm = globalObject->vm();
    220     switch (impl().type()) {
     221    switch (impl().type(vm)) {
    221222    case DebuggerCallFrame::FunctionType:
    222223        return jsNontrivialString(vm, "function"_s);
  • trunk/Source/JavaScriptCore/inspector/JavaScriptCallFrame.h

    r283903 r292891  
    4747    int column() const { return m_debuggerCallFrame->column(); }
    4848
    49     String functionName() const { return m_debuggerCallFrame->functionName(); }
    50     JSC::DebuggerCallFrame::Type type() const { return m_debuggerCallFrame->type(); }
    51     JSC::DebuggerScope* scopeChain() const { return m_debuggerCallFrame->scope(); }
    52     JSC::JSGlobalObject* deprecatedVMEntryGlobalObject() const { return m_debuggerCallFrame->deprecatedVMEntryGlobalObject(); }
     49    String functionName(JSC::VM& vm) const { return m_debuggerCallFrame->functionName(vm); }
     50    JSC::DebuggerCallFrame::Type type(JSC::VM& vm) const { return m_debuggerCallFrame->type(vm); }
     51    JSC::DebuggerScope* scopeChain(JSC::VM& vm) const { return m_debuggerCallFrame->scope(vm); }
    5352    bool isTailDeleted() const { return m_debuggerCallFrame->isTailDeleted(); }
    5453
    5554    JSC::JSValue thisValue(JSC::VM& vm) const { return m_debuggerCallFrame->thisValue(vm); }
    56     JSC::JSValue evaluateWithScopeExtension(const String& script, JSC::JSObject* scopeExtension, NakedPtr<JSC::Exception>& exception) const { return m_debuggerCallFrame->evaluateWithScopeExtension(script, scopeExtension, exception); }
     55    JSC::JSValue evaluateWithScopeExtension(JSC::VM& vm, const String& script, JSC::JSObject* scopeExtension, NakedPtr<JSC::Exception>& exception) const { return m_debuggerCallFrame->evaluateWithScopeExtension(vm, script, scopeExtension, exception); }
    5756
    5857private:
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp

    r291779 r292891  
    11281128        return JSC::Debugger::Client::debuggerScopeExtensionObject(debugger, globalObject, debuggerCallFrame);
    11291129
    1130     auto* debuggerGlobalObject = debuggerCallFrame.scope()->globalObject();
     1130    auto* debuggerGlobalObject = debuggerCallFrame.scope(globalObject->vm())->globalObject();
    11311131    auto callFrame = toJS(debuggerGlobalObject, debuggerGlobalObject, JavaScriptCallFrame::create(debuggerCallFrame).ptr());
    11321132    return injectedScript.createCommandLineAPIObject(callFrame);
     
    12041204    m_pausedGlobalObject = globalObject;
    12051205
    1206     auto* debuggerGlobalObject = debuggerCallFrame.scope()->globalObject();
     1206    auto* debuggerGlobalObject = debuggerCallFrame.scope(globalObject->vm())->globalObject();
    12071207    m_currentCallStack = { m_pausedGlobalObject->vm(), toJS(debuggerGlobalObject, debuggerGlobalObject, JavaScriptCallFrame::create(debuggerCallFrame).ptr()) };
    12081208
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r292830 r292891  
    14181418NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookType debugHookType)
    14191419{
    1420     VM& vm = callFrame->deprecatedVM();
     1420    VM& vm = m_vm;
    14211421    DeferTermination deferScope(vm);
    14221422    auto scope = DECLARE_CATCH_SCOPE(vm);
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r292857 r292891  
     12022-04-14  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Reduce use of CallFrame::deprecatedVM
     4        https://bugs.webkit.org/show_bug.cgi?id=239326
     5
     6        Reviewed by Devin Rousso.
     7
     8        * WebView/WebScriptDebugger.mm:
     9        (WebScriptDebugger::handlePause):
     10
    1112022-04-13  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WebKitLegacy/mac/WebView/WebScriptDebugger.mm

    r272828 r292891  
    127127    m_callingDelegate = true;
    128128
     129    JSC::VM& vm = globalObject->vm();
    129130    WebFrame *webFrame = toWebFrame(globalObject);
    130131    WebView *webView = [webFrame webView];
    131132    JSC::DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
    132133    JSC::JSValue exceptionValue = currentException();
    133     String functionName = debuggerCallFrame.functionName();
     134    String functionName = debuggerCallFrame.functionName(vm);
    134135    RetainPtr<WebScriptCallFrame> webCallFrame = adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script().windowScriptObject() functionName:functionName exceptionValue:exceptionValue]);
    135136
Note: See TracChangeset for help on using the changeset viewer.