Bug 1424946 - Move GeneralParser::finishFunction into a baser class. r=arai
authorJeff Walden <jwalden@mit.edu>
Tue, 12 Dec 2017 15:20:59 -0600
changeset 448157 4daa95c889080272786d3874cf9c1a02e34688bc
parent 448156 cfe57fd2ed05f83bd5959bc7e9359bf98d3e13e7
child 448158 8de7ca55eae49ddef44e76294d8758b159e46b8b
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1424946
milestone59.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 1424946 - Move GeneralParser::finishFunction into a baser class. r=arai
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2384,19 +2384,19 @@ PerHandlerParser<ParseHandler>::finishFu
     if (funbox->function()->isNamedLambda() && !isStandaloneFunction) {
         if (!propagateFreeNamesAndMarkClosedOverBindings(pc->namedLambdaScope()))
             return false;
     }
 
     return true;
 }
 
-template <typename CharT>
+template <>
 bool
-Parser<FullParseHandler, CharT>::finishFunction(bool isStandaloneFunction /* = false */)
+PerHandlerParser<FullParseHandler>::finishFunction(bool isStandaloneFunction /* = false */)
 {
     if (!finishFunctionScopes(isStandaloneFunction))
         return false;
 
     FunctionBox* funbox = pc->functionBox();
     bool hasParameterExprs = funbox->hasParameterExprs;
 
     if (hasParameterExprs) {
@@ -2419,19 +2419,19 @@ Parser<FullParseHandler, CharT>::finishF
         if (!bindings)
             return false;
         funbox->namedLambdaBindings().set(*bindings);
     }
 
     return true;
 }
 
-template <typename CharT>
+template <>
 bool
-Parser<SyntaxParseHandler, CharT>::finishFunction(bool isStandaloneFunction /* = false */)
+PerHandlerParser<SyntaxParseHandler>::finishFunction(bool isStandaloneFunction /* = false */)
 {
     // The LazyScript for a lazily parsed function needs to know its set of
     // free variables and inner functions so that when it is fully parsed, we
     // can skip over any already syntax parsed inner functions and still
     // retain correct scope information.
 
     if (!finishFunctionScopes(isStandaloneFunction))
         return false;
@@ -2479,23 +2479,16 @@ Parser<SyntaxParseHandler, CharT>::finis
     // Flags that need to copied back into the parser when we do the full
     // parse.
     PropagateTransitiveParseFlags(funbox, lazy);
 
     fun->initLazyScript(lazy);
     return true;
 }
 
-template <class ParseHandler, typename CharT>
-inline bool
-GeneralParser<ParseHandler, CharT>::finishFunction(bool isStandaloneFunction /* = false */)
-{
-    return asFinalParser()->finishFunction(isStandaloneFunction);
-}
-
 static YieldHandling
 GetYieldHandling(GeneratorKind generatorKind)
 {
     if (generatorKind == GeneratorKind::NotGenerator)
         return YieldIsName;
     return YieldIsKeyword;
 }
 
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -329,16 +329,17 @@ class PerHandlerParser
         return ParserBase::noteUsedNameInternal(name);
     }
 
     // Required on Scope exit.
     bool propagateFreeNamesAndMarkClosedOverBindings(ParseContext::Scope& scope);
 
     bool finishFunctionScopes(bool isStandaloneFunction);
     Node finishLexicalScope(ParseContext::Scope& scope, Node body);
+    bool finishFunction(bool isStandaloneFunction = false);
 
     bool declareFunctionThis();
 
     inline Node newName(PropertyName* name);
     inline Node newName(PropertyName* name, TokenPos pos);
 
     Node newInternalDotName(HandlePropertyName name);
     Node newThisName();
@@ -521,16 +522,17 @@ class GeneralParser
     using Base::handler;
     using Base::isValidSimpleAssignmentTarget;
     using Base::pc;
     using Base::usedNames;
 
   private:
     using Base::declareDotGeneratorName;
     using Base::declareFunctionThis;
+    using Base::finishFunction;
     using Base::hasUsedName;
     using Base::newDotGeneratorName;
     using Base::newInternalDotName;
     using Base::newThisName;
     using Base::noteDestructuredPositionalFormalParameter;
     using Base::noteUsedName;
 
   private:
@@ -1003,18 +1005,16 @@ class GeneralParser
     bool matchLabel(YieldHandling yieldHandling, MutableHandle<PropertyName*> label);
 
     // Indicate if the next token (tokenized as Operand) is |in| or |of|.  If
     // so, consume it.
     bool matchInOrOf(bool* isForInp, bool* isForOfp);
 
     bool declareFunctionArgumentsObject();
 
-    inline bool finishFunction(bool isStandaloneFunction = false);
-
     bool leaveInnerFunction(ParseContext* outerpc);
 
   private:
     bool checkIncDecOperand(Node operand, uint32_t operandOffset);
     bool checkStrictAssignment(Node lhs);
 
     void reportMissingClosing(unsigned errorNumber, unsigned noteNumber, uint32_t openedPos);
 
@@ -1187,18 +1187,16 @@ class Parser<SyntaxParseHandler, CharT> 
                                      InHandling inHandling, YieldHandling yieldHandling,
                                      FunctionSyntaxKind kind, GeneratorKind generatorKind,
                                      FunctionAsyncKind asyncKind, bool tryAnnexB,
                                      Directives inheritedDirectives, Directives* newDirectives);
 
     bool skipLazyInnerFunction(Node funcNode, uint32_t toStringStart, FunctionSyntaxKind kind,
                                bool tryAnnexB);
 
-    bool finishFunction(bool isStandaloneFunction = false);
-
     bool asmJS(Node list);
 
     // Functions present only in Parser<SyntaxParseHandler, CharT>.
 };
 
 template <typename CharT>
 class Parser<FullParseHandler, CharT> final
   : public GeneralParser<FullParseHandler, CharT>
@@ -1304,18 +1302,16 @@ class Parser<FullParseHandler, CharT> fi
                                      InHandling inHandling, YieldHandling yieldHandling,
                                      FunctionSyntaxKind kind, GeneratorKind generatorKind,
                                      FunctionAsyncKind asyncKind, bool tryAnnexB,
                                      Directives inheritedDirectives, Directives* newDirectives);
 
     bool skipLazyInnerFunction(Node funcNode, uint32_t toStringStart, FunctionSyntaxKind kind,
                                bool tryAnnexB);
 
-    bool finishFunction(bool isStandaloneFunction = false);
-
     // Functions present only in Parser<FullParseHandler, CharT>.
 
     // Parse the body of an eval.
     //
     // Eval scripts are distinguished from global scripts in that in ES6, per
     // 18.2.1.1 steps 9 and 10, all eval scripts are executed under a fresh
     // lexical scope.
     Node evalBody(EvalSharedContext* evalsc);