Ignore:
Timestamp:
Mar 9, 2016, 11:36:21 AM (9 years ago)
Author:
[email protected]
Message:

FunctionExecutable::ecmaName() should not be based on inferredName().
https://bugs.webkit.org/show_bug.cgi?id=155203

Reviewed by Michael Saboff.

Source/JavaScriptCore:

The ES6 rules for how a function name should be inferred closely matches JSC's
implementation with one exception:

var o = {}
o.foo = function() {}

JSC's inferredName for o.foo would be "foo".
ES6 specifies that o.foo.name is "".

The fix is to add a distinct FunctionExecutable::ecmaName() which applies the ES6
rules for inferring the initial value of Function.name.

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

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

(JSC::ASTBuilder::createAssignResolve):
(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::makeAssignNode):

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

(JSC::JSFunction::reifyName):

  • tests/es6.yaml:

LayoutTests:

  • js/script-tests/function-toString-vs-name.js:
  • Fixed up object property test section and added new test cases.
  • platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r197815 r197867  
    669669    bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); }
    670670    const Identifier& name() { return m_unlinkedExecutable->name(); }
     671    const Identifier& ecmaName() { return m_unlinkedExecutable->ecmaName(); }
    671672    const Identifier& inferredName() { return m_unlinkedExecutable->inferredName(); }
    672     // FIXME: ecmaName() needs to be reimplement to be based on ES6 rules of determining the inferred
    673     // Function.name from non-computed names. https://bugs.webkit.org/show_bug.cgi?id=155203
    674     const Identifier& ecmaName() { return inferredName(); }
    675673    size_t parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'!
    676674    SourceParseMode parseMode() const { return m_unlinkedExecutable->parseMode(); }
Note: See TracChangeset for help on using the changeset viewer.