<!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>[196675] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196675">196675</a></dd>
<dt>Author</dt> <dd>keith_miller@apple.com</dd>
<dt>Date</dt> <dd>2016-02-16 17:29:37 -0800 (Tue, 16 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Spread operator should be allowed when not the first argument of parameter list
https://bugs.webkit.org/show_bug.cgi?id=152721

Reviewed by Saam Barati.

Source/JavaScriptCore:

Spread arguments to functions should now be ES6 compliant. Before we
would only take a spread operator if it was the sole argument to a
function. Additionally, we would not use the Symbol.iterator on the
object to generate the arguments. Instead we would do a loop up to the
length mapping indexed properties to the corresponding argument. We fix
both these issues by doing an AST transformation from foo(...a, b, ...c, d)
to foo(...[...a, b, ...c, d]) (where the spread on the rhs uses the
old spread semantics). This solution has the downside of requiring the
allocation of another object and copying each element twice but avoids a
large change to the vm calling convention.

* interpreter/Interpreter.cpp:
(JSC::loadVarargs):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createElementList):
* parser/Parser.cpp:
(JSC::Parser&lt;LexerType&gt;::parseArguments):
(JSC::Parser&lt;LexerType&gt;::parseArgument):
(JSC::Parser&lt;LexerType&gt;::parseMemberExpression):
* parser/Parser.h:
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createElementList):
* tests/es6.yaml:
* tests/stress/spread-calling.js: Added.
(testFunction):
(testEmpty):
(makeObject):
(otherIterator.return.next):
(otherIterator):
(totalIter):
(throwingIter.return.next):
(throwingIter):
(i.catch):

LayoutTests:

Update tests with new semantics of spread calling.

* js/basic-spread-expected.txt:
* js/parser-syntax-check-expected.txt:
* js/script-tests/basic-spread.js:
* js/script-tests/parser-syntax-check.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsbasicspreadexpectedtxt">trunk/LayoutTests/js/basic-spread-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsparsersyntaxcheckexpectedtxt">trunk/LayoutTests/js/parser-syntax-check-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsbasicspreadjs">trunk/LayoutTests/js/script-tests/basic-spread.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsparsersyntaxcheckjs">trunk/LayoutTests/js/script-tests/parser-syntax-check.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinterpreterInterpretercpp">trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserASTBuilderh">trunk/Source/JavaScriptCore/parser/ASTBuilder.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParsercpp">trunk/Source/JavaScriptCore/parser/Parser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserh">trunk/Source/JavaScriptCore/parser/Parser.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserSyntaxCheckerh">trunk/Source/JavaScriptCore/parser/SyntaxChecker.h</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6yaml">trunk/Source/JavaScriptCore/tests/es6.yaml</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressspreadcallingjs">trunk/Source/JavaScriptCore/tests/stress/spread-calling.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/LayoutTests/ChangeLog        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-02-16  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Spread operator should be allowed when not the first argument of parameter list
+        https://bugs.webkit.org/show_bug.cgi?id=152721
+
+        Reviewed by Saam Barati.
+
+        Update tests with new semantics of spread calling.
+
+        * js/basic-spread-expected.txt:
+        * js/parser-syntax-check-expected.txt:
+        * js/script-tests/basic-spread.js:
+        * js/script-tests/parser-syntax-check.js:
+
</ins><span class="cx"> 2016-02-16  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Navigator.geolocation should not be marked a [Replaceable] and should be on the prototype
</span></span></pre></div>
<a id="trunkLayoutTestsjsbasicspreadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/basic-spread-expected.txt (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/basic-spread-expected.txt        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/LayoutTests/js/basic-spread-expected.txt        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -43,46 +43,6 @@
</span><span class="cx"> PASS args[1] is undefined
</span><span class="cx"> PASS args[2] is null
</span><span class="cx"> PASS args[3] is 4
</span><del>-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
-PASS passedThis is o
-PASS args[0] is 1
-PASS args[1] is undefined
-PASS args[2] is null
-PASS args[3] is 4
</del><span class="cx"> PASS a is [1,2,3]
</span><span class="cx"> PASS [...a] is [1,2,3]
</span><span class="cx"> PASS [...a] is [1,2,3]
</span></span></pre></div>
<a id="trunkLayoutTestsjsparsersyntaxcheckexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/parser-syntax-check-expected.txt (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/parser-syntax-check-expected.txt        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/LayoutTests/js/parser-syntax-check-expected.txt        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -757,18 +757,18 @@
</span><span class="cx"> PASS Invalid: &quot;function f() { o.foo(bar...) }&quot;
</span><span class="cx"> PASS Invalid: &quot;o[foo](bar...)&quot;
</span><span class="cx"> PASS Invalid: &quot;function f() { o[foo](bar...) }&quot;
</span><del>-PASS Invalid: &quot;foo(a,...bar)&quot;
-PASS Invalid: &quot;function f() { foo(a,...bar) }&quot;
-PASS Invalid: &quot;o.foo(a,...bar)&quot;
-PASS Invalid: &quot;function f() { o.foo(a,...bar) }&quot;
-PASS Invalid: &quot;o[foo](a,...bar)&quot;
-PASS Invalid: &quot;function f() { o[foo](a,...bar) }&quot;
-PASS Invalid: &quot;foo(...bar, a)&quot;
-PASS Invalid: &quot;function f() { foo(...bar, a) }&quot;
-PASS Invalid: &quot;o.foo(...bar, a)&quot;
-PASS Invalid: &quot;function f() { o.foo(...bar, a) }&quot;
-PASS Invalid: &quot;o[foo](...bar, a)&quot;
-PASS Invalid: &quot;function f() { o[foo](...bar, a) }&quot;
</del><ins>+PASS Valid:   &quot;foo(a,...bar)&quot; with ReferenceError
+PASS Valid:   &quot;function f() { foo(a,...bar) }&quot;
+PASS Valid:   &quot;o.foo(a,...bar)&quot; with ReferenceError
+PASS Valid:   &quot;function f() { o.foo(a,...bar) }&quot;
+PASS Valid:   &quot;o[foo](a,...bar)&quot; with ReferenceError
+PASS Valid:   &quot;function f() { o[foo](a,...bar) }&quot;
+PASS Valid:   &quot;foo(...bar, a)&quot; with ReferenceError
+PASS Valid:   &quot;function f() { foo(...bar, a) }&quot;
+PASS Valid:   &quot;o.foo(...bar, a)&quot; with ReferenceError
+PASS Valid:   &quot;function f() { o.foo(...bar, a) }&quot;
+PASS Valid:   &quot;o[foo](...bar, a)&quot; with ReferenceError
+PASS Valid:   &quot;function f() { o[foo](...bar, a) }&quot;
</ins><span class="cx"> PASS Valid:   &quot;[...bar]&quot; with ReferenceError
</span><span class="cx"> PASS Valid:   &quot;function f() { [...bar] }&quot;
</span><span class="cx"> PASS Valid:   &quot;[a, ...bar]&quot; with ReferenceError
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsbasicspreadjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/basic-spread.js (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/basic-spread.js        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/LayoutTests/js/script-tests/basic-spread.js        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -17,18 +17,12 @@
</span><span class="cx"> o.f = f;
</span><span class="cx"> var test1 = [1, undefined, null, 4]
</span><span class="cx"> var test2 = [1, , null, 4]
</span><del>-var test3 = {length: 4, 0: 1, 2: null, 3: 4}
-var test4 = {length: 4, 0: 1, 1: undefined, 2: null, 3: 4}
</del><span class="cx"> o.f(...test1)
</span><span class="cx"> o.f(...test2)
</span><del>-o.f(...test3)
-o.f(...test4)
</del><span class="cx"> 
</span><span class="cx"> var h=eval('&quot;f&quot;')
</span><span class="cx"> o[h](...test1)
</span><span class="cx"> o[h](...test2)
</span><del>-o[h](...test3)
-o[h](...test4)
</del><span class="cx"> 
</span><span class="cx"> function g()
</span><span class="cx"> {
</span><span class="lines">@@ -37,13 +31,9 @@
</span><span class="cx"> 
</span><span class="cx"> g.apply(null, test1)
</span><span class="cx"> g.apply(null, test2)
</span><del>-g.apply(null, test3)
-g.apply(null, test4)
</del><span class="cx"> 
</span><span class="cx"> g(...test1)
</span><span class="cx"> g(...test2)
</span><del>-g(...test3)
-g(...test4)
</del><span class="cx"> 
</span><span class="cx"> var a=[1,2,3]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsparsersyntaxcheckjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/parser-syntax-check.js (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/parser-syntax-check.js        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/LayoutTests/js/script-tests/parser-syntax-check.js        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -471,12 +471,12 @@
</span><span class="cx"> invalid(&quot;foo(bar...)&quot;)
</span><span class="cx"> invalid(&quot;o.foo(bar...)&quot;)
</span><span class="cx"> invalid(&quot;o[foo](bar...)&quot;)
</span><del>-invalid(&quot;foo(a,...bar)&quot;)
-invalid(&quot;o.foo(a,...bar)&quot;)
-invalid(&quot;o[foo](a,...bar)&quot;)
-invalid(&quot;foo(...bar, a)&quot;)
-invalid(&quot;o.foo(...bar, a)&quot;)
-invalid(&quot;o[foo](...bar, a)&quot;)
</del><ins>+valid(&quot;foo(a,...bar)&quot;)
+valid(&quot;o.foo(a,...bar)&quot;)
+valid(&quot;o[foo](a,...bar)&quot;)
+valid(&quot;foo(...bar, a)&quot;)
+valid(&quot;o.foo(...bar, a)&quot;)
+valid(&quot;o[foo](...bar, a)&quot;)
</ins><span class="cx"> valid(&quot;[...bar]&quot;)
</span><span class="cx"> valid(&quot;[a, ...bar]&quot;)
</span><span class="cx"> valid(&quot;[...bar, a]&quot;)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-02-16  Keith Miller  &lt;keith_miller@apple.com&gt;
+
+        Spread operator should be allowed when not the first argument of parameter list
+        https://bugs.webkit.org/show_bug.cgi?id=152721
+
+        Reviewed by Saam Barati.
+
+        Spread arguments to functions should now be ES6 compliant. Before we
+        would only take a spread operator if it was the sole argument to a
+        function. Additionally, we would not use the Symbol.iterator on the
+        object to generate the arguments. Instead we would do a loop up to the
+        length mapping indexed properties to the corresponding argument. We fix
+        both these issues by doing an AST transformation from foo(...a, b, ...c, d)
+        to foo(...[...a, b, ...c, d]) (where the spread on the rhs uses the
+        old spread semantics). This solution has the downside of requiring the
+        allocation of another object and copying each element twice but avoids a
+        large change to the vm calling convention.
+
+        * interpreter/Interpreter.cpp:
+        (JSC::loadVarargs):
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::createElementList):
+        * parser/Parser.cpp:
+        (JSC::Parser&lt;LexerType&gt;::parseArguments):
+        (JSC::Parser&lt;LexerType&gt;::parseArgument):
+        (JSC::Parser&lt;LexerType&gt;::parseMemberExpression):
+        * parser/Parser.h:
+        * parser/SyntaxChecker.h:
+        (JSC::SyntaxChecker::createElementList):
+        * tests/es6.yaml:
+        * tests/stress/spread-calling.js: Added.
+        (testFunction):
+        (testEmpty):
+        (makeObject):
+        (otherIterator.return.next):
+        (otherIterator):
+        (totalIter):
+        (throwingIter.return.next):
+        (throwingIter):
+        (i.catch):
+
</ins><span class="cx"> 2016-02-16  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Enable B3 on ARM64
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinterpreterInterpretercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -247,7 +247,7 @@
</span><span class="cx"> 
</span><span class="cx"> void loadVarargs(CallFrame* callFrame, VirtualRegister firstElementDest, JSValue arguments, uint32_t offset, uint32_t length)
</span><span class="cx"> {
</span><del>-    if (UNLIKELY(!arguments.isCell()))
</del><ins>+    if (UNLIKELY(!arguments.isCell()) || !length)
</ins><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     JSCell* cell = arguments.asCell();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserASTBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/ASTBuilder.h (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -441,6 +441,17 @@
</span><span class="cx"> 
</span><span class="cx">     ElementNode* createElementList(int elisions, ExpressionNode* expr) { return new (m_parserArena) ElementNode(elisions, expr); }
</span><span class="cx">     ElementNode* createElementList(ElementNode* elems, int elisions, ExpressionNode* expr) { return new (m_parserArena) ElementNode(elems, elisions, expr); }
</span><ins>+    ElementNode* createElementList(ArgumentListNode* elems)
+    {
+        ElementNode* head = new (m_parserArena) ElementNode(0, elems-&gt;m_expr);
+        ElementNode* tail = head;
+        elems = elems-&gt;m_next;
+        while (elems) {
+            tail = new (m_parserArena) ElementNode(tail, 0, elems-&gt;m_expr);
+            elems = elems-&gt;m_next;
+        }
+        return head;
+    }
</ins><span class="cx"> 
</span><span class="cx">     FormalParameterList createFormalParameterList() { return new (m_parserArena) FunctionParameters(); }
</span><span class="cx">     void appendParameter(FormalParameterList list, DestructuringPattern pattern, ExpressionNode* defaultValue) 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.cpp (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.cpp        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/Source/JavaScriptCore/parser/Parser.cpp        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -3703,7 +3703,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename LexerType&gt;
</span><del>-template &lt;class TreeBuilder&gt; TreeArguments Parser&lt;LexerType&gt;::parseArguments(TreeBuilder&amp; context, SpreadMode mode)
</del><ins>+template &lt;class TreeBuilder&gt; TreeArguments Parser&lt;LexerType&gt;::parseArguments(TreeBuilder&amp; context)
</ins><span class="cx"> {
</span><span class="cx">     consumeOrFailWithFlags(OPENPAREN, TreeBuilder::DontBuildStrings, &quot;Expected opening '(' at start of argument list&quot;);
</span><span class="cx">     JSTokenLocation location(tokenLocation());
</span><span class="lines">@@ -3711,42 +3711,63 @@
</span><span class="cx">         next(TreeBuilder::DontBuildStrings);
</span><span class="cx">         return context.createArguments();
</span><span class="cx">     }
</span><del>-    if (match(DOTDOTDOT) &amp;&amp; mode == AllowSpread) {
-        JSTokenLocation spreadLocation(tokenLocation());
-        auto start = m_token.m_startPosition;
-        auto divot = m_token.m_endPosition;
-        next();
-        auto spreadExpr = parseAssignmentExpression(context);
-        auto end = m_lastTokenEndPosition;
-        if (!spreadExpr)
-            failWithMessage(&quot;Cannot parse spread expression&quot;);
-        if (!consume(CLOSEPAREN)) {
-            if (match(COMMA))
-                semanticFail(&quot;Spread operator may only be applied to the last argument passed to a function&quot;);
-            handleProductionOrFail(CLOSEPAREN, &quot;)&quot;, &quot;end&quot;, &quot;argument list&quot;);
-        }
-        auto spread = context.createSpreadExpression(spreadLocation, spreadExpr, start, divot, end);
-        TreeArgumentsList argList = context.createArgumentsList(location, spread);
-        return context.createArguments(argList);
-    }
-    TreeExpression firstArg = parseAssignmentExpression(context);
</del><ins>+    auto argumentsStart = m_token.m_startPosition;
+    auto argumentsDivot = m_token.m_endPosition;
+
+    ArgumentType argType = ArgumentType::Normal;
+    TreeExpression firstArg = parseArgument(context, argType);
</ins><span class="cx">     failIfFalse(firstArg, &quot;Cannot parse function argument&quot;);
</span><del>-    
</del><ins>+    semanticFailIfTrue(match(DOTDOTDOT), &quot;The '...' operator should come before the target expression&quot;);
+
+    bool hasSpread = false;
+    if (argType == ArgumentType::Spread)
+        hasSpread = true;
</ins><span class="cx">     TreeArgumentsList argList = context.createArgumentsList(location, firstArg);
</span><span class="cx">     TreeArgumentsList tail = argList;
</span><ins>+
</ins><span class="cx">     while (match(COMMA)) {
</span><span class="cx">         JSTokenLocation argumentLocation(tokenLocation());
</span><span class="cx">         next(TreeBuilder::DontBuildStrings);
</span><del>-        TreeExpression arg = parseAssignmentExpression(context);
-        failIfFalse(arg, &quot;Cannot parse function argument&quot;);
</del><ins>+
+        TreeExpression arg = parseArgument(context, argType);
+        propagateError();
+        semanticFailIfTrue(match(DOTDOTDOT), &quot;The '...' operator should come before the target expression&quot;);
+
+        if (argType == ArgumentType::Spread)
+            hasSpread = true;
+
</ins><span class="cx">         tail = context.createArgumentsList(argumentLocation, tail, arg);
</span><span class="cx">     }
</span><del>-    semanticFailIfTrue(match(DOTDOTDOT), &quot;The '...' operator should come before the target expression&quot;);
</del><ins>+
</ins><span class="cx">     handleProductionOrFail(CLOSEPAREN, &quot;)&quot;, &quot;end&quot;, &quot;argument list&quot;);
</span><ins>+    if (hasSpread) {
+        TreeExpression spreadArray = context.createSpreadExpression(location, context.createArray(location, context.createElementList(argList)), argumentsStart, argumentsDivot, m_lastTokenEndPosition);
+        return context.createArguments(context.createArgumentsList(location, spreadArray));
+    }
+
</ins><span class="cx">     return context.createArguments(argList);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename LexerType&gt;
</span><ins>+template &lt;class TreeBuilder&gt; TreeExpression Parser&lt;LexerType&gt;::parseArgument(TreeBuilder&amp; context, ArgumentType&amp; type)
+{
+    if (UNLIKELY(match(DOTDOTDOT))) {
+        JSTokenLocation spreadLocation(tokenLocation());
+        auto start = m_token.m_startPosition;
+        auto divot = m_token.m_endPosition;
+        next();
+        TreeExpression spreadExpr = parseAssignmentExpression(context);
+        propagateError();
+        auto end = m_lastTokenEndPosition;
+        type = ArgumentType::Spread;
+        return context.createSpreadExpression(spreadLocation, spreadExpr, start, divot, end);
+    }
+
+    type = ArgumentType::Normal;
+    return parseAssignmentExpression(context);
+}
+
+template &lt;typename LexerType&gt;
</ins><span class="cx"> template &lt;class TreeBuilder&gt; TreeExpression Parser&lt;LexerType&gt;::parseMemberExpression(TreeBuilder&amp; context)
</span><span class="cx"> {
</span><span class="cx">     TreeExpression base = 0;
</span><span class="lines">@@ -3814,12 +3835,12 @@
</span><span class="cx">             if (newCount) {
</span><span class="cx">                 newCount--;
</span><span class="cx">                 JSTextPosition expressionEnd = lastTokenEndPosition();
</span><del>-                TreeArguments arguments = parseArguments(context, AllowSpread);
</del><ins>+                TreeArguments arguments = parseArguments(context);
</ins><span class="cx">                 failIfFalse(arguments, &quot;Cannot parse call arguments&quot;);
</span><span class="cx">                 base = context.createNewExpr(location, base, arguments, expressionStart, expressionEnd, lastTokenEndPosition());
</span><span class="cx">             } else {
</span><span class="cx">                 JSTextPosition expressionEnd = lastTokenEndPosition();
</span><del>-                TreeArguments arguments = parseArguments(context, AllowSpread);
</del><ins>+                TreeArguments arguments = parseArguments(context);
</ins><span class="cx">                 failIfFalse(arguments, &quot;Cannot parse call arguments&quot;);
</span><span class="cx">                 if (baseIsSuper)
</span><span class="cx">                     currentFunctionScope()-&gt;setHasDirectSuper();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -677,6 +677,11 @@
</span><span class="cx">     unsigned m_index;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum class ArgumentType {
+    Normal,
+    Spread
+};
+
</ins><span class="cx"> template &lt;typename LexerType&gt;
</span><span class="cx"> class Parser {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(Parser);
</span><span class="lines">@@ -1239,8 +1244,8 @@
</span><span class="cx">     template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeExpression parseObjectLiteral(TreeBuilder&amp;);
</span><span class="cx">     template &lt;class TreeBuilder&gt; NEVER_INLINE TreeExpression parseStrictObjectLiteral(TreeBuilder&amp;);
</span><span class="cx">     template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeExpression parseFunctionExpression(TreeBuilder&amp;);
</span><del>-    enum SpreadMode { AllowSpread, DontAllowSpread };
-    template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeArguments parseArguments(TreeBuilder&amp;, SpreadMode);
</del><ins>+    template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeArguments parseArguments(TreeBuilder&amp;);
+    template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeExpression parseArgument(TreeBuilder&amp;, ArgumentType&amp;);
</ins><span class="cx">     template &lt;class TreeBuilder&gt; TreeProperty parseProperty(TreeBuilder&amp;, bool strict);
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeExpression parsePropertyMethod(TreeBuilder&amp; context, const Identifier* methodName, bool isGenerator);
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeProperty parseGetterSetter(TreeBuilder&amp;, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset, ConstructorKind = ConstructorKind::None, SuperBinding = SuperBinding::NotNeeded);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserSyntaxCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SyntaxChecker.h (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -221,6 +221,7 @@
</span><span class="cx">     int createPropertyList(const JSTokenLocation&amp;, Property, int) { return PropertyListResult; }
</span><span class="cx">     int createElementList(int, int) { return ElementsListResult; }
</span><span class="cx">     int createElementList(int, int, int) { return ElementsListResult; }
</span><ins>+    int createElementList(int) { return ElementsListResult; }
</ins><span class="cx">     int createFormalParameterList() { return FormalParameterListResult; }
</span><span class="cx">     void appendParameter(int, DestructuringPattern, int) { }
</span><span class="cx">     int createClause(int, int) { return ClauseResult; }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6yaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6.yaml (196674 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6.yaml        2016-02-17 01:14:13 UTC (rev 196674)
+++ trunk/Source/JavaScriptCore/tests/es6.yaml        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -1113,11 +1113,11 @@
</span><span class="cx"> - path: es6/Set_Set[Symbol.species].js
</span><span class="cx">   cmd: runES6 :normal
</span><span class="cx"> - path: es6/spread_..._operator_with_astral_plane_strings_in_function_calls.js
</span><del>-  cmd: runES6 :fail
</del><ins>+  cmd: runES6 :normal
</ins><span class="cx"> - path: es6/spread_..._operator_with_generator_instances_in_arrays.js
</span><span class="cx">   cmd: runES6 :normal
</span><span class="cx"> - path: es6/spread_..._operator_with_generator_instances_in_calls.js
</span><del>-  cmd: runES6 :fail
</del><ins>+  cmd: runES6 :normal
</ins><span class="cx"> - path: es6/spread_..._operator_with_generic_iterables_in_arrays.js
</span><span class="cx">   cmd: runES6 :fail
</span><span class="cx"> - path: es6/spread_..._operator_with_generic_iterables_in_calls.js
</span><span class="lines">@@ -1127,7 +1127,7 @@
</span><span class="cx"> - path: es6/spread_..._operator_with_instances_of_iterables_in_calls.js
</span><span class="cx">   cmd: runES6 :fail
</span><span class="cx"> - path: es6/spread_..._operator_with_strings_in_function_calls.js
</span><del>-  cmd: runES6 :fail
</del><ins>+  cmd: runES6 :normal
</ins><span class="cx"> - path: es6/typed_arrays_%TypedArray%.from.js
</span><span class="cx">   cmd: runES6 :normal
</span><span class="cx"> - path: es6/typed_arrays_%TypedArray%.of.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressspreadcallingjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/spread-calling.js (0 => 196675)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/spread-calling.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/spread-calling.js        2016-02-17 01:29:37 UTC (rev 196675)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+function testFunction() {
+    if (arguments.length !== 10)
+        throw &quot;wrong number of arguments expected 10 was &quot; + arguments.length;
+    for (let i in arguments) {
+        if ((arguments[i] | 0) !== (i | 0))
+            throw &quot;argument &quot; + i + &quot; expected &quot; + i + &quot; was &quot; + arguments[i];
+    }
+}
+
+function testEmpty() {
+    if (arguments.length !== 0)
+        throw &quot;wrong length expected 0 was &quot; + arguments.length;
+}
+
+iter = Array.prototype.values;
+
+function makeObject(array, iterator) {
+    let obj = { [Symbol.iterator]: iterator, length: array.length };
+    for (let i in array)
+        obj[i] = array[i];
+    return obj;
+}
+
+function otherIterator() {
+    return {
+        count: 6,
+        next: function() {
+            if (this.count &lt; 10)
+                return { value: this.count++, done: false };
+            return { done: true };
+        }
+    };
+}
+
+count = 0;
+function* totalIter() {
+    for (let i = count; i &lt; count+5; i++) {
+        yield i;
+    }
+    count += 5;
+}
+
+function throwingIter() {
+     return {
+        count: 0,
+        next: function() {
+            if (this.count &lt; 10)
+                return { value: this.count++, done: false };
+            throw new Error(&quot;this should have been caught&quot;);
+        }
+    };
+}
+
+object1 = makeObject([1, 2, 3], iter);
+object2 = makeObject([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], iter);
+object3 = makeObject([], otherIterator);
+object4 = makeObject([], totalIter);
+objectThrow = makeObject([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], throwingIter);
+
+for (let i = 0; i &lt; 10000; i++) {
+    count = 0;
+    testFunction(0, ...[1, 2, 3], ...[4], 5, 6, ...[7, 8, 9]);
+    testFunction(...[0, 1], 2, 3, ...[4, 5, 6, 7, 8], 9);
+    testFunction(...[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+    testFunction(0, ...object1, 4, 5, ...[6, 7, 8, 9]);
+    testFunction(...object2);
+    testFunction(0, ...object1, 4, 5, ...object3);
+    testFunction(0, ...&quot;12345&quot;, ...object3);
+    testEmpty(...[]);
+    testFunction(...object4, ...object4);
+    let failed = false;
+    try {
+        testFunction(...objectThrow);
+        failed = true;
+    } catch (e) {
+        if (!e instanceof Error)
+            failed = true;
+    }
+    if (failed)
+        throw &quot;did not throw an exeption even though it should have&quot;;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>