<!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>[162739] branches/jsCStack/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/162739">162739</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-01-24 16:59:29 -0800 (Fri, 24 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>DFG should allow inlining of op_call_varargs calls
https://bugs.webkit.org/show_bug.cgi?id=127538
Reviewed by Michael Saboff and Mark Hahnenberg.
Previously, op_call_varargs was directly lowered to a Call by the ByteCodeParser and
we bypassed all of the call optimizations (intrinsics, inlining) provided by
ByteCodeParser::handleCall().
This changes op_call_varargs handling so that it first sets up the stack to look like
it would have if it had been a normal call, and then it calls handleCall(). This
gives us inlining of op_call_varargs.
* bytecode/CallLinkStatus.cpp:
(JSC::CallLinkStatus::computeFromLLInt):
* bytecode/CodeOrigin.h:
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::addCall):
(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::isLiveInBytecode):
* tests/stress/inline-call-varargs-and-call.js: Added.
(foo):
(bar):
(baz):
* tests/stress/inline-call-varargs.js: Added.
(foo):
(bar):
(baz):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorebytecodeCallLinkStatuscpp">branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkStatus.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorebytecodeCodeOriginh">branches/jsCStack/Source/JavaScriptCore/bytecode/CodeOrigin.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGByteCodeParsercpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGGraphcpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGGraph.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstressinlinecallvarargsandcalljs">branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs-and-call.js</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoretestsstressinlinecallvarargsjs">branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (162738 => 162739)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-25 00:52:21 UTC (rev 162738)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-25 00:59:29 UTC (rev 162739)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2014-01-24 Filip Pizlo <fpizlo@apple.com>
+
+ DFG should allow inlining of op_call_varargs calls
+ https://bugs.webkit.org/show_bug.cgi?id=127538
+
+ Reviewed by Michael Saboff and Mark Hahnenberg.
+
+ Previously, op_call_varargs was directly lowered to a Call by the ByteCodeParser and
+ we bypassed all of the call optimizations (intrinsics, inlining) provided by
+ ByteCodeParser::handleCall().
+
+ This changes op_call_varargs handling so that it first sets up the stack to look like
+ it would have if it had been a normal call, and then it calls handleCall(). This
+ gives us inlining of op_call_varargs.
+
+ * bytecode/CallLinkStatus.cpp:
+ (JSC::CallLinkStatus::computeFromLLInt):
+ * bytecode/CodeOrigin.h:
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::addCall):
+ (JSC::DFG::ByteCodeParser::handleCall):
+ (JSC::DFG::ByteCodeParser::parseBlock):
+ * dfg/DFGGraph.cpp:
+ (JSC::DFG::Graph::isLiveInBytecode):
+ * tests/stress/inline-call-varargs-and-call.js: Added.
+ (foo):
+ (bar):
+ (baz):
+ * tests/stress/inline-call-varargs.js: Added.
+ (foo):
+ (bar):
+ (baz):
+
</ins><span class="cx"> 2014-01-24 Mark Hahnenberg <mhahnenberg@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge branch up to ToT r162711.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorebytecodeCallLinkStatuscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkStatus.cpp (162738 => 162739)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkStatus.cpp        2014-01-25 00:52:21 UTC (rev 162738)
+++ branches/jsCStack/Source/JavaScriptCore/bytecode/CallLinkStatus.cpp        2014-01-25 00:59:29 UTC (rev 162739)
</span><span class="lines">@@ -92,7 +92,13 @@
</span><span class="cx"> return takesSlowPath();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ VM& vm = *profiledBlock->vm();
+
</ins><span class="cx"> Instruction* instruction = profiledBlock->instructions().begin() + bytecodeIndex;
</span><ins>+ OpcodeID op = vm.interpreter->getOpcodeID(instruction[0].u.opcode);
+ if (op != op_call && op != op_construct)
+ return CallLinkStatus();
+
</ins><span class="cx"> LLIntCallLinkInfo* callLinkInfo = instruction[5].u.callLinkInfo;
</span><span class="cx">
</span><span class="cx"> return CallLinkStatus(callLinkInfo->lastSeenCallee.get());
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorebytecodeCodeOriginh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/bytecode/CodeOrigin.h (162738 => 162739)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/bytecode/CodeOrigin.h        2014-01-25 00:52:21 UTC (rev 162738)
+++ branches/jsCStack/Source/JavaScriptCore/bytecode/CodeOrigin.h        2014-01-25 00:59:29 UTC (rev 162739)
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct InlineCallFrame {
</span><del>- Vector<ValueRecovery> arguments;
</del><ins>+ Vector<ValueRecovery> arguments; // Includes 'this'.
</ins><span class="cx"> WriteBarrier<ScriptExecutable> executable;
</span><span class="cx"> ValueRecovery calleeRecovery;
</span><span class="cx"> CodeOrigin caller;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGByteCodeParsercpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (162738 => 162739)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2014-01-25 00:52:21 UTC (rev 162738)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2014-01-25 00:59:29 UTC (rev 162739)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #include "Operations.h"
</span><span class="cx"> #include "PreciseJumpTargets.h"
</span><span class="cx"> #include "PutByIdStatus.h"
</span><ins>+#include "StackAlignment.h"
</ins><span class="cx"> #include "StringConstructor.h"
</span><span class="cx"> #include <wtf/CommaPrinter.h>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="lines">@@ -160,7 +161,8 @@
</span><span class="cx"> bool handleMinMax(int resultOperand, NodeType op, int registerOffset, int argumentCountIncludingThis);
</span><span class="cx">
</span><span class="cx"> // Handle calls. This resolves issues surrounding inlining and intrinsics.
</span><del>- void handleCall(Instruction* currentInstruction, NodeType op, CodeSpecializationKind);
</del><ins>+ void handleCall(int result, NodeType op, CodeSpecializationKind, unsigned instructionSize, int callee, int argCount, int registerOffset);
+ void handleCall(Instruction* pc, NodeType op, CodeSpecializationKind kind);
</ins><span class="cx"> void emitFunctionChecks(const CallLinkStatus&, Node* callTarget, int registerOffset, CodeSpecializationKind);
</span><span class="cx"> void emitArgumentPhantoms(int registerOffset, int argumentCountIncludingThis, CodeSpecializationKind);
</span><span class="cx"> // Handle inlining. Return true if it succeeded, false if we need to plant a call.
</span><span class="lines">@@ -773,23 +775,21 @@
</span><span class="cx"> m_numPassedVarArgs++;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- Node* addCall(Instruction* currentInstruction, NodeType op)
</del><ins>+ Node* addCall(int result, NodeType op, int callee, int argCount, int registerOffset)
</ins><span class="cx"> {
</span><span class="cx"> SpeculatedType prediction = getPrediction();
</span><span class="cx">
</span><del>- addVarArgChild(get(VirtualRegister(currentInstruction[2].u.operand)));
- int argCount = currentInstruction[3].u.operand;
</del><ins>+ addVarArgChild(get(VirtualRegister(callee)));
</ins><span class="cx"> size_t parameterSlots = JSStack::CallFrameHeaderSize - JSStack::CallerFrameAndPCSize + argCount;
</span><span class="cx"> if (parameterSlots > m_parameterSlots)
</span><span class="cx"> m_parameterSlots = parameterSlots;
</span><span class="cx">
</span><del>- int registerOffset = -currentInstruction[4].u.operand;
</del><span class="cx"> int dummyThisArgument = op == Call ? 0 : 1;
</span><span class="cx"> for (int i = 0 + dummyThisArgument; i < argCount; ++i)
</span><span class="cx"> addVarArgChild(get(virtualRegisterForArgument(i, registerOffset)));
</span><span class="cx">
</span><span class="cx"> Node* call = addToGraph(Node::VarArg, op, OpInfo(0), OpInfo(prediction));
</span><del>- set(VirtualRegister(currentInstruction[1].u.operand), call);
</del><ins>+ set(VirtualRegister(result), call);
</ins><span class="cx"> return call;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1147,12 +1147,21 @@
</span><span class="cx"> m_currentIndex += OPCODE_LENGTH(name); \
</span><span class="cx"> return shouldContinueParsing
</span><span class="cx">
</span><ins>+void ByteCodeParser::handleCall(Instruction* pc, NodeType op, CodeSpecializationKind kind)
+{
+ ASSERT(OPCODE_LENGTH(op_call) == OPCODE_LENGTH(op_construct));
+ handleCall(
+ pc[1].u.operand, op, kind, OPCODE_LENGTH(op_call),
+ pc[2].u.operand, pc[3].u.operand, -pc[4].u.operand);
+}
</ins><span class="cx">
</span><del>-void ByteCodeParser::handleCall(Instruction* currentInstruction, NodeType op, CodeSpecializationKind kind)
</del><ins>+void ByteCodeParser::handleCall(
+ int result, NodeType op, CodeSpecializationKind kind, unsigned instructionSize,
+ int callee, int argumentCountIncludingThis, int registerOffset)
</ins><span class="cx"> {
</span><del>- ASSERT(OPCODE_LENGTH(op_call) == OPCODE_LENGTH(op_construct));
</del><ins>+ ASSERT(registerOffset <= 0);
</ins><span class="cx">
</span><del>- Node* callTarget = get(VirtualRegister(currentInstruction[2].u.operand));
</del><ins>+ Node* callTarget = get(VirtualRegister(callee));
</ins><span class="cx">
</span><span class="cx"> CallLinkStatus callLinkStatus;
</span><span class="cx">
</span><span class="lines">@@ -1165,19 +1174,15 @@
</span><span class="cx"> // Oddly, this conflates calls that haven't executed with calls that behaved sufficiently polymorphically
</span><span class="cx"> // that we cannot optimize them.
</span><span class="cx">
</span><del>- addCall(currentInstruction, op);
</del><ins>+ addCall(result, op, callee, argumentCountIncludingThis, registerOffset);
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- int argumentCountIncludingThis = currentInstruction[3].u.operand;
- int registerOffset = -currentInstruction[4].u.operand;
-
- int resultOperand = currentInstruction[1].u.operand;
- unsigned nextOffset = m_currentIndex + OPCODE_LENGTH(op_call);
</del><ins>+ unsigned nextOffset = m_currentIndex + instructionSize;
</ins><span class="cx"> SpeculatedType prediction = getPrediction();
</span><span class="cx">
</span><span class="cx"> if (InternalFunction* function = callLinkStatus.internalFunction()) {
</span><del>- if (handleConstantInternalFunction(resultOperand, function, registerOffset, argumentCountIncludingThis, prediction, kind)) {
</del><ins>+ if (handleConstantInternalFunction(result, function, registerOffset, argumentCountIncludingThis, prediction, kind)) {
</ins><span class="cx"> // This phantoming has to be *after* the code for the intrinsic, to signify that
</span><span class="cx"> // the inputs must be kept alive whatever exits the intrinsic may do.
</span><span class="cx"> addToGraph(Phantom, callTarget);
</span><span class="lines">@@ -1186,7 +1191,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Can only handle this using the generic call handler.
</span><del>- addCall(currentInstruction, op);
</del><ins>+ addCall(result, op, callee, argumentCountIncludingThis, registerOffset);
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1194,7 +1199,7 @@
</span><span class="cx"> if (intrinsic != NoIntrinsic) {
</span><span class="cx"> emitFunctionChecks(callLinkStatus, callTarget, registerOffset, kind);
</span><span class="cx">
</span><del>- if (handleIntrinsic(resultOperand, intrinsic, registerOffset, argumentCountIncludingThis, prediction)) {
</del><ins>+ if (handleIntrinsic(result, intrinsic, registerOffset, argumentCountIncludingThis, prediction)) {
</ins><span class="cx"> // This phantoming has to be *after* the code for the intrinsic, to signify that
</span><span class="cx"> // the inputs must be kept alive whatever exits the intrinsic may do.
</span><span class="cx"> addToGraph(Phantom, callTarget);
</span><span class="lines">@@ -1203,13 +1208,13 @@
</span><span class="cx"> m_graph.compilation()->noticeInlinedCall();
</span><span class="cx"> return;
</span><span class="cx"> }
</span><del>- } else if (handleInlining(callTarget, resultOperand, callLinkStatus, registerOffset, argumentCountIncludingThis, nextOffset, kind)) {
</del><ins>+ } else if (handleInlining(callTarget, result, callLinkStatus, registerOffset, argumentCountIncludingThis, nextOffset, kind)) {
</ins><span class="cx"> if (m_graph.compilation())
</span><span class="cx"> m_graph.compilation()->noticeInlinedCall();
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- addCall(currentInstruction, op);
</del><ins>+ addCall(result, op, callee, argumentCountIncludingThis, registerOffset);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ByteCodeParser::emitFunctionChecks(const CallLinkStatus& callLinkStatus, Node* callTarget, int registerOffset, CodeSpecializationKind kind)
</span><span class="lines">@@ -2963,31 +2968,41 @@
</span><span class="cx"> NEXT_OPCODE(op_construct);
</span><span class="cx">
</span><span class="cx"> case op_call_varargs: {
</span><ins>+ int result = currentInstruction[1].u.operand;
+ int callee = currentInstruction[2].u.operand;
+ int thisReg = currentInstruction[3].u.operand;
+ int arguments = currentInstruction[4].u.operand;
+ int firstFreeReg = currentInstruction[5].u.operand;
+
</ins><span class="cx"> ASSERT(inlineCallFrame());
</span><del>- ASSERT(currentInstruction[4].u.operand == m_inlineStackTop->m_codeBlock->argumentsRegister().offset());
</del><ins>+ ASSERT_UNUSED(arguments, arguments == m_inlineStackTop->m_codeBlock->argumentsRegister().offset());
</ins><span class="cx"> ASSERT(!m_inlineStackTop->m_codeBlock->symbolTable()->slowArguments());
</span><del>- // It would be cool to funnel this into handleCall() so that it can handle
- // inlining. But currently that won't be profitable anyway, since none of the
- // uses of call_varargs will be inlineable. So we set this up manually and
- // without inline/intrinsic detection.
-
- SpeculatedType prediction = getPrediction();
-
</del><ins>+
</ins><span class="cx"> addToGraph(CheckArgumentsNotCreated);
</span><span class="cx">
</span><span class="cx"> unsigned argCount = inlineCallFrame()->arguments.size();
</span><del>- size_t parameterSlots = JSStack::CallFrameHeaderSize - JSStack::CallerFrameAndPCSize + argCount;
- if (parameterSlots > m_parameterSlots)
- m_parameterSlots = parameterSlots;
</del><span class="cx">
</span><del>- addVarArgChild(get(VirtualRegister(currentInstruction[2].u.operand))); // callee
- addVarArgChild(get(VirtualRegister(currentInstruction[3].u.operand))); // this
</del><ins>+ // Let's compute the register offset. We start with the last used register, and
+ // then adjust for the things we want in the call frame.
+ int registerOffset = firstFreeReg + 1;
+ registerOffset -= argCount; // We will be passing some arguments.
+ registerOffset -= JSStack::CallFrameHeaderSize; // We will pretend to have a call frame header.
+
+ // Get the alignment right.
+ registerOffset = -WTF::roundUpToMultipleOf(
+ stackAlignmentRegisters(),
+ -registerOffset);
+
+ // The bytecode wouldn't have set up the arguments. But we'll do it and make it
+ // look like the bytecode had done it.
+ int nextRegister = registerOffset + JSStack::CallFrameHeaderSize;
+ set(VirtualRegister(nextRegister++), get(VirtualRegister(thisReg)), ImmediateSet);
</ins><span class="cx"> for (unsigned argument = 1; argument < argCount; ++argument)
</span><del>- addVarArgChild(get(virtualRegisterForArgument(argument)));
</del><ins>+ set(VirtualRegister(nextRegister++), get(virtualRegisterForArgument(argument)), ImmediateSet);
</ins><span class="cx">
</span><del>- set(VirtualRegister(currentInstruction[1].u.operand),
- addToGraph(Node::VarArg, Call, OpInfo(0), OpInfo(prediction)));
-
</del><ins>+ handleCall(
+ result, Call, CodeForCall, OPCODE_LENGTH(op_call_varargs),
+ callee, argCount, registerOffset);
</ins><span class="cx"> NEXT_OPCODE(op_call_varargs);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGGraphcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGGraph.cpp (162738 => 162739)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGGraph.cpp        2014-01-25 00:52:21 UTC (rev 162738)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGGraph.cpp        2014-01-25 00:59:29 UTC (rev 162739)
</span><span class="lines">@@ -680,10 +680,10 @@
</span><span class="cx"> bool Graph::isLiveInBytecode(VirtualRegister operand, CodeOrigin codeOrigin)
</span><span class="cx"> {
</span><span class="cx"> for (;;) {
</span><ins>+ VirtualRegister reg = VirtualRegister(
+ operand.offset() - codeOrigin.stackOffset());
+
</ins><span class="cx"> if (operand.offset() < codeOrigin.stackOffset() + JSStack::CallFrameHeaderSize) {
</span><del>- VirtualRegister reg = VirtualRegister(
- operand.offset() - codeOrigin.stackOffset());
-
</del><span class="cx"> if (reg.isArgument()) {
</span><span class="cx"> RELEASE_ASSERT(reg.offset() < JSStack::CallFrameHeaderSize);
</span><span class="cx">
</span><span class="lines">@@ -702,10 +702,18 @@
</span><span class="cx"> reg.offset(), codeOrigin.bytecodeIndex);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!codeOrigin.inlineCallFrame)
</del><ins>+ InlineCallFrame* inlineCallFrame = codeOrigin.inlineCallFrame;
+ if (!inlineCallFrame)
</ins><span class="cx"> break;
</span><ins>+
+ // Arguments are always live. This would be redundant if it wasn't for our
+ // op_call_varargs inlining.
+ if (reg.isArgument()
+ && reg.toArgument()
+ && static_cast<size_t>(reg.toArgument()) < inlineCallFrame->arguments.size())
+ return true;
</ins><span class="cx">
</span><del>- codeOrigin = codeOrigin.inlineCallFrame->caller;
</del><ins>+ codeOrigin = inlineCallFrame->caller;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return true;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstressinlinecallvarargsandcalljs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs-and-call.js (0 => 162739)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs-and-call.js         (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs-and-call.js        2014-01-25 00:59:29 UTC (rev 162739)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+function foo(a, b) {
+ return bar(a, b);
+}
+
+function bar(a, b) {
+ var x = baz.apply(null, arguments);
+ var y = baz(a, b)
+ return x + y * 3;
+}
+
+function baz(a, b) {
+ return a + b * 2;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+ var result = foo(7, 11);
+ if (result != 116)
+ throw "Error: bad result: " + result;
+}
+
+var result = foo(5, 2147483646);
+if (result != 17179869188)
+ throw "Error: bad result: " + result;
</ins></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoretestsstressinlinecallvarargsjs"></a>
<div class="addfile"><h4>Added: branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs.js (0 => 162739)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs.js         (rev 0)
+++ branches/jsCStack/Source/JavaScriptCore/tests/stress/inline-call-varargs.js        2014-01-25 00:59:29 UTC (rev 162739)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+function foo(a, b) {
+ return bar(a, b);
+}
+
+function bar(a, b) {
+ return baz.apply(null, arguments);
+}
+
+function baz(a, b) {
+ return a + b * 2;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+ var result = foo(7, 11);
+ if (result != 29)
+ throw "Error: bad result: " + result;
+}
+
+var result = foo(5, 2147483646);
+if (result != 4294967297)
+ throw "Error: bad result: " + result;
</ins></span></pre>
</div>
</div>
</body>
</html>