<!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>[201589] trunk/Source/JavaScriptCore</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/201589">201589</a></dd>
<dt>Author</dt> <dd>msaboff@apple.com</dd>
<dt>Date</dt> <dd>2016-06-01 21:07:14 -0700 (Wed, 01 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Runaway WebContent process CPU &amp; memory @ foxnews.com
https://bugs.webkit.org/show_bug.cgi?id=158290

Reviewed by Mark Lam.

Clear the thrown value at the end of the catch block so that the stack scanner won't
find the value during GC.

Added a new stress test.

* bytecompiler/NodesCodegen.cpp:
(JSC::TryNode::emitBytecode):
* tests/stress/recursive-try-catch.js: Added.
(logError):
(tryCallingBadFunction):
(recurse):
(test):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerNodesCodegencpp">trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressrecursivetrycatchjs">trunk/Source/JavaScriptCore/tests/stress/recursive-try-catch.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (201588 => 201589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-06-02 04:01:35 UTC (rev 201588)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-06-02 04:07:14 UTC (rev 201589)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-06-01  Michael Saboff  &lt;msaboff@apple.com&gt;
+
+        Runaway WebContent process CPU &amp; memory @ foxnews.com
+        https://bugs.webkit.org/show_bug.cgi?id=158290
+
+        Reviewed by Mark Lam.
+
+        Clear the thrown value at the end of the catch block so that the stack scanner won't
+        find the value during GC.
+
+        Added a new stress test.
+
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::TryNode::emitBytecode):
+        * tests/stress/recursive-try-catch.js: Added.
+        (logError):
+        (tryCallingBadFunction):
+        (recurse):
+        (test):
+
</ins><span class="cx"> 2016-06-01  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Some setters for components of Date do not timeClip() their result
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerNodesCodegencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (201588 => 201589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2016-06-02 04:01:35 UTC (rev 201588)
+++ trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2016-06-02 04:07:14 UTC (rev 201589)
</span><span class="lines">@@ -3127,6 +3127,7 @@
</span><span class="cx">             generator.emitNode(dst, m_catchBlock);
</span><span class="cx">         else
</span><span class="cx">             generator.emitNodeInTailPosition(dst, m_catchBlock);
</span><ins>+        generator.emitLoad(thrownValueRegister.get(), jsUndefined());
</ins><span class="cx">         generator.emitPopCatchScope(m_lexicalVariables);
</span><span class="cx">         generator.emitLabel(catchEndLabel.get());
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressrecursivetrycatchjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/recursive-try-catch.js (0 => 201589)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/recursive-try-catch.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/recursive-try-catch.js        2016-06-02 04:07:14 UTC (rev 201589)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+// This test should run to completion without excessive memory usage
+
+let maxHeapAllowed = 10 * 1024 * 1024; // This test should run using much less than 10MB.
+let badFunction = undefined;
+let loggedError = undefined;
+
+function logError(error)
+{
+    loggedError = error;
+}
+
+function tryCallingBadFunction()
+{
+    try {
+        badFunction(42);
+    } catch(error) {
+        logError(error);
+    }
+
+    recurse();
+}
+
+function recurse()
+{
+    // Make the frame big to run out of stack with fewer recursive calls.
+    let val1, val2, val3, val4, val5, val6, val7, val8, val9, val10;
+    let val11, val12, val13, val14, val15, val16, val17, val18, val19, val20;
+    let val21, val22, val23, val24, val25, val26, val27, val28, val29, val30;
+    let val31, val32, val33, val34, val35, val36, val37, val38, val39, val40;
+    let val41, val42, val43, val44, val45, val46, val47, val48, val49, val50;
+    let val51, val52, val53, val54, val55, val56, val57, val58, val59, val60;
+    let val61, val62, val63, val64, val65, val66, val67, val68, val69, val70;
+    let val71, val72, val73, val74, val75, val76, val77, val78, val79, val80;
+    let val81, val82, val83, val84, val85, val86, val87, val88, val89, val90;
+    let val91, val92, val93, val94, val95, val96, val97, val98, val99, val100;
+    let val101, val102, val103, val104, val105, val106, val107, val108, val109, val110;
+    let val111, val112, val113, val114, val115, val116, val117, val118, val119, val120;
+    let val121, val122, val123, val124, val125, val126, val127, val128, val129, val130;
+    let val131, val132, val133, val134, val135, val136, val137, val138, val139, val140;
+    let val141, val142, val143, val144, val145, val146, val147, val148, val149, val150;
+    let val151, val152, val153, val154, val155, val156, val157, val158, val159, val160;
+    let val161, val162, val163, val164, val165, val166, val167, val168, val169, val170;
+    let val171, val172, val173, val174, val175, val176, val177, val178, val179, val180;
+    let val181, val182, val183, val184, val185, val186, val187, val188, val189, val190;
+    let val191, val192, val193, val194, val195, val196, val197, val198, val199, val200;
+    let val201, val202, val203, val204, val205, val206, val207, val208, val209, val210;
+    let val211, val212, val213, val214, val215, val216, val217, val218, val219, val220;
+    let val221, val222, val223, val224, val225, val226, val227, val228, val229, val230;
+    let val231, val232, val233, val234, val235, val236, val237, val238, val239, val240;
+    let val241, val242, val243, val244, val245, val246, val247, val248, val249, val250;
+    let val251, val252, val253, val254, val255, val256, val257, val258, val259, val260;
+    let val261, val262, val263, val264, val265, val266, val267, val268, val269, val270;
+    let val271, val272, val273, val274, val275, val276, val277, val278, val279, val280;
+    let val281, val282, val283, val284, val285, val286, val287, val288, val289, val290;
+    let val291, val292, val293, val294, val295, val296, val297, val298, val299, val300;
+    let val301, val302, val303, val304, val305, val306, val307, val308, val309, val310;
+    let val311, val312, val313, val314, val315, val316, val317, val318, val319, val320;
+    let val321, val322, val323, val324, val325, val326, val327, val328, val329, val330;
+    let val331, val332, val333, val334, val335, val336, val337, val338, val339, val340;
+    let val341, val342, val343, val344, val345, val346, val347, val348, val349, val350;
+    let val351, val352, val353, val354, val355, val356, val357, val358, val359, val360;
+    let val361, val362, val363, val364, val365, val366, val367, val368, val369, val370;
+    let val371, val372, val373, val374, val375, val376, val377, val378, val379, val380;
+    let val381, val382, val383, val384, val385, val386, val387, val388, val389, val390;
+    let val391, val392, val393, val394, val395, val396, val397, val398, val399, val400;
+
+    tryCallingBadFunction();
+}
+
+function test()
+{
+    try {
+        recurse();
+    } catch(error) {
+        if (error != &quot;RangeError: Maximum call stack size exceeded.&quot;)
+            throw &quot;Expected: \&quot;RangeError: Maximum call stack size exceeded.\&quot;, but got: &quot; + error;
+
+        let heapUsed = gcHeapSize();
+        if (heapUsed &gt; maxHeapAllowed)
+            throw &quot;Used too much heap.  Limit was &quot; + maxHeapAllowed + &quot; bytes, but we used &quot; + heapUsed + &quot; bytes.&quot;;
+    }
+
+    if (loggedError.name != &quot;TypeError&quot;)
+        throw &quot;Expected logged error to be: \&quot;TypeError\&quot;, but got: &quot; + loggedError.name;
+}
+
+test();
+
</ins></span></pre>
</div>
</div>

</body>
</html>