<!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>[180907] trunk</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/180907">180907</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2015-03-02 16:24:24 -0800 (Mon, 02 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>
Source/JavaScriptCore:
Exception stack unwinding in JSC hangs while the Timeline Profiler is enabled.
&lt;https://webkit.org/b/142191&gt;

Reviewed by Geoffrey Garen.

Imagine a scenario where the Inspector is paused / suspended at a breakpoint or
while the user is stepping through JS code. The user then tries to evaluate an
expression in the console, and that evaluation results in an exception being
thrown. Currently, if the Timeline Profiler is enabled while this exception is
being thrown, the WebProcess will hang while trying to handle that exception.

The issue is that the Timeline Profiler's ProfileGenerator::didExecute() will
return early and decline to process ProfileNodes if the Inspector is paused.
This is proper because it does not want to count work done for injected scripts
(e.g. from the console) towards the timeline profile of the webpage being run.
However, this is in conflict with ProfileGenerator::exceptionUnwind()'s
expectation that didExecute() will process ProfileNodes in order to do the stack
unwinding for the exception handling. As a result,
ProfileGenerator::exceptionUnwind() hangs.

ProfileGenerator::exceptionUnwind() is in error. While the Inspector is paused,
there will not be any ProfileNodes that it needs to &quot;unwind&quot;. Hence, the fix is
simply to return early also in ProfileGenerator::exceptionUnwind() if the
Inspector is paused.

* profiler/ProfileGenerator.cpp:
(JSC::ProfileGenerator::exceptionUnwind):

LayoutTests:
Last gardening after <a href="http://trac.webkit.org/projects/webkit/changeset/177774">r177774</a>

Unreviewed.

Patch by Myles C. Maxfield &lt;mmaxfield@apple.com&gt; on 2015-03-02

* fast/text/font-kerning-expected.html:
* fast/text/font-variant-ligatures-expected.html:
* fast/text/whitespace/inline-whitespace-wrapping-7-expected.html:
* fast/text/whitespace/inline-whitespace-wrapping-7.html:
* mathml/presentation/scripts-subsup-expected.html:
* mathml/presentation/scripts-subsup.html:
* platform/mac/TestExpectations:
* platform/mac/fast/text/multiple-codeunit-vertical-upright-expected.html:
* platform/mac/fast/text/multiple-codeunit-vertical-upright.html:
* platform/mac/fast/text/resources/multiple-codeunit-vertical-upright.otf: Removed.
* svg/text/svg-font-word-rounding-hacks-spaces-expected.html:
* svg/text/svg-font-word-rounding-hacks-spaces.html:
* svg/text/tspan-outline-expected.svg:
* svg/text/tspan-outline.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreprofilerProfileGeneratorcpp">trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectortimelineexceptionininjectedscriptwhilerecordingexpectedtxt">trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectortimelineexceptionininjectedscriptwhilerecordinghtml">trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (180906 => 180907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-02 23:57:49 UTC (rev 180906)
+++ trunk/LayoutTests/ChangeLog        2015-03-03 00:24:24 UTC (rev 180907)
</span><span class="lines">@@ -21,6 +21,16 @@
</span><span class="cx"> 
</span><span class="cx"> 2015-03-02  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Exception stack unwinding in JSC hangs while the Timeline Profiler is enabled.
+        &lt;https://webkit.org/b/142191&gt;
+
+        Reviewed by Geoffrey Garen.
+
+        * inspector/timeline/exception-in-injected-script-while-recording-expected.txt: Added.
+        * inspector/timeline/exception-in-injected-script-while-recording.html: Added.
+
+2015-03-02  Mark Lam  &lt;mark.lam@apple.com&gt;
+
</ins><span class="cx">         The InspectorTimelineAgent should gracefully handle attempts to start more than once.
</span><span class="cx">         &lt;https://webkit.org/b/142189&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectortimelineexceptionininjectedscriptwhilerecordingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording-expected.txt (0 => 180907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording-expected.txt        2015-03-03 00:24:24 UTC (rev 180907)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+Testing that an injected script, run while the debugger is paused and the timeline profiler is enabled, should not loop forever if it has an exception thrown.
+
+Added a breakpoint inside hook().
+Debugger paused;
+An exception was thrown from the injected script.
+Debugger resumed; stopping timeline capture.
+Timeline capturing stopped. Inspecting the active recording....
+TimerFired timeline record has profile attached: TRUE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectortimelineexceptionininjectedscriptwhilerecordinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording.html (0 => 180907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording.html                                (rev 0)
+++ trunk/LayoutTests/inspector/timeline/exception-in-injected-script-while-recording.html        2015-03-03 00:24:24 UTC (rev 180907)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv=&quot;Content-Security-Policy&quot; content=&quot;script-src 'self' 'unsafe-inline'&quot;&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;../../http/tests/inspector/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;./resources/timeline-helper.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function installTimer()
+{
+    setTimeout(function() {
+        callFunction(mul, add(1, 3), 3);
+        hook();
+    });
+}
+
+function add(a, b)
+{
+    InspectorTestProxy.addResult(&quot;Calling add(): &quot; + a + &quot; + &quot; + b);
+    return a + b;
+}
+
+function mul(a, b)
+{
+    InspectorTestProxy.addResult(&quot;Calling mul(): &quot; + a + &quot; * &quot; + b);
+    return a * b;
+}
+
+function test()
+{
+    // First, set up the breakpoint, start timeline capturing, and trigger execution of installTimer().
+    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, function(event) {
+        var scriptObject = event.data.script;
+
+        if (!/timeline-helper\.js$/.test(scriptObject.url))
+            return;
+
+        var location = scriptObject.createSourceCodeLocation(17, 0);  // Inside timeline-helper.js:hook()
+        var breakpoint = new WebInspector.Breakpoint(location);
+        WebInspector.debuggerManager.addBreakpoint(breakpoint);
+        InspectorTest.addResult(&quot;Added a breakpoint inside hook().&quot;)
+
+        WebInspector.timelineManager.startCapturing();
+        InspectorTest.evaluateInPage(&quot;installTimer()&quot;);
+    });
+
+    // Second, the debugger will pause during timeline capturing. Resume, then stop timeline capturing.
+    WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Paused, function(event) {
+        InspectorTest.addResult(&quot;Debugger paused;&quot;);
+        checkIfExceptionLoopsForever();
+    });
+
+    function checkIfExceptionLoopsForever() {
+        WebInspector.runtimeManager.evaluateInInspectedWindow(&quot;({}).x.x&quot;, &quot;test&quot;, true, true, false, false, false, function(result, wasThrown) {
+            InspectorTest.addResult(&quot;An exception was &quot; + (wasThrown ? &quot;&quot; : &quot;not &quot;) + &quot;thrown from the injected script.&quot;);
+            WebInspector.debuggerManager.resume().then(function() {
+                InspectorTest.addResult(&quot;Debugger resumed; stopping timeline capture.&quot;);
+                WebInspector.timelineManager.stopCapturing();
+            });
+        });
+    }
+
+    // When timeline capturing stops, inspect the resulting timeline records for a profile.
+    WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.Event.CapturingStopped, function(event) {
+        var recording = WebInspector.timelineManager.activeRecording;
+        var scriptTimeline = recording.timelines.get(WebInspector.TimelineRecord.Type.Script);
+        console.assert(scriptTimeline);
+
+        InspectorTest.addResult(&quot;Timeline capturing stopped. Inspecting the active recording....&quot;);
+
+        for (var record of scriptTimeline.records) {
+            if (record.eventType !== WebInspector.ScriptTimelineRecord.EventType.TimerFired)
+                continue;
+
+            var result = record.profile ? &quot;TRUE&quot; : &quot;FALSE&quot;;
+            InspectorTest.addResult(&quot;TimerFired timeline record has profile attached: &quot; + result);
+        }
+
+        InspectorTest.completeTest();
+    });
+
+    InspectorTest.reloadPage();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;p&gt;Testing that an injected script, run while the debugger is paused and the timeline profiler is enabled, should not loop forever if it has an exception thrown.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (180906 => 180907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-03-02 23:57:49 UTC (rev 180906)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-03-03 00:24:24 UTC (rev 180907)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-03-02  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Exception stack unwinding in JSC hangs while the Timeline Profiler is enabled.
+        &lt;https://webkit.org/b/142191&gt;
+
+        Reviewed by Geoffrey Garen.
+
+        Imagine a scenario where the Inspector is paused / suspended at a breakpoint or
+        while the user is stepping through JS code. The user then tries to evaluate an
+        expression in the console, and that evaluation results in an exception being
+        thrown. Currently, if the Timeline Profiler is enabled while this exception is
+        being thrown, the WebProcess will hang while trying to handle that exception.
+
+        The issue is that the Timeline Profiler's ProfileGenerator::didExecute() will
+        return early and decline to process ProfileNodes if the Inspector is paused.
+        This is proper because it does not want to count work done for injected scripts
+        (e.g. from the console) towards the timeline profile of the webpage being run.
+        However, this is in conflict with ProfileGenerator::exceptionUnwind()'s
+        expectation that didExecute() will process ProfileNodes in order to do the stack
+        unwinding for the exception handling. As a result,
+        ProfileGenerator::exceptionUnwind() hangs.
+
+        ProfileGenerator::exceptionUnwind() is in error. While the Inspector is paused,
+        there will not be any ProfileNodes that it needs to &quot;unwind&quot;. Hence, the fix is
+        simply to return early also in ProfileGenerator::exceptionUnwind() if the
+        Inspector is paused.
+
+        * profiler/ProfileGenerator.cpp:
+        (JSC::ProfileGenerator::exceptionUnwind):
+
</ins><span class="cx"> 2015-03-02  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         FTL should correctly document where it puts the argument count for inlined varargs frames
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreprofilerProfileGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp (180906 => 180907)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp        2015-03-02 23:57:49 UTC (rev 180906)
+++ trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp        2015-03-03 00:24:24 UTC (rev 180907)
</span><span class="lines">@@ -194,6 +194,9 @@
</span><span class="cx"> 
</span><span class="cx"> void ProfileGenerator::exceptionUnwind(ExecState* handlerCallFrame, const CallIdentifier&amp;)
</span><span class="cx"> {
</span><ins>+    if (m_suspended)
+        return;
+
</ins><span class="cx">     // If the current node was called by the handler (==) or any
</span><span class="cx">     // more nested function (&gt;) the we have exited early from it.
</span><span class="cx">     ASSERT(m_currentNode);
</span></span></pre>
</div>
</div>

</body>
</html>