Bug 1450574 - Remove NoExpressionClosure FunctionSyntaxKind values. r=jorendorff
authorTom Schuster <evilpies@gmail.com>
Sun, 01 Apr 2018 18:47:52 +0200
changeset 411902 0a136c8bccf1eaf5898731497aaff70a953bfae4
parent 411901 41ab21c6f36e12cd13254935b58d7aa29eb29a97
child 411903 26420aad431e5089cf4f9ec61115d10b30f11904
push id33774
push usernerli@mozilla.com
push dateThu, 05 Apr 2018 15:16:07 +0000
treeherdermozilla-central@110f32790d38 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1450574
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1450574 - Remove NoExpressionClosure FunctionSyntaxKind values. r=jorendorff
js/src/frontend/ParseNode.h
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -1459,50 +1459,36 @@ enum FunctionSyntaxKind
     // A named function appearing as a Statement.
     Statement,
 
     Arrow,
     Method,
     ClassConstructor,
     DerivedClassConstructor,
     Getter,
-    GetterNoExpressionClosure,
     Setter,
-    SetterNoExpressionClosure
 };
 
 static inline bool
 IsFunctionExpression(FunctionSyntaxKind kind)
 {
     return kind == AssignmentExpression || kind == PrimaryExpression;
 }
 
 static inline bool
 IsConstructorKind(FunctionSyntaxKind kind)
 {
     return kind == ClassConstructor || kind == DerivedClassConstructor;
 }
 
 static inline bool
-IsGetterKind(FunctionSyntaxKind kind)
-{
-    return kind == Getter || kind == GetterNoExpressionClosure;
-}
-
-static inline bool
-IsSetterKind(FunctionSyntaxKind kind)
-{
-    return kind == Setter || kind == SetterNoExpressionClosure;
-}
-
-static inline bool
 IsMethodDefinitionKind(FunctionSyntaxKind kind)
 {
     return kind == Method || IsConstructorKind(kind) ||
-           IsGetterKind(kind) || IsSetterKind(kind);
+           kind == Getter || kind == Setter;
 }
 
 static inline ParseNode*
 FunctionFormalParametersList(ParseNode* fn, unsigned* numFormals)
 {
     MOZ_ASSERT(fn->isKind(ParseNodeKind::Function));
     ParseNode* argsBody = fn->pn_body;
     MOZ_ASSERT(argsBody->isKind(ParseNodeKind::ParamsBody));
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2813,22 +2813,20 @@ ParserBase::newFunction(HandleAtom atom,
         allocKind = gc::AllocKind::FUNCTION_EXTENDED;
         break;
       case ClassConstructor:
       case DerivedClassConstructor:
         flags = JSFunction::INTERPRETED_CLASS_CONSTRUCTOR;
         allocKind = gc::AllocKind::FUNCTION_EXTENDED;
         break;
       case Getter:
-      case GetterNoExpressionClosure:
         flags = JSFunction::INTERPRETED_GETTER;
         allocKind = gc::AllocKind::FUNCTION_EXTENDED;
         break;
       case Setter:
-      case SetterNoExpressionClosure:
         flags = JSFunction::INTERPRETED_SETTER;
         allocKind = gc::AllocKind::FUNCTION_EXTENDED;
         break;
       default:
         MOZ_ASSERT(kind == Statement);
 #ifdef DEBUG
         if (options().selfHostingMode && !pc->isFunctionBox()) {
             isGlobalSelfHostedBuiltin = true;
@@ -2930,20 +2928,20 @@ ParserBase::leaveInnerFunction(ParseCont
 
     return true;
 }
 
 JSAtom*
 ParserBase::prefixAccessorName(PropertyType propType, HandleAtom propAtom)
 {
     RootedAtom prefix(context);
-    if (propType == PropertyType::Setter || propType == PropertyType::SetterNoExpressionClosure) {
+    if (propType == PropertyType::Setter) {
         prefix = context->names().setPrefix;
     } else {
-        MOZ_ASSERT(propType == PropertyType::Getter || propType == PropertyType::GetterNoExpressionClosure);
+        MOZ_ASSERT(propType == PropertyType::Getter);
         prefix = context->names().getPrefix;
     }
 
     RootedString str(context, ConcatStrings<CanGC>(context, prefix, propAtom));
     if (!str)
         return nullptr;
 
     return AtomizeString(context, str);
@@ -3036,17 +3034,17 @@ GeneralParser<ParseHandler, CharT>::func
     }
     if (hasArguments) {
         bool hasRest = false;
         bool hasDefault = false;
         bool duplicatedParam = false;
         bool disallowDuplicateParams = kind == Arrow || kind == Method || kind == ClassConstructor;
         AtomVector& positionalFormals = pc->positionalFormalParameterNames();
 
-        if (IsGetterKind(kind)) {
+        if (kind == Getter) {
             error(JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");
             return false;
         }
 
         while (true) {
             if (hasRest) {
                 error(JSMSG_PARAMETER_AFTER_REST);
                 return false;
@@ -3054,17 +3052,17 @@ GeneralParser<ParseHandler, CharT>::func
 
             TokenKind tt;
             if (!tokenStream.getToken(&tt, argModifier))
                 return false;
             argModifier = TokenStream::Operand;
             MOZ_ASSERT_IF(parenFreeArrow, TokenKindIsPossibleIdentifier(tt));
 
             if (tt == TokenKind::TripleDot) {
-                if (IsSetterKind(kind)) {
+                if (kind == Setter) {
                     error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
                     return false;
                 }
 
                 disallowDuplicateParams = true;
                 if (duplicatedParam) {
                     // Has duplicated args before the rest parameter.
                     error(JSMSG_BAD_DUP_ARGS);
@@ -3181,17 +3179,17 @@ GeneralParser<ParseHandler, CharT>::func
                 Node def_expr = assignExprWithoutYieldOrAwait(yieldHandling);
                 if (!def_expr)
                     return false;
                 if (!handler.setLastFunctionFormalParameterDefault(funcpn, def_expr))
                     return false;
             }
 
             // Setter syntax uniquely requires exactly one argument.
-            if (IsSetterKind(kind))
+            if (kind == Setter)
                 break;
 
             if (!tokenStream.matchToken(&matched, TokenKind::Comma, TokenStream::Operand))
                 return false;
             if (!matched)
                 break;
 
             if (!hasRest) {
@@ -3202,34 +3200,34 @@ GeneralParser<ParseHandler, CharT>::func
             }
         }
 
         if (!parenFreeArrow) {
             TokenKind tt;
             if (!tokenStream.getToken(&tt, TokenStream::Operand))
                 return false;
             if (tt != TokenKind::Rp) {
-                if (IsSetterKind(kind)) {
+                if (kind == Setter) {
                     error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
                     return false;
                 }
 
                 error(JSMSG_PAREN_AFTER_FORMAL);
                 return false;
             }
         }
 
         if (!hasDefault)
             funbox->length = positionalFormals.length() - hasRest;
 
         if (funbox->hasParameterExprs && funbox->hasDirectEval())
             funbox->hasDirectEvalInParameterExpr = true;
 
         funbox->function()->setArgCount(positionalFormals.length());
-    } else if (IsSetterKind(kind)) {
+    } else if (kind == Setter) {
         error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
         return false;
     }
 
     return true;
 }
 
 template <typename CharT>
@@ -7152,20 +7150,18 @@ GeneralParser<ParseHandler, CharT>::debu
     return handler.newDebuggerStatement(p);
 }
 
 static AccessorType
 ToAccessorType(PropertyType propType)
 {
     switch (propType) {
       case PropertyType::Getter:
-      case PropertyType::GetterNoExpressionClosure:
         return AccessorType::Getter;
       case PropertyType::Setter:
-      case PropertyType::SetterNoExpressionClosure:
         return AccessorType::Setter;
       case PropertyType::Normal:
       case PropertyType::Method:
       case PropertyType::GeneratorMethod:
       case PropertyType::AsyncMethod:
       case PropertyType::AsyncGeneratorMethod:
       case PropertyType::Constructor:
       case PropertyType::DerivedConstructor:
@@ -7292,21 +7288,16 @@ GeneralParser<ParseHandler, CharT>::clas
             propType != PropertyType::Method && propType != PropertyType::GeneratorMethod &&
             propType != PropertyType::AsyncMethod &&
             propType != PropertyType::AsyncGeneratorMethod)
         {
             errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
             return null();
         }
 
-        if (propType == PropertyType::Getter)
-            propType = PropertyType::GetterNoExpressionClosure;
-        if (propType == PropertyType::Setter)
-            propType = PropertyType::SetterNoExpressionClosure;
-
         bool isConstructor = !isStatic && propAtom == context->names().constructor;
         if (isConstructor) {
             if (propType != PropertyType::Method) {
                 errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
                 return null();
             }
             if (classStmt.constructorBox) {
                 errorAt(nameOffset, JSMSG_DUPLICATE_PROPERTY, "constructor");
@@ -7315,18 +7306,18 @@ GeneralParser<ParseHandler, CharT>::clas
             propType = hasHeritage ? PropertyType::DerivedConstructor : PropertyType::Constructor;
         } else if (isStatic && propAtom == context->names().prototype) {
             errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
             return null();
         }
 
         RootedAtom funName(context);
         switch (propType) {
-          case PropertyType::GetterNoExpressionClosure:
-          case PropertyType::SetterNoExpressionClosure:
+          case PropertyType::Getter:
+          case PropertyType::Setter:
             if (!anyChars.isCurrentTokenType(TokenKind::Rb)) {
                 funName = prefixAccessorName(propType, propAtom);
                 if (!funName)
                     return null();
             }
             break;
           case PropertyType::Constructor:
           case PropertyType::DerivedConstructor:
@@ -9745,28 +9736,20 @@ GeneralParser<ParseHandler, CharT>::meth
                                                      HandleAtom funName)
 {
     FunctionSyntaxKind kind;
     switch (propType) {
       case PropertyType::Getter:
         kind = Getter;
         break;
 
-      case PropertyType::GetterNoExpressionClosure:
-        kind = GetterNoExpressionClosure;
-        break;
-
       case PropertyType::Setter:
         kind = Setter;
         break;
 
-      case PropertyType::SetterNoExpressionClosure:
-        kind = SetterNoExpressionClosure;
-        break;
-
       case PropertyType::Method:
       case PropertyType::GeneratorMethod:
       case PropertyType::AsyncMethod:
       case PropertyType::AsyncGeneratorMethod:
         kind = Method;
         break;
 
       case PropertyType::Constructor:
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -229,19 +229,17 @@ Directives::Directives(ParseContext* par
 
 enum VarContext { HoistVars, DontHoistVars };
 enum PropListType { ObjectLiteral, ClassBody, DerivedClassBody };
 enum class PropertyType {
     Normal,
     Shorthand,
     CoverInitializedName,
     Getter,
-    GetterNoExpressionClosure,
     Setter,
-    SetterNoExpressionClosure,
     Method,
     GeneratorMethod,
     AsyncMethod,
     AsyncGeneratorMethod,
     Constructor,
     DerivedConstructor
 };