Ignore:
Timestamp:
Sep 22, 2016, 12:11:23 PM (9 years ago)
Author:
[email protected]
Message:

test262: Function length should be number of parameters before parameters with default values
https://bugs.webkit.org/show_bug.cgi?id=162377

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2016-09-22
Reviewed by Saam Barati.

JSTests:

  • stress/es6-default-parameters.js:

Add our own tests for function lengths with default parameters.

  • test262.yaml:

We now pass all dflt-length tests.

Source/JavaScriptCore:

https://tc39.github.io/ecma262/#sec-function-definitions-static-semantics-expectedargumentcount

NOTE: The ExpectedArgumentCount of a FormalParameterList is the number of
FormalParameters to the left of either the rest parameter or the first
FormalParameter with an Initializer. A FormalParameter without an
initializer is allowed after the first parameter with an initializer
but such parameters are considered to be optional with undefined as
their default value.

Alongside the parameterCount value, maintain a separate count,
functionLength, which will be the count before seeing a rest parameter
or parameter with a default value. This will be the function's length.

  • bytecode/UnlinkedCodeBlock.h:
  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

  • bytecode/UnlinkedFunctionExecutable.h:
  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFunctionMetadata):

  • parser/Nodes.cpp:

(JSC::FunctionMetadataNode::FunctionMetadataNode):

  • parser/Nodes.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::isArrowFunctionParameters):
(JSC::Parser<LexerType>::parseGeneratorFunctionSourceElements):
(JSC::Parser<LexerType>::parseFormalParameters):
(JSC::Parser<LexerType>::parseFunctionBody):
(JSC::Parser<LexerType>::parseFunctionParameters):
(JSC::Parser<LexerType>::parseFunctionInfo):

  • parser/Parser.h:
  • parser/ParserFunctionInfo.h:
  • parser/SourceProviderCacheItem.h:

(JSC::SourceProviderCacheItem::SourceProviderCacheItem):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createFunctionMetadata):

  • runtime/Executable.h:
  • runtime/JSFunction.cpp:

(JSC::JSFunction::createBuiltinFunction):
(JSC::JSFunction::reifyLength):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Nodes.cpp

    r204470 r206268  
    136136    const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn,
    137137    int functionKeywordStart, int functionNameStart, int parametersStart, bool isInStrictContext,
    138     ConstructorKind constructorKind, SuperBinding superBinding, unsigned parameterCount, SourceParseMode mode, bool isArrowFunctionBodyExpression)
     138    ConstructorKind constructorKind, SuperBinding superBinding, unsigned parameterCount, unsigned functionLength, SourceParseMode mode, bool isArrowFunctionBodyExpression)
    139139        : Node(endLocation)
    140140        , m_startColumn(startColumn)
     
    145145        , m_startStartOffset(startLocation.startOffset)
    146146        , m_parameterCount(parameterCount)
     147        , m_functionLength(functionLength)
    147148        , m_parseMode(mode)
    148149        , m_isInStrictContext(isInStrictContext)
Note: See TracChangeset for help on using the changeset viewer.