Commit 46f7b628 authored by keishi@chromium.org's avatar keishi@chromium.org

Oilpan: Prepare moving AsyncCallStackTracker to Oilpan

BUG=340522

Review URL: https://codereview.chromium.org/422273002

git-svn-id: svn://svn.chromium.org/blink/trunk@180088 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8f844b42
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "bindings/core/v8/V8Binding.h" #include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8RecursionScope.h" #include "bindings/core/v8/V8RecursionScope.h"
#include "core/dom/ContextLifecycleObserver.h"
#include "core/dom/ExecutionContext.h" #include "core/dom/ExecutionContext.h"
#include "core/dom/ExecutionContextTask.h" #include "core/dom/ExecutionContextTask.h"
#include "core/events/Event.h" #include "core/events/Event.h"
...@@ -56,48 +55,36 @@ static const char enqueueMutationRecordName[] = "Mutation"; ...@@ -56,48 +55,36 @@ static const char enqueueMutationRecordName[] = "Mutation";
namespace blink { namespace blink {
class AsyncCallStackTracker::ExecutionContextData FINAL : public ContextLifecycleObserver { void AsyncCallStackTracker::ExecutionContextData::contextDestroyed()
WTF_MAKE_FAST_ALLOCATED; {
public:
ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* executionContext)
: ContextLifecycleObserver(executionContext)
, m_circularSequentialID(0)
, m_tracker(tracker)
{
}
virtual void contextDestroyed() OVERRIDE
{
ASSERT(executionContext()); ASSERT(executionContext());
ExecutionContextData* self = m_tracker->m_executionContextDataMap.take(executionContext()); OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionContextDataMap.take(executionContext());
ASSERT(self == this); ASSERT(self == this);
ContextLifecycleObserver::contextDestroyed(); ContextLifecycleObserver::contextDestroyed();
delete self; }
}
int circularSequentialID() int AsyncCallStackTracker::ExecutionContextData::circularSequentialID()
{ {
++m_circularSequentialID; ++m_circularSequentialID;
if (m_circularSequentialID <= 0) if (m_circularSequentialID <= 0)
m_circularSequentialID = 1; m_circularSequentialID = 1;
return m_circularSequentialID; return m_circularSequentialID;
} }
private: void AsyncCallStackTracker::ExecutionContextData::trace(Visitor* visitor)
int m_circularSequentialID; {
visitor->trace(m_tracker);
public: #if ENABLE(OILPAN)
AsyncCallStackTracker* m_tracker; visitor->trace(m_timerCallChains);
HashSet<int> m_intervalTimerIds; visitor->trace(m_animationFrameCallChains);
HashMap<int, RefPtr<AsyncCallChain> > m_timerCallChains; visitor->trace(m_eventCallChains);
HashMap<int, RefPtr<AsyncCallChain> > m_animationFrameCallChains; visitor->trace(m_xhrCallChains);
HashMap<Event*, RefPtr<AsyncCallChain> > m_eventCallChains; visitor->trace(m_mutationObserverCallChains);
HashMap<EventTarget*, RefPtr<AsyncCallChain> > m_xhrCallChains; visitor->trace(m_executionContextTaskCallChains);
HashMap<MutationObserver*, RefPtr<AsyncCallChain> > m_mutationObserverCallChains; visitor->trace(m_v8AsyncTaskCallChains);
HashMap<ExecutionContextTask*, RefPtr<AsyncCallChain> > m_executionContextTaskCallChains; visitor->trace(m_asyncOperationCallChains);
HashMap<String, RefPtr<AsyncCallChain> > m_v8AsyncTaskCallChains; #endif
HashMap<int, RefPtr<AsyncCallChain> > m_asyncOperationCallChains; }
};
static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget)
{ {
...@@ -109,6 +96,11 @@ static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) ...@@ -109,6 +96,11 @@ static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget)
return 0; return 0;
} }
void AsyncCallStackTracker::AsyncCallChain::trace(Visitor* visitor)
{
visitor->trace(m_callStacks);
}
AsyncCallStackTracker::AsyncCallStack::AsyncCallStack(const String& description, const ScriptValue& callFrames) AsyncCallStackTracker::AsyncCallStack::AsyncCallStack(const String& description, const ScriptValue& callFrames)
: m_description(description) : m_description(description)
, m_callFrames(callFrames) , m_callFrames(callFrames)
...@@ -411,19 +403,19 @@ void AsyncCallStackTracker::didFireAsyncCall() ...@@ -411,19 +403,19 @@ void AsyncCallStackTracker::didFireAsyncCall()
clearCurrentAsyncCallChain(); clearCurrentAsyncCallChain();
} }
PassRefPtr<AsyncCallStackTracker::AsyncCallChain> AsyncCallStackTracker::createAsyncCallChain(const String& description, const ScriptValue& callFrames) PassRefPtrWillBeRawPtr<AsyncCallStackTracker::AsyncCallChain> AsyncCallStackTracker::createAsyncCallChain(const String& description, const ScriptValue& callFrames)
{ {
if (callFrames.isEmpty()) { if (callFrames.isEmpty()) {
ASSERT(m_currentAsyncCallChain); ASSERT(m_currentAsyncCallChain);
return m_currentAsyncCallChain; // Propogate async call stack chain. return m_currentAsyncCallChain; // Propogate async call stack chain.
} }
RefPtr<AsyncCallChain> chain = adoptRef(m_currentAsyncCallChain ? new AsyncCallStackTracker::AsyncCallChain(*m_currentAsyncCallChain) : new AsyncCallStackTracker::AsyncCallChain()); RefPtrWillBeRawPtr<AsyncCallChain> chain = adoptRefWillBeNoop(m_currentAsyncCallChain ? new AsyncCallStackTracker::AsyncCallChain(*m_currentAsyncCallChain) : new AsyncCallStackTracker::AsyncCallChain());
ensureMaxAsyncCallChainDepth(chain.get(), m_maxAsyncCallStackDepth - 1); ensureMaxAsyncCallChainDepth(chain.get(), m_maxAsyncCallStackDepth - 1);
chain->m_callStacks.prepend(adoptRef(new AsyncCallStackTracker::AsyncCallStack(description, callFrames))); chain->m_callStacks.prepend(adoptRefWillBeNoop(new AsyncCallStackTracker::AsyncCallStack(description, callFrames)));
return chain.release(); return chain.release();
} }
void AsyncCallStackTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassRefPtr<AsyncCallChain> chain) void AsyncCallStackTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassRefPtrWillBeRawPtr<AsyncCallChain> chain)
{ {
if (chain && !V8RecursionScope::recursionLevel(toIsolate(context))) { if (chain && !V8RecursionScope::recursionLevel(toIsolate(context))) {
// Current AsyncCallChain corresponds to the bottommost JS call frame. // Current AsyncCallChain corresponds to the bottommost JS call frame.
...@@ -459,8 +451,8 @@ AsyncCallStackTracker::ExecutionContextData* AsyncCallStackTracker::createContex ...@@ -459,8 +451,8 @@ AsyncCallStackTracker::ExecutionContextData* AsyncCallStackTracker::createContex
{ {
ExecutionContextData* data = m_executionContextDataMap.get(context); ExecutionContextData* data = m_executionContextDataMap.get(context);
if (!data) { if (!data) {
data = new AsyncCallStackTracker::ExecutionContextData(this, context); data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new AsyncCallStackTracker::ExecutionContextData(this, context)))
m_executionContextDataMap.set(context, data); .storedValue->value.get();
} }
return data; return data;
} }
...@@ -469,10 +461,15 @@ void AsyncCallStackTracker::clear() ...@@ -469,10 +461,15 @@ void AsyncCallStackTracker::clear()
{ {
m_currentAsyncCallChain.clear(); m_currentAsyncCallChain.clear();
m_nestedAsyncCallCount = 0; m_nestedAsyncCallCount = 0;
ExecutionContextDataMap copy; m_executionContextDataMap.clear();
m_executionContextDataMap.swap(copy); }
for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.end(); ++it)
delete it->value; void AsyncCallStackTracker::trace(Visitor* visitor)
{
visitor->trace(m_currentAsyncCallChain);
#if ENABLE(OILPAN)
visitor->trace(m_executionContextDataMap);
#endif
} }
} // namespace blink } // namespace blink
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define AsyncCallStackTracker_h #define AsyncCallStackTracker_h
#include "bindings/core/v8/ScriptValue.h" #include "bindings/core/v8/ScriptValue.h"
#include "core/dom/ContextLifecycleObserver.h"
#include "wtf/Deque.h" #include "wtf/Deque.h"
#include "wtf/HashMap.h" #include "wtf/HashMap.h"
#include "wtf/HashSet.h" #include "wtf/HashSet.h"
...@@ -49,13 +50,14 @@ class ExecutionContextTask; ...@@ -49,13 +50,14 @@ class ExecutionContextTask;
class MutationObserver; class MutationObserver;
class XMLHttpRequest; class XMLHttpRequest;
class AsyncCallStackTracker { class AsyncCallStackTracker FINAL : public NoBaseWillBeGarbageCollectedFinalized<AsyncCallStackTracker> {
WTF_MAKE_NONCOPYABLE(AsyncCallStackTracker); WTF_MAKE_NONCOPYABLE(AsyncCallStackTracker);
public: public:
class AsyncCallStack : public RefCounted<AsyncCallStack> { class AsyncCallStack FINAL : public RefCountedWillBeGarbageCollectedFinalized<AsyncCallStack> {
public: public:
AsyncCallStack(const String&, const ScriptValue&); AsyncCallStack(const String&, const ScriptValue&);
~AsyncCallStack(); ~AsyncCallStack();
void trace(Visitor*) { }
String description() const { return m_description; } String description() const { return m_description; }
ScriptValue callFrames() const { return m_callFrames; } ScriptValue callFrames() const { return m_callFrames; }
private: private:
...@@ -63,18 +65,51 @@ public: ...@@ -63,18 +65,51 @@ public:
ScriptValue m_callFrames; ScriptValue m_callFrames;
}; };
typedef Deque<RefPtr<AsyncCallStack>, 4> AsyncCallStackVector; typedef WillBeHeapDeque<RefPtrWillBeMember<AsyncCallStack>, 4> AsyncCallStackVector;
class AsyncCallChain : public RefCounted<AsyncCallChain> { class AsyncCallChain FINAL : public RefCountedWillBeGarbageCollected<AsyncCallChain> {
public: public:
AsyncCallChain() { } AsyncCallChain() { }
AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) { } AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) { }
AsyncCallStackVector callStacks() const { return m_callStacks; } AsyncCallStackVector callStacks() const { return m_callStacks; }
void trace(Visitor*);
private: private:
friend class AsyncCallStackTracker; friend class AsyncCallStackTracker;
AsyncCallStackVector m_callStacks; AsyncCallStackVector m_callStacks;
}; };
class ExecutionContextData FINAL : public NoBaseWillBeGarbageCollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* executionContext)
: ContextLifecycleObserver(executionContext)
, m_circularSequentialID(0)
, m_tracker(tracker)
{
}
virtual void contextDestroyed() OVERRIDE;
int circularSequentialID();
void trace(Visitor*);
private:
int m_circularSequentialID;
public:
RawPtrWillBeMember<AsyncCallStackTracker> m_tracker;
HashSet<int> m_intervalTimerIds;
WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_timerCallChains;
WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_animationFrameCallChains;
WillBeHeapHashMap<RawPtrWillBeMember<Event>, RefPtrWillBeMember<AsyncCallChain> > m_eventCallChains;
WillBeHeapHashMap<RawPtrWillBeMember<EventTarget>, RefPtrWillBeMember<AsyncCallChain> > m_xhrCallChains;
WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, RefPtrWillBeMember<AsyncCallChain> > m_mutationObserverCallChains;
WillBeHeapHashMap<ExecutionContextTask*, RefPtrWillBeMember<AsyncCallChain> > m_executionContextTaskCallChains;
WillBeHeapHashMap<String, RefPtrWillBeMember<AsyncCallChain> > m_v8AsyncTaskCallChains;
WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_asyncOperationCallChains;
};
AsyncCallStackTracker(); AsyncCallStackTracker();
bool isEnabled() const { return m_maxAsyncCallStackDepth; } bool isEnabled() const { return m_maxAsyncCallStackDepth; }
...@@ -115,22 +150,23 @@ public: ...@@ -115,22 +150,23 @@ public:
void didFireAsyncCall(); void didFireAsyncCall();
void clear(); void clear();
void trace(Visitor*);
private: private:
void willHandleXHREvent(XMLHttpRequest*, Event*); void willHandleXHREvent(XMLHttpRequest*, Event*);
PassRefPtr<AsyncCallChain> createAsyncCallChain(const String& description, const ScriptValue& callFrames); PassRefPtrWillBeRawPtr<AsyncCallChain> createAsyncCallChain(const String& description, const ScriptValue& callFrames);
void setCurrentAsyncCallChain(ExecutionContext*, PassRefPtr<AsyncCallChain>); void setCurrentAsyncCallChain(ExecutionContext*, PassRefPtrWillBeRawPtr<AsyncCallChain>);
void clearCurrentAsyncCallChain(); void clearCurrentAsyncCallChain();
static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned); static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned);
bool validateCallFrames(const ScriptValue& callFrames); bool validateCallFrames(const ScriptValue& callFrames);
class ExecutionContextData;
ExecutionContextData* createContextDataIfNeeded(ExecutionContext*); ExecutionContextData* createContextDataIfNeeded(ExecutionContext*);
unsigned m_maxAsyncCallStackDepth; unsigned m_maxAsyncCallStackDepth;
RefPtr<AsyncCallChain> m_currentAsyncCallChain; RefPtrWillBeMember<AsyncCallChain> m_currentAsyncCallChain;
unsigned m_nestedAsyncCallCount; unsigned m_nestedAsyncCallCount;
typedef HashMap<ExecutionContext*, ExecutionContextData*> ExecutionContextDataMap; typedef WillBeHeapHashMap<RawPtrWillBeMember<ExecutionContext>, OwnPtrWillBeMember<ExecutionContextData> > ExecutionContextDataMap;
ExecutionContextDataMap m_executionContextDataMap; ExecutionContextDataMap m_executionContextDataMap;
}; };
......
...@@ -123,6 +123,7 @@ InspectorDebuggerAgent::InspectorDebuggerAgent(InjectedScriptManager* injectedSc ...@@ -123,6 +123,7 @@ InspectorDebuggerAgent::InspectorDebuggerAgent(InjectedScriptManager* injectedSc
, m_listener(nullptr) , m_listener(nullptr)
, m_skippedStepInCount(0) , m_skippedStepInCount(0)
, m_skipAllPauses(false) , m_skipAllPauses(false)
, m_asyncCallStackTracker(adoptPtrWillBeNoop(new AsyncCallStackTracker()))
{ {
} }
...@@ -221,7 +222,7 @@ void InspectorDebuggerAgent::restore() ...@@ -221,7 +222,7 @@ void InspectorDebuggerAgent::restore()
m_skipAllPauses = false; m_skipAllPauses = false;
m_state->setBoolean(DebuggerAgentState::skipAllPauses, false); m_state->setBoolean(DebuggerAgentState::skipAllPauses, false);
} }
m_asyncCallStackTracker.setAsyncCallStackDepth(m_state->getLong(DebuggerAgentState::asyncCallStackDepth)); asyncCallStackTracker().setAsyncCallStackDepth(m_state->getLong(DebuggerAgentState::asyncCallStackDepth));
} }
} }
...@@ -713,185 +714,185 @@ void InspectorDebuggerAgent::cancelPauseOnNextStatement() ...@@ -713,185 +714,185 @@ void InspectorDebuggerAgent::cancelPauseOnNextStatement()
void InspectorDebuggerAgent::didInstallTimer(ExecutionContext* context, int timerId, int timeout, bool singleShot) void InspectorDebuggerAgent::didInstallTimer(ExecutionContext* context, int timerId, int timeout, bool singleShot)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didInstallTimer(context, timerId, singleShot, scriptDebugServer().currentCallFramesForAsyncStack()); asyncCallStackTracker().didInstallTimer(context, timerId, singleShot, scriptDebugServer().currentCallFramesForAsyncStack());
} }
void InspectorDebuggerAgent::didRemoveTimer(ExecutionContext* context, int timerId) void InspectorDebuggerAgent::didRemoveTimer(ExecutionContext* context, int timerId)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didRemoveTimer(context, timerId); asyncCallStackTracker().didRemoveTimer(context, timerId);
} }
bool InspectorDebuggerAgent::willFireTimer(ExecutionContext* context, int timerId) bool InspectorDebuggerAgent::willFireTimer(ExecutionContext* context, int timerId)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.willFireTimer(context, timerId); asyncCallStackTracker().willFireTimer(context, timerId);
return true; return true;
} }
void InspectorDebuggerAgent::didFireTimer() void InspectorDebuggerAgent::didFireTimer()
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didFireAsyncCall(); asyncCallStackTracker().didFireAsyncCall();
cancelPauseOnNextStatement(); cancelPauseOnNextStatement();
} }
void InspectorDebuggerAgent::didRequestAnimationFrame(Document* document, int callbackId) void InspectorDebuggerAgent::didRequestAnimationFrame(Document* document, int callbackId)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didRequestAnimationFrame(document, callbackId, scriptDebugServer().currentCallFramesForAsyncStack()); asyncCallStackTracker().didRequestAnimationFrame(document, callbackId, scriptDebugServer().currentCallFramesForAsyncStack());
} }
void InspectorDebuggerAgent::didCancelAnimationFrame(Document* document, int callbackId) void InspectorDebuggerAgent::didCancelAnimationFrame(Document* document, int callbackId)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didCancelAnimationFrame(document, callbackId); asyncCallStackTracker().didCancelAnimationFrame(document, callbackId);
} }
bool InspectorDebuggerAgent::willFireAnimationFrame(Document* document, int callbackId) bool InspectorDebuggerAgent::willFireAnimationFrame(Document* document, int callbackId)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.willFireAnimationFrame(document, callbackId); asyncCallStackTracker().willFireAnimationFrame(document, callbackId);
return true; return true;
} }
void InspectorDebuggerAgent::didFireAnimationFrame() void InspectorDebuggerAgent::didFireAnimationFrame()
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didFireAsyncCall(); asyncCallStackTracker().didFireAsyncCall();
} }
void InspectorDebuggerAgent::didEnqueueEvent(EventTarget* eventTarget, Event* event) void InspectorDebuggerAgent::didEnqueueEvent(EventTarget* eventTarget, Event* event)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didEnqueueEvent(eventTarget, event, scriptDebugServer().currentCallFramesForAsyncStack()); asyncCallStackTracker().didEnqueueEvent(eventTarget, event, scriptDebugServer().currentCallFramesForAsyncStack());
} }
void InspectorDebuggerAgent::didRemoveEvent(EventTarget* eventTarget, Event* event) void InspectorDebuggerAgent::didRemoveEvent(EventTarget* eventTarget, Event* event)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didRemoveEvent(eventTarget, event); asyncCallStackTracker().didRemoveEvent(eventTarget, event);
} }
void InspectorDebuggerAgent::willHandleEvent(EventTarget* eventTarget, Event* event, EventListener* listener, bool useCapture) void InspectorDebuggerAgent::willHandleEvent(EventTarget* eventTarget, Event* event, EventListener* listener, bool useCapture)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.willHandleEvent(eventTarget, event, listener, useCapture); asyncCallStackTracker().willHandleEvent(eventTarget, event, listener, useCapture);
} }
void InspectorDebuggerAgent::didHandleEvent() void InspectorDebuggerAgent::didHandleEvent()
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didFireAsyncCall(); asyncCallStackTracker().didFireAsyncCall();
cancelPauseOnNextStatement(); cancelPauseOnNextStatement();
} }
void InspectorDebuggerAgent::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*, const AtomicString&, const KURL&, bool async, FormData*, const HTTPHeaderMap&, bool) void InspectorDebuggerAgent::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*, const AtomicString&, const KURL&, bool async, FormData*, const HTTPHeaderMap&, bool)
{ {
if (m_asyncCallStackTracker.isEnabled() && async) if (asyncCallStackTracker().isEnabled() && async)
m_asyncCallStackTracker.willLoadXHR(xhr, scriptDebugServer().currentCallFramesForAsyncStack()); asyncCallStackTracker().willLoadXHR(xhr, scriptDebugServer().currentCallFramesForAsyncStack());
} }
void InspectorDebuggerAgent::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr) void InspectorDebuggerAgent::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didLoadXHR(xhr); asyncCallStackTracker().didLoadXHR(xhr);
} }
void InspectorDebuggerAgent::didEnqueueMutationRecord(ExecutionContext* context, MutationObserver* observer) void InspectorDebuggerAgent::didEnqueueMutationRecord(ExecutionContext* context, MutationObserver* observer)
{ {
if (m_asyncCallStackTracker.isEnabled() && !m_asyncCallStackTracker.hasEnqueuedMutationRecord(context, observer)) if (asyncCallStackTracker().isEnabled() && !asyncCallStackTracker().hasEnqueuedMutationRecord(context, observer))
m_asyncCallStackTracker.didEnqueueMutationRecord(context, observer, scriptDebugServer().currentCallFramesForAsyncStack()); asyncCallStackTracker().didEnqueueMutationRecord(context, observer, scriptDebugServer().currentCallFramesForAsyncStack());
} }
void InspectorDebuggerAgent::didClearAllMutationRecords(ExecutionContext* context, MutationObserver* observer) void InspectorDebuggerAgent::didClearAllMutationRecords(ExecutionContext* context, MutationObserver* observer)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didClearAllMutationRecords(context, observer); asyncCallStackTracker().didClearAllMutationRecords(context, observer);
} }
void InspectorDebuggerAgent::willDeliverMutationRecords(ExecutionContext* context, MutationObserver* observer) void InspectorDebuggerAgent::willDeliverMutationRecords(ExecutionContext* context, MutationObserver* observer)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.willDeliverMutationRecords(context, observer); asyncCallStackTracker().willDeliverMutationRecords(context, observer);
} }
void InspectorDebuggerAgent::didDeliverMutationRecords() void InspectorDebuggerAgent::didDeliverMutationRecords()
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didFireAsyncCall(); asyncCallStackTracker().didFireAsyncCall();
} }
void InspectorDebuggerAgent::didPostExecutionContextTask(ExecutionContext* context, ExecutionContextTask* task) void InspectorDebuggerAgent::didPostExecutionContextTask(ExecutionContext* context, ExecutionContextTask* task)
{ {
if (m_asyncCallStackTracker.isEnabled() && !task->taskNameForInstrumentation().isEmpty()) if (asyncCallStackTracker().isEnabled() && !task->taskNameForInstrumentation().isEmpty())
m_asyncCallStackTracker.didPostExecutionContextTask(context, task, scriptDebugServer().currentCallFramesForAsyncStack()); asyncCallStackTracker().didPostExecutionContextTask(context, task, scriptDebugServer().currentCallFramesForAsyncStack());
} }
void InspectorDebuggerAgent::didKillAllExecutionContextTasks(ExecutionContext* context) void InspectorDebuggerAgent::didKillAllExecutionContextTasks(ExecutionContext* context)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didKillAllExecutionContextTasks(context); asyncCallStackTracker().didKillAllExecutionContextTasks(context);
} }
void InspectorDebuggerAgent::willPerformExecutionContextTask(ExecutionContext* context, ExecutionContextTask* task) void InspectorDebuggerAgent::willPerformExecutionContextTask(ExecutionContext* context, ExecutionContextTask* task)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.willPerformExecutionContextTask(context, task); asyncCallStackTracker().willPerformExecutionContextTask(context, task);
} }
void InspectorDebuggerAgent::didPerformExecutionContextTask() void InspectorDebuggerAgent::didPerformExecutionContextTask()
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didFireAsyncCall(); asyncCallStackTracker().didFireAsyncCall();
} }
int InspectorDebuggerAgent::traceAsyncOperationStarting(ExecutionContext* context, const String& operationName, int prevOperationId) int InspectorDebuggerAgent::traceAsyncOperationStarting(ExecutionContext* context, const String& operationName, int prevOperationId)
{ {
if (!m_asyncCallStackTracker.isEnabled()) if (!asyncCallStackTracker().isEnabled())
return 0; return 0;
if (prevOperationId) if (prevOperationId)
m_asyncCallStackTracker.traceAsyncOperationCompleted(context, prevOperationId); asyncCallStackTracker().traceAsyncOperationCompleted(context, prevOperationId);
return m_asyncCallStackTracker.traceAsyncOperationStarting(context, operationName, scriptDebugServer().currentCallFramesForAsyncStack()); return asyncCallStackTracker().traceAsyncOperationStarting(context, operationName, scriptDebugServer().currentCallFramesForAsyncStack());
} }
void InspectorDebuggerAgent::traceAsyncOperationCompleted(ExecutionContext* context, int operationId) void InspectorDebuggerAgent::traceAsyncOperationCompleted(ExecutionContext* context, int operationId)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.traceAsyncOperationCompleted(context, operationId); asyncCallStackTracker().traceAsyncOperationCompleted(context, operationId);
} }
void InspectorDebuggerAgent::traceAsyncOperationCompletedCallbackStarting(ExecutionContext* context, int operationId) void InspectorDebuggerAgent::traceAsyncOperationCompletedCallbackStarting(ExecutionContext* context, int operationId)
{ {
if (!m_asyncCallStackTracker.isEnabled()) if (!asyncCallStackTracker().isEnabled())
return; return;
m_asyncCallStackTracker.traceAsyncCallbackStarting(context, operationId); asyncCallStackTracker().traceAsyncCallbackStarting(context, operationId);
m_asyncCallStackTracker.traceAsyncOperationCompleted(context, operationId); asyncCallStackTracker().traceAsyncOperationCompleted(context, operationId);
} }
void InspectorDebuggerAgent::traceAsyncCallbackStarting(ExecutionContext* context, int operationId) void InspectorDebuggerAgent::traceAsyncCallbackStarting(ExecutionContext* context, int operationId)
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.traceAsyncCallbackStarting(context, operationId); asyncCallStackTracker().traceAsyncCallbackStarting(context, operationId);
} }
void InspectorDebuggerAgent::traceAsyncCallbackCompleted() void InspectorDebuggerAgent::traceAsyncCallbackCompleted()
{ {
if (m_asyncCallStackTracker.isEnabled()) if (asyncCallStackTracker().isEnabled())
m_asyncCallStackTracker.didFireAsyncCall(); asyncCallStackTracker().didFireAsyncCall();
} }
void InspectorDebuggerAgent::didReceiveV8AsyncTaskEvent(ExecutionContext* context, const String& eventType, const String& eventName, int id) void InspectorDebuggerAgent::didReceiveV8AsyncTaskEvent(ExecutionContext* context, const String& eventType, const String& eventName, int id)
{ {
if (!m_asyncCallStackTracker.isEnabled()) if (!asyncCallStackTracker().isEnabled())
return; return;
if (eventType == v8AsyncTaskEventEnqueue) if (eventType == v8AsyncTaskEventEnqueue)
m_asyncCallStackTracker.didEnqueueV8AsyncTask(context, eventName, id, scriptDebugServer().currentCallFramesForAsyncStack()); asyncCallStackTracker().didEnqueueV8AsyncTask(context, eventName, id, scriptDebugServer().currentCallFramesForAsyncStack());
else if (eventType == v8AsyncTaskEventWillHandle) else if (eventType == v8AsyncTaskEventWillHandle)
m_asyncCallStackTracker.willHandleV8AsyncTask(context, eventName, id); asyncCallStackTracker().willHandleV8AsyncTask(context, eventName, id);
else if (eventType == v8AsyncTaskEventDidHandle) else if (eventType == v8AsyncTaskEventDidHandle)
m_asyncCallStackTracker.didFireAsyncCall(); asyncCallStackTracker().didFireAsyncCall();
else else
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
...@@ -992,7 +993,7 @@ void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const ...@@ -992,7 +993,7 @@ void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const
} }
Vector<ScriptValue> asyncCallStacks; Vector<ScriptValue> asyncCallStacks;
const AsyncCallStackTracker::AsyncCallChain* asyncChain = m_asyncCallStackTracker.isEnabled() ? m_asyncCallStackTracker.currentAsyncCallChain() : 0; const AsyncCallStackTracker::AsyncCallChain* asyncChain = asyncCallStackTracker().isEnabled() ? asyncCallStackTracker().currentAsyncCallChain() : 0;
if (asyncChain) { if (asyncChain) {
const AsyncCallStackTracker::AsyncCallStackVector& callStacks = asyncChain->callStacks(); const AsyncCallStackTracker::AsyncCallStackVector& callStacks = asyncChain->callStacks();
asyncCallStacks.resize(callStacks.size()); asyncCallStacks.resize(callStacks.size());
...@@ -1134,7 +1135,7 @@ void InspectorDebuggerAgent::skipStackFrames(ErrorString* errorString, const Str ...@@ -1134,7 +1135,7 @@ void InspectorDebuggerAgent::skipStackFrames(ErrorString* errorString, const Str
void InspectorDebuggerAgent::setAsyncCallStackDepth(ErrorString*, int depth) void InspectorDebuggerAgent::setAsyncCallStackDepth(ErrorString*, int depth)
{ {
m_state->setLong(DebuggerAgentState::asyncCallStackDepth, depth); m_state->setLong(DebuggerAgentState::asyncCallStackDepth, depth);
m_asyncCallStackTracker.setAsyncCallStackDepth(depth); asyncCallStackTracker().setAsyncCallStackDepth(depth);
} }
void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText) void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText)
...@@ -1160,9 +1161,9 @@ PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() ...@@ -1160,9 +1161,9 @@ PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames()
PassRefPtr<StackTrace> InspectorDebuggerAgent::currentAsyncStackTrace() PassRefPtr<StackTrace> InspectorDebuggerAgent::currentAsyncStackTrace()
{ {
if (!m_pausedScriptState || !m_asyncCallStackTracker.isEnabled()) if (!m_pausedScriptState || !asyncCallStackTracker().isEnabled())
return nullptr; return nullptr;
const AsyncCallStackTracker::AsyncCallChain* chain = m_asyncCallStackTracker.currentAsyncCallChain(); const AsyncCallStackTracker::AsyncCallChain* chain = asyncCallStackTracker().currentAsyncCallChain();
if (!chain) if (!chain)
return nullptr; return nullptr;
const AsyncCallStackTracker::AsyncCallStackVector& callStacks = chain->callStacks(); const AsyncCallStackTracker::AsyncCallStackVector& callStacks = chain->callStacks();
...@@ -1206,9 +1207,9 @@ static PassRefPtrWillBeRawPtr<ScriptCallStack> toScriptCallStack(JavaScriptCallF ...@@ -1206,9 +1207,9 @@ static PassRefPtrWillBeRawPtr<ScriptCallStack> toScriptCallStack(JavaScriptCallF
PassRefPtrWillBeRawPtr<ScriptAsyncCallStack> InspectorDebuggerAgent::currentAsyncStackTraceForConsole() PassRefPtrWillBeRawPtr<ScriptAsyncCallStack> InspectorDebuggerAgent::currentAsyncStackTraceForConsole()
{ {
if (!m_asyncCallStackTracker.isEnabled()) if (!asyncCallStackTracker().isEnabled())
return nullptr; return nullptr;
const AsyncCallStackTracker::AsyncCallChain* chain = m_asyncCallStackTracker.currentAsyncCallChain(); const AsyncCallStackTracker::AsyncCallChain* chain = asyncCallStackTracker().currentAsyncCallChain();
if (!chain) if (!chain)
return nullptr; return nullptr;
const AsyncCallStackTracker::AsyncCallStackVector& callStacks = chain->callStacks(); const AsyncCallStackTracker::AsyncCallStackVector& callStacks = chain->callStacks();
...@@ -1398,7 +1399,7 @@ void InspectorDebuggerAgent::clear() ...@@ -1398,7 +1399,7 @@ void InspectorDebuggerAgent::clear()
m_currentCallStack = ScriptValue(); m_currentCallStack = ScriptValue();
m_scripts.clear(); m_scripts.clear();
m_breakpointIdToDebugServerBreakpointIds.clear(); m_breakpointIdToDebugServerBreakpointIds.clear();
m_asyncCallStackTracker.clear(); asyncCallStackTracker().clear();
m_continueToLocationBreakpointId = String(); m_continueToLocationBreakpointId = String();
clearBreakDetails(); clearBreakDetails();
m_javaScriptPauseScheduled = false; m_javaScriptPauseScheduled = false;
...@@ -1440,7 +1441,7 @@ void InspectorDebuggerAgent::reset() ...@@ -1440,7 +1441,7 @@ void InspectorDebuggerAgent::reset()
{ {
m_scripts.clear(); m_scripts.clear();
m_breakpointIdToDebugServerBreakpointIds.clear(); m_breakpointIdToDebugServerBreakpointIds.clear();
m_asyncCallStackTracker.clear(); asyncCallStackTracker().clear();
if (m_frontend) if (m_frontend)
m_frontend->globalObjectCleared(); m_frontend->globalObjectCleared();
} }
...@@ -1449,6 +1450,7 @@ void InspectorDebuggerAgent::trace(Visitor* visitor) ...@@ -1449,6 +1450,7 @@ void InspectorDebuggerAgent::trace(Visitor* visitor)
{ {
visitor->trace(m_injectedScriptManager); visitor->trace(m_injectedScriptManager);
visitor->trace(m_listener); visitor->trace(m_listener);
visitor->trace(m_asyncCallStackTracker);
InspectorBaseAgent::trace(visitor); InspectorBaseAgent::trace(visitor);
} }
......
...@@ -238,6 +238,7 @@ private: ...@@ -238,6 +238,7 @@ private:
PassRefPtrWillBeRawPtr<JavaScriptCallFrame> topCallFrameSkipUnknownSources(); PassRefPtrWillBeRawPtr<JavaScriptCallFrame> topCallFrameSkipUnknownSources();
String scriptURL(JavaScriptCallFrame*); String scriptURL(JavaScriptCallFrame*);
AsyncCallStackTracker& asyncCallStackTracker() { return *m_asyncCallStackTracker; };
typedef HashMap<String, Script> ScriptsMap; typedef HashMap<String, Script> ScriptsMap;
typedef HashMap<String, Vector<String> > BreakpointIdToDebugServerBreakpointIdsMap; typedef HashMap<String, Vector<String> > BreakpointIdToDebugServerBreakpointIdsMap;
...@@ -263,7 +264,7 @@ private: ...@@ -263,7 +264,7 @@ private:
int m_minFrameCountForSkip; int m_minFrameCountForSkip;
bool m_skipAllPauses; bool m_skipAllPauses;
OwnPtr<ScriptRegexp> m_cachedSkipStackRegExp; OwnPtr<ScriptRegexp> m_cachedSkipStackRegExp;
AsyncCallStackTracker m_asyncCallStackTracker; OwnPtrWillBeMember<AsyncCallStackTracker> m_asyncCallStackTracker;
}; };
} // namespace blink } // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment