Bug 1524507 - Remove sum interface and typedef from BinToken.h. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Thu, 14 Feb 2019 08:46:52 +0000
changeset 459025 7f857fddc9031e54cc3641518729562ee804fc57
parent 459024 e6a874b75c0bd45b9d782b9edde3bb30c0134d14
child 459026 b7713efeb5f1ad8044b816d09bf9fe6d95967214
push id35554
push userrgurzau@mozilla.com
push dateThu, 14 Feb 2019 17:00:27 +0000
treeherdermozilla-central@db6bcdbe4040 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1524507
milestone67.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 1524507 - Remove sum interface and typedef from BinToken.h. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D19726
js/src/frontend/BinToken.h
js/src/frontend/binsource/src/main.rs
--- a/js/src/frontend/BinToken.h
+++ b/js/src/frontend/BinToken.h
@@ -56,68 +56,52 @@ namespace frontend {
  * FOR_EACH_BIN_KIND(WITH_KIND)
  * ```
  *
  *
  * (sorted by alphabetical order)
  */
 #define FOR_EACH_BIN_KIND(F)                                                  \
   F(_Null, "")                                                                \
-  F(Arguments, "Arguments")                                                   \
   F(ArrayAssignmentTarget, "ArrayAssignmentTarget")                           \
   F(ArrayBinding, "ArrayBinding")                                             \
   F(ArrayExpression, "ArrayExpression")                                       \
-  F(ArrowExpression, "ArrowExpression")                                       \
   F(ArrowExpressionContentsWithExpression,                                    \
     "ArrowExpressionContentsWithExpression")                                  \
   F(ArrowExpressionContentsWithFunctionBody,                                  \
     "ArrowExpressionContentsWithFunctionBody")                                \
   F(AssertedBlockScope, "AssertedBlockScope")                                 \
   F(AssertedBoundName, "AssertedBoundName")                                   \
   F(AssertedBoundNamesScope, "AssertedBoundNamesScope")                       \
-  F(AssertedDeclaredKind, "AssertedDeclaredKind")                             \
   F(AssertedDeclaredName, "AssertedDeclaredName")                             \
-  F(AssertedMaybePositionalParameterName,                                     \
-    "AssertedMaybePositionalParameterName")                                   \
   F(AssertedParameterName, "AssertedParameterName")                           \
   F(AssertedParameterScope, "AssertedParameterScope")                         \
   F(AssertedPositionalParameterName, "AssertedPositionalParameterName")       \
   F(AssertedRestParameterName, "AssertedRestParameterName")                   \
   F(AssertedScriptGlobalScope, "AssertedScriptGlobalScope")                   \
   F(AssertedVarScope, "AssertedVarScope")                                     \
   F(AssignmentExpression, "AssignmentExpression")                             \
-  F(AssignmentTarget, "AssignmentTarget")                                     \
   F(AssignmentTargetIdentifier, "AssignmentTargetIdentifier")                 \
-  F(AssignmentTargetOrAssignmentTargetWithInitializer,                        \
-    "AssignmentTargetOrAssignmentTargetWithInitializer")                      \
-  F(AssignmentTargetPattern, "AssignmentTargetPattern")                       \
-  F(AssignmentTargetProperty, "AssignmentTargetProperty")                     \
   F(AssignmentTargetPropertyIdentifier, "AssignmentTargetPropertyIdentifier") \
   F(AssignmentTargetPropertyProperty, "AssignmentTargetPropertyProperty")     \
   F(AssignmentTargetWithInitializer, "AssignmentTargetWithInitializer")       \
   F(AwaitExpression, "AwaitExpression")                                       \
   F(BinaryExpression, "BinaryExpression")                                     \
-  F(BinaryOperator, "BinaryOperator")                                         \
-  F(Binding, "Binding")                                                       \
   F(BindingIdentifier, "BindingIdentifier")                                   \
-  F(BindingOrBindingWithInitializer, "BindingOrBindingWithInitializer")       \
-  F(BindingPattern, "BindingPattern")                                         \
-  F(BindingProperty, "BindingProperty")                                       \
   F(BindingPropertyIdentifier, "BindingPropertyIdentifier")                   \
   F(BindingPropertyProperty, "BindingPropertyProperty")                       \
   F(BindingWithInitializer, "BindingWithInitializer")                         \
   F(Block, "Block")                                                           \
   F(BreakStatement, "BreakStatement")                                         \
   F(CallExpression, "CallExpression")                                         \
   F(CatchClause, "CatchClause")                                               \
   F(ClassDeclaration, "ClassDeclaration")                                     \
   F(ClassElement, "ClassElement")                                             \
   F(ClassExpression, "ClassExpression")                                       \
   F(CompoundAssignmentExpression, "CompoundAssignmentExpression")             \
-  F(CompoundAssignmentOperator, "CompoundAssignmentOperator")                 \
   F(ComputedMemberAssignmentTarget, "ComputedMemberAssignmentTarget")         \
   F(ComputedMemberExpression, "ComputedMemberExpression")                     \
   F(ComputedPropertyName, "ComputedPropertyName")                             \
   F(ConditionalExpression, "ConditionalExpression")                           \
   F(ContinueStatement, "ContinueStatement")                                   \
   F(DataProperty, "DataProperty")                                             \
   F(DebuggerStatement, "DebuggerStatement")                                   \
   F(Directive, "Directive")                                                   \
@@ -128,168 +112,92 @@ namespace frontend {
   F(EagerFunctionDeclaration, "EagerFunctionDeclaration")                     \
   F(EagerFunctionExpression, "EagerFunctionExpression")                       \
   F(EagerGetter, "EagerGetter")                                               \
   F(EagerMethod, "EagerMethod")                                               \
   F(EagerSetter, "EagerSetter")                                               \
   F(EmptyStatement, "EmptyStatement")                                         \
   F(Export, "Export")                                                         \
   F(ExportAllFrom, "ExportAllFrom")                                           \
-  F(ExportDeclaration, "ExportDeclaration")                                   \
   F(ExportDefault, "ExportDefault")                                           \
   F(ExportFrom, "ExportFrom")                                                 \
   F(ExportFromSpecifier, "ExportFromSpecifier")                               \
   F(ExportLocalSpecifier, "ExportLocalSpecifier")                             \
   F(ExportLocals, "ExportLocals")                                             \
-  F(Expression, "Expression")                                                 \
-  F(ExpressionOrSuper, "ExpressionOrSuper")                                   \
-  F(ExpressionOrTemplateElement, "ExpressionOrTemplateElement")               \
   F(ExpressionStatement, "ExpressionStatement")                               \
   F(ForInOfBinding, "ForInOfBinding")                                         \
-  F(ForInOfBindingOrAssignmentTarget, "ForInOfBindingOrAssignmentTarget")     \
   F(ForInStatement, "ForInStatement")                                         \
   F(ForOfStatement, "ForOfStatement")                                         \
   F(ForStatement, "ForStatement")                                             \
   F(FormalParameters, "FormalParameters")                                     \
-  F(FunctionBody, "FunctionBody")                                             \
-  F(FunctionDeclaration, "FunctionDeclaration")                               \
-  F(FunctionDeclarationOrClassDeclarationOrExpression,                        \
-    "FunctionDeclarationOrClassDeclarationOrExpression")                      \
-  F(FunctionDeclarationOrClassDeclarationOrVariableDeclaration,               \
-    "FunctionDeclarationOrClassDeclarationOrVariableDeclaration")             \
-  F(FunctionExpression, "FunctionExpression")                                 \
   F(FunctionExpressionContents, "FunctionExpressionContents")                 \
   F(FunctionOrMethodContents, "FunctionOrMethodContents")                     \
-  F(Getter, "Getter")                                                         \
   F(GetterContents, "GetterContents")                                         \
-  F(Identifier, "Identifier")                                                 \
   F(IdentifierExpression, "IdentifierExpression")                             \
-  F(IdentifierName, "IdentifierName")                                         \
   F(IfStatement, "IfStatement")                                               \
   F(Import, "Import")                                                         \
-  F(ImportDeclaration, "ImportDeclaration")                                   \
-  F(ImportDeclarationOrExportDeclarationOrStatement,                          \
-    "ImportDeclarationOrExportDeclarationOrStatement")                        \
   F(ImportNamespace, "ImportNamespace")                                       \
   F(ImportSpecifier, "ImportSpecifier")                                       \
-  F(IterationStatement, "IterationStatement")                                 \
-  F(Label, "Label")                                                           \
   F(LabelledStatement, "LabelledStatement")                                   \
   F(LazyArrowExpressionWithExpression, "LazyArrowExpressionWithExpression")   \
   F(LazyArrowExpressionWithFunctionBody,                                      \
     "LazyArrowExpressionWithFunctionBody")                                    \
   F(LazyFunctionDeclaration, "LazyFunctionDeclaration")                       \
   F(LazyFunctionExpression, "LazyFunctionExpression")                         \
   F(LazyGetter, "LazyGetter")                                                 \
   F(LazyMethod, "LazyMethod")                                                 \
   F(LazySetter, "LazySetter")                                                 \
-  F(ListOfAssertedBoundName, "ListOfAssertedBoundName")                       \
-  F(ListOfAssertedDeclaredName, "ListOfAssertedDeclaredName")                 \
-  F(ListOfAssertedMaybePositionalParameterName,                               \
-    "ListOfAssertedMaybePositionalParameterName")                             \
-  F(ListOfAssignmentTargetOrAssignmentTargetWithInitializer,                  \
-    "ListOfAssignmentTargetOrAssignmentTargetWithInitializer")                \
-  F(ListOfAssignmentTargetProperty, "ListOfAssignmentTargetProperty")         \
-  F(ListOfBindingProperty, "ListOfBindingProperty")                           \
-  F(ListOfClassElement, "ListOfClassElement")                                 \
-  F(ListOfDirective, "ListOfDirective")                                       \
-  F(ListOfExportFromSpecifier, "ListOfExportFromSpecifier")                   \
-  F(ListOfExportLocalSpecifier, "ListOfExportLocalSpecifier")                 \
-  F(ListOfExpressionOrTemplateElement, "ListOfExpressionOrTemplateElement")   \
-  F(ListOfImportDeclarationOrExportDeclarationOrStatement,                    \
-    "ListOfImportDeclarationOrExportDeclarationOrStatement")                  \
-  F(ListOfImportSpecifier, "ListOfImportSpecifier")                           \
-  F(ListOfObjectProperty, "ListOfObjectProperty")                             \
-  F(ListOfOptionalBindingOrBindingWithInitializer,                            \
-    "ListOfOptionalBindingOrBindingWithInitializer")                          \
-  F(ListOfOptionalSpreadElementOrExpression,                                  \
-    "ListOfOptionalSpreadElementOrExpression")                                \
-  F(ListOfParameter, "ListOfParameter")                                       \
-  F(ListOfStatement, "ListOfStatement")                                       \
-  F(ListOfSwitchCase, "ListOfSwitchCase")                                     \
-  F(ListOfVariableDeclarator, "ListOfVariableDeclarator")                     \
-  F(Literal, "Literal")                                                       \
   F(LiteralBooleanExpression, "LiteralBooleanExpression")                     \
   F(LiteralInfinityExpression, "LiteralInfinityExpression")                   \
   F(LiteralNullExpression, "LiteralNullExpression")                           \
   F(LiteralNumericExpression, "LiteralNumericExpression")                     \
   F(LiteralPropertyName, "LiteralPropertyName")                               \
   F(LiteralRegExpExpression, "LiteralRegExpExpression")                       \
   F(LiteralStringExpression, "LiteralStringExpression")                       \
-  F(Method, "Method")                                                         \
-  F(MethodDefinition, "MethodDefinition")                                     \
   F(Module, "Module")                                                         \
   F(NewExpression, "NewExpression")                                           \
   F(NewTargetExpression, "NewTargetExpression")                               \
   F(ObjectAssignmentTarget, "ObjectAssignmentTarget")                         \
   F(ObjectBinding, "ObjectBinding")                                           \
   F(ObjectExpression, "ObjectExpression")                                     \
-  F(ObjectProperty, "ObjectProperty")                                         \
-  F(OptionalAssignmentTarget, "OptionalAssignmentTarget")                     \
-  F(OptionalBinding, "OptionalBinding")                                       \
-  F(OptionalBindingIdentifier, "OptionalBindingIdentifier")                   \
-  F(OptionalBindingOrBindingWithInitializer,                                  \
-    "OptionalBindingOrBindingWithInitializer")                                \
-  F(OptionalCatchClause, "OptionalCatchClause")                               \
-  F(OptionalExpression, "OptionalExpression")                                 \
-  F(OptionalIdentifierName, "OptionalIdentifierName")                         \
-  F(OptionalLabel, "OptionalLabel")                                           \
-  F(OptionalPropertyKey, "OptionalPropertyKey")                               \
-  F(OptionalSpreadElementOrExpression, "OptionalSpreadElementOrExpression")   \
-  F(OptionalStatement, "OptionalStatement")                                   \
-  F(OptionalVariableDeclarationOrExpression,                                  \
-    "OptionalVariableDeclarationOrExpression")                                \
-  F(Parameter, "Parameter")                                                   \
-  F(Program, "Program")                                                       \
-  F(PropertyKey, "PropertyKey")                                               \
-  F(PropertyName, "PropertyName")                                             \
   F(ReturnStatement, "ReturnStatement")                                       \
   F(Script, "Script")                                                         \
-  F(Setter, "Setter")                                                         \
   F(SetterContents, "SetterContents")                                         \
   F(ShorthandProperty, "ShorthandProperty")                                   \
-  F(SimpleAssignmentTarget, "SimpleAssignmentTarget")                         \
   F(SpreadElement, "SpreadElement")                                           \
-  F(SpreadElementOrExpression, "SpreadElementOrExpression")                   \
-  F(Statement, "Statement")                                                   \
   F(StaticMemberAssignmentTarget, "StaticMemberAssignmentTarget")             \
   F(StaticMemberExpression, "StaticMemberExpression")                         \
   F(Super, "Super")                                                           \
   F(SwitchCase, "SwitchCase")                                                 \
   F(SwitchDefault, "SwitchDefault")                                           \
   F(SwitchStatement, "SwitchStatement")                                       \
   F(SwitchStatementWithDefault, "SwitchStatementWithDefault")                 \
   F(TemplateElement, "TemplateElement")                                       \
   F(TemplateExpression, "TemplateExpression")                                 \
   F(ThisExpression, "ThisExpression")                                         \
   F(ThrowStatement, "ThrowStatement")                                         \
   F(TryCatchStatement, "TryCatchStatement")                                   \
   F(TryFinallyStatement, "TryFinallyStatement")                               \
   F(UnaryExpression, "UnaryExpression")                                       \
-  F(UnaryOperator, "UnaryOperator")                                           \
   F(UpdateExpression, "UpdateExpression")                                     \
-  F(UpdateOperator, "UpdateOperator")                                         \
   F(VariableDeclaration, "VariableDeclaration")                               \
-  F(VariableDeclarationKind, "VariableDeclarationKind")                       \
-  F(VariableDeclarationOrExpression, "VariableDeclarationOrExpression")       \
   F(VariableDeclarator, "VariableDeclarator")                                 \
   F(WhileStatement, "WhileStatement")                                         \
   F(WithStatement, "WithStatement")                                           \
   F(YieldExpression, "YieldExpression")                                       \
-  F(YieldStarExpression, "YieldStarExpression")                               \
-  F(String, "string")
+  F(YieldStarExpression, "YieldStarExpression")
 
 enum class BinKind {
 #define EMIT_ENUM(name, _) name,
   FOR_EACH_BIN_KIND(EMIT_ENUM)
 #undef EMIT_ENUM
 };
 
 // The number of distinct values of BinKind.
-const size_t BINKIND_LIMIT = 200;
+const size_t BINKIND_LIMIT = 120;
 
 /**
  * The different fields of Binary AST nodes, as per the specifications of
  * Binary AST.
  *
  * Usage:
  *
  * ```c++
--- a/js/src/frontend/binsource/src/main.rs
+++ b/js/src/frontend/binsource/src/main.rs
@@ -928,83 +928,87 @@ impl CPPExporter {
     fn export_declare_kinds_and_fields_enums(&self, buffer: &mut String) {
         buffer.push_str(&self.rules.hpp_tokens_header.reindent(""));
 
         buffer.push_str("\n\n");
         if self.rules.hpp_tokens_kind_doc.is_some() {
             buffer.push_str(&self.rules.hpp_tokens_kind_doc.reindent(""));
         }
 
-        let node_names = self.syntax.node_names()
+        let node_names = self.syntax.interfaces_by_name()
             .keys()
+            .map(|n| n.to_string())
             .sorted();
+        let kind_limit = node_names.len();
         buffer.push_str(&format!("\n#define FOR_EACH_BIN_KIND(F) \\\n{nodes}\n",
             nodes = node_names.iter()
                 .map(|name| format!("    F({enum_name}, \"{spec_name}\")",
                     enum_name = name.to_cpp_enum_case(),
                     spec_name = name))
                 .format(" \\\n")));
         buffer.push_str("
 enum class BinKind {
 #define EMIT_ENUM(name, _) name,
     FOR_EACH_BIN_KIND(EMIT_ENUM)
 #undef EMIT_ENUM
 };
 ");
 
-        buffer.push_str(&format!("\n// The number of distinct values of BinKind.\nconst size_t BINKIND_LIMIT = {};\n\n\n", self.syntax.node_names().len()));
+        buffer.push_str(&format!("\n// The number of distinct values of BinKind.\nconst size_t BINKIND_LIMIT = {};\n\n\n", kind_limit));
         buffer.push_str("\n\n");
         if self.rules.hpp_tokens_field_doc.is_some() {
             buffer.push_str(&self.rules.hpp_tokens_field_doc.reindent(""));
         }
 
         let field_names = self.syntax.field_names()
             .keys()
             .sorted();
+        let field_limit = field_names.len();
         buffer.push_str(&format!("\n#define FOR_EACH_BIN_FIELD(F) \\\n{nodes}\n",
             nodes = field_names.iter()
                 .map(|name| format!("    F({enum_name}, \"{spec_name}\")",
                     spec_name = name,
                     enum_name = name.to_cpp_enum_case()))
                 .format(" \\\n")));
         buffer.push_str("
 enum class BinField {
 #define EMIT_ENUM(name, _) name,
     FOR_EACH_BIN_FIELD(EMIT_ENUM)
 #undef EMIT_ENUM
 };
 ");
-        buffer.push_str(&format!("\n// The number of distinct values of BinField.\nconst size_t BINFIELD_LIMIT = {};\n\n\n", self.syntax.field_names().len()));
+        buffer.push_str(&format!("\n// The number of distinct values of BinField.\nconst size_t BINFIELD_LIMIT = {};\n\n\n", field_limit));
 
         if self.rules.hpp_tokens_variants_doc.is_some() {
             buffer.push_str(&self.rules.hpp_tokens_variants_doc.reindent(""));
         }
         let enum_variants : Vec<_> = self.variants_by_symbol
             .iter()
             .sorted_by(|&(ref symbol_1, ref name_1), &(ref symbol_2, ref name_2)| {
                 Ord::cmp(name_1, name_2)
                     .then_with(|| Ord::cmp(symbol_1, symbol_2))
             });
+        let variants_limit = enum_variants.len();
 
         buffer.push_str(&format!("\n#define FOR_EACH_BIN_VARIANT(F) \\\n{nodes}\n",
             nodes = enum_variants.into_iter()
                 .map(|(symbol, name)| format!("    F({variant_name}, \"{spec_name}\")",
                     spec_name = symbol,
                     variant_name = name))
                 .format(" \\\n")));
 
         buffer.push_str("
 enum class BinVariant {
 #define EMIT_ENUM(name, _) name,
     FOR_EACH_BIN_VARIANT(EMIT_ENUM)
 #undef EMIT_ENUM
 };
 ");
         buffer.push_str(&format!("\n// The number of distinct values of BinVariant.\nconst size_t BINVARIANT_LIMIT = {};\n\n\n",
-            self.variants_by_symbol.len()));
+            variants_limit));
 
         buffer.push_str(&self.rules.hpp_tokens_footer.reindent(""));
         buffer.push_str("\n");
     }
 
     /// Declare string enums
     fn export_declare_string_enums(&self, buffer: &mut String) {
         buffer.push_str("