Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ heap/HeapSnapshotBuilder.h
heap/MarkedBlock.h
heap/SlotVisitor.h
heap/WeakSet.h
inspector/InspectorAgentBase.h
inspector/InspectorBackendDispatchers.h
inspector/JSGlobalObjectConsoleClient.h
inspector/JSGlobalObjectInspectorController.h
inspector/agents/InspectorDebuggerAgent.h
interpreter/StackVisitor.h
jit/JIT.h
jit/JITCode.h
Expand Down
4 changes: 3 additions & 1 deletion Source/JavaScriptCore/inspector/InjectedScriptManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <JavaScriptCore/Exception.h>
#include <JavaScriptCore/InjectedScript.h>
#include <JavaScriptCore/InspectorEnvironment.h>
#include <wtf/CheckedRef.h>
#include <wtf/Expected.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
Expand All @@ -47,9 +48,10 @@ namespace Inspector {

class InjectedScriptHost;

class InjectedScriptManager {
class InjectedScriptManager : public CanMakeThreadSafeCheckedPtr<InjectedScriptManager> {
WTF_MAKE_NONCOPYABLE(InjectedScriptManager);
WTF_MAKE_TZONE_ALLOCATED(InjectedScriptManager);
WTF_OVERRIDE_DELETE_FOR_CHECKED_PTR(InjectedScriptManager);
public:
JS_EXPORT_PRIVATE InjectedScriptManager(InspectorEnvironment&, Ref<InjectedScriptHost>&&);
JS_EXPORT_PRIVATE virtual ~InjectedScriptManager();
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/inspector/InspectorAgentBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#pragma once

#include <JavaScriptCore/InjectedScriptManager.h>
#include <JavaScriptCore/InspectorEnvironment.h>
#include <JavaScriptCore/InspectorFrontendRouter.h>
#include <wtf/CheckedRef.h>
Expand All @@ -39,11 +40,10 @@ class JSGlobalObject;
namespace Inspector {

class BackendDispatcher;
class InjectedScriptManager;

struct AgentContext {
CheckedRef<InspectorEnvironment> environment;
InjectedScriptManager& injectedScriptManager;
CheckedRef<InjectedScriptManager> injectedScriptManager;
CheckedRef<FrontendRouter> frontendRouter;
BackendDispatcher& backendDispatcher;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ JSAgentContext JSGlobalObjectInspectorController::jsAgentContext()
{
AgentContext baseContext = {
*this,
m_injectedScriptManager,
m_injectedScriptManager.get(),
m_frontendRouter.get(),
m_backendDispatcher
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <JavaScriptCore/InspectorAgentBase.h>
#include <JavaScriptCore/InspectorBackendDispatchers.h>
#include <JavaScriptCore/JSCInlines.h>
#include <wtf/CheckedRef.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/TZoneMalloc.h>
Expand Down Expand Up @@ -72,7 +73,7 @@ class JS_EXPORT_PRIVATE InspectorAuditAgent : public InspectorAgentBase, public

private:
const Ref<AuditBackendDispatcher> m_backendDispatcher;
InjectedScriptManager& m_injectedScriptManager;
const CheckedRef<InjectedScriptManager> m_injectedScriptManager;
JSC::Debugger& m_debugger;

JSC::Strong<JSC::JSObject> m_injectedWebInspectorAuditValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Protocol::ErrorStringOr<void> InspectorConsoleAgent::setConsoleClearAPIEnabled(b

bool InspectorConsoleAgent::developerExtrasEnabled() const
{
return m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled();
return m_injectedScriptManager->inspectorEnvironment().developerExtrasEnabled();
}

void InspectorConsoleAgent::mainFrameNavigated()
Expand All @@ -128,7 +128,7 @@ void InspectorConsoleAgent::clearMessages(Inspector::Protocol::Console::ClearRea
m_consoleMessages.clear();
m_expiredConsoleMessageCount = 0;

m_injectedScriptManager.releaseObjectGroup("console"_s);
m_injectedScriptManager->releaseObjectGroup("console"_s);

if (m_enabled)
m_frontendDispatcher->messagesCleared(reason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <JavaScriptCore/InspectorAgentBase.h>
#include <JavaScriptCore/InspectorBackendDispatchers.h>
#include <JavaScriptCore/InspectorFrontendDispatchers.h>
#include <wtf/CheckedRef.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/MonotonicTime.h>
Expand Down Expand Up @@ -88,7 +89,7 @@ class JS_EXPORT_PRIVATE InspectorConsoleAgent : public InspectorAgentBase, publi
void addConsoleMessage(std::unique_ptr<ConsoleMessage>);
void clearMessages(Protocol::Console::ClearReason);

InjectedScriptManager& m_injectedScriptManager;
const CheckedRef<InjectedScriptManager> m_injectedScriptManager;
const UniqueRef<ConsoleFrontendDispatcher> m_frontendDispatcher;
const Ref<ConsoleBackendDispatcher> m_backendDispatcher;

Expand Down
22 changes: 11 additions & 11 deletions Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ Protocol::ErrorStringOr<void> InspectorDebuggerAgent::removeBreakpoint(const Pro

for (auto& debuggerBreakpoint : m_debuggerBreakpointsForProtocolBreakpointID.take(protocolBreakpointID)) {
for (const auto& action : debuggerBreakpoint->actions())
m_injectedScriptManager.releaseObjectGroup(objectGroupForBreakpointAction(action.id));
injectedScriptManager().releaseObjectGroup(objectGroupForBreakpointAction(action.id));

JSC::JSLockHolder locker(m_debugger.vm());
m_debugger.removeBreakpoint(debuggerBreakpoint);
Expand Down Expand Up @@ -972,7 +972,7 @@ Protocol::ErrorStringOr<Ref<Protocol::Debugger::FunctionDetails>> InspectorDebug
{
Protocol::ErrorString errorString;

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(functionId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(functionId);
if (injectedScript.hasNoValue())
return makeUnexpected("Missing injected script for given functionId"_s);

Expand Down Expand Up @@ -1257,7 +1257,7 @@ Protocol::ErrorStringOr<void> InspectorDebuggerAgent::setPauseOnMicrotasks(bool

Protocol::ErrorStringOr<std::tuple<Ref<Protocol::Runtime::RemoteObject>, std::optional<bool> /* wasThrown */, std::optional<int> /* savedResultIndex */>> InspectorDebuggerAgent::evaluateOnCallFrame(const Protocol::Debugger::CallFrameId& callFrameId, const String& expression, const String& objectGroup, std::optional<bool>&& includeCommandLineAPI, std::optional<bool>&& doNotPauseOnExceptionsAndMuteConsole, std::optional<bool>&& returnByValue, std::optional<bool>&& generatePreview, std::optional<bool>&& saveResult, std::optional<bool>&& emulateUserGesture)
{
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(callFrameId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(callFrameId);
if (injectedScript.hasNoValue())
return makeUnexpected("Missing injected script for given callFrameId"_s);

Expand Down Expand Up @@ -1586,7 +1586,7 @@ bool InspectorDebuggerAgent::isInspectorDebuggerAgent() const

JSC::JSObject* InspectorDebuggerAgent::debuggerScopeExtensionObject(JSC::Debugger& debugger, JSC::JSGlobalObject* globalObject, JSC::DebuggerCallFrame& debuggerCallFrame)
{
auto injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject);
auto injectedScript = injectedScriptManager().injectedScriptFor(globalObject);
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return JSC::Debugger::Client::debuggerScopeExtensionObject(debugger, globalObject, debuggerCallFrame);
Expand Down Expand Up @@ -1694,7 +1694,7 @@ void InspectorDebuggerAgent::didPause(JSC::JSGlobalObject* globalObject, JSC::De
auto* debuggerGlobalObject = debuggerCallFrame.scope(globalObject->vm())->globalObject();
m_currentCallStack = { m_pausedGlobalObject->vm(), toJS(debuggerGlobalObject, debuggerGlobalObject, JavaScriptCallFrame::create(debuggerCallFrame).ptr()) };

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(m_pausedGlobalObject);
auto injectedScript = injectedScriptManager().injectedScriptFor(m_pausedGlobalObject);

// If a high level pause pause reason is not already set, try to infer a reason from the debugger.
if (m_pauseReason == DebuggerFrontendDispatcher::Reason::Other) {
Expand Down Expand Up @@ -1780,7 +1780,7 @@ void InspectorDebuggerAgent::didPause(JSC::JSGlobalObject* globalObject, JSC::De
m_continueToLocationDebuggerBreakpoint = nullptr;
}

auto& stopwatch = m_injectedScriptManager.checkedInspectorEnvironment()->executionStopwatch();
auto& stopwatch = injectedScriptManager().checkedInspectorEnvironment()->executionStopwatch();
if (stopwatch.isActive()) {
stopwatch.stop();
m_didPauseStopwatch = true;
Expand Down Expand Up @@ -1809,7 +1809,7 @@ void InspectorDebuggerAgent::breakpointActionSound(JSC::BreakpointActionID id)

void InspectorDebuggerAgent::breakpointActionProbe(JSC::JSGlobalObject* globalObject, JSC::BreakpointActionID actionID, unsigned batchId, unsigned sampleId, JSC::JSValue sample)
{
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject);
auto injectedScript = injectedScriptManager().injectedScriptFor(globalObject);
auto payload = injectedScript.wrapObject(sample, objectGroupForBreakpointAction(actionID), true);
if (!payload)
return;
Expand All @@ -1818,7 +1818,7 @@ void InspectorDebuggerAgent::breakpointActionProbe(JSC::JSGlobalObject* globalOb
.setProbeId(actionID)
.setBatchId(batchId)
.setSampleId(sampleId)
.setTimestamp(m_injectedScriptManager.checkedInspectorEnvironment()->executionStopwatch().elapsedTime().seconds())
.setTimestamp(injectedScriptManager().checkedInspectorEnvironment()->executionStopwatch().elapsedTime().seconds())
.setPayload(payload.releaseNonNull())
.release();
m_frontendDispatcher->didSampleProbe(WTF::move(result));
Expand All @@ -1828,12 +1828,12 @@ void InspectorDebuggerAgent::didContinue()
{
if (m_didPauseStopwatch) {
m_didPauseStopwatch = false;
m_injectedScriptManager.checkedInspectorEnvironment()->executionStopwatch().start();
injectedScriptManager().checkedInspectorEnvironment()->executionStopwatch().start();
}

m_pausedGlobalObject = nullptr;
m_currentCallStack = { };
m_injectedScriptManager.releaseObjectGroup(InspectorDebuggerAgent::backtraceObjectGroup);
injectedScriptManager().releaseObjectGroup(InspectorDebuggerAgent::backtraceObjectGroup);
clearPauseDetails();
clearExceptionValue();

Expand Down Expand Up @@ -1954,7 +1954,7 @@ void InspectorDebuggerAgent::clearPauseDetails()
void InspectorDebuggerAgent::clearExceptionValue()
{
if (m_hasExceptionValue) {
m_injectedScriptManager.clearExceptionValue();
injectedScriptManager().clearExceptionValue();
m_hasExceptionValue = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <JavaScriptCore/InspectorFrontendDispatchers.h>
#include <JavaScriptCore/Microtask.h>
#include <JavaScriptCore/RegularExpression.h>
#include <wtf/CheckedRef.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
Expand Down Expand Up @@ -250,7 +251,7 @@ class JS_EXPORT_PRIVATE InspectorDebuggerAgent
const Ref<DebuggerBackendDispatcher> m_backendDispatcher;

JSC::Debugger& m_debugger;
InjectedScriptManager& m_injectedScriptManager;
const CheckedRef<InjectedScriptManager> m_injectedScriptManager;
UncheckedKeyHashMap<JSC::SourceID, JSC::Debugger::Script> m_scripts;

struct BlackboxedScript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Protocol::ErrorStringOr<std::tuple<String, RefPtr<Protocol::Debugger::FunctionDe
if (!globalObject)
return makeUnexpected("Unable to get object details - GlobalObject"_s);

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject);
auto injectedScript = m_injectedScriptManager->injectedScriptFor(globalObject);
if (injectedScript.hasNoValue())
return makeUnexpected("Unable to get object details - InjectedScript"_s);

Expand Down Expand Up @@ -244,7 +244,7 @@ Protocol::ErrorStringOr<Ref<Protocol::Runtime::RemoteObject>> InspectorHeapAgent
if (!globalObject)
return makeUnexpected("Unable to get object details - GlobalObject"_s);

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptFor(globalObject);
auto injectedScript = m_injectedScriptManager->injectedScriptFor(globalObject);
if (injectedScript.hasNoValue())
return makeUnexpected("Unable to get object details - InjectedScript"_s);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <JavaScriptCore/InspectorAgentBase.h>
#include <JavaScriptCore/InspectorBackendDispatchers.h>
#include <JavaScriptCore/InspectorFrontendDispatchers.h>
#include <wtf/CheckedRef.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/Seconds.h>
Expand Down Expand Up @@ -82,7 +83,7 @@ class JS_EXPORT_PRIVATE InspectorHeapAgent : public InspectorAgentBase, public H
private:
std::optional<JSC::HeapSnapshotNode> nodeForHeapObjectIdentifier(Protocol::ErrorString&, unsigned heapObjectIdentifier);

InjectedScriptManager& m_injectedScriptManager;
const CheckedRef<InjectedScriptManager> m_injectedScriptManager;
const UniqueRef<HeapFrontendDispatcher> m_frontendDispatcher;
const Ref<HeapBackendDispatcher> m_backendDispatcher;
WeakRef<InspectorEnvironment> m_environment;
Expand Down
20 changes: 10 additions & 10 deletions Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Protocol::ErrorStringOr<std::tuple<Ref<Protocol::Runtime::RemoteObject>, std::op

void InspectorRuntimeAgent::awaitPromise(const Protocol::Runtime::RemoteObjectId& promiseObjectId, std::optional<bool>&& returnByValue, std::optional<bool>&& generatePreview, std::optional<bool>&& saveResult, Ref<AwaitPromiseCallback>&& callback)
{
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(promiseObjectId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(promiseObjectId);
if (injectedScript.hasNoValue()) {
callback->sendFailure("Missing injected script for given promiseObjectId"_s);
return;
Expand All @@ -182,7 +182,7 @@ void InspectorRuntimeAgent::awaitPromise(const Protocol::Runtime::RemoteObjectId

void InspectorRuntimeAgent::callFunctionOn(const Protocol::Runtime::RemoteObjectId& objectId, const String& functionDeclaration, RefPtr<JSON::Array>&& arguments, std::optional<bool>&& doNotPauseOnExceptionsAndMuteConsole, std::optional<bool>&& returnByValue, std::optional<bool>&& generatePreview, std::optional<bool>&& emulateUserGesture, std::optional<bool>&& awaitPromise, Ref<CallFunctionOnCallback>&& callback)
{
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
callback->sendFailure("Missing injected script for given objectId"_s);
return;
Expand Down Expand Up @@ -219,7 +219,7 @@ Protocol::ErrorStringOr<Ref<Protocol::Runtime::ObjectPreview>> InspectorRuntimeA
{
Protocol::ErrorString errorString;

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue())
return makeUnexpected("Missing injected script for given objectId"_s);

Expand All @@ -244,7 +244,7 @@ Protocol::ErrorStringOr<std::tuple<Ref<JSON::ArrayOf<Protocol::Runtime::Property
{
Protocol::ErrorString errorString;

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue())
return makeUnexpected("Missing injected script for given objectId"_s);

Expand Down Expand Up @@ -282,7 +282,7 @@ Protocol::ErrorStringOr<std::tuple<Ref<JSON::ArrayOf<Protocol::Runtime::Property
{
Protocol::ErrorString errorString;

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue())
return makeUnexpected("Missing injected script for given objectId"_s);

Expand Down Expand Up @@ -320,7 +320,7 @@ Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>>
{
Protocol::ErrorString errorString;

InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue())
return makeUnexpected("Missing injected script for given objectId"_s);

Expand Down Expand Up @@ -354,7 +354,7 @@ Protocol::ErrorStringOr<std::optional<int> /* saveResultIndex */> InspectorRunti
if (injectedScript.hasNoValue())
return makeUnexpected(errorString);
} else {
injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue())
return makeUnexpected("Missing injected script for given objectId"_s);
}
Expand All @@ -371,14 +371,14 @@ Protocol::ErrorStringOr<std::optional<int> /* saveResultIndex */> InspectorRunti

Protocol::ErrorStringOr<void> InspectorRuntimeAgent::setSavedResultAlias(const String& savedResultAlias)
{
m_injectedScriptManager.injectedScriptHost().setSavedResultAlias(savedResultAlias);
injectedScriptManager().injectedScriptHost().setSavedResultAlias(savedResultAlias);

return { };
}

Protocol::ErrorStringOr<void> InspectorRuntimeAgent::releaseObject(const Protocol::Runtime::RemoteObjectId& objectId)
{
InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
auto injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
if (!injectedScript.hasNoValue())
injectedScript.releaseObject(objectId);

Expand All @@ -387,7 +387,7 @@ Protocol::ErrorStringOr<void> InspectorRuntimeAgent::releaseObject(const Protoco

Protocol::ErrorStringOr<void> InspectorRuntimeAgent::releaseObjectGroup(const String& objectGroup)
{
m_injectedScriptManager.releaseObjectGroup(objectGroup);
injectedScriptManager().releaseObjectGroup(objectGroup);

return { };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <JavaScriptCore/InspectorAgentBase.h>
#include <JavaScriptCore/InspectorBackendDispatchers.h>
#include <wtf/CheckedRef.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/TZoneMalloc.h>
Expand Down Expand Up @@ -96,7 +97,7 @@ class JS_EXPORT_PRIVATE InspectorRuntimeAgent : public InspectorAgentBase, publi
void setTypeProfilerEnabledState(bool);
void setControlFlowProfilerEnabledState(bool);

InjectedScriptManager& m_injectedScriptManager;
const CheckedRef<InjectedScriptManager> m_injectedScriptManager;
JSC::Debugger& m_debugger;
JSC::VM& m_vm;
bool m_enabled {false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ InjectedScript JSGlobalObjectAuditAgent::injectedScriptForEval(Protocol::ErrorSt
return InjectedScript();
}

InjectedScript injectedScript = injectedScriptManager().injectedScriptFor(&m_globalObject);
auto injectedScript = injectedScriptManager().injectedScriptFor(&m_globalObject);
if (injectedScript.hasNoValue())
errorString = "Internal error: main world execution context not found"_s;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ InjectedScript JSGlobalObjectRuntimeAgent::injectedScriptForEval(Protocol::Error
return InjectedScript();
}

InjectedScript injectedScript = injectedScriptManager().injectedScriptFor(&m_globalObject);
auto injectedScript = injectedScriptManager().injectedScriptFor(&m_globalObject);
if (injectedScript.hasNoValue())
errorString = "Missing execution context for given executionContextId."_s;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ inspector/InspectorStyleSheet.h
inspector/InstrumentingAgents.h
inspector/PageInspectorController.h
inspector/UserGestureEmulationScope.h
inspector/agents/InspectorNetworkAgent.h
inspector/agents/InspectorPageAgent.h
layout/formattingContexts/inline/InlineFormattingContext.h
layout/formattingContexts/inline/InlineItemsBuilder.cpp
Expand Down
Loading