Ignore:
Timestamp:
Feb 17, 2016, 5:17:36 PM (9 years ago)
Author:
[email protected]
Message:

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<LexerType>::parseArguments):
(JSC::Parser<LexerType>::parseArgument):
(JSC::Parser<LexerType>::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. Additionally,
adjust benchmarks to run in a more reasonable time now that
spread is implemented correctly.

  • js/basic-spread-expected.txt:
  • js/parser-syntax-check-expected.txt:
  • js/regress/script-tests/deltablue-varargs.js:

(deltaBlue):

  • js/regress/script-tests/varargs-construct.js:
  • js/script-tests/basic-spread.js:
  • js/script-tests/parser-syntax-check.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r196704 r196734  
    222222    int createElementList(int, int) { return ElementsListResult; }
    223223    int createElementList(int, int, int) { return ElementsListResult; }
     224    int createElementList(int) { return ElementsListResult; }
    224225    int createFormalParameterList() { return FormalParameterListResult; }
    225226    void appendParameter(int, DestructuringPattern, int) { }
Note: See TracChangeset for help on using the changeset viewer.