<!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>[215165] 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/215165">215165</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-04-09 14:39:02 -0700 (Sun, 09 Apr 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>test262: test262/test/annexB/language/expressions/object/__proto__-fn-name.js
https://bugs.webkit.org/show_bug.cgi?id=170650
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-04-09
Reviewed by Saam Barati.
JSTests:
* stress/inferred-names.js:
* test262.yaml:
Source/JavaScriptCore:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseProperty):
There needs to be special handling of:
PropertyDefinition : PropertyName ':' AssignmentExpression
When the property name is __proto__. In this case the
SetFunctionName path does not happen, so the name "__proto__"
is not inferred on any anonymous function. See:
https://tc39.github.io/ecma262/#sec-__proto__-property-names-in-object-initializers
* parser/Parser.h:
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createProperty):
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createProperty):
Add an extra parameter to see if inferring / setting names are allowed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestsstressinferrednamesjs">trunk/JSTests/stress/inferred-names.js</a></li>
<li><a href="#trunkJSTeststest262yaml">trunk/JSTests/test262.yaml</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/JSTests/ChangeLog        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -1,5 +1,15 @@
</span><span class="cx"> 2017-04-09 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><ins>+ test262: test262/test/annexB/language/expressions/object/__proto__-fn-name.js
+ https://bugs.webkit.org/show_bug.cgi?id=170650
+
+ Reviewed by Saam Barati.
+
+ * stress/inferred-names.js:
+ * test262.yaml:
+
+2017-04-09 Joseph Pecoraro <pecoraro@apple.com>
+
</ins><span class="cx"> test262: test262/test/annexB/language/literals/regexp/identity-escape.js
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=170651
</span><span class="cx">
</span></span></pre></div>
<a id="trunkJSTestsstressinferrednamesjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/inferred-names.js (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/inferred-names.js        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/JSTests/stress/inferred-names.js        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -120,3 +120,15 @@
</span><span class="cx"> assert( ({ method([func = ()=>{}]) { return func.name } }).method([]) === "func" );
</span><span class="cx"> assert( ({ method({klass = class{}}) { return klass.name } }).method({}) === "klass" );
</span><span class="cx"> assert( ({ method([klass = class{}]) { return klass.name } }).method([]) === "klass" );
</span><ins>+
+// B.3.1__proto__ Property Names in Object Initializers
+
+assert( ({__proto__: function(){}}).__proto__.name === "" );
+assert( ({__proto__: function*(){}}).__proto__.name === "" );
+assert( ({__proto__: ()=>{}}).__proto__.name === "" );
+assert( ({["__proto__"]: function(){}}).__proto__.name === "__proto__" );
+assert( ({["__proto__"]: function*(){}}).__proto__.name === "__proto__" );
+assert( ({["__proto__"]: ()=>{}}).__proto__.name === "__proto__" );
+assert( ({__proto__(){}}).__proto__.name === "__proto__" );
+assert( ({*__proto__(){}}).__proto__.name === "__proto__" );
+assert( ({__proto__(){}}).__proto__.name === "__proto__" );
</ins></span></pre></div>
<a id="trunkJSTeststest262yaml"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/test262.yaml (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/test262.yaml        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/JSTests/test262.yaml        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -1810,9 +1810,9 @@
</span><span class="cx"> - path: test262/test/annexB/language/expressions/object/__proto__-duplicate.js
</span><span class="cx"> cmd: runTest262 :normal, "SyntaxError", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
</span><span class="cx"> - path: test262/test/annexB/language/expressions/object/__proto__-fn-name.js
</span><del>- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
</del><ins>+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
</ins><span class="cx"> - path: test262/test/annexB/language/expressions/object/__proto__-fn-name.js
</span><del>- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], [:strict]
</del><ins>+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], [:strict]
</ins><span class="cx"> - path: test262/test/annexB/language/expressions/object/__proto__-value-non-object.js
</span><span class="cx"> cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
</span><span class="cx"> - path: test262/test/annexB/language/expressions/object/__proto__-value-non-object.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -1,5 +1,31 @@
</span><span class="cx"> 2017-04-09 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><ins>+ test262: test262/test/annexB/language/expressions/object/__proto__-fn-name.js
+ https://bugs.webkit.org/show_bug.cgi?id=170650
+
+ Reviewed by Saam Barati.
+
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::parseClass):
+ (JSC::Parser<LexerType>::parseProperty):
+ There needs to be special handling of:
+
+ PropertyDefinition : PropertyName ':' AssignmentExpression
+
+ When the property name is __proto__. In this case the
+ SetFunctionName path does not happen, so the name "__proto__"
+ is not inferred on any anonymous function. See:
+ https://tc39.github.io/ecma262/#sec-__proto__-property-names-in-object-initializers
+
+ * parser/Parser.h:
+ * parser/SyntaxChecker.h:
+ (JSC::SyntaxChecker::createProperty):
+ * parser/ASTBuilder.h:
+ (JSC::ASTBuilder::createProperty):
+ Add an extra parameter to see if inferring / setting names are allowed.
+
+2017-04-09 Joseph Pecoraro <pecoraro@apple.com>
+
</ins><span class="cx"> test262: test262/test/annexB/language/literals/regexp/identity-escape.js
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=170651
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserASTBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/ASTBuilder.h (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -490,14 +490,16 @@
</span><span class="cx"> ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ExpressionNode* arg) { return new (m_parserArena) ArgumentListNode(location, arg); }
</span><span class="cx"> ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ArgumentListNode* args, ExpressionNode* arg) { return new (m_parserArena) ArgumentListNode(location, args, arg); }
</span><span class="cx">
</span><del>- PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding, bool isClassProperty)
</del><ins>+ PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding, InferName inferName, bool isClassProperty)
</ins><span class="cx"> {
</span><del>- if (node->isBaseFuncExprNode()) {
- auto metadata = static_cast<BaseFuncExprNode*>(node)->metadata();
- metadata->setEcmaName(*propertyName);
- metadata->setInferredName(*propertyName);
- } else if (node->isClassExprNode())
- static_cast<ClassExprNode*>(node)->setEcmaName(*propertyName);
</del><ins>+ if (inferName == InferName::Allowed) {
+ if (node->isBaseFuncExprNode()) {
+ auto metadata = static_cast<BaseFuncExprNode*>(node)->metadata();
+ metadata->setEcmaName(*propertyName);
+ metadata->setInferredName(*propertyName);
+ } else if (node->isClassExprNode())
+ static_cast<ClassExprNode*>(node)->setEcmaName(*propertyName);
+ }
</ins><span class="cx"> return new (m_parserArena) PropertyNode(*propertyName, node, type, putType, superBinding, isClassProperty);
</span><span class="cx"> }
</span><span class="cx"> PropertyNode* createProperty(ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding, bool isClassProperty)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.cpp (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.cpp        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/Source/JavaScriptCore/parser/Parser.cpp        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -2709,7 +2709,7 @@
</span><span class="cx"> property = context.createProperty(computedPropertyName, method, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Computed),
</span><span class="cx"> PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, isClassProperty);
</span><span class="cx"> } else
</span><del>- property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, isClassProperty);
</del><ins>+ property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, InferName::Allowed, isClassProperty);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TreePropertyList& tail = isStaticMethod ? staticMethodsTail : instanceMethodsTail;
</span><span class="lines">@@ -3702,13 +3702,14 @@
</span><span class="cx"> TreeExpression node = parseAssignmentExpressionOrPropagateErrorClass(context);
</span><span class="cx"> failIfFalse(node, "Cannot parse expression for property declaration");
</span><span class="cx"> context.setEndOffset(node, m_lexer->currentOffset());
</span><del>- return context.createProperty(ident, node, PropertyNode::Constant, PropertyNode::Unknown, complete, SuperBinding::NotNeeded, isClassProperty);
</del><ins>+ InferName inferName = ident && *ident == m_vm->propertyNames->underscoreProto ? InferName::Disallowed : InferName::Allowed;
+ return context.createProperty(ident, node, PropertyNode::Constant, PropertyNode::Unknown, complete, SuperBinding::NotNeeded, inferName, isClassProperty);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (match(OPENPAREN)) {
</span><span class="cx"> auto method = parsePropertyMethod(context, ident, isGenerator, isAsyncMethod);
</span><span class="cx"> propagateError();
</span><del>- return context.createProperty(ident, method, PropertyNode::Constant, PropertyNode::KnownDirect, complete, SuperBinding::Needed, isClassProperty);
</del><ins>+ return context.createProperty(ident, method, PropertyNode::Constant, PropertyNode::KnownDirect, complete, SuperBinding::Needed, InferName::Allowed, isClassProperty);
</ins><span class="cx"> }
</span><span class="cx"> failIfTrue(isGenerator || isAsyncMethod, "Expected a parenthesis for argument list");
</span><span class="cx">
</span><span class="lines">@@ -3721,7 +3722,7 @@
</span><span class="cx"> if (currentScope()->isArrowFunction())
</span><span class="cx"> currentScope()->setInnerArrowFunctionUsesEval();
</span><span class="cx"> TreeExpression node = context.createResolve(location, *ident, start, lastTokenEndPosition());
</span><del>- return context.createProperty(ident, node, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Shorthand), PropertyNode::KnownDirect, complete, SuperBinding::NotNeeded, isClassProperty);
</del><ins>+ return context.createProperty(ident, node, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Shorthand), PropertyNode::KnownDirect, complete, SuperBinding::NotNeeded, InferName::Allowed, isClassProperty);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (match(EQUAL)) // CoverInitializedName is exclusive to BindingPattern and AssignmentPattern
</span><span class="lines">@@ -3749,7 +3750,7 @@
</span><span class="cx"> const Identifier& ident = m_parserArena.identifierArena().makeNumericIdentifier(const_cast<VM*>(m_vm), propertyName);
</span><span class="cx"> auto method = parsePropertyMethod(context, &ident, isGenerator, isAsyncMethod);
</span><span class="cx"> propagateError();
</span><del>- return context.createProperty(&ident, method, PropertyNode::Constant, PropertyNode::Unknown, complete, SuperBinding::Needed, isClassProperty);
</del><ins>+ return context.createProperty(&ident, method, PropertyNode::Constant, PropertyNode::Unknown, complete, SuperBinding::Needed, InferName::Allowed, isClassProperty);
</ins><span class="cx"> }
</span><span class="cx"> failIfTrue(isGenerator || isAsyncMethod, "Expected a parenthesis for argument list");
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -104,6 +104,11 @@
</span><span class="cx"> ExportDefault,
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+enum class InferName {
+ Allowed,
+ Disallowed,
+};
+
</ins><span class="cx"> template <typename T> inline bool isEvalNode() { return false; }
</span><span class="cx"> template <> inline bool isEvalNode<EvalNode>() { return true; }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserSyntaxCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SyntaxChecker.h (215164 => 215165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2017-04-09 18:49:22 UTC (rev 215164)
+++ trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2017-04-09 21:39:02 UTC (rev 215165)
</span><span class="lines">@@ -206,7 +206,7 @@
</span><span class="cx">
</span><span class="cx"> int createArgumentsList(const JSTokenLocation&, int) { return ArgumentsListResult; }
</span><span class="cx"> int createArgumentsList(const JSTokenLocation&, int, int) { return ArgumentsListResult; }
</span><del>- Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, bool)
</del><ins>+ Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, InferName, bool)
</ins><span class="cx"> {
</span><span class="cx"> if (!complete)
</span><span class="cx"> return Property(type);
</span></span></pre>
</div>
</div>
</body>
</html>