Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (292890 => 292891)
--- trunk/Source/_javascript_Core/ChangeLog 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-04-14 21:56:27 UTC (rev 292891)
@@ -1,3 +1,42 @@
+2022-04-14 Yusuke Suzuki <[email protected]>
+
+ [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.
+
+ * debugger/Debugger.cpp:
+ (JSC::Debugger::evaluateBreakpointCondition):
+ (JSC::Debugger::evaluateBreakpointActions):
+ (JSC::Debugger::exceptionOrCaughtValue):
+ * 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.
+ * debugger/DebuggerCallFrame.h:
+ * inspector/JSJavaScriptCallFrame.cpp:
+ (Inspector::JSJavaScriptCallFrame::evaluateWithScopeExtension):
+ (Inspector::JSJavaScriptCallFrame::scopeDescriptions):
+ (Inspector::JSJavaScriptCallFrame::functionName const):
+ (Inspector::JSJavaScriptCallFrame::scopeChain const):
+ (Inspector::JSJavaScriptCallFrame::type const):
+ * inspector/_javascript_CallFrame.h:
+ (Inspector::_javascript_CallFrame::functionName const):
+ (Inspector::_javascript_CallFrame::type const):
+ (Inspector::_javascript_CallFrame::scopeChain const):
+ (Inspector::_javascript_CallFrame::evaluateWithScopeExtension const):
+ (Inspector::_javascript_CallFrame::deprecatedVMEntryGlobalObject const): Deleted.
+ * inspector/agents/InspectorDebuggerAgent.cpp:
+ (Inspector::InspectorDebuggerAgent::debuggerScopeExtensionObject):
+ (Inspector::InspectorDebuggerAgent::didPause):
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::debug):
+
2022-04-14 Alexey Shvayka <[email protected]>
InternalFunction::createSubclassStructure() should use base object's global object
Modified: trunk/Source/_javascript_Core/debugger/Debugger.cpp (292890 => 292891)
--- trunk/Source/_javascript_Core/debugger/Debugger.cpp 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/debugger/Debugger.cpp 2022-04-14 21:56:27 UTC (rev 292891)
@@ -607,6 +607,7 @@
ASSERT(m_isPaused);
ASSERT(isAttached(globalObject));
+ VM& vm = globalObject->vm();
const String& condition = breakpoint.condition();
if (condition.isEmpty())
return true;
@@ -614,7 +615,7 @@
NakedPtr<Exception> exception;
DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
- JSValue result = debuggerCallFrame.evaluateWithScopeExtension(condition, scopeExtensionObject, exception);
+ JSValue result = debuggerCallFrame.evaluateWithScopeExtension(vm, condition, scopeExtensionObject, exception);
// We can lose the debugger while executing _javascript_.
if (!m_currentCallFrame)
@@ -633,6 +634,8 @@
ASSERT(m_isPaused);
ASSERT(isAttached(globalObject));
+ VM& vm = globalObject->vm();
+
m_currentProbeBatchId++;
for (const auto& action : breakpoint.actions()) {
@@ -644,7 +647,7 @@
switch (action.type) {
case Breakpoint::Action::Type::Log:
dispatchFunctionToObservers([&] (Observer& observer) {
- observer.breakpointActionLog(debuggerCallFrame.globalObject(), action.data);
+ observer.breakpointActionLog(debuggerCallFrame.globalObject(vm), action.data);
});
break;
@@ -651,9 +654,9 @@
case Breakpoint::Action::Type::Evaluate: {
NakedPtr<Exception> exception;
JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
- debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
+ debuggerCallFrame.evaluateWithScopeExtension(vm, action.data, scopeExtensionObject, exception);
if (exception)
- reportException(debuggerCallFrame.globalObject(), exception);
+ reportException(debuggerCallFrame.globalObject(vm), exception);
break;
}
@@ -666,8 +669,8 @@
case Breakpoint::Action::Type::Probe: {
NakedPtr<Exception> exception;
JSObject* scopeExtensionObject = m_client ? m_client->debuggerScopeExtensionObject(*this, globalObject, debuggerCallFrame) : nullptr;
- JSValue result = debuggerCallFrame.evaluateWithScopeExtension(action.data, scopeExtensionObject, exception);
- JSC::JSGlobalObject* debuggerGlobalObject = debuggerCallFrame.globalObject();
+ JSValue result = debuggerCallFrame.evaluateWithScopeExtension(vm, action.data, scopeExtensionObject, exception);
+ JSC::JSGlobalObject* debuggerGlobalObject = debuggerCallFrame.globalObject(vm);
if (exception)
reportException(debuggerGlobalObject, exception);
@@ -1026,8 +1029,9 @@
if (reasonForPause() == PausedForException)
return currentException();
+ VM& vm = globalObject->vm();
for (RefPtr<DebuggerCallFrame> frame = ¤tDebuggerCallFrame(); frame; frame = frame->callerFrame()) {
- DebuggerScope& scope = *frame->scope();
+ DebuggerScope& scope = *frame->scope(vm);
if (scope.isCatchScope())
return scope.caughtValue(globalObject);
}
Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp (292890 => 292891)
--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2022-04-14 21:56:27 UTC (rev 292891)
@@ -111,20 +111,11 @@
return m_caller;
}
-JSGlobalObject* DebuggerCallFrame::globalObject()
+JSGlobalObject* DebuggerCallFrame::globalObject(VM& vm)
{
- return scope()->globalObject();
+ return scope(vm)->globalObject();
}
-JSC::JSGlobalObject* DebuggerCallFrame::deprecatedVMEntryGlobalObject() const
-{
- ASSERT(isValid());
- if (!isValid())
- return nullptr;
- VM& vm = m_validMachineFrame->deprecatedVM();
- return vm.deprecatedVMEntryGlobalObject(m_validMachineFrame->lexicalGlobalObject(vm));
-}
-
SourceID DebuggerCallFrame::sourceID() const
{
ASSERT(isValid());
@@ -135,13 +126,12 @@
return sourceIDForCallFrame(m_validMachineFrame);
}
-String DebuggerCallFrame::functionName() const
+String DebuggerCallFrame::functionName(VM& vm) const
{
ASSERT(isValid());
if (!isValid())
return String();
- VM& vm = m_validMachineFrame->deprecatedVM();
if (isTailDeleted()) {
if (JSFunction* func = jsDynamicCast<JSFunction*>(vm, m_shadowChickenFrame.callee))
return func->calculatedDisplayName(vm);
@@ -151,7 +141,7 @@
return m_validMachineFrame->friendlyFunctionName();
}
-DebuggerScope* DebuggerCallFrame::scope()
+DebuggerScope* DebuggerCallFrame::scope(VM& vm)
{
ASSERT(isValid());
if (!isValid())
@@ -158,7 +148,6 @@
return nullptr;
if (!m_scope) {
- VM& vm = m_validMachineFrame->deprecatedVM();
JSScope* scope;
CodeBlock* codeBlock = m_validMachineFrame->codeBlock();
if (isTailDeleted())
@@ -175,7 +164,7 @@
return m_scope.get();
}
-DebuggerCallFrame::Type DebuggerCallFrame::type() const
+DebuggerCallFrame::Type DebuggerCallFrame::type(VM& vm) const
{
ASSERT(isValid());
if (!isValid())
@@ -184,7 +173,7 @@
if (isTailDeleted())
return FunctionType;
- if (jsDynamicCast<JSFunction*>(m_validMachineFrame->deprecatedVM(), m_validMachineFrame->jsCallee()))
+ if (jsDynamicCast<JSFunction*>(vm, m_validMachineFrame->jsCallee()))
return FunctionType;
return ProgramType;
@@ -216,7 +205,7 @@
}
// Evaluate some _javascript_ code in the scope of this frame.
-JSValue DebuggerCallFrame::evaluateWithScopeExtension(const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception)
+JSValue DebuggerCallFrame::evaluateWithScopeExtension(VM& vm, const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception)
{
CallFrame* callFrame = nullptr;
CodeBlock* codeBlock = nullptr;
@@ -242,7 +231,6 @@
if (!callFrame || !codeBlock)
return jsUndefined();
- VM& vm = callFrame->deprecatedVM();
JSLockHolder lock(vm);
auto catchScope = DECLARE_CATCH_SCOPE(vm);
@@ -260,7 +248,7 @@
TDZEnvironment variablesUnderTDZ;
PrivateNameEnvironment privateNameEnvironment;
- JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ, privateNameEnvironment);
+ JSScope::collectClosureVariablesUnderTDZ(scope(vm)->jsScope(), variablesUnderTDZ, privateNameEnvironment);
ECMAMode ecmaMode = codeBlock->ownerExecutable()->isInStrictContext() ? ECMAMode::strict() : ECMAMode::sloppy();
auto* eval = DirectEvalExecutable::create(globalObject, makeSource(script, callFrame->callerSourceOrigin(vm)), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->needsClassFieldInitializer(), codeBlock->unlinkedCodeBlock()->privateBrandRequirement(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), codeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ, &privateNameEnvironment, ecmaMode);
@@ -275,7 +263,7 @@
globalObject->setGlobalScopeExtension(JSWithScope::create(vm, globalObject, ignoredPreviousScope, scopeExtensionObject));
}
- JSValue result = vm.interpreter->execute(eval, globalObject, debuggerCallFrame->thisValue(vm), debuggerCallFrame->scope()->jsScope());
+ JSValue result = vm.interpreter->execute(eval, globalObject, debuggerCallFrame->thisValue(vm), debuggerCallFrame->scope(vm)->jsScope());
if (UNLIKELY(catchScope.exception())) {
exception = catchScope.exception();
catchScope.clearException();
Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.h (292890 => 292891)
--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.h 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.h 2022-04-14 21:56:27 UTC (rev 292891)
@@ -48,7 +48,7 @@
static Ref<DebuggerCallFrame> create(VM&, CallFrame*);
JS_EXPORT_PRIVATE RefPtr<DebuggerCallFrame> callerFrame();
- JSGlobalObject* globalObject();
+ JSGlobalObject* globalObject(VM&);
JS_EXPORT_PRIVATE SourceID sourceID() const;
// line and column are in base 0 e.g. the first line is line 0.
@@ -56,13 +56,12 @@
int column() const { return m_position.m_column.zeroBasedInt(); }
JS_EXPORT_PRIVATE const TextPosition& position() const { return m_position; }
- JS_EXPORT_PRIVATE JSGlobalObject* deprecatedVMEntryGlobalObject() const;
- JS_EXPORT_PRIVATE DebuggerScope* scope();
- JS_EXPORT_PRIVATE String functionName() const;
- JS_EXPORT_PRIVATE Type type() const;
+ JS_EXPORT_PRIVATE DebuggerScope* scope(VM&);
+ JS_EXPORT_PRIVATE String functionName(VM&) const;
+ JS_EXPORT_PRIVATE Type type(VM&) const;
JS_EXPORT_PRIVATE JSValue thisValue(VM&) const;
- JSValue evaluateWithScopeExtension(const String&, JSObject* scopeExtensionObject, NakedPtr<Exception>&);
+ JSValue evaluateWithScopeExtension(VM&, const String&, JSObject* scopeExtensionObject, NakedPtr<Exception>&);
bool isValid() const { return !!m_validMachineFrame || isTailDeleted(); }
JS_EXPORT_PRIVATE void invalidate();
Modified: trunk/Source/_javascript_Core/inspector/JSJavaScriptCallFrame.cpp (292890 => 292891)
--- trunk/Source/_javascript_Core/inspector/JSJavaScriptCallFrame.cpp 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/inspector/JSJavaScriptCallFrame.cpp 2022-04-14 21:56:27 UTC (rev 292891)
@@ -85,7 +85,7 @@
NakedPtr<Exception> exception;
JSObject* scopeExtension = callFrame->argument(1).getObject();
- JSValue result = impl().evaluateWithScopeExtension(script, scopeExtension, exception);
+ JSValue result = impl().evaluateWithScopeExtension(vm, script, scopeExtension, exception);
if (exception)
throwException(globalObject, scope, exception);
@@ -130,7 +130,7 @@
VM& vm = globalObject->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
- DebuggerScope* scopeChain = impl().scopeChain();
+ DebuggerScope* scopeChain = impl().scopeChain(vm);
if (!scopeChain)
return jsUndefined();
@@ -173,7 +173,8 @@
JSValue JSJavaScriptCallFrame::functionName(JSGlobalObject* globalObject) const
{
- return jsString(globalObject->vm(), impl().functionName());
+ VM& vm = globalObject->vm();
+ return jsString(vm, impl().functionName(vm));
}
JSValue JSJavaScriptCallFrame::scopeChain(JSGlobalObject* globalObject) const
@@ -181,10 +182,10 @@
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
- if (!impl().scopeChain())
+ if (!impl().scopeChain(vm))
return jsNull();
- DebuggerScope* scopeChain = impl().scopeChain();
+ DebuggerScope* scopeChain = impl().scopeChain(vm);
DebuggerScope::iterator iter = scopeChain->begin();
DebuggerScope::iterator end = scopeChain->end();
@@ -217,7 +218,7 @@
JSValue JSJavaScriptCallFrame::type(JSGlobalObject* globalObject) const
{
VM& vm = globalObject->vm();
- switch (impl().type()) {
+ switch (impl().type(vm)) {
case DebuggerCallFrame::FunctionType:
return jsNontrivialString(vm, "function"_s);
case DebuggerCallFrame::ProgramType:
Modified: trunk/Source/_javascript_Core/inspector/_javascript_CallFrame.h (292890 => 292891)
--- trunk/Source/_javascript_Core/inspector/_javascript_CallFrame.h 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/inspector/_javascript_CallFrame.h 2022-04-14 21:56:27 UTC (rev 292891)
@@ -46,14 +46,13 @@
int line() const { return m_debuggerCallFrame->line(); }
int column() const { return m_debuggerCallFrame->column(); }
- String functionName() const { return m_debuggerCallFrame->functionName(); }
- JSC::DebuggerCallFrame::Type type() const { return m_debuggerCallFrame->type(); }
- JSC::DebuggerScope* scopeChain() const { return m_debuggerCallFrame->scope(); }
- JSC::JSGlobalObject* deprecatedVMEntryGlobalObject() const { return m_debuggerCallFrame->deprecatedVMEntryGlobalObject(); }
+ String functionName(JSC::VM& vm) const { return m_debuggerCallFrame->functionName(vm); }
+ JSC::DebuggerCallFrame::Type type(JSC::VM& vm) const { return m_debuggerCallFrame->type(vm); }
+ JSC::DebuggerScope* scopeChain(JSC::VM& vm) const { return m_debuggerCallFrame->scope(vm); }
bool isTailDeleted() const { return m_debuggerCallFrame->isTailDeleted(); }
JSC::JSValue thisValue(JSC::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); }
+ 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); }
private:
_javascript_CallFrame(Ref<JSC::DebuggerCallFrame>&&);
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (292890 => 292891)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2022-04-14 21:56:27 UTC (rev 292891)
@@ -1127,7 +1127,7 @@
if (injectedScript.hasNoValue())
return JSC::Debugger::Client::debuggerScopeExtensionObject(debugger, globalObject, debuggerCallFrame);
- auto* debuggerGlobalObject = debuggerCallFrame.scope()->globalObject();
+ auto* debuggerGlobalObject = debuggerCallFrame.scope(globalObject->vm())->globalObject();
auto callFrame = toJS(debuggerGlobalObject, debuggerGlobalObject, _javascript_CallFrame::create(debuggerCallFrame).ptr());
return injectedScript.createCommandLineAPIObject(callFrame);
}
@@ -1203,7 +1203,7 @@
ASSERT(!m_pausedGlobalObject);
m_pausedGlobalObject = globalObject;
- auto* debuggerGlobalObject = debuggerCallFrame.scope()->globalObject();
+ auto* debuggerGlobalObject = debuggerCallFrame.scope(globalObject->vm())->globalObject();
m_currentCallStack = { m_pausedGlobalObject->vm(), toJS(debuggerGlobalObject, debuggerGlobalObject, _javascript_CallFrame::create(debuggerCallFrame).ptr()) };
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(m_pausedGlobalObject);
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (292890 => 292891)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2022-04-14 21:56:27 UTC (rev 292891)
@@ -1417,7 +1417,7 @@
NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookType debugHookType)
{
- VM& vm = callFrame->deprecatedVM();
+ VM& vm = m_vm;
DeferTermination deferScope(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (292890 => 292891)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2022-04-14 21:56:27 UTC (rev 292891)
@@ -1,3 +1,13 @@
+2022-04-14 Yusuke Suzuki <[email protected]>
+
+ [JSC] Reduce use of CallFrame::deprecatedVM
+ https://bugs.webkit.org/show_bug.cgi?id=239326
+
+ Reviewed by Devin Rousso.
+
+ * WebView/WebScriptDebugger.mm:
+ (WebScriptDebugger::handlePause):
+
2022-04-13 Chris Dumez <[email protected]>
Replace calls to substring(0, x) with the more concise left(x)
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebScriptDebugger.mm (292890 => 292891)
--- trunk/Source/WebKitLegacy/mac/WebView/WebScriptDebugger.mm 2022-04-14 21:15:31 UTC (rev 292890)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebScriptDebugger.mm 2022-04-14 21:56:27 UTC (rev 292891)
@@ -126,11 +126,12 @@
m_callingDelegate = true;
+ JSC::VM& vm = globalObject->vm();
WebFrame *webFrame = toWebFrame(globalObject);
WebView *webView = [webFrame webView];
JSC::DebuggerCallFrame& debuggerCallFrame = currentDebuggerCallFrame();
JSC::JSValue exceptionValue = currentException();
- String functionName = debuggerCallFrame.functionName();
+ String functionName = debuggerCallFrame.functionName(vm);
RetainPtr<WebScriptCallFrame> webCallFrame = adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script().windowScriptObject() functionName:functionName exceptionValue:exceptionValue]);
WebScriptDebugDelegateImplementationCache* cache = WebViewGetScriptDebugDelegateImplementations(webView);