Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (219888 => 219889)
--- trunk/Source/_javascript_Core/ChangeLog 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-07-25 21:46:42 UTC (rev 219889)
@@ -1,3 +1,21 @@
+2017-07-25 Matt Baker <mattba...@apple.com>
+
+ Web Inspector: Refactoring: extract async stack trace logic from InspectorInstrumentation
+ https://bugs.webkit.org/show_bug.cgi?id=174738
+
+ Reviewed by Brian Burg.
+
+ Move AsyncCallType enum to InspectorDebuggerAgent, which manages async
+ stack traces. This preserves the call type in JSC, makes the range of
+ possible call types explicit, and is safer than passing ints.
+
+ * inspector/agents/InspectorDebuggerAgent.cpp:
+ (Inspector::InspectorDebuggerAgent::asyncCallIdentifier):
+ (Inspector::InspectorDebuggerAgent::didScheduleAsyncCall):
+ (Inspector::InspectorDebuggerAgent::didCancelAsyncCall):
+ (Inspector::InspectorDebuggerAgent::willDispatchAsyncCall):
+ * inspector/agents/InspectorDebuggerAgent.h:
+
2017-07-25 Mark Lam <mark....@apple.com>
Fix bugs in probe code to change sp on x86, x86_64 and 32-bit ARM.
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (219888 => 219889)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp 2017-07-25 21:46:42 UTC (rev 219889)
@@ -223,8 +223,13 @@
breakProgram(DebuggerFrontendDispatcher::Reason::Assert, buildAssertPauseReason(message));
}
-void InspectorDebuggerAgent::didScheduleAsyncCall(JSC::ExecState* exec, int asyncCallType, int callbackIdentifier, bool singleShot)
+InspectorDebuggerAgent::AsyncCallIdentifier InspectorDebuggerAgent::asyncCallIdentifier(AsyncCallType asyncCallType, int callbackId)
{
+ return std::make_pair(static_cast<unsigned>(asyncCallType), callbackId);
+}
+
+void InspectorDebuggerAgent::didScheduleAsyncCall(JSC::ExecState* exec, AsyncCallType asyncCallType, int callbackId, bool singleShot)
+{
if (!m_asyncStackTraceDepth)
return;
@@ -243,18 +248,18 @@
parentStackTrace = it->value;
}
- auto identifier = std::make_pair(asyncCallType, callbackIdentifier);
+ auto identifier = asyncCallIdentifier(asyncCallType, callbackId);
auto asyncStackTrace = AsyncStackTrace::create(WTFMove(callStack), singleShot, WTFMove(parentStackTrace));
m_pendingAsyncCalls.set(identifier, WTFMove(asyncStackTrace));
}
-void InspectorDebuggerAgent::didCancelAsyncCall(int asyncCallType, int callbackIdentifier)
+void InspectorDebuggerAgent::didCancelAsyncCall(AsyncCallType asyncCallType, int callbackId)
{
if (!m_asyncStackTraceDepth)
return;
- auto identifier = std::make_pair(asyncCallType, callbackIdentifier);
+ auto identifier = asyncCallIdentifier(asyncCallType, callbackId);
auto it = m_pendingAsyncCalls.find(identifier);
if (it == m_pendingAsyncCalls.end())
return;
@@ -268,7 +273,7 @@
m_pendingAsyncCalls.remove(identifier);
}
-void InspectorDebuggerAgent::willDispatchAsyncCall(int asyncCallType, int callbackIdentifier)
+void InspectorDebuggerAgent::willDispatchAsyncCall(AsyncCallType asyncCallType, int callbackId)
{
if (!m_asyncStackTraceDepth)
return;
@@ -278,7 +283,7 @@
// A call can be scheduled before the Inspector is opened, or while async stack
// traces are disabled. If no call data exists, do nothing.
- auto identifier = std::make_pair(asyncCallType, callbackIdentifier);
+ auto identifier = asyncCallIdentifier(asyncCallType, callbackId);
auto it = m_pendingAsyncCalls.find(identifier);
if (it == m_pendingAsyncCalls.end())
return;
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h (219888 => 219889)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h 2017-07-25 21:46:42 UTC (rev 219889)
@@ -91,9 +91,14 @@
void handleConsoleAssert(const String& message);
- void didScheduleAsyncCall(JSC::ExecState*, int asyncCallType, int callbackIdentifier, bool singleShot);
- void didCancelAsyncCall(int asyncCallType, int callbackIdentifier);
- void willDispatchAsyncCall(int asyncCallType, int callbackIdentifier);
+ enum class AsyncCallType {
+ DOMTimer,
+ RequestAnimationFrame,
+ };
+
+ void didScheduleAsyncCall(JSC::ExecState*, AsyncCallType, int callbackId, bool singleShot);
+ void didCancelAsyncCall(AsyncCallType, int callbackId);
+ void willDispatchAsyncCall(AsyncCallType, int callbackId);
void didDispatchAsyncCall();
void schedulePauseOnNextStatement(DebuggerFrontendDispatcher::Reason breakReason, RefPtr<InspectorObject>&& data);
@@ -161,7 +166,8 @@
bool breakpointActionsFromProtocol(ErrorString&, RefPtr<InspectorArray>& actions, BreakpointActions* result);
- typedef std::pair<int, int> AsyncCallIdentifier;
+ typedef std::pair<unsigned, int> AsyncCallIdentifier;
+ static AsyncCallIdentifier asyncCallIdentifier(AsyncCallType, int callbackId);
typedef HashMap<JSC::SourceID, Script> ScriptsMap;
typedef HashMap<String, Vector<JSC::BreakpointID>> BreakpointIdentifierToDebugServerBreakpointIDsMap;
Modified: trunk/Source/WebCore/ChangeLog (219888 => 219889)
--- trunk/Source/WebCore/ChangeLog 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/WebCore/ChangeLog 2017-07-25 21:46:42 UTC (rev 219889)
@@ -1,3 +1,42 @@
+2017-07-25 Matt Baker <mattba...@apple.com>
+
+ Web Inspector: Refactoring: extract async stack trace logic from InspectorInstrumentation
+ https://bugs.webkit.org/show_bug.cgi?id=174738
+
+ Reviewed by Brian Burg.
+
+ Relocate AsyncCallType from InspectorInstrumentation to the debugger
+ agent. Plumbing for `requestAnimationFrame` notifications has been added
+ to PageDebuggerAgent, which is responsible for managing async stack traces.
+
+ * dom/ScriptedAnimationController.cpp:
+ (WebCore::ScriptedAnimationController::registerCallback):
+ (WebCore::ScriptedAnimationController::cancelCallback):
+ (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
+
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore::InspectorInstrumentation::didInstallTimerImpl):
+ (WebCore::InspectorInstrumentation::didRemoveTimerImpl):
+ (WebCore::InspectorInstrumentation::willFireTimerImpl):
+ (WebCore::InspectorInstrumentation::didRequestAnimationFrameImpl):
+ (WebCore::InspectorInstrumentation::didCancelAnimationFrameImpl):
+ (WebCore::InspectorInstrumentation::willFireAnimationFrameImpl):
+ (): Deleted.
+ (WebCore::didScheduleAsyncCall): Deleted.
+
+ * inspector/InspectorInstrumentation.h:
+ (WebCore::InspectorInstrumentation::didRequestAnimationFrame):
+ (WebCore::InspectorInstrumentation::didCancelAnimationFrame):
+ (WebCore::InspectorInstrumentation::willFireAnimationFrame):
+ Replaced Frame and Document pointers with references and moved
+ pointer validation upstream.
+
+ * inspector/PageDebuggerAgent.cpp:
+ (WebCore::PageDebuggerAgent::didRequestAnimationFrame):
+ (WebCore::PageDebuggerAgent::willFireAnimationFrame):
+ (WebCore::PageDebuggerAgent::didCancelAnimationFrame):
+ * inspector/PageDebuggerAgent.h:
+
2017-07-25 Said Abou-Hallawa <sabouhall...@apple.com>
Async image decoding for large images should be disabled after the first time a tile is painted
Modified: trunk/Source/WebCore/dom/ScriptedAnimationController.cpp (219888 => 219889)
--- trunk/Source/WebCore/dom/ScriptedAnimationController.cpp 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/WebCore/dom/ScriptedAnimationController.cpp 2017-07-25 21:46:42 UTC (rev 219889)
@@ -174,7 +174,8 @@
callback->m_id = id;
m_callbacks.append(WTFMove(callback));
- InspectorInstrumentation::didRequestAnimationFrame(m_document, id);
+ if (m_document)
+ InspectorInstrumentation::didRequestAnimationFrame(*m_document, id);
if (!m_suspendCount)
scheduleAnimation();
@@ -186,7 +187,7 @@
for (size_t i = 0; i < m_callbacks.size(); ++i) {
if (m_callbacks[i]->m_id == id) {
m_callbacks[i]->m_firedOrCancelled = true;
- InspectorInstrumentation::didCancelAnimationFrame(m_document, id);
+ InspectorInstrumentation::didCancelAnimationFrame(*m_document, id);
m_callbacks.remove(i);
return;
}
@@ -214,7 +215,7 @@
for (auto& callback : callbacks) {
if (!callback->m_firedOrCancelled) {
callback->m_firedOrCancelled = true;
- InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(m_document, callback->m_id);
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(*m_document, callback->m_id);
if (callback->m_useLegacyTimeBase)
callback->handleEvent(legacyHighResNowMs);
else
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (219888 => 219889)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2017-07-25 21:46:42 UTC (rev 219889)
@@ -82,11 +82,6 @@
static const char* const clearTimerEventName = "clearTimer";
static const char* const timerFiredEventName = "timerFired";
-enum AsyncCallType {
- AsyncCallTypeRequestAnimationFrame,
- AsyncCallTypeTimer,
-};
-
namespace {
static HashSet<InstrumentingAgents*>* s_instrumentingAgentsSet = nullptr;
}
@@ -103,17 +98,6 @@
platformStrategies()->loaderStrategy()->setCaptureExtraNetworkLoadMetricsEnabled(false);
}
-static void didScheduleAsyncCall(InstrumentingAgents& instrumentingAgents, AsyncCallType type, int callbackId, ScriptExecutionContext& context, bool singleShot)
-{
- if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent()) {
- JSC::ExecState* scriptState = context.execState();
- if (!scriptState)
- return;
-
- debuggerAgent->didScheduleAsyncCall(scriptState, type, callbackId, singleShot);
- }
-}
-
static Frame* frameForScriptExecutionContext(ScriptExecutionContext* context)
{
Frame* frame = nullptr;
@@ -348,8 +332,10 @@
void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext& context)
{
pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, true);
- didScheduleAsyncCall(instrumentingAgents, AsyncCallTypeTimer, timerId, context, singleShot);
+ if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
+ debuggerAgent->didScheduleAsyncCall(context.execState(), InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId, singleShot);
+
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
timelineAgent->didInstallTimer(timerId, timeout, singleShot, frameForScriptExecutionContext(context));
}
@@ -359,7 +345,7 @@
pauseOnNativeEventIfNeeded(instrumentingAgents, false, clearTimerEventName, true);
if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
- debuggerAgent->didCancelAsyncCall(AsyncCallTypeTimer, timerId);
+ debuggerAgent->didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId);
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
timelineAgent->didRemoveTimer(timerId, frameForScriptExecutionContext(context));
}
@@ -442,7 +428,7 @@
pauseOnNativeEventIfNeeded(instrumentingAgents, false, timerFiredEventName, false);
if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
- debuggerAgent->willDispatchAsyncCall(AsyncCallTypeTimer, timerId);
+ debuggerAgent->willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId);
int timelineAgentId = 0;
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) {
@@ -1033,35 +1019,36 @@
domDebuggerAgent->pauseOnNativeEventIfNeeded(isDOMEvent, eventName, synchronous);
}
-void InspectorInstrumentation::didRequestAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Frame* frame)
+void InspectorInstrumentation::didRequestAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Document& document)
{
pauseOnNativeEventIfNeeded(instrumentingAgents, false, requestAnimationFrameEventName, true);
- didScheduleAsyncCall(instrumentingAgents, AsyncCallTypeRequestAnimationFrame, callbackId, *frame->document(), true);
+ if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+ pageDebuggerAgent->didRequestAnimationFrame(callbackId, document);
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
- timelineAgent->didRequestAnimationFrame(callbackId, frame);
+ timelineAgent->didRequestAnimationFrame(callbackId, document.frame());
}
-void InspectorInstrumentation::didCancelAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Frame* frame)
+void InspectorInstrumentation::didCancelAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Document& document)
{
pauseOnNativeEventIfNeeded(instrumentingAgents, false, cancelAnimationFrameEventName, true);
- if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
- debuggerAgent->didCancelAsyncCall(AsyncCallTypeRequestAnimationFrame, callbackId);
+ if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+ pageDebuggerAgent->didCancelAnimationFrame(callbackId);
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
- timelineAgent->didCancelAnimationFrame(callbackId, frame);
+ timelineAgent->didCancelAnimationFrame(callbackId, document.frame());
}
-InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Frame* frame)
+InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrameImpl(InstrumentingAgents& instrumentingAgents, int callbackId, Document& document)
{
pauseOnNativeEventIfNeeded(instrumentingAgents, false, animationFrameFiredEventName, false);
- if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent())
- debuggerAgent->willDispatchAsyncCall(AsyncCallTypeRequestAnimationFrame, callbackId);
+ if (PageDebuggerAgent* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent())
+ pageDebuggerAgent->willFireAnimationFrame(callbackId);
int timelineAgentId = 0;
if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) {
- timelineAgent->willFireAnimationFrame(callbackId, frame);
+ timelineAgent->willFireAnimationFrame(callbackId, document.frame());
timelineAgentId = timelineAgent->id();
}
return InspectorInstrumentationCookie(instrumentingAgents, timelineAgentId);
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (219888 => 219889)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h 2017-07-25 21:46:42 UTC (rev 219889)
@@ -193,9 +193,9 @@
static void startProfiling(Page&, JSC::ExecState*, const String& title);
static void stopProfiling(Page&, JSC::ExecState*, const String& title);
- static void didRequestAnimationFrame(Document*, int callbackId);
- static void didCancelAnimationFrame(Document*, int callbackId);
- static InspectorInstrumentationCookie willFireAnimationFrame(Document*, int callbackId);
+ static void didRequestAnimationFrame(Document&, int callbackId);
+ static void didCancelAnimationFrame(Document&, int callbackId);
+ static InspectorInstrumentationCookie willFireAnimationFrame(Document&, int callbackId);
static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
static void didOpenDatabase(ScriptExecutionContext*, RefPtr<Database>&&, const String& domain, const String& name, const String& version);
@@ -344,9 +344,9 @@
static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&);
static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
- static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
- static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
- static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Frame*);
+ static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
+ static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
+ static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
@@ -1165,22 +1165,22 @@
stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
}
-inline void InspectorInstrumentation::didRequestAnimationFrame(Document* document, int callbackId)
+inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)
{
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
- didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document->frame());
+ didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document);
}
-inline void InspectorInstrumentation::didCancelAnimationFrame(Document* document, int callbackId)
+inline void InspectorInstrumentation::didCancelAnimationFrame(Document& document, int callbackId)
{
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
- didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document->frame());
+ didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document);
}
-inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document* document, int callbackId)
+inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document& document, int callbackId)
{
if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
- return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document->frame());
+ return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document);
return InspectorInstrumentationCookie();
}
Modified: trunk/Source/WebCore/inspector/PageDebuggerAgent.cpp (219888 => 219889)
--- trunk/Source/WebCore/inspector/PageDebuggerAgent.cpp 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/WebCore/inspector/PageDebuggerAgent.cpp 2017-07-25 21:46:42 UTC (rev 219889)
@@ -33,6 +33,7 @@
#include "PageDebuggerAgent.h"
#include "CachedResource.h"
+#include "Document.h"
#include "InspectorOverlay.h"
#include "InspectorPageAgent.h"
#include "InstrumentingAgents.h"
@@ -150,4 +151,26 @@
setSuppressAllPauses(false);
}
+void PageDebuggerAgent::didRequestAnimationFrame(int callbackId, Document& document)
+{
+ if (!breakpointsActive())
+ return;
+
+ JSC::ExecState* scriptState = document.execState();
+ if (!scriptState)
+ return;
+
+ didScheduleAsyncCall(scriptState, InspectorDebuggerAgent::AsyncCallType::RequestAnimationFrame, callbackId, true);
+}
+
+void PageDebuggerAgent::willFireAnimationFrame(int callbackId)
+{
+ willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::RequestAnimationFrame, callbackId);
+}
+
+void PageDebuggerAgent::didCancelAnimationFrame(int callbackId)
+{
+ didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::RequestAnimationFrame, callbackId);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/PageDebuggerAgent.h (219888 => 219889)
--- trunk/Source/WebCore/inspector/PageDebuggerAgent.h 2017-07-25 21:43:14 UTC (rev 219888)
+++ trunk/Source/WebCore/inspector/PageDebuggerAgent.h 2017-07-25 21:46:42 UTC (rev 219889)
@@ -35,6 +35,7 @@
namespace WebCore {
+class Document;
class InspectorOverlay;
class InspectorPageAgent;
class Page;
@@ -52,6 +53,10 @@
void mainFrameStoppedLoading();
void mainFrameNavigated();
+ void didRequestAnimationFrame(int callbackId, Document&);
+ void willFireAnimationFrame(int callbackId);
+ void didCancelAnimationFrame(int callbackId);
+
protected:
void enable() override;
void disable(bool isBeingDestroyed) override;