<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[174095] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/174095">174095</a></dd>
<dt>Author</dt> <dd>burg@cs.washington.edu</dd>
<dt>Date</dt> <dd>2014-09-29 20:34:11 -0700 (Mon, 29 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>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/JavaScriptCore:

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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreprofilerLegacyProfilercpp">trunk/Source/JavaScriptCore/profiler/LegacyProfiler.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreprofilerLegacyProfilerh">trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreprofilerProfileGeneratorcpp">trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreprofilerProfileGeneratorh">trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorControllercpp">trunk/Source/WebCore/inspector/InspectorController.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (174094 => 174095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-09-30 03:34:11 UTC (rev 174095)
</span><span class="lines">@@ -1,5 +1,26 @@
</span><span class="cx"> 2014-09-29  Brian J. Burg  &lt;burg@cs.washington.edu&gt;
</span><span class="cx"> 
</span><ins>+        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  &lt;burg@cs.washington.edu&gt;
+
</ins><span class="cx">         Web Inspector: InspectorValues should use references for out parameters
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=137190
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreprofilerLegacyProfilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/profiler/LegacyProfiler.cpp (174094 => 174095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/profiler/LegacyProfiler.cpp        2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/JavaScriptCore/profiler/LegacyProfiler.cpp        2014-09-30 03:34:11 UTC (rev 174095)
</span><span class="lines">@@ -123,6 +123,22 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void LegacyProfiler::suspendProfiling(JSC::ExecState* exec)
+{
+    if (!exec)
+        return;
+
+    callFunctionForProfilesWithGroup(std::bind(&amp;ProfileGenerator::setIsSuspended, std::placeholders::_1, true), m_currentProfiles, exec-&gt;lexicalGlobalObject()-&gt;profileGroup());
+}
+
+void LegacyProfiler::unsuspendProfiling(JSC::ExecState* exec)
+{
+    if (!exec)
+        return;
+
+    callFunctionForProfilesWithGroup(std::bind(&amp;ProfileGenerator::setIsSuspended, std::placeholders::_1, false), m_currentProfiles, exec-&gt;lexicalGlobalObject()-&gt;profileGroup());
+}
+
</ins><span class="cx"> void LegacyProfiler::willExecute(ExecState* callerCallFrame, JSValue function)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!m_currentProfiles.isEmpty());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreprofilerLegacyProfilerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h (174094 => 174095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h        2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/JavaScriptCore/profiler/LegacyProfiler.h        2014-09-30 03:34:11 UTC (rev 174095)
</span><span class="lines">@@ -55,6 +55,10 @@
</span><span class="cx">     JS_EXPORT_PRIVATE PassRefPtr&lt;Profile&gt; stopProfiling(ExecState*, const WTF::String&amp; title);
</span><span class="cx">     void stopProfiling(JSGlobalObject*);
</span><span class="cx"> 
</span><ins>+    // Used to ignore profile node subtrees rooted at InjectedScript calls.
+    JS_EXPORT_PRIVATE void suspendProfiling(ExecState*);
+    JS_EXPORT_PRIVATE void unsuspendProfiling(ExecState*);
+
</ins><span class="cx">     void willExecute(ExecState* callerCallFrame, JSValue function);
</span><span class="cx">     void willExecute(ExecState* callerCallFrame, const WTF::String&amp; sourceURL, unsigned startingLineNumber, unsigned startingColumnNumber);
</span><span class="cx">     void didExecute(ExecState* callerCallFrame, JSValue function);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreprofilerProfileGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp (174094 => 174095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp        2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp        2014-09-30 03:34:11 UTC (rev 174095)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     , m_profileGroup(exec ? exec-&gt;lexicalGlobalObject()-&gt;profileGroup() : 0)
</span><span class="cx">     , m_debuggerPausedTimestamp(NAN)
</span><span class="cx">     , m_foundConsoleStartParent(false)
</span><ins>+    , m_suspended(false)
</ins><span class="cx"> {
</span><span class="cx">     if (Debugger* debugger = exec-&gt;lexicalGlobalObject()-&gt;debugger())
</span><span class="cx">         m_debuggerPausedTimestamp = debugger-&gt;isPaused() ? currentTime() : NAN;
</span><span class="lines">@@ -162,6 +163,9 @@
</span><span class="cx">     if (!m_origin)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    if (m_suspended)
+        return;
+
</ins><span class="cx">     RefPtr&lt;ProfileNode&gt; calleeNode = nullptr;
</span><span class="cx"> 
</span><span class="cx">     // Find or create a node for the callee call frame.
</span><span class="lines">@@ -190,6 +194,9 @@
</span><span class="cx">     if (!m_origin)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    if (m_suspended)
+        return;
+
</ins><span class="cx">     // Make a new node if the caller node has never seen this callee call frame before.
</span><span class="cx">     // This can happen if |console.profile()| is called several frames deep in the call stack.
</span><span class="cx">     ASSERT(m_currentNode);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreprofilerProfileGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h (174094 => 174095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h        2014-09-30 03:30:54 UTC (rev 174094)
+++ trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h        2014-09-30 03:34:11 UTC (rev 174095)
</span><span class="lines">@@ -57,10 +57,10 @@
</span><span class="cx">         void didPause(PassRefPtr&lt;DebuggerCallFrame&gt;, const CallIdentifier&amp;);
</span><span class="cx">         void didContinue(PassRefPtr&lt;DebuggerCallFrame&gt;, const CallIdentifier&amp;);
</span><span class="cx"> 
</span><ins>+        void setIsSuspended(bool suspended) { ASSERT(m_suspended != suspended); m_suspended = suspended; }
+
</ins><span class="cx">         void stopProfiling();
</span><span class="cx"> 
</span><del>-        typedef void (ProfileGenerator::*ProfileFunction)(ExecState* callerOrHandlerCallFrame, const CallIdentifier&amp; callIdentifier);
-
</del><span class="cx">     private:
</span><span class="cx">         ProfileGenerator(ExecState*, const WTF::String&amp; title, unsigned uid);
</span><span class="cx">         void addParentForConsoleStart(ExecState*);
</span><span class="lines">@@ -79,6 +79,7 @@
</span><span class="cx">         RefPtr&lt;ProfileNode&gt; m_rootNode;
</span><span class="cx">         RefPtr&lt;ProfileNode&gt; m_currentNode;
</span><span class="cx">         bool m_foundConsoleStartParent;
</span><ins>+        bool m_suspended;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (174094 => 174095)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2014-09-29  Brian J. Burg  &lt;burg@cs.washington.edu&gt;
</span><span class="cx"> 
</span><ins>+        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  &lt;burg@cs.washington.edu&gt;
+
</ins><span class="cx">         Web Inspector: InspectorValues should use references for out parameters
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=137190
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (174094 => 174095)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx"> #include &lt;inspector/IdentifiersFactory.h&gt;
</span><span class="cx"> #include &lt;inspector/InspectorBackendDispatcher.h&gt;
</span><span class="cx"> #include &lt;inspector/agents/InspectorAgent.h&gt;
</span><ins>+#include &lt;profiler/LegacyProfiler.h&gt;
</ins><span class="cx"> #include &lt;runtime/JSLock.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="lines">@@ -432,19 +433,14 @@
</span><span class="cx">     return WebCore::evaluateHandlerFromAnyThread;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InspectorController::willCallInjectedScriptFunction(JSC::ExecState* scriptState, const String&amp; scriptName, int scriptLine)
</del><ins>+void InspectorController::willCallInjectedScriptFunction(JSC::ExecState* scriptState, const String&amp;, int)
</ins><span class="cx"> {
</span><del>-    ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(scriptState);
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(scriptExecutionContext, scriptName, scriptLine);
-    m_injectedScriptInstrumentationCookies.append(cookie);
</del><ins>+    LegacyProfiler::profiler()-&gt;suspendProfiling(scriptState);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InspectorController::didCallInjectedScriptFunction(JSC::ExecState* scriptState)
</span><span class="cx"> {
</span><del>-    ASSERT(!m_injectedScriptInstrumentationCookies.isEmpty());
-    ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromExecState(scriptState);
-    InspectorInstrumentationCookie cookie = m_injectedScriptInstrumentationCookies.takeLast();
-    InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext);
</del><ins>+    LegacyProfiler::profiler()-&gt;unsuspendProfiling(scriptState);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InspectorController::frontendInitialized()
</span></span></pre>
</div>
</div>

</body>
</html>