<!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>[192814] 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/192814">192814</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2015-11-30 12:36:54 -0800 (Mon, 30 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>implement op_get_rest_length so that we can allocate the rest array with the right size from the start
https://bugs.webkit.org/show_bug.cgi?id=151467

Reviewed by Geoffrey Garen and Mark Lam.

This patch implements op_get_rest_length which returns the length
that the rest parameter array will be. We're implementing this because
it might be a constant value in the presence of inlining in the DFG.
We will take advantage of this optimization opportunity in a future patch:
https://bugs.webkit.org/show_bug.cgi?id=151454
to emit better code for op_copy_rest.

op_get_rest_length has two operands: 
1) a destination
2) A constant indicating the number of parameters to skip when copying the rest array.

op_get_rest_length lowers to a JSConstant node when we're inlined
and not a varargs call (in this case, we statically know the arguments
length). When that condition isn't met, we lower op_get_rest_length to 
GetRestArray. GetRestArray produces its result as an int32.

* bytecode/BytecodeList.json:
* bytecode/BytecodeUseDef.h:
(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpBytecode):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitNewArray):
(JSC::BytecodeGenerator::emitNewArrayWithSize):
(JSC::BytecodeGenerator::emitNewFunction):
(JSC::BytecodeGenerator::emitExpectedFunctionSnippet):
(JSC::BytecodeGenerator::emitRestParameter):
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::RestParameterNode::emit):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter&lt;AbstractStateType&gt;::executeEffects):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGCapabilities.cpp:
(JSC::DFG::capabilityLevel):
* dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGMayExit.cpp:
(JSC::DFG::mayExit):
* dfg/DFGNode.h:
(JSC::DFG::Node::numberOfArgumentsToSkip):
* dfg/DFGNodeType.h:
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* dfg/DFGPredictionPropagationPhase.cpp:
(JSC::DFG::PredictionPropagationPhase::propagate):
* dfg/DFGSafeToExecute.h:
(JSC::DFG::safeToExecute):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCopyRest):
(JSC::DFG::SpeculativeJIT::compileGetRestLength):
(JSC::DFG::SpeculativeJIT::compileNotifyWrite):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
(JSC::FTL::DFG::LowerDFGToLLVM::compileCopyRest):
(JSC::FTL::DFG::LowerDFGToLLVM::compileGetRestLength):
(JSC::FTL::DFG::LowerDFGToLLVM::compileNewObject):
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
* jit/JIT.h:
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_copy_rest):
(JSC::JIT::emit_op_get_rest_length):
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
* runtime/CommonSlowPaths.cpp:
(JSC::SLOW_PATH_DECL):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeBytecodeListjson">trunk/Source/JavaScriptCore/bytecode/BytecodeList.json</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeBytecodeUseDefh">trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorh">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerNodesCodegencpp">trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh">trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp">trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGCapabilitiescpp">trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGClobberizeh">trunk/Source/JavaScriptCore/dfg/DFGClobberize.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGDoesGCcpp">trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGFixupPhasecpp">trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGMayExitcpp">trunk/Source/JavaScriptCore/dfg/DFGMayExit.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGNodeh">trunk/Source/JavaScriptCore/dfg/DFGNode.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGNodeTypeh">trunk/Source/JavaScriptCore/dfg/DFGNodeType.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGOperationscpp">trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGOperationsh">trunk/Source/JavaScriptCore/dfg/DFGOperations.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGPredictionPropagationPhasecpp">trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSafeToExecuteh">trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITh">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLCapabilitiescpp">trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITcpp">trunk/Source/JavaScriptCore/jit/JIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITh">trunk/Source/JavaScriptCore/jit/JIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOpcodescpp">trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreterasm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm</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>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp">trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -1,3 +1,93 @@
</span><ins>+2015-11-30  Saam barati  &lt;sbarati@apple.com&gt;
+
+        implement op_get_rest_length so that we can allocate the rest array with the right size from the start
+        https://bugs.webkit.org/show_bug.cgi?id=151467
+
+        Reviewed by Geoffrey Garen and Mark Lam.
+
+        This patch implements op_get_rest_length which returns the length
+        that the rest parameter array will be. We're implementing this because
+        it might be a constant value in the presence of inlining in the DFG.
+        We will take advantage of this optimization opportunity in a future patch:
+        https://bugs.webkit.org/show_bug.cgi?id=151454
+        to emit better code for op_copy_rest.
+
+        op_get_rest_length has two operands: 
+        1) a destination
+        2) A constant indicating the number of parameters to skip when copying the rest array.
+
+        op_get_rest_length lowers to a JSConstant node when we're inlined
+        and not a varargs call (in this case, we statically know the arguments
+        length). When that condition isn't met, we lower op_get_rest_length to 
+        GetRestArray. GetRestArray produces its result as an int32.
+
+        * bytecode/BytecodeList.json:
+        * bytecode/BytecodeUseDef.h:
+        (JSC::computeUsesForBytecodeOffset):
+        (JSC::computeDefsForBytecodeOffset):
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::dumpBytecode):
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::emitNewArray):
+        (JSC::BytecodeGenerator::emitNewArrayWithSize):
+        (JSC::BytecodeGenerator::emitNewFunction):
+        (JSC::BytecodeGenerator::emitExpectedFunctionSnippet):
+        (JSC::BytecodeGenerator::emitRestParameter):
+        * bytecompiler/BytecodeGenerator.h:
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::RestParameterNode::emit):
+        * dfg/DFGAbstractInterpreterInlines.h:
+        (JSC::DFG::AbstractInterpreter&lt;AbstractStateType&gt;::executeEffects):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::parseBlock):
+        * dfg/DFGCapabilities.cpp:
+        (JSC::DFG::capabilityLevel):
+        * dfg/DFGClobberize.h:
+        (JSC::DFG::clobberize):
+        * dfg/DFGDoesGC.cpp:
+        (JSC::DFG::doesGC):
+        * dfg/DFGFixupPhase.cpp:
+        (JSC::DFG::FixupPhase::fixupNode):
+        * dfg/DFGMayExit.cpp:
+        (JSC::DFG::mayExit):
+        * dfg/DFGNode.h:
+        (JSC::DFG::Node::numberOfArgumentsToSkip):
+        * dfg/DFGNodeType.h:
+        * dfg/DFGOperations.cpp:
+        * dfg/DFGOperations.h:
+        * dfg/DFGPredictionPropagationPhase.cpp:
+        (JSC::DFG::PredictionPropagationPhase::propagate):
+        * dfg/DFGSafeToExecute.h:
+        (JSC::DFG::safeToExecute):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileCopyRest):
+        (JSC::DFG::SpeculativeJIT::compileGetRestLength):
+        (JSC::DFG::SpeculativeJIT::compileNotifyWrite):
+        * dfg/DFGSpeculativeJIT.h:
+        (JSC::DFG::SpeculativeJIT::callOperation):
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileCopyRest):
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileGetRestLength):
+        (JSC::FTL::DFG::LowerDFGToLLVM::compileNewObject):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompileMainPass):
+        * jit/JIT.h:
+        * jit/JITOpcodes.cpp:
+        (JSC::JIT::emit_op_copy_rest):
+        (JSC::JIT::emit_op_get_rest_length):
+        * llint/LowLevelInterpreter.asm:
+        * llint/LowLevelInterpreter32_64.asm:
+        * llint/LowLevelInterpreter64.asm:
+        * runtime/CommonSlowPaths.cpp:
+        (JSC::SLOW_PATH_DECL):
+
</ins><span class="cx"> 2015-11-30  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         MacroAssembler needs an API for disabling scratch registers
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeBytecodeListjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/BytecodeList.json (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/BytecodeList.json        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/bytecode/BytecodeList.json        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -129,7 +129,8 @@
</span><span class="cx">             { &quot;name&quot; : &quot;op_to_index_string&quot;, &quot;length&quot; : 3 },
</span><span class="cx">             { &quot;name&quot; : &quot;op_load_arrowfunction_this&quot;, &quot;length&quot; : 2 },
</span><span class="cx">             { &quot;name&quot; : &quot;op_assert&quot;, &quot;length&quot; : 3 },
</span><del>-            { &quot;name&quot; : &quot;op_copy_rest&quot;, &quot;length&quot;: 3 }
</del><ins>+            { &quot;name&quot; : &quot;op_copy_rest&quot;, &quot;length&quot;: 4 },
+            { &quot;name&quot; : &quot;op_get_rest_length&quot;, &quot;length&quot;: 3 }
</ins><span class="cx">         ]
</span><span class="cx">     },
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeBytecodeUseDefh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx">     case op_profile_control_flow:
</span><span class="cx">     case op_create_direct_arguments:
</span><span class="cx">     case op_create_out_of_band_arguments:
</span><ins>+    case op_get_rest_length:
</ins><span class="cx">         return;
</span><span class="cx">     case op_assert:
</span><span class="cx">     case op_get_scope:
</span><span class="lines">@@ -70,8 +71,7 @@
</span><span class="cx">     case op_jeq_null:
</span><span class="cx">     case op_jneq_null:
</span><span class="cx">     case op_dec:
</span><del>-    case op_inc: 
-    case op_copy_rest: {
</del><ins>+    case op_inc: {
</ins><span class="cx">         functor(codeBlock, instruction, opcodeID, instruction[1].u.operand);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -82,7 +82,8 @@
</span><span class="cx">     case op_jnlesseq:
</span><span class="cx">     case op_jngreater:
</span><span class="cx">     case op_jngreatereq:
</span><del>-    case op_jless: {
</del><ins>+    case op_jless:
+    case op_copy_rest: {
</ins><span class="cx">         functor(codeBlock, instruction, opcodeID, instruction[1].u.operand);
</span><span class="cx">         functor(codeBlock, instruction, opcodeID, instruction[2].u.operand);
</span><span class="cx">         return;
</span><span class="lines">@@ -377,7 +378,8 @@
</span><span class="cx">     case op_del_by_id:
</span><span class="cx">     case op_del_by_val:
</span><span class="cx">     case op_unsigned:
</span><del>-    case op_get_from_arguments: {
</del><ins>+    case op_get_from_arguments: 
+    case op_get_rest_length: {
</ins><span class="cx">         functor(codeBlock, instruction, opcodeID, instruction[1].u.operand);
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -783,7 +783,16 @@
</span><span class="cx">         }
</span><span class="cx">         case op_copy_rest: {
</span><span class="cx">             int r0 = (++it)-&gt;u.operand;
</span><ins>+            int r1 = (++it)-&gt;u.operand;
+            unsigned argumentOffset = (++it)-&gt;u.unsignedValue;
</ins><span class="cx">             printLocationAndOp(out, exec, location, it, &quot;copy_rest&quot;);
</span><ins>+            out.printf(&quot;%s, %s, &quot;, registerName(r0).data(), registerName(r1).data());
+            out.printf(&quot;ArgumentsOffset: %u&quot;, argumentOffset);
+            break;
+        }
+        case op_get_rest_length: {
+            int r0 = (++it)-&gt;u.operand;
+            printLocationAndOp(out, exec, location, it, &quot;get_rest_length&quot;);
</ins><span class="cx">             out.printf(&quot;%s, &quot;, registerName(r0).data());
</span><span class="cx">             unsigned argumentOffset = (++it)-&gt;u.unsignedValue;
</span><span class="cx">             out.printf(&quot;ArgumentsOffset: %u&quot;, argumentOffset);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -2471,6 +2471,16 @@
</span><span class="cx">     return dst;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RegisterID* BytecodeGenerator::emitNewArrayWithSize(RegisterID* dst, RegisterID* length)
+{
+    emitOpcode(op_new_array_with_size);
+    instructions().append(dst-&gt;index());
+    instructions().append(length-&gt;index());
+    instructions().append(newArrayAllocationProfile());
+
+    return dst;
+}
+
</ins><span class="cx"> RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionMetadataNode* function)
</span><span class="cx"> {
</span><span class="cx">     return emitNewFunctionInternal(dst, m_codeBlock-&gt;addFunctionDecl(makeFunction(function)));
</span><span class="lines">@@ -2600,12 +2610,9 @@
</span><span class="cx">         instructions().append(realCall-&gt;bind(begin, instructions().size()));
</span><span class="cx">         
</span><span class="cx">         if (dst != ignoredResult()) {
</span><del>-            if (callArguments.argumentCountIncludingThis() == 2) {
-                emitOpcode(op_new_array_with_size);
-                instructions().append(dst-&gt;index());
-                instructions().append(callArguments.argumentRegister(0)-&gt;index());
-                instructions().append(newArrayAllocationProfile());
-            } else {
</del><ins>+            if (callArguments.argumentCountIncludingThis() == 2)
+                emitNewArrayWithSize(dst, callArguments.argumentRegister(0));
+            else {
</ins><span class="cx">                 ASSERT(callArguments.argumentCountIncludingThis() == 1);
</span><span class="cx">                 emitOpcode(op_new_array);
</span><span class="cx">                 instructions().append(dst-&gt;index());
</span><span class="lines">@@ -3833,10 +3840,16 @@
</span><span class="cx"> 
</span><span class="cx"> RegisterID* BytecodeGenerator::emitRestParameter(RegisterID* result, unsigned numParametersToSkip)
</span><span class="cx"> {
</span><del>-    emitNewArray(result, nullptr, 0);
</del><ins>+    RefPtr&lt;RegisterID&gt; restArrayLength = newTemporary();
+    emitOpcode(op_get_rest_length);
+    instructions().append(restArrayLength-&gt;index());
+    instructions().append(numParametersToSkip);
</ins><span class="cx"> 
</span><ins>+    emitNewArrayWithSize(result, restArrayLength.get());
+
</ins><span class="cx">     emitOpcode(op_copy_rest);
</span><span class="cx">     instructions().append(result-&gt;index());
</span><ins>+    instructions().append(restArrayLength-&gt;index());
</ins><span class="cx">     instructions().append(numParametersToSkip);
</span><span class="cx"> 
</span><span class="cx">     return result;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -497,6 +497,7 @@
</span><span class="cx">         void liftTDZCheckIfPossible(const Variable&amp;);
</span><span class="cx">         RegisterID* emitNewObject(RegisterID* dst);
</span><span class="cx">         RegisterID* emitNewArray(RegisterID* dst, ElementNode*, unsigned length); // stops at first elision
</span><ins>+        RegisterID* emitNewArrayWithSize(RegisterID* dst, RegisterID* length);
</ins><span class="cx"> 
</span><span class="cx">         RegisterID* emitNewFunction(RegisterID* dst, FunctionMetadataNode*);
</span><span class="cx">         RegisterID* emitNewFunctionInternal(RegisterID* dst, unsigned index);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerNodesCodegencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -3483,7 +3483,8 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RefPtr&lt;RegisterID&gt; restParameterArray = generator.emitRestParameter(generator.newTemporary(), m_numParametersToSkip);
</del><ins>+    RefPtr&lt;RegisterID&gt; restParameterArray = generator.newTemporary();
+    generator.emitRestParameter(restParameterArray.get(), m_numParametersToSkip);
</ins><span class="cx">     generator.emitProfileType(restParameterArray.get(), var, m_divotStart, m_divotEnd);
</span><span class="cx">     RefPtr&lt;RegisterID&gt; scope = generator.emitResolveScope(nullptr, var);
</span><span class="cx">     generator.emitExpressionInfo(m_divotEnd, m_divotStart, m_divotEnd);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGAbstractInterpreterInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -1763,6 +1763,10 @@
</span><span class="cx">         forNode(node).setType(SpecInt32);
</span><span class="cx">         break;
</span><span class="cx">         
</span><ins>+    case GetRestLength:
+        forNode(node).setType(SpecInt32);
+        break;
+        
</ins><span class="cx">     case GetGetter: {
</span><span class="cx">         JSValue base = forNode(node-&gt;child1()).m_value;
</span><span class="cx">         if (base) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGByteCodeParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -3331,10 +3331,31 @@
</span><span class="cx">             NEXT_OPCODE(op_new_regexp);
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        case op_get_rest_length: {
+            InlineCallFrame* inlineCallFrame = this-&gt;inlineCallFrame();
+            Node* length;
+            if (inlineCallFrame &amp;&amp; !inlineCallFrame-&gt;isVarargs()) {
+                unsigned argumentsLength = inlineCallFrame-&gt;arguments.size() - 1;
+                unsigned numParamsToSkip = currentInstruction[2].u.unsignedValue;
+                JSValue restLength;
+                if (argumentsLength &lt;= numParamsToSkip)
+                    restLength = jsNumber(0);
+                else
+                    restLength = jsNumber(argumentsLength - numParamsToSkip);
+
+                length = jsConstant(restLength);
+            } else
+                length = addToGraph(GetRestLength, OpInfo(currentInstruction[2].u.unsignedValue));
+            set(VirtualRegister(currentInstruction[1].u.operand), length);
+            NEXT_OPCODE(op_get_rest_length);
+        }
+
</ins><span class="cx">         case op_copy_rest: {
</span><span class="cx">             noticeArgumentsUse();
</span><del>-            addToGraph(CopyRest,
-                OpInfo(currentInstruction[2].u.unsignedValue), get(VirtualRegister(currentInstruction[1].u.operand)));
</del><ins>+            Node* array = get(VirtualRegister(currentInstruction[1].u.operand));
+            Node* arrayLength = get(VirtualRegister(currentInstruction[2].u.operand));
+            addToGraph(CopyRest, OpInfo(currentInstruction[3].u.unsignedValue),
+                array, arrayLength);
</ins><span class="cx">             NEXT_OPCODE(op_copy_rest);
</span><span class="cx">         }
</span><span class="cx">             
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGCapabilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -220,6 +220,7 @@
</span><span class="cx">     case op_get_parent_scope:
</span><span class="cx">     case op_catch:
</span><span class="cx">     case op_copy_rest:
</span><ins>+    case op_get_rest_length:
</ins><span class="cx">         return CanCompileAndInline;
</span><span class="cx"> 
</span><span class="cx">     case op_put_to_scope: {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGClobberizeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGClobberize.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -428,6 +428,10 @@
</span><span class="cx">         read(AbstractHeap(Stack, JSStack::ArgumentCount));
</span><span class="cx">         def(HeapLocation(StackPayloadLoc, AbstractHeap(Stack, JSStack::ArgumentCount)), LazyNode(node));
</span><span class="cx">         return;
</span><ins>+
+    case GetRestLength:
+        read(Stack);
+        return;
</ins><span class="cx">         
</span><span class="cx">     case GetLocal:
</span><span class="cx">         read(AbstractHeap(Stack, node-&gt;local()));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGDoesGCcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     case Identity:
</span><span class="cx">     case GetCallee:
</span><span class="cx">     case GetArgumentCount:
</span><ins>+    case GetRestLength:
</ins><span class="cx">     case GetLocal:
</span><span class="cx">     case SetLocal:
</span><span class="cx">     case MovHint:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGFixupPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -1370,6 +1370,7 @@
</span><span class="cx"> 
</span><span class="cx">         case CopyRest: {
</span><span class="cx">             fixEdge&lt;KnownCellUse&gt;(node-&gt;child1());
</span><ins>+            fixEdge&lt;KnownInt32Use&gt;(node-&gt;child2());
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1381,6 +1382,7 @@
</span><span class="cx">         case GetLocal:
</span><span class="cx">         case GetCallee:
</span><span class="cx">         case GetArgumentCount:
</span><ins>+        case GetRestLength:
</ins><span class="cx">         case Flush:
</span><span class="cx">         case PhantomLocal:
</span><span class="cx">         case GetLocalUnlinked:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGMayExitcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGMayExit.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGMayExit.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGMayExit.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -113,6 +113,7 @@
</span><span class="cx">     case GetStack:
</span><span class="cx">     case GetCallee:
</span><span class="cx">     case GetArgumentCount:
</span><ins>+    case GetRestLength:
</ins><span class="cx">     case GetScope:
</span><span class="cx">     case PhantomLocal:
</span><span class="cx">     case CountExecution:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGNode.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGNode.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGNode.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -2161,7 +2161,7 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned numberOfArgumentsToSkip()
</span><span class="cx">     {
</span><del>-        ASSERT(op() == CopyRest);
</del><ins>+        ASSERT(op() == CopyRest || op() == GetRestLength);
</ins><span class="cx">         return static_cast&lt;unsigned&gt;(m_opInfo);
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGNodeTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGNodeType.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGNodeType.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -262,6 +262,8 @@
</span><span class="cx">     macro(NewArrayBuffer, NodeResultJS) \
</span><span class="cx">     macro(NewTypedArray, NodeResultJS | NodeMustGenerate) \
</span><span class="cx">     macro(NewRegexp, NodeResultJS) \
</span><ins>+    /* Rest Parameter */\
+    macro(GetRestLength, NodeResultInt32) \
</ins><span class="cx">     macro(CopyRest, NodeMustGenerate) \
</span><span class="cx">     \
</span><span class="cx">     /* Support for allocation sinking. */\
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -818,11 +818,11 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JIT_OPERATION operationCopyRest(ExecState* exec, JSCell* arrayAsCell, Register* argumentStart, unsigned numberOfParamsToSkip, unsigned numberOfArguments)
</del><ins>+void JIT_OPERATION operationCopyRest(ExecState* exec, JSCell* arrayAsCell, Register* argumentStart, unsigned numberOfParamsToSkip, unsigned arraySize)
</ins><span class="cx"> {
</span><del>-    RELEASE_ASSERT(numberOfArguments &gt; numberOfParamsToSkip); // We should only call this from JIT code when this condition is true.
</del><ins>+    ASSERT(arraySize);
</ins><span class="cx">     JSArray* array = jsCast&lt;JSArray*&gt;(arrayAsCell);
</span><del>-    unsigned arraySize = numberOfArguments - numberOfParamsToSkip;
</del><ins>+    ASSERT(arraySize == array-&gt;length());
</ins><span class="cx">     array-&gt;setLength(exec, arraySize);
</span><span class="cx">     for (unsigned i = 0; i &lt; arraySize; i++)
</span><span class="cx">         array-&gt;putDirectIndex(exec, i, argumentStart[i + numberOfParamsToSkip].jsValue());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGOperations.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGOperations.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx"> JSCell* JIT_OPERATION operationCreateScopedArguments(ExecState*, Structure*, Register* argumentStart, int32_t length, JSFunction* callee, JSLexicalEnvironment*);
</span><span class="cx"> JSCell* JIT_OPERATION operationCreateClonedArgumentsDuringExit(ExecState*, InlineCallFrame*, JSFunction*, int32_t argumentCount);
</span><span class="cx"> JSCell* JIT_OPERATION operationCreateClonedArguments(ExecState*, Structure*, Register* argumentStart, int32_t length, JSFunction* callee);
</span><del>-void JIT_OPERATION operationCopyRest(ExecState*, JSCell*, Register* argumentStart, unsigned numberOfParamsToSkip, unsigned argumentsCount);
</del><ins>+void JIT_OPERATION operationCopyRest(ExecState*, JSCell*, Register* argumentStart, unsigned numberOfParamsToSkip, unsigned arraySize);
</ins><span class="cx"> double JIT_OPERATION operationFModOnInts(int32_t, int32_t) WTF_INTERNAL;
</span><span class="cx"> size_t JIT_OPERATION operationObjectIsObject(ExecState*, JSGlobalObject*, JSCell*) WTF_INTERNAL;
</span><span class="cx"> size_t JIT_OPERATION operationObjectIsFunction(ExecState*, JSGlobalObject*, JSCell*) WTF_INTERNAL;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGPredictionPropagationPhasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -219,6 +219,11 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        case GetRestLength: {
+            changed |= setPrediction(SpecInt32);
+            break;
+        }
+
</ins><span class="cx">         case GetTypedArrayByteOffset:
</span><span class="cx">         case GetArrayLength: {
</span><span class="cx">             changed |= setPrediction(SpecInt32);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSafeToExecuteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -140,6 +140,7 @@
</span><span class="cx">     case CreateThis:
</span><span class="cx">     case GetCallee:
</span><span class="cx">     case GetArgumentCount:
</span><ins>+    case GetRestLength:
</ins><span class="cx">     case GetLocal:
</span><span class="cx">     case SetLocal:
</span><span class="cx">     case PutStack:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -5352,22 +5352,20 @@
</span><span class="cx">     ASSERT(node-&gt;op() == CopyRest);
</span><span class="cx"> 
</span><span class="cx">     SpeculateCellOperand array(this, node-&gt;child1());
</span><ins>+    GPRTemporary argumentsStart(this);
+    SpeculateStrictInt32Operand arrayLength(this, node-&gt;child2());
+
</ins><span class="cx">     GPRReg arrayGPR = array.gpr();
</span><del>-
-    GPRTemporary argumentsLength(this);
-    GPRReg argumentsLengthGPR = argumentsLength.gpr();
-
-    GPRTemporary argumentsStart(this);
</del><span class="cx">     GPRReg argumentsStartGPR = argumentsStart.gpr();
</span><ins>+    GPRReg arrayLengthGPR = arrayLength.gpr();
</ins><span class="cx"> 
</span><del>-    emitGetLength(node-&gt;origin.semantic, argumentsLengthGPR);
-    CCallHelpers::Jump done = m_jit.branch32(MacroAssembler::LessThanOrEqual, argumentsLengthGPR, TrustedImm32(node-&gt;numberOfArgumentsToSkip()));
</del><ins>+    CCallHelpers::Jump done = m_jit.branch32(MacroAssembler::Equal, arrayLengthGPR, TrustedImm32(0));
</ins><span class="cx"> 
</span><span class="cx">     emitGetArgumentStart(node-&gt;origin.semantic, argumentsStartGPR);
</span><del>-    silentSpillAllRegisters(argumentsLengthGPR, argumentsStartGPR);
-    // Arguments: 0:exec, 1:JSCell* array, 2:arguments start, 3:number of arguments to skip, 4:number of arguments
-    callOperation(operationCopyRest, arrayGPR, argumentsStartGPR, TrustedImm32(node-&gt;numberOfArgumentsToSkip()), argumentsLengthGPR);
-    silentFillAllRegisters(argumentsLengthGPR);
</del><ins>+    silentSpillAllRegisters(argumentsStartGPR);
+    // Arguments: 0:exec, 1:JSCell* array, 2:arguments start, 3:number of arguments to skip, 4:array length
+    callOperation(operationCopyRest, arrayGPR, argumentsStartGPR, Imm32(node-&gt;numberOfArgumentsToSkip()), arrayLengthGPR);
+    silentFillAllRegisters(argumentsStartGPR);
</ins><span class="cx">     m_jit.exceptionCheck();
</span><span class="cx"> 
</span><span class="cx">     done.link(&amp;m_jit);
</span><span class="lines">@@ -5375,6 +5373,24 @@
</span><span class="cx">     noResult(node);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SpeculativeJIT::compileGetRestLength(Node* node)
+{
+    ASSERT(node-&gt;op() == GetRestLength);
+
+    GPRTemporary result(this);
+    GPRReg resultGPR = result.gpr();
+
+    emitGetLength(node-&gt;origin.semantic, resultGPR);
+    CCallHelpers::Jump hasNonZeroLength = m_jit.branch32(MacroAssembler::Above, resultGPR, Imm32(node-&gt;numberOfArgumentsToSkip()));
+    m_jit.move(TrustedImm32(0), resultGPR);
+    CCallHelpers::Jump done = m_jit.jump();
+    hasNonZeroLength.link(&amp;m_jit);
+    if (node-&gt;numberOfArgumentsToSkip())
+        m_jit.sub32(TrustedImm32(node-&gt;numberOfArgumentsToSkip()), resultGPR);
+    done.link(&amp;m_jit);
+    int32Result(resultGPR, node);
+}
+
</ins><span class="cx"> void SpeculativeJIT::compileNotifyWrite(Node* node)
</span><span class="cx"> {
</span><span class="cx">     WatchpointSet* set = node-&gt;watchpointSet();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -1221,9 +1221,9 @@
</span><span class="cx">         return appendCall(operation);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    JITCompiler::Call callOperation(V_JITOperation_ECRUiUi operation, GPRReg arg1, GPRReg arg2, TrustedImm32 arg3, GPRReg arg4)
</del><ins>+    JITCompiler::Call callOperation(V_JITOperation_ECRUiUi operation, GPRReg arg1, GPRReg arg2, Imm32 arg3, GPRReg arg4)
</ins><span class="cx">     {
</span><del>-        m_jit.setupArgumentsWithExecState(arg1, arg2, arg3, arg4);
</del><ins>+        m_jit.setupArgumentsWithExecState(arg1, arg2, arg3.asTrustedImm32(), arg4);
</ins><span class="cx">         return appendCall(operation);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2245,6 +2245,7 @@
</span><span class="cx">     void compileCreateScopedArguments(Node*);
</span><span class="cx">     void compileCreateClonedArguments(Node*);
</span><span class="cx">     void compileCopyRest(Node*);
</span><ins>+    void compileGetRestLength(Node*);
</ins><span class="cx">     void compileNotifyWrite(Node*);
</span><span class="cx">     bool compileRegExpExec(Node*);
</span><span class="cx">     void compileIsObjectOrNull(Node*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -4443,6 +4443,11 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    case GetRestLength: {
+        compileGetRestLength(node);
+        break;
+    }
+
</ins><span class="cx">     case NewFunction:
</span><span class="cx">     case NewArrowFunction:
</span><span class="cx">         compileNewFunction(node);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -3827,6 +3827,11 @@
</span><span class="cx">         int32Result(result.gpr(), node);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+
+    case GetRestLength: {
+        compileGetRestLength(node);
+        break;
+    }
</ins><span class="cx">         
</span><span class="cx">     case GetScope:
</span><span class="cx">         compileGetScope(node);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLCapabilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -211,6 +211,7 @@
</span><span class="cx">     case PutGetterByVal:
</span><span class="cx">     case PutSetterByVal:
</span><span class="cx">     case CopyRest:
</span><ins>+    case GetRestLength:
</ins><span class="cx">         // These are OK.
</span><span class="cx">         break;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToLLVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -970,6 +970,9 @@
</span><span class="cx">         case CopyRest:
</span><span class="cx">             compileCopyRest();
</span><span class="cx">             break;
</span><ins>+        case GetRestLength:
+            compileGetRestLength();
+            break;
</ins><span class="cx"> 
</span><span class="cx">         case PhantomLocal:
</span><span class="cx">         case LoopHint:
</span><span class="lines">@@ -3645,22 +3648,42 @@
</span><span class="cx">         LBasicBlock doCopyRest = FTL_NEW_BLOCK(m_out, (&quot;CopyRest C call&quot;));
</span><span class="cx">         LBasicBlock continuation = FTL_NEW_BLOCK(m_out, (&quot;FillRestParameter continuation&quot;));
</span><span class="cx"> 
</span><del>-        LValue numberOfArgumentsToSkip = m_out.constInt32(m_node-&gt;numberOfArgumentsToSkip());
-        LValue numberOfArguments = getArgumentsLength().value;
</del><ins>+        LValue arrayLength = lowInt32(m_node-&gt;child2());
</ins><span class="cx"> 
</span><span class="cx">         m_out.branch(
</span><del>-            m_out.above(numberOfArguments, numberOfArgumentsToSkip),
-            unsure(doCopyRest), unsure(continuation));
</del><ins>+            m_out.equal(arrayLength, m_out.constInt32(0)),
+            unsure(continuation), unsure(doCopyRest));
</ins><span class="cx">             
</span><span class="cx">         LBasicBlock lastNext = m_out.appendTo(doCopyRest, continuation);
</span><del>-        // Arguments: 0:exec, 1:JSCell* array, 2:arguments start, 3:number of arguments to skip, 4:number of arguments
</del><ins>+        // Arguments: 0:exec, 1:JSCell* array, 2:arguments start, 3:number of arguments to skip, 4:array length
+        LValue numberOfArgumentsToSkip = m_out.constInt32(m_node-&gt;numberOfArgumentsToSkip());
</ins><span class="cx">         vmCall(
</span><span class="cx">             m_out.voidType,m_out.operation(operationCopyRest), m_callFrame, lowCell(m_node-&gt;child1()),
</span><del>-            getArgumentsStart(), numberOfArgumentsToSkip, numberOfArguments);
</del><ins>+            getArgumentsStart(), numberOfArgumentsToSkip, arrayLength);
</ins><span class="cx">         m_out.jump(continuation);
</span><span class="cx"> 
</span><span class="cx">         m_out.appendTo(continuation, lastNext);
</span><span class="cx">     }
</span><ins>+
+    void compileGetRestLength()
+    {
+        LBasicBlock nonZeroLength = FTL_NEW_BLOCK(m_out, (&quot;GetRestLength non zero&quot;));
+        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, (&quot;GetRestLength continuation&quot;));
+        
+        ValueFromBlock zeroLengthResult = m_out.anchor(m_out.constInt32(0));
+
+        LValue numberOfArgumentsToSkip = m_out.constInt32(m_node-&gt;numberOfArgumentsToSkip());
+        LValue argumentsLength = getArgumentsLength().value;
+        m_out.branch(m_out.above(argumentsLength, numberOfArgumentsToSkip),
+            unsure(nonZeroLength), unsure(continuation));
+        
+        LBasicBlock lastNext = m_out.appendTo(nonZeroLength, continuation);
+        ValueFromBlock nonZeroLengthResult = m_out.anchor(m_out.sub(argumentsLength, numberOfArgumentsToSkip));
+        m_out.jump(continuation);
+        
+        m_out.appendTo(continuation, lastNext);
+        setInt32(m_out.phi(m_out.int32, zeroLengthResult, nonZeroLengthResult));
+    }
</ins><span class="cx">     
</span><span class="cx">     void compileNewObject()
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JIT.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JIT.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/jit/JIT.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -212,6 +212,7 @@
</span><span class="cx">         DEFINE_OP(op_create_scoped_arguments)
</span><span class="cx">         DEFINE_OP(op_create_out_of_band_arguments)
</span><span class="cx">         DEFINE_OP(op_copy_rest)
</span><ins>+        DEFINE_OP(op_get_rest_length)
</ins><span class="cx">         DEFINE_OP(op_check_tdz)
</span><span class="cx">         DEFINE_OP(op_assert)
</span><span class="cx">         DEFINE_OP(op_debug)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JIT.h (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JIT.h        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/jit/JIT.h        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -491,6 +491,7 @@
</span><span class="cx">         void emit_op_create_scoped_arguments(Instruction*);
</span><span class="cx">         void emit_op_create_out_of_band_arguments(Instruction*);
</span><span class="cx">         void emit_op_copy_rest(Instruction*);
</span><ins>+        void emit_op_get_rest_length(Instruction*);
</ins><span class="cx">         void emit_op_check_tdz(Instruction*);
</span><span class="cx">         void emit_op_assert(Instruction*);
</span><span class="cx">         void emit_op_debug(Instruction*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOpcodescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -1405,6 +1405,35 @@
</span><span class="cx">     slowPathCall.call();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void JIT::emit_op_get_rest_length(Instruction* currentInstruction)
+{
+    int dst = currentInstruction[1].u.operand;
+    unsigned numParamsToSkip = currentInstruction[2].u.unsignedValue;
+    load32(payloadFor(JSStack::ArgumentCount), regT0);
+    sub32(TrustedImm32(1), regT0);
+    Jump zeroLength = branch32(LessThanOrEqual, regT0, Imm32(numParamsToSkip));
+    sub32(Imm32(numParamsToSkip), regT0);
+#if USE(JSVALUE64)
+    boxInt32(regT0, JSValueRegs(regT0));
+#endif
+    Jump done = jump();
+
+    zeroLength.link(this);
+#if USE(JSVALUE64)
+    move(TrustedImm64(JSValue::encode(jsNumber(0))), regT0);
+#else
+    move(TrustedImm32(0), regT0);
+#endif
+
+    done.link(this);
+#if USE(JSVALUE64)
+    emitPutVirtualRegister(dst, regT0);
+#else
+    move(TrustedImm32(JSValue::Int32Tag), regT1);
+    emitPutVirtualRegister(dst, JSValueRegs(regT1, regT0));
+#endif
+}
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(JIT)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreterasm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -1678,7 +1678,7 @@
</span><span class="cx"> _llint_op_copy_rest:
</span><span class="cx">     traceExecution()
</span><span class="cx">     callSlowPath(_slow_path_copy_rest)
</span><del>-    dispatch(3)
</del><ins>+    dispatch(4)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> # Lastly, make sure that we can link even though we don't support all opcodes.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreter32_64asm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -2430,3 +2430,20 @@
</span><span class="cx">     storei CellTag, TagOffset[cfr, t1, 8]
</span><span class="cx">     storei t0, PayloadOffset[cfr, t1, 8]
</span><span class="cx">     dispatch(2)
</span><ins>+
+
+_llint_op_get_rest_length:
+    traceExecution()
+    loadi PayloadOffset + ArgumentCount[cfr], t0
+    subi 1, t0
+    loadisFromInstruction(2, t1)
+    bilteq t0, t1, .storeZero
+    subi t1, t0
+    jmp .finish
+.storeZero:
+    move 0, t0
+.finish:
+    loadisFromInstruction(1, t1)
+    storei t0, PayloadOffset[cfr, t1, 8]
+    storei Int32Tag, TagOffset[cfr, t1, 8]
+    dispatch(3)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreter64asm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -2298,3 +2298,20 @@
</span><span class="cx">     loadisFromInstruction(1, t1)
</span><span class="cx">     storeq t0, [cfr, t1, 8]
</span><span class="cx">     dispatch(2)
</span><ins>+
+
+_llint_op_get_rest_length:
+    traceExecution()
+    loadi PayloadOffset + ArgumentCount[cfr], t0
+    subi 1, t0
+    loadisFromInstruction(2, t1)
+    bilteq t0, t1, .storeZero
+    subi t1, t0
+    jmp .boxUp
+.storeZero:
+    move 0, t0
+.boxUp:
+    orq tagTypeNumber, t0
+    loadisFromInstruction(1, t1)
+    storeq t0, [cfr, t1, 8]
+    dispatch(3)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (192813 => 192814)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2015-11-30 20:12:07 UTC (rev 192813)
+++ trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2015-11-30 20:36:54 UTC (rev 192814)
</span><span class="lines">@@ -704,14 +704,14 @@
</span><span class="cx"> SLOW_PATH_DECL(slow_path_copy_rest)
</span><span class="cx"> {
</span><span class="cx">     BEGIN();
</span><del>-    unsigned numParamsToSkip = pc[2].u.unsignedValue;
-    unsigned numArgumentsToFunction = exec-&gt;argumentCount();
-    if (numArgumentsToFunction &lt;= numParamsToSkip)
</del><ins>+    unsigned arraySize = OP_C(2).jsValue().asUInt32();
+    if (!arraySize) {
+        ASSERT(!jsCast&lt;JSArray*&gt;(OP(1).jsValue())-&gt;length());
</ins><span class="cx">         END();
</span><del>-
</del><ins>+    }
</ins><span class="cx">     JSArray* array = jsCast&lt;JSArray*&gt;(OP(1).jsValue());
</span><del>-    unsigned arraySize = numArgumentsToFunction - numParamsToSkip;
-    array-&gt;setLength(exec, arraySize);
</del><ins>+    ASSERT(arraySize == array-&gt;length());
+    unsigned numParamsToSkip = pc[3].u.unsignedValue;
</ins><span class="cx">     for (unsigned i = 0; i &lt; arraySize; i++)
</span><span class="cx">         array-&gt;putDirectIndex(exec, i, exec-&gt;uncheckedArgument(i + numParamsToSkip));
</span><span class="cx">     END();
</span></span></pre>
</div>
</div>

</body>
</html>