<!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>[177578] 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/177578">177578</a></dd>
<dt>Author</dt> <dd>msaboff@apple.com</dd>
<dt>Date</dt> <dd>2014-12-19 10:48:25 -0800 (Fri, 19 Dec 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION(174226): Captured arguments in a using function compiled by the DFG have the initial value when the closure was invoked
https://bugs.webkit.org/show_bug.cgi?id=139808
Reviewed by Oliver Hunt.
Source/JavaScriptCore:
There are three changes here.
1) Create a VariableWatchpointSet for captured arguments variables.
2) Properly use the VariableWatchpointSet* found in op_put_to_scope in the 64 bit LLInt code.
3) Add the same putLocalClosureVar path to the 32 bit LLInt code that exists in the 64 bit version.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
LayoutTests:
New regression test.
* js/regress-139808-expected.txt: Added.
* js/regress-139808.html: Added.
* js/script-tests/regress-139808.js: Added.
(theClosureFunction.rot13):
(theClosureFunction):</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="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreter32_64asm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreter64asm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsregress139808expectedtxt">trunk/LayoutTests/js/regress-139808-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregress139808html">trunk/LayoutTests/js/regress-139808.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsregress139808js">trunk/LayoutTests/js/script-tests/regress-139808.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (177577 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-12-19 18:43:33 UTC (rev 177577)
+++ trunk/LayoutTests/ChangeLog        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-12-19 Michael Saboff <msaboff@apple.com>
+
+ REGRESSION(174226): Captured arguments in a using function compiled by the DFG have the initial value when the closure was invoked
+ https://bugs.webkit.org/show_bug.cgi?id=139808
+
+ Reviewed by Oliver Hunt.
+
+ New regression test.
+
+ * js/regress-139808-expected.txt: Added.
+ * js/regress-139808.html: Added.
+ * js/script-tests/regress-139808.js: Added.
+ (theClosureFunction.rot13):
+ (theClosureFunction):
+
</ins><span class="cx"> 2014-12-19 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> Updte WebKit2 test expectations based on what bots see now.
</span></span></pre></div>
<a id="trunkLayoutTestsjsregress139808expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress-139808-expected.txt (0 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress-139808-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/regress-139808-expected.txt        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+Regression test for https://webkit.org/b/139808. This test should run without any exceptions.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregress139808html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regress-139808.html (0 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regress-139808.html         (rev 0)
+++ trunk/LayoutTests/js/regress-139808.html        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/regress-139808.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsregress139808js"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/regress-139808.js (0 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/regress-139808.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/regress-139808.js        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+description(
+"Regression test for https://webkit.org/b/139808. This test should run without any exceptions."
+);
+
+function theClosureFunction(a)
+{
+ var o = {
+ 1: "Gur dhvpx oebja sbk whzcrq bire gur ynml qbt\'f onpx.",
+ 2: "Abj vf gur gvzr sbe nyy zra gb pbzr gb gur nvq bs gurve cnegl.",
+ 3: "N zna n cyna n pnany, Cnanzn."
+ };
+
+ var expect = {
+ 1: "The quick brown fox jumped over the lazy dog\'s back.",
+ 2: "Now is the time for all men to come to the aid of their party.",
+ 3: "A man a plan a canal, Panama."
+ };
+
+ e = expect[a]
+ a = o[a];
+
+ var rot13 = function(startIndex) {
+ result = "";
+
+ for (var i = startIndex; i < a.length; i++) {
+ c = a.charAt(i);
+ if (c >= 'a' && c <= 'z')
+ c = String.fromCharCode((a.charCodeAt(i) - 84) % 26 + 97);
+ else if (c >= 'A' && c <= 'Z')
+ c = String.fromCharCode((a.charCodeAt(i) - 52) % 26 + 65);
+
+         result += c;
+        }
+
+        return result;
+ }
+
+ // Call in a loop to tier up to DFG
+ for (var i = 0; i < 1000; i++)
+ s = rot13(0);
+
+ return s == e;
+}
+
+for (var i = 1; i <= 3; i++)
+ if (!theClosureFunction(i))
+ throw "Incorrect result calling theClosureFunction";
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (177577 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-12-19 18:43:33 UTC (rev 177577)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2014-12-19 Michael Saboff <msaboff@apple.com>
+
+ REGRESSION(174226): Captured arguments in a using function compiled by the DFG have the initial value when the closure was invoked
+ https://bugs.webkit.org/show_bug.cgi?id=139808
+
+ Reviewed by Oliver Hunt.
+
+ There are three changes here.
+ 1) Create a VariableWatchpointSet for captured arguments variables.
+ 2) Properly use the VariableWatchpointSet* found in op_put_to_scope in the 64 bit LLInt code.
+ 3) Add the same putLocalClosureVar path to the 32 bit LLInt code that exists in the 64 bit version.
+
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::BytecodeGenerator):
+ * llint/LowLevelInterpreter32_64.asm:
+ * llint/LowLevelInterpreter64.asm:
+
</ins><span class="cx"> 2014-12-19 David Kilzer <ddkilzer@apple.com>
</span><span class="cx">
</span><span class="cx"> Switch from using PLATFORM_NAME to SDK selectors in WebCore, WebInspectorUI, WebKit, WebKit2
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (177577 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2014-12-19 18:43:33 UTC (rev 177577)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -316,7 +316,7 @@
</span><span class="cx"> if (!functionNode->captures(ident) && !shouldCaptureAllTheThings)
</span><span class="cx"> continue;
</span><span class="cx"> capturesAnyArgumentByName = true;
</span><del>- capturedArguments[i] = addVar();
</del><ins>+ capturedArguments[i] = addVar(ident, IsVariable, IsWatchable);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreter32_64asm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm (177577 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2014-12-19 18:43:33 UTC (rev 177577)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -2339,7 +2339,20 @@
</span><span class="cx"> storei t3, PayloadOffset[t0, t1, 8]
</span><span class="cx"> end
</span><span class="cx">
</span><ins>+macro putLocalClosureVar()
+ loadisFromInstruction(3, t1)
+ loadConstantOrVariable(t1, t2, t3)
+ loadpFromInstruction(5, t4)
+ btpz t4, .noVariableWatchpointSet
+ notifyWrite(t4, t2, t3, t1, .pDynamic)
+.noVariableWatchpointSet:
+ loadp JSEnvironmentRecord::m_registers[t0], t0
+ loadisFromInstruction(6, t1)
+ storei t2, TagOffset[t0, t1, 8]
+ storei t3, PayloadOffset[t0, t1, 8]
+end
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> _llint_op_put_to_scope:
</span><span class="cx"> traceExecution()
</span><span class="cx"> loadisFromInstruction(4, t0)
</span><span class="lines">@@ -2349,7 +2362,7 @@
</span><span class="cx"> bineq t0, LocalClosureVar, .pGlobalProperty
</span><span class="cx"> writeBarrierOnOperands(1, 3)
</span><span class="cx"> loadVariable(1, t2, t1, t0)
</span><del>- putClosureVar()
</del><ins>+ putLocalClosureVar()
</ins><span class="cx"> dispatch(7)
</span><span class="cx">
</span><span class="cx"> .pGlobalProperty:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreter64asm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (177577 => 177578)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2014-12-19 18:43:33 UTC (rev 177577)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2014-12-19 18:48:25 UTC (rev 177578)
</span><span class="lines">@@ -2165,7 +2165,10 @@
</span><span class="cx"> macro putLocalClosureVar()
</span><span class="cx"> loadisFromInstruction(3, t1)
</span><span class="cx"> loadConstantOrVariable(t1, t2)
</span><del>- notifyWrite(t0, t2, t1, .pDynamic)
</del><ins>+ loadpFromInstruction(5, t3)
+ btpz t3, .noVariableWatchpointSet
+ notifyWrite(t3, t2, t1, .pDynamic)
+.noVariableWatchpointSet:
</ins><span class="cx"> loadp JSEnvironmentRecord::m_registers[t0], t0
</span><span class="cx"> loadisFromInstruction(6, t1)
</span><span class="cx"> storeq t2, [t0, t1, 8]
</span></span></pre>
</div>
</div>
</body>
</html>