<!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>[166276] 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/166276">166276</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-03-25 19:14:40 -0700 (Tue, 25 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>DFG::ByteCodeParser::SetMode should distinguish between setting immediately without a flush and setting immediately with a flush
https://bugs.webkit.org/show_bug.cgi?id=130760
Reviewed by Mark Hahnenberg.
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::setLocal):
(JSC::DFG::ByteCodeParser::setArgument):
(JSC::DFG::ByteCodeParser::handleInlining):
(JSC::DFG::ByteCodeParser::parseBlock):
* tests/stress/assign-argument-in-inlined-call.js: Added.
(f1):
(getF2Arguments):
(f2):
(f3):
* tests/stress/assign-captured-argument-in-inlined-call.js: Added.
(f1):
(f2):
(f3):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp">trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressassignargumentininlinedcalljs">trunk/Source/JavaScriptCore/tests/stress/assign-argument-in-inlined-call.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressassigncapturedargumentininlinedcalljs">trunk/Source/JavaScriptCore/tests/stress/assign-captured-argument-in-inlined-call.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (166275 => 166276)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-03-26 01:47:26 UTC (rev 166275)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-03-26 02:14:40 UTC (rev 166276)
</span><span class="lines">@@ -1,5 +1,27 @@
</span><span class="cx"> 2014-03-25 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><ins>+ DFG::ByteCodeParser::SetMode should distinguish between setting immediately without a flush and setting immediately with a flush
+ https://bugs.webkit.org/show_bug.cgi?id=130760
+
+ Reviewed by Mark Hahnenberg.
+
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::setLocal):
+ (JSC::DFG::ByteCodeParser::setArgument):
+ (JSC::DFG::ByteCodeParser::handleInlining):
+ (JSC::DFG::ByteCodeParser::parseBlock):
+ * tests/stress/assign-argument-in-inlined-call.js: Added.
+ (f1):
+ (getF2Arguments):
+ (f2):
+ (f3):
+ * tests/stress/assign-captured-argument-in-inlined-call.js: Added.
+ (f1):
+ (f2):
+ (f3):
+
+2014-03-25 Filip Pizlo <fpizlo@apple.com>
+
</ins><span class="cx"> Fix 32-bit getter call alignment.
</span><span class="cx">
</span><span class="cx"> Reviewed by Mark Hahnenberg.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (166275 => 166276)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2014-03-26 01:47:26 UTC (rev 166275)
+++ trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2014-03-26 02:14:40 UTC (rev 166276)
</span><span class="lines">@@ -249,7 +249,25 @@
</span><span class="cx"> return getDirect(m_inlineStackTop->remapOperand(operand));
</span><span class="cx"> }
</span><span class="cx">
</span><del>- enum SetMode { NormalSet, ImmediateSet };
</del><ins>+ enum SetMode {
+ // A normal set which follows a two-phase commit that spans code origins. During
+ // the current code origin it issues a MovHint, and at the start of the next
+ // code origin there will be a SetLocal. If the local needs flushing, the second
+ // SetLocal will be preceded with a Flush.
+ NormalSet,
+
+ // A set where the SetLocal happens immediately and there is still a Flush. This
+ // is relevant when assigning to a local in tricky situations for the delayed
+ // SetLocal logic but where we know that we have not performed any side effects
+ // within this code origin. This is a safe replacement for NormalSet anytime we
+ // know that we have not yet performed side effects in this code origin.
+ ImmediateSetWithFlush,
+
+ // A set where the SetLocal happens immediately and we do not Flush it even if
+ // this is a local that is marked as needing it. This is relevant when
+ // initializing locals at the top of a function.
+ ImmediateNakedSet
+ };
</ins><span class="cx"> Node* setDirect(VirtualRegister operand, Node* value, SetMode setMode = NormalSet)
</span><span class="cx"> {
</span><span class="cx"> addToGraph(MovHint, OpInfo(operand.offset()), value);
</span><span class="lines">@@ -340,7 +358,7 @@
</span><span class="cx"> unsigned local = operand.toLocal();
</span><span class="cx"> bool isCaptured = m_codeBlock->isCaptured(operand, inlineCallFrame());
</span><span class="cx">
</span><del>- if (setMode == NormalSet) {
</del><ins>+ if (setMode != ImmediateNakedSet) {
</ins><span class="cx"> ArgumentPosition* argumentPosition = findArgumentPositionForLocal(operand);
</span><span class="cx"> if (isCaptured || argumentPosition)
</span><span class="cx"> flushDirect(operand, argumentPosition);
</span><span class="lines">@@ -399,7 +417,7 @@
</span><span class="cx"> // Always flush arguments, except for 'this'. If 'this' is created by us,
</span><span class="cx"> // then make sure that it's never unboxed.
</span><span class="cx"> if (argument) {
</span><del>- if (setMode == NormalSet)
</del><ins>+ if (setMode != ImmediateNakedSet)
</ins><span class="cx"> flushDirect(operand);
</span><span class="cx"> } else if (m_codeBlock->specializationKind() == CodeForConstruct)
</span><span class="cx"> variableAccessData->mergeShouldNeverUnbox(true);
</span><span class="lines">@@ -1399,9 +1417,9 @@
</span><span class="cx"> == callLinkStatus.isClosureCall());
</span><span class="cx"> if (callLinkStatus.isClosureCall()) {
</span><span class="cx"> VariableAccessData* calleeVariable =
</span><del>- set(VirtualRegister(JSStack::Callee), callTargetNode, ImmediateSet)->variableAccessData();
</del><ins>+ set(VirtualRegister(JSStack::Callee), callTargetNode, ImmediateNakedSet)->variableAccessData();
</ins><span class="cx"> VariableAccessData* scopeVariable =
</span><del>- set(VirtualRegister(JSStack::ScopeChain), addToGraph(GetScope, callTargetNode), ImmediateSet)->variableAccessData();
</del><ins>+ set(VirtualRegister(JSStack::ScopeChain), addToGraph(GetScope, callTargetNode), ImmediateNakedSet)->variableAccessData();
</ins><span class="cx">
</span><span class="cx"> calleeVariable->mergeShouldNeverUnbox(true);
</span><span class="cx"> scopeVariable->mergeShouldNeverUnbox(true);
</span><span class="lines">@@ -2147,9 +2165,9 @@
</span><span class="cx"> case op_enter:
</span><span class="cx"> // Initialize all locals to undefined.
</span><span class="cx"> for (int i = 0; i < m_inlineStackTop->m_codeBlock->m_numVars; ++i)
</span><del>- set(virtualRegisterForLocal(i), constantUndefined(), ImmediateSet);
</del><ins>+ set(virtualRegisterForLocal(i), constantUndefined(), ImmediateNakedSet);
</ins><span class="cx"> if (m_inlineStackTop->m_codeBlock->specializationKind() == CodeForConstruct)
</span><del>- set(virtualRegisterForArgument(0), constantUndefined(), ImmediateSet);
</del><ins>+ set(virtualRegisterForArgument(0), constantUndefined(), ImmediateNakedSet);
</ins><span class="cx"> NEXT_OPCODE(op_enter);
</span><span class="cx">
</span><span class="cx"> case op_touch_entry:
</span><span class="lines">@@ -2845,7 +2863,7 @@
</span><span class="cx"> flushForReturn();
</span><span class="cx"> if (inlineCallFrame()) {
</span><span class="cx"> ASSERT(m_inlineStackTop->m_returnValue.isValid());
</span><del>- setDirect(m_inlineStackTop->m_returnValue, get(VirtualRegister(currentInstruction[1].u.operand)), ImmediateSet);
</del><ins>+ setDirect(m_inlineStackTop->m_returnValue, get(VirtualRegister(currentInstruction[1].u.operand)), ImmediateSetWithFlush);
</ins><span class="cx"> m_inlineStackTop->m_didReturn = true;
</span><span class="cx"> if (m_inlineStackTop->m_unlinkedBlocks.isEmpty()) {
</span><span class="cx"> // If we're returning from the first block, then we're done parsing.
</span><span class="lines">@@ -2928,9 +2946,9 @@
</span><span class="cx"> // The bytecode wouldn't have set up the arguments. But we'll do it and make it
</span><span class="cx"> // look like the bytecode had done it.
</span><span class="cx"> int nextRegister = registerOffset + JSStack::CallFrameHeaderSize;
</span><del>- set(VirtualRegister(nextRegister++), get(VirtualRegister(thisReg)), ImmediateSet);
</del><ins>+ set(VirtualRegister(nextRegister++), get(VirtualRegister(thisReg)), ImmediateNakedSet);
</ins><span class="cx"> for (unsigned argument = 1; argument < argCount; ++argument)
</span><del>- set(VirtualRegister(nextRegister++), get(virtualRegisterForArgument(argument)), ImmediateSet);
</del><ins>+ set(VirtualRegister(nextRegister++), get(virtualRegisterForArgument(argument)), ImmediateNakedSet);
</ins><span class="cx">
</span><span class="cx"> handleCall(
</span><span class="cx"> result, Call, CodeForCall, OPCODE_LENGTH(op_call_varargs),
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressassignargumentininlinedcalljs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/assign-argument-in-inlined-call.js (0 => 166276)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/assign-argument-in-inlined-call.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/assign-argument-in-inlined-call.js        2014-03-26 02:14:40 UTC (rev 166276)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+function f1(a) {
+ return a[0];
+}
+
+function getF2Arguments() {
+ return f2.arguments;
+}
+
+noInline(getF2Arguments);
+
+function f2(a) {
+ a = f1(getF2Arguments());
+ return a;
+}
+
+function f3(a) {
+ return f2(a);
+}
+
+noInline(f3);
+
+for (var i = 0; i < 10000; ++i) {
+ var result = f3(42);
+ if (result != 42)
+ throw "Error: bad result: " + result;
+}
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressassigncapturedargumentininlinedcalljs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/assign-captured-argument-in-inlined-call.js (0 => 166276)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/assign-captured-argument-in-inlined-call.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/assign-captured-argument-in-inlined-call.js        2014-03-26 02:14:40 UTC (rev 166276)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+function f1(a) {
+ return a[0];
+}
+
+function f2(a) {
+ a = f1(arguments);
+ return a;
+}
+
+function f3(a) {
+ return f2(a);
+}
+
+noInline(f3);
+
+for (var i = 0; i < 10000; ++i) {
+ var result = f3(42);
+ if (result != 42)
+ throw "Error: bad result: " + result;
+}
+
</ins></span></pre>
</div>
</div>
</body>
</html>