Changeset 243150 in webkit


Ignore:
Timestamp:
Mar 19, 2019 10:50:19 AM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Heap: lazily create the agent
https://bugs.webkit.org/show_bug.cgi?id=195590
<rdar://problem/48791750>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

  • inspector/agents/InspectorHeapAgent.h:
  • inspector/agents/InspectorHeapAgent.cpp:

(Inspector::InspectorHeapAgent::~InspectorHeapAgent): Deleted.

  • inspector/agents/InspectorConsoleAgent.h:

(Inspector::InspectorConsoleAgent::setInspectorHeapAgent): Added.

  • inspector/agents/InspectorConsoleAgent.cpp:

(Inspector::InspectorConsoleAgent::InspectorConsoleAgent):
(Inspector::InspectorConsoleAgent::takeHeapSnapshot):
(Inspector::InspectorConsoleAgent::~InspectorConsoleAgent): Deleted.

  • inspector/JSGlobalObjectInspectorController.cpp:

(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::createLazyAgents):

Source/WebCore:

No change in functionality.

  • inspector/agents/page/PageHeapAgent.cpp:

(WebCore::PageHeapAgent::disable):

  • inspector/agents/WebHeapAgent.h:
  • inspector/agents/WebHeapAgent.cpp:

(WebCore::WebHeapAgent::WebHeapAgent):
(WebCore::WebHeapAgent::enable): Added.
(WebCore::WebHeapAgent::disable):

  • inspector/agents/page/PageConsoleAgent.h:
  • inspector/agents/page/PageConsoleAgent.cpp:

(WebCore::PageConsoleAgent::PageConsoleAgent):

  • inspector/agents/WebConsoleAgent.h:
  • inspector/agents/WebConsoleAgent.cpp:

(WebCore::WebConsoleAgent::WebConsoleAgent):

  • inspector/agents/worker/WorkerConsoleAgent.h:
  • inspector/agents/worker/WorkerConsoleAgent.cpp:

(WebCore::WorkerConsoleAgent::WorkerConsoleAgent):

  • inspector/InspectorController.cpp:

(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::createLazyAgents):

  • inspector/WorkerInspectorController.cpp:

(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::createLazyAgents):

Location:
trunk/Source
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r243136 r243150  
     12019-03-19  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Heap: lazily create the agent
     4        https://bugs.webkit.org/show_bug.cgi?id=195590
     5        <rdar://problem/48791750>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * inspector/agents/InspectorHeapAgent.h:
     10        * inspector/agents/InspectorHeapAgent.cpp:
     11        (Inspector::InspectorHeapAgent::~InspectorHeapAgent): Deleted.
     12
     13        * inspector/agents/InspectorConsoleAgent.h:
     14        (Inspector::InspectorConsoleAgent::setInspectorHeapAgent): Added.
     15        * inspector/agents/InspectorConsoleAgent.cpp:
     16        (Inspector::InspectorConsoleAgent::InspectorConsoleAgent):
     17        (Inspector::InspectorConsoleAgent::takeHeapSnapshot):
     18        (Inspector::InspectorConsoleAgent::~InspectorConsoleAgent): Deleted.
     19
     20        * inspector/JSGlobalObjectInspectorController.cpp:
     21        (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
     22        (Inspector::JSGlobalObjectInspectorController::createLazyAgents):
     23
    1242019-03-19  Caio Lima  <ticaiolima@gmail.com>
    225
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp

    r239976 r243150  
    7474    auto inspectorAgent = std::make_unique<InspectorAgent>(context);
    7575    auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(context);
    76     auto heapAgent = std::make_unique<InspectorHeapAgent>(context);
    77     auto consoleAgent = std::make_unique<InspectorConsoleAgent>(context, heapAgent.get());
     76    auto consoleAgent = std::make_unique<InspectorConsoleAgent>(context);
    7877    auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, consoleAgent.get());
    7978    auto scriptProfilerAgent = std::make_unique<InspectorScriptProfilerAgent>(context);
     
    8887    m_agents.append(WTFMove(consoleAgent));
    8988    m_agents.append(WTFMove(debuggerAgent));
    90     m_agents.append(WTFMove(heapAgent));
    9189    m_agents.append(WTFMove(scriptProfilerAgent));
    9290
     
    315313    auto context = jsAgentContext();
    316314
     315    auto heapAgent = std::make_unique<InspectorHeapAgent>(context);
     316    if (m_consoleAgent)
     317        m_consoleAgent->setInspectorHeapAgent(heapAgent.get());
     318    m_agents.append(WTFMove(heapAgent));
     319
    317320    m_agents.append(std::make_unique<JSGlobalObjectAuditAgent>(context));
    318321}
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp

    r241244 r243150  
    4343static const int expireConsoleMessagesStep = 10;
    4444
    45 InspectorConsoleAgent::InspectorConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent)
     45InspectorConsoleAgent::InspectorConsoleAgent(AgentContext& context)
    4646    : InspectorAgentBase("Console"_s)
    4747    , m_injectedScriptManager(context.injectedScriptManager)
    4848    , m_frontendDispatcher(std::make_unique<ConsoleFrontendDispatcher>(context.frontendRouter))
    4949    , m_backendDispatcher(ConsoleBackendDispatcher::create(context.backendDispatcher, this))
    50     , m_heapAgent(heapAgent)
    51 {
    52 }
    53 
    54 InspectorConsoleAgent::~InspectorConsoleAgent()
    5550{
    5651}
     
    172167{
    173168    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     169        return;
     170
     171    if (!m_heapAgent)
    174172        return;
    175173
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h

    r228600 r243150  
    5353    WTF_MAKE_FAST_ALLOCATED;
    5454public:
    55     InspectorConsoleAgent(AgentContext&, InspectorHeapAgent*);
    56     virtual ~InspectorConsoleAgent();
     55    InspectorConsoleAgent(AgentContext&);
     56    virtual ~InspectorConsoleAgent() = default;
    5757
    5858    void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override;
    5959    void willDestroyFrontendAndBackend(DisconnectReason) override;
    6060    void discardValues() override;
     61
     62    void setInspectorHeapAgent(InspectorHeapAgent* agent) { m_heapAgent = agent; }
    6163
    6264    void enable(ErrorString&) override;
     
    8385    std::unique_ptr<ConsoleFrontendDispatcher> m_frontendDispatcher;
    8486    RefPtr<ConsoleBackendDispatcher> m_backendDispatcher;
    85     InspectorHeapAgent* m_heapAgent;
     87    InspectorHeapAgent* m_heapAgent { nullptr };
    8688
    8789    Vector<std::unique_ptr<ConsoleMessage>> m_consoleMessages;
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp

    r239427 r243150  
    4949}
    5050
    51 InspectorHeapAgent::~InspectorHeapAgent()
    52 {
    53 }
    54 
    5551void InspectorHeapAgent::didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*)
    5652{
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.h

    r239427 r243150  
    4848public:
    4949    InspectorHeapAgent(AgentContext&);
    50     virtual ~InspectorHeapAgent();
     50    virtual ~InspectorHeapAgent() = default;
    5151
    5252    void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override;
  • trunk/Source/WebCore/ChangeLog

    r243146 r243150  
     12019-03-19  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Heap: lazily create the agent
     4        https://bugs.webkit.org/show_bug.cgi?id=195590
     5        <rdar://problem/48791750>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        No change in functionality.
     10
     11        * inspector/agents/page/PageHeapAgent.cpp:
     12        (WebCore::PageHeapAgent::disable):
     13        * inspector/agents/WebHeapAgent.h:
     14        * inspector/agents/WebHeapAgent.cpp:
     15        (WebCore::WebHeapAgent::WebHeapAgent):
     16        (WebCore::WebHeapAgent::enable): Added.
     17        (WebCore::WebHeapAgent::disable):
     18
     19        * inspector/agents/page/PageConsoleAgent.h:
     20        * inspector/agents/page/PageConsoleAgent.cpp:
     21        (WebCore::PageConsoleAgent::PageConsoleAgent):
     22        * inspector/agents/WebConsoleAgent.h:
     23        * inspector/agents/WebConsoleAgent.cpp:
     24        (WebCore::WebConsoleAgent::WebConsoleAgent):
     25        * inspector/agents/worker/WorkerConsoleAgent.h:
     26        * inspector/agents/worker/WorkerConsoleAgent.cpp:
     27        (WebCore::WorkerConsoleAgent::WorkerConsoleAgent):
     28
     29        * inspector/InspectorController.cpp:
     30        (WebCore::InspectorController::InspectorController):
     31        (WebCore::InspectorController::createLazyAgents):
     32        * inspector/WorkerInspectorController.cpp:
     33        (WebCore::WorkerInspectorController::WorkerInspectorController):
     34        (WebCore::WorkerInspectorController::createLazyAgents):
     35
    1362019-03-19  Simon Fraser  <simon.fraser@apple.com>
    237
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r243119 r243150  
    132132    m_agents.append(WTFMove(domStorageAgentPtr));
    133133
    134     auto heapAgentPtr = std::make_unique<PageHeapAgent>(pageContext);
    135     InspectorHeapAgent* heapAgent = heapAgentPtr.get();
    136     m_agents.append(WTFMove(heapAgentPtr));
    137 
    138134    auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(pageContext);
    139135    m_instrumentingAgents->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
    140136    m_agents.append(WTFMove(scriptProfilerAgentPtr));
    141137
    142     auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, heapAgent, m_domAgent);
     138    auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, m_domAgent);
    143139    WebConsoleAgent* consoleAgent = consoleAgentPtr.get();
    144140    m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get());
     
    203199    m_agents.append(std::make_unique<InspectorCPUProfilerAgent>(pageContext));
    204200    m_agents.append(std::make_unique<InspectorMemoryAgent>(pageContext));
     201    m_agents.append(std::make_unique<PageHeapAgent>(pageContext));
    205202#endif
    206203    m_agents.append(std::make_unique<PageAuditAgent>(pageContext));
  • trunk/Source/WebCore/inspector/WorkerInspectorController.cpp

    r242940 r243150  
    7070    auto workerContext = workerAgentContext();
    7171
    72     auto heapAgent = std::make_unique<WebHeapAgent>(workerContext);
    73     auto consoleAgent = std::make_unique<WorkerConsoleAgent>(workerContext, heapAgent.get());
    74 
     72    auto consoleAgent = std::make_unique<WorkerConsoleAgent>(workerContext);
    7573    m_instrumentingAgents->setWebConsoleAgent(consoleAgent.get());
    7674
     
    7876    m_agents.append(std::make_unique<WorkerDebuggerAgent>(workerContext));
    7977    m_agents.append(WTFMove(consoleAgent));
    80     m_agents.append(WTFMove(heapAgent));
    8178
    8279    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
     
    179176#endif
    180177
     178    m_agents.append(std::make_unique<WebHeapAgent>(workerContext));
    181179    m_agents.append(std::make_unique<WorkerAuditAgent>(workerContext));
    182180}
  • trunk/Source/WebCore/inspector/agents/WebConsoleAgent.cpp

    r243141 r243150  
    4444using namespace Inspector;
    4545
    46 WebConsoleAgent::WebConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent)
    47     : InspectorConsoleAgent(context, heapAgent)
     46WebConsoleAgent::WebConsoleAgent(AgentContext& context)
     47    : InspectorConsoleAgent(context)
    4848{
    4949}
  • trunk/Source/WebCore/inspector/agents/WebConsoleAgent.h

    r228218 r243150  
    3939    WTF_MAKE_FAST_ALLOCATED;
    4040public:
    41     WebConsoleAgent(Inspector::AgentContext&, Inspector::InspectorHeapAgent*);
     41    WebConsoleAgent(Inspector::AgentContext&);
    4242    virtual ~WebConsoleAgent() = default;
    4343
  • trunk/Source/WebCore/inspector/agents/WebHeapAgent.cpp

    r229174 r243150  
    9393}
    9494
    95 WebHeapAgent::WebHeapAgent(Inspector::AgentContext& context)
     95WebHeapAgent::WebHeapAgent(WebAgentContext& context)
    9696    : InspectorHeapAgent(context)
     97    , m_instrumentingAgents(context.instrumentingAgents)
    9798    , m_sendGarbageCollectionEventsTask(std::make_unique<SendGarbageCollectionEventsTask>(*this))
    9899{
     
    104105}
    105106
     107void WebHeapAgent::enable(ErrorString& errorString)
     108{
     109    InspectorHeapAgent::enable(errorString);
     110
     111    if (auto* consoleAgent = m_instrumentingAgents.webConsoleAgent())
     112        consoleAgent->setInspectorHeapAgent(this);
     113}
     114
    106115void WebHeapAgent::disable(ErrorString& errorString)
    107116{
    108117    m_sendGarbageCollectionEventsTask->reset();
     118
     119    if (auto* consoleAgent = m_instrumentingAgents.webConsoleAgent())
     120        consoleAgent->setInspectorHeapAgent(nullptr);
    109121
    110122    InspectorHeapAgent::disable(errorString);
  • trunk/Source/WebCore/inspector/agents/WebHeapAgent.h

    r229174 r243150  
    2626#pragma once
    2727
     28#include "InspectorWebAgentBase.h"
    2829#include <JavaScriptCore/InspectorHeapAgent.h>
    2930#include <wtf/Forward.h>
     
    4041    friend class SendGarbageCollectionEventsTask;
    4142public:
    42     WebHeapAgent(Inspector::AgentContext&);
     43    WebHeapAgent(WebAgentContext&);
    4344    virtual ~WebHeapAgent();
    4445
    4546protected:
     47    void enable(ErrorString&) override;
    4648    void disable(ErrorString&) override;
    4749
     
    5052    void dispatchGarbageCollectionEventsAfterDelay(Vector<GarbageCollectionData>&& collections);
    5153
     54    InstrumentingAgents& m_instrumentingAgents;
     55
    5256    std::unique_ptr<SendGarbageCollectionEventsTask> m_sendGarbageCollectionEventsTask;
    5357};
  • trunk/Source/WebCore/inspector/agents/page/PageConsoleAgent.cpp

    r225263 r243150  
    4343using namespace Inspector;
    4444
    45 PageConsoleAgent::PageConsoleAgent(WebAgentContext& context, InspectorHeapAgent* heapAgent, InspectorDOMAgent* domAgent)
    46     : WebConsoleAgent(context, heapAgent)
     45PageConsoleAgent::PageConsoleAgent(WebAgentContext& context, InspectorDOMAgent* domAgent)
     46    : WebConsoleAgent(context)
    4747    , m_inspectorDOMAgent(domAgent)
    4848{
  • trunk/Source/WebCore/inspector/agents/page/PageConsoleAgent.h

    r224345 r243150  
    4343    WTF_MAKE_FAST_ALLOCATED;
    4444public:
    45     PageConsoleAgent(WebAgentContext&, Inspector::InspectorHeapAgent*, InspectorDOMAgent*);
     45    PageConsoleAgent(WebAgentContext&, InspectorDOMAgent*);
    4646    virtual ~PageConsoleAgent() = default;
    4747
  • trunk/Source/WebCore/inspector/agents/page/PageHeapAgent.cpp

    r225263 r243150  
    4646void PageHeapAgent::disable(ErrorString& errorString)
    4747{
     48    m_instrumentingAgents.setPageHeapAgent(nullptr);
    4849    WebHeapAgent::disable(errorString);
    49     m_instrumentingAgents.setPageHeapAgent(nullptr);
    5050}
    5151
  • trunk/Source/WebCore/inspector/agents/worker/WorkerConsoleAgent.cpp

    r224788 r243150  
    3333using namespace Inspector;
    3434
    35 WorkerConsoleAgent::WorkerConsoleAgent(WorkerAgentContext& context, InspectorHeapAgent* heapAgent)
    36     : WebConsoleAgent(context, heapAgent)
     35WorkerConsoleAgent::WorkerConsoleAgent(WorkerAgentContext& context)
     36    : WebConsoleAgent(context)
    3737{
    3838    ASSERT(context.workerGlobalScope.isContextThread());
  • trunk/Source/WebCore/inspector/agents/worker/WorkerConsoleAgent.h

    r224345 r243150  
    3535    WTF_MAKE_FAST_ALLOCATED;
    3636public:
    37     WorkerConsoleAgent(WorkerAgentContext&, Inspector::InspectorHeapAgent*);
     37    WorkerConsoleAgent(WorkerAgentContext&);
    3838    ~WorkerConsoleAgent() = default;
    3939};
Note: See TracChangeset for help on using the changeset viewer.