Title: [174095] trunk/Source
Revision
174095
Author
b...@cs.washington.edu
Date
2014-09-29 20:34:11 -0700 (Mon, 29 Sep 2014)

Log Message

Web Inspector: InjectedScripts should not be profiled or displayed in Timeline
https://bugs.webkit.org/show_bug.cgi?id=136806

Reviewed by Timothy Hatcher.

Source/_javascript_Core:

It doesn't make sense to show profile nodes for injected scripts when profiling user content.
For now, omit nodes by suspending profiling before and after executing injected scripts.

* profiler/LegacyProfiler.cpp:
(JSC::LegacyProfiler::suspendProfiling): Added.
(JSC::LegacyProfiler::unsuspendProfiling): Added.
* profiler/LegacyProfiler.h:
* profiler/ProfileGenerator.cpp: Add isSuspended() flag, remove unused typedef.
(JSC::ProfileGenerator::ProfileGenerator):
(JSC::ProfileGenerator::willExecute):
(JSC::ProfileGenerator::didExecute):
* profiler/ProfileGenerator.h:
(JSC::ProfileGenerator::setIsSuspended): Added.

Source/WebCore:

Instead of creating timeline records for injected scripts, suspend profiling
of the current page before and after calling injected script functions.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::willCallInjectedScriptFunction):
(WebCore::InspectorController::didCallInjectedScriptFunction):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (174094 => 174095)


--- trunk/Source/_javascript_Core/ChangeLog	2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-09-30 03:34:11 UTC (rev 174095)
@@ -1,5 +1,26 @@
 2014-09-29  Brian J. Burg  <b...@cs.washington.edu>
 
+        Web Inspector: InjectedScripts should not be profiled or displayed in Timeline
+        https://bugs.webkit.org/show_bug.cgi?id=136806
+
+        Reviewed by Timothy Hatcher.
+
+        It doesn't make sense to show profile nodes for injected scripts when profiling user content.
+        For now, omit nodes by suspending profiling before and after executing injected scripts.
+
+        * profiler/LegacyProfiler.cpp:
+        (JSC::LegacyProfiler::suspendProfiling): Added.
+        (JSC::LegacyProfiler::unsuspendProfiling): Added.
+        * profiler/LegacyProfiler.h:
+        * profiler/ProfileGenerator.cpp: Add isSuspended() flag, remove unused typedef.
+        (JSC::ProfileGenerator::ProfileGenerator):
+        (JSC::ProfileGenerator::willExecute):
+        (JSC::ProfileGenerator::didExecute):
+        * profiler/ProfileGenerator.h:
+        (JSC::ProfileGenerator::setIsSuspended): Added.
+
+2014-09-29  Brian J. Burg  <b...@cs.washington.edu>
+
         Web Inspector: InspectorValues should use references for out parameters
         https://bugs.webkit.org/show_bug.cgi?id=137190
 

Modified: trunk/Source/_javascript_Core/profiler/LegacyProfiler.cpp (174094 => 174095)


--- trunk/Source/_javascript_Core/profiler/LegacyProfiler.cpp	2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/_javascript_Core/profiler/LegacyProfiler.cpp	2014-09-30 03:34:11 UTC (rev 174095)
@@ -123,6 +123,22 @@
     }
 }
 
+void LegacyProfiler::suspendProfiling(JSC::ExecState* exec)
+{
+    if (!exec)
+        return;
+
+    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::setIsSuspended, std::placeholders::_1, true), m_currentProfiles, exec->lexicalGlobalObject()->profileGroup());
+}
+
+void LegacyProfiler::unsuspendProfiling(JSC::ExecState* exec)
+{
+    if (!exec)
+        return;
+
+    callFunctionForProfilesWithGroup(std::bind(&ProfileGenerator::setIsSuspended, std::placeholders::_1, false), m_currentProfiles, exec->lexicalGlobalObject()->profileGroup());
+}
+
 void LegacyProfiler::willExecute(ExecState* callerCallFrame, JSValue function)
 {
     ASSERT(!m_currentProfiles.isEmpty());

Modified: trunk/Source/_javascript_Core/profiler/LegacyProfiler.h (174094 => 174095)


--- trunk/Source/_javascript_Core/profiler/LegacyProfiler.h	2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/_javascript_Core/profiler/LegacyProfiler.h	2014-09-30 03:34:11 UTC (rev 174095)
@@ -55,6 +55,10 @@
     JS_EXPORT_PRIVATE PassRefPtr<Profile> stopProfiling(ExecState*, const WTF::String& title);
     void stopProfiling(JSGlobalObject*);
 
+    // Used to ignore profile node subtrees rooted at InjectedScript calls.
+    JS_EXPORT_PRIVATE void suspendProfiling(ExecState*);
+    JS_EXPORT_PRIVATE void unsuspendProfiling(ExecState*);
+
     void willExecute(ExecState* callerCallFrame, JSValue function);
     void willExecute(ExecState* callerCallFrame, const WTF::String& sourceURL, unsigned startingLineNumber, unsigned startingColumnNumber);
     void didExecute(ExecState* callerCallFrame, JSValue function);

Modified: trunk/Source/_javascript_Core/profiler/ProfileGenerator.cpp (174094 => 174095)


--- trunk/Source/_javascript_Core/profiler/ProfileGenerator.cpp	2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/_javascript_Core/profiler/ProfileGenerator.cpp	2014-09-30 03:34:11 UTC (rev 174095)
@@ -50,6 +50,7 @@
     , m_profileGroup(exec ? exec->lexicalGlobalObject()->profileGroup() : 0)
     , m_debuggerPausedTimestamp(NAN)
     , m_foundConsoleStartParent(false)
+    , m_suspended(false)
 {
     if (Debugger* debugger = exec->lexicalGlobalObject()->debugger())
         m_debuggerPausedTimestamp = debugger->isPaused() ? currentTime() : NAN;
@@ -162,6 +163,9 @@
     if (!m_origin)
         return;
 
+    if (m_suspended)
+        return;
+
     RefPtr<ProfileNode> calleeNode = nullptr;
 
     // Find or create a node for the callee call frame.
@@ -190,6 +194,9 @@
     if (!m_origin)
         return;
 
+    if (m_suspended)
+        return;
+
     // Make a new node if the caller node has never seen this callee call frame before.
     // This can happen if |console.profile()| is called several frames deep in the call stack.
     ASSERT(m_currentNode);

Modified: trunk/Source/_javascript_Core/profiler/ProfileGenerator.h (174094 => 174095)


--- trunk/Source/_javascript_Core/profiler/ProfileGenerator.h	2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/_javascript_Core/profiler/ProfileGenerator.h	2014-09-30 03:34:11 UTC (rev 174095)
@@ -57,10 +57,10 @@
         void didPause(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&);
         void didContinue(PassRefPtr<DebuggerCallFrame>, const CallIdentifier&);
 
+        void setIsSuspended(bool suspended) { ASSERT(m_suspended != suspended); m_suspended = suspended; }
+
         void stopProfiling();
 
-        typedef void (ProfileGenerator::*ProfileFunction)(ExecState* callerOrHandlerCallFrame, const CallIdentifier& callIdentifier);
-
     private:
         ProfileGenerator(ExecState*, const WTF::String& title, unsigned uid);
         void addParentForConsoleStart(ExecState*);
@@ -79,6 +79,7 @@
         RefPtr<ProfileNode> m_rootNode;
         RefPtr<ProfileNode> m_currentNode;
         bool m_foundConsoleStartParent;
+        bool m_suspended;
     };
 
 } // namespace JSC

Modified: trunk/Source/WebCore/ChangeLog (174094 => 174095)


--- trunk/Source/WebCore/ChangeLog	2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/WebCore/ChangeLog	2014-09-30 03:34:11 UTC (rev 174095)
@@ -1,5 +1,19 @@
 2014-09-29  Brian J. Burg  <b...@cs.washington.edu>
 
+        Web Inspector: InjectedScripts should not be profiled or displayed in Timeline
+        https://bugs.webkit.org/show_bug.cgi?id=136806
+
+        Reviewed by Timothy Hatcher.
+
+        Instead of creating timeline records for injected scripts, suspend profiling
+        of the current page before and after calling injected script functions.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::willCallInjectedScriptFunction):
+        (WebCore::InspectorController::didCallInjectedScriptFunction):
+
+2014-09-29  Brian J. Burg  <b...@cs.washington.edu>
+
         Web Inspector: InspectorValues should use references for out parameters
         https://bugs.webkit.org/show_bug.cgi?id=137190
 

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (174094 => 174095)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2014-09-30 03:34:11 UTC (rev 174095)
@@ -72,6 +72,7 @@
 #include <inspector/IdentifiersFactory.h>
 #include <inspector/InspectorBackendDispatcher.h>
 #include <inspector/agents/InspectorAgent.h>
+#include <profiler/LegacyProfiler.h>
 #include <runtime/JSLock.h>
 
 #if ENABLE(REMOTE_INSPECTOR)
@@ -432,19 +433,14 @@
     return WebCore::evaluateHandlerFromAnyThread;
 }
 
-void InspectorController::willCallInjectedScriptFunction(JSC::ExecState* scriptState, const String& scriptName, int scriptLine)
+void InspectorController::willCallInjectedScriptFunction(JSC::ExecState* scriptState, const String&, int)
 {
-    ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(scriptState);
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(scriptExecutionContext, scriptName, scriptLine);
-    m_injectedScriptInstrumentationCookies.append(cookie);
+    LegacyProfiler::profiler()->suspendProfiling(scriptState);
 }
 
 void InspectorController::didCallInjectedScriptFunction(JSC::ExecState* scriptState)
 {
-    ASSERT(!m_injectedScriptInstrumentationCookies.isEmpty());
-    ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(scriptState);
-    InspectorInstrumentationCookie cookie = m_injectedScriptInstrumentationCookies.takeLast();
-    InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext);
+    LegacyProfiler::profiler()->unsuspendProfiling(scriptState);
 }
 
 void InspectorController::frontendInitialized()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to