Diff
Modified: trunk/LayoutTests/ChangeLog (197866 => 197867)
--- trunk/LayoutTests/ChangeLog 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/LayoutTests/ChangeLog 2016-03-09 19:36:21 UTC (rev 197867)
@@ -1,3 +1,14 @@
+2016-03-09 Mark Lam <[email protected]>
+
+ FunctionExecutable::ecmaName() should not be based on inferredName().
+ https://bugs.webkit.org/show_bug.cgi?id=155203
+
+ Reviewed by Michael Saboff.
+
+ * 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:
+
2016-03-09 Chris Dumez <[email protected]>
Align HTMLKeygenElement.keytype with the specification
Modified: trunk/LayoutTests/js/script-tests/function-toString-vs-name.js (197866 => 197867)
--- trunk/LayoutTests/js/script-tests/function-toString-vs-name.js 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/LayoutTests/js/script-tests/function-toString-vs-name.js 2016-03-09 19:36:21 UTC (rev 197867)
@@ -158,15 +158,6 @@
}) ();
test(foo4, "", "function() {}");
- // Test functions in object properties.
- section = "Object property";
- let o = {
- prop1: function() {},
- prop2: function namedProp2() {}
- };
- test(o.prop1, "prop1", "function() {}");
- test(o.prop2, "namedProp2", "function namedProp2() {}");
-
section = "bound JS function";
{
let o = {}
@@ -183,6 +174,32 @@
}
}
+section = "Object property";
+{
+ let o = {
+ prop1: function() {},
+ prop2: function namedProp2() {}
+ };
+ o.prop3 = function() { };
+ o.prop4 = function namedProp4() {};
+ test(o.prop1, "prop1", "function() {}");
+ test(o.prop2, "namedProp2", "function namedProp2() {}");
+ test(o.prop3, "", "function() {}");
+ test(o.prop4, "namedProp4", "function namedProp4() {}");
+
+ section = "bound Object property";
+ {
+ let boundProp1 = o.prop1.bind({});
+ test(boundProp1, "bound prop1", "function prop1() { [native code] }");
+ let boundFoo2 = o.prop2.bind({});
+ test(boundFoo2, "bound namedProp2", "function namedProp2() { [native code] }");
+ let boundFoo3 = o.prop3.bind({});
+ test(boundFoo3, "bound ", "function() { [native code] }");
+ let boundFoo4 = o.prop4.bind({});
+ test(boundFoo4, "bound namedProp4", "function namedProp4() { [native code] }");
+ }
+}
+
section = "object shorthand method";
{
let o = {
Modified: trunk/LayoutTests/platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt (197866 => 197867)
--- trunk/LayoutTests/platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/LayoutTests/platform/mac/http/tests/media/media-source/mediasource-sourcebuffer-mode-expected.txt 2016-03-09 19:36:21 UTC (rev 197867)
@@ -8,7 +8,7 @@
assert_throws@http://127.0.0.1:8000/w3c/resources/testharness.js:947:19
http://127.0.0.1:8000/media/media-source/mediasource-sourcebuffer-mode.html:114:32
handleWaitCallback_@http://127.0.0.1:8000/media/media-source/mediasource-util.js:97:17
-handleWaitCallback_@[native code]
+[native code]
step@http://127.0.0.1:8000/w3c/resources/testharness.js:1160:30
http://127.0.0.1:8000/w3c/resources/testharness.js:1189:33)
Modified: trunk/Source/_javascript_Core/ChangeLog (197866 => 197867)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-09 19:36:21 UTC (rev 197867)
@@ -1,3 +1,35 @@
+2016-03-09 Mark Lam <[email protected]>
+
+ FunctionExecutable::ecmaName() should not be based on inferredName().
+ https://bugs.webkit.org/show_bug.cgi?id=155203
+
+ Reviewed by Michael Saboff.
+
+ 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:
+
2016-03-09 Michael Saboff <[email protected]>
Harden JSC Root element functions from bad values
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp (197866 => 197867)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2016-03-09 19:36:21 UTC (rev 197867)
@@ -102,6 +102,7 @@
, m_derivedContextType(static_cast<unsigned>(derivedContextType))
, m_sourceParseMode(static_cast<unsigned>(node->parseMode()))
, m_name(node->ident())
+ , m_ecmaName(node->ecmaName())
, m_inferredName(node->inferredName())
, m_sourceOverride(WTFMove(sourceOverride))
{
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h (197866 => 197867)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2016-03-09 19:36:21 UTC (rev 197867)
@@ -75,6 +75,7 @@
}
const Identifier& name() const { return m_name; }
+ const Identifier& ecmaName() const { return m_ecmaName; }
const Identifier& inferredName() const { return m_inferredName; }
unsigned parameterCount() const { return m_parameterCount; };
SourceParseMode parseMode() const { return static_cast<SourceParseMode>(m_sourceParseMode); };
@@ -159,6 +160,7 @@
WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForConstruct;
Identifier m_name;
+ Identifier m_ecmaName;
Identifier m_inferredName;
RefPtr<SourceProvider> m_sourceOverride;
Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (197866 => 197867)
--- trunk/Source/_javascript_Core/parser/ASTBuilder.h 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h 2016-03-09 19:36:21 UTC (rev 197867)
@@ -341,8 +341,11 @@
ExpressionNode* createAssignResolve(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* rhs, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end, AssignmentContext assignmentContext)
{
- if (rhs->isFuncExprNode() || rhs->isArrowFuncExprNode())
- static_cast<FuncExprNode*>(rhs)->metadata()->setInferredName(ident);
+ if (rhs->isFuncExprNode() || rhs->isArrowFuncExprNode()) {
+ auto metadata = static_cast<FuncExprNode*>(rhs)->metadata();
+ metadata->setEcmaName(ident);
+ metadata->setInferredName(ident);
+ }
AssignResolveNode* node = new (m_parserArena) AssignResolveNode(location, ident, rhs, assignmentContext);
setExceptionLocation(node, start, divot, end);
return node;
@@ -400,6 +403,7 @@
{
ASSERT(name);
functionInfo.body->setLoc(functionInfo.startLine, functionInfo.endLine, location.startOffset, location.lineStartOffset);
+ functionInfo.body->setEcmaName(*name);
functionInfo.body->setInferredName(*name);
SourceCode source = m_sourceCode->subExpression(functionInfo.startOffset, functionInfo.endOffset, functionInfo.startLine, functionInfo.bodyStartColumn);
FuncExprNode* funcExpr = new (m_parserArena) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, functionInfo.body, source);
@@ -433,8 +437,11 @@
PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding = SuperBinding::NotNeeded)
{
- if (node->isFuncExprNode())
- static_cast<FuncExprNode*>(node)->metadata()->setInferredName(*propertyName);
+ if (node->isFuncExprNode()) {
+ auto metadata = static_cast<FuncExprNode*>(node)->metadata();
+ metadata->setEcmaName(*propertyName);
+ metadata->setInferredName(*propertyName);
+ }
return new (m_parserArena) PropertyNode(*propertyName, node, type, putType, superBinding);
}
PropertyNode* createProperty(VM* vm, ParserArena& parserArena, double propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool)
@@ -1290,8 +1297,11 @@
if (loc->isResolveNode()) {
ResolveNode* resolve = static_cast<ResolveNode*>(loc);
if (op == OpEqual) {
- if (expr->isFuncExprNode())
- static_cast<FuncExprNode*>(expr)->metadata()->setInferredName(resolve->identifier());
+ if (expr->isFuncExprNode()) {
+ auto metadata = static_cast<FuncExprNode*>(expr)->metadata();
+ metadata->setEcmaName(resolve->identifier());
+ metadata->setInferredName(resolve->identifier());
+ }
AssignResolveNode* node = new (m_parserArena) AssignResolveNode(location, resolve->identifier(), expr, AssignmentContext::AssignmentExpression);
setExceptionLocation(node, start, divot, end);
return node;
@@ -1309,8 +1319,11 @@
ASSERT(loc->isDotAccessorNode());
DotAccessorNode* dot = static_cast<DotAccessorNode*>(loc);
if (op == OpEqual) {
- if (expr->isFuncExprNode())
+ if (expr->isFuncExprNode()) {
+ // We don't also set the ecma name here because ES6 specifies that the
+ // function should not pick up the name of the dot->identifier().
static_cast<FuncExprNode*>(expr)->metadata()->setInferredName(dot->identifier());
+ }
return new (m_parserArena) AssignDotNode(location, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), start, end);
}
Modified: trunk/Source/_javascript_Core/parser/Nodes.h (197866 => 197867)
--- trunk/Source/_javascript_Core/parser/Nodes.h 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/parser/Nodes.h 2016-03-09 19:36:21 UTC (rev 197867)
@@ -1841,6 +1841,8 @@
void overrideName(const Identifier& ident) { m_ident = ident; }
const Identifier& ident() { return m_ident; }
+ void setEcmaName(const Identifier& ecmaName) { ASSERT(!ecmaName.isNull()); m_ecmaName = ecmaName; }
+ const Identifier& ecmaName() { return m_ident.isEmpty() ? m_ecmaName : m_ident; }
void setInferredName(const Identifier& inferredName) { ASSERT(!inferredName.isNull()); m_inferredName = inferredName; }
const Identifier& inferredName() { return m_inferredName.isEmpty() ? m_ident : m_inferredName; }
@@ -1874,6 +1876,7 @@
protected:
Identifier m_ident;
+ Identifier m_ecmaName;
Identifier m_inferredName;
FunctionMode m_functionMode;
unsigned m_startColumn;
Modified: trunk/Source/_javascript_Core/runtime/Executable.h (197866 => 197867)
--- trunk/Source/_javascript_Core/runtime/Executable.h 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/runtime/Executable.h 2016-03-09 19:36:21 UTC (rev 197867)
@@ -668,10 +668,8 @@
DerivedContextType derivedContextType() const { return m_unlinkedExecutable->derivedContextType(); }
bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); }
const Identifier& name() { return m_unlinkedExecutable->name(); }
+ const Identifier& ecmaName() { return m_unlinkedExecutable->ecmaName(); }
const Identifier& inferredName() { return m_unlinkedExecutable->inferredName(); }
- // FIXME: ecmaName() needs to be reimplement to be based on ES6 rules of determining the inferred
- // Function.name from non-computed names. https://bugs.webkit.org/show_bug.cgi?id=155203
- const Identifier& ecmaName() { return inferredName(); }
size_t parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'!
SourceParseMode parseMode() const { return m_unlinkedExecutable->parseMode(); }
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (197866 => 197867)
--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2016-03-09 19:36:21 UTC (rev 197867)
@@ -595,10 +595,7 @@
unsigned initialAttributes = DontEnum | ReadOnly;
const Identifier& propID = exec->propertyNames().name;
- const Identifier& nameID = jsExecutable()->name();
- String name = nameID.string();
- if (name.isEmpty())
- name = jsExecutable()->ecmaName().string();
+ String name = jsExecutable()->ecmaName().string();
if (jsExecutable()->isGetter())
name = makeString("get ", name);
Modified: trunk/Source/_javascript_Core/tests/es6.yaml (197866 => 197867)
--- trunk/Source/_javascript_Core/tests/es6.yaml 2016-03-09 19:29:29 UTC (rev 197866)
+++ trunk/Source/_javascript_Core/tests/es6.yaml 2016-03-09 19:36:21 UTC (rev 197867)
@@ -803,7 +803,7 @@
- path: es6/function_name_property_object_methods_class.js
cmd: runES6 :fail
- path: es6/function_name_property_object_methods_function.js
- cmd: runES6 :fail
+ cmd: runES6 :normal
- path: es6/function_name_property_shorthand_methods_no_lexical_binding.js
cmd: runES6 :fail
- path: es6/function_name_property_symbol-keyed_methods.js