Bug 1424946 - Move GeneralParser::checkOptions into a baser class. r=arai
authorJeff Walden <jwalden@mit.edu>
Tue, 12 Dec 2017 15:20:57 -0600
changeset 448144 e934b45172edc7425a3a5a22f7005db734f8f659
parent 448143 1c3667804652d4eac9bf1d9ce018f4e485de70d2
child 448145 8d12eae2c379704ab79914f5b0d822962f203333
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::checkOptions 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
@@ -819,18 +819,30 @@ ParserBase::ParserBase(JSContext* cx, Li
 #endif
     isUnexpectedEOF_(false),
     awaitHandling_(AwaitIsName)
 {
     cx->frontendCollectionPool().addActiveCompilation();
     tempPoolMark = alloc.mark();
 }
 
+bool
+ParserBase::checkOptions()
+{
+#ifdef DEBUG
+    checkOptionsCalled = true;
+#endif
+
+    return anyChars.checkOptions();
+}
+
 ParserBase::~ParserBase()
 {
+    MOZ_ASSERT(checkOptionsCalled);
+
     alloc.release(tempPoolMark);
 
     /*
      * The parser can allocate enormous amounts of memory for large functions.
      * Eagerly free the memory now (which otherwise won't be freed until the
      * next GC) to avoid unnecessary OOMs.
      */
     alloc.freeAllIfHugeAndUnused();
@@ -859,33 +871,16 @@ GeneralParser<ParseHandler, CharT>::Gene
                                                   SyntaxParser* syntaxParser,
                                                   LazyScript* lazyOuterFunction)
   : Base(cx, alloc, options, chars, length, foldConstants, usedNames, lazyOuterFunction),
     AutoGCRooter(cx, PARSER),
     syntaxParser_(syntaxParser),
     tokenStream(cx, options, chars, length)
 {}
 
-template<class ParseHandler, typename CharT>
-bool
-GeneralParser<ParseHandler, CharT>::checkOptions()
-{
-#ifdef DEBUG
-    checkOptionsCalled = true;
-#endif
-
-    return anyChars.checkOptions();
-}
-
-template <class ParseHandler, typename CharT>
-GeneralParser<ParseHandler, CharT>::~GeneralParser()
-{
-    MOZ_ASSERT(checkOptionsCalled);
-}
-
 template <typename CharT>
 void
 Parser<SyntaxParseHandler, CharT>::setAwaitHandling(AwaitHandling awaitHandling)
 {
     this->awaitHandling_ = awaitHandling;
 }
 
 template <typename CharT>
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -157,16 +157,18 @@ class ParserBase : public StrictModeGett
 
     template<class, typename> friend class AutoAwaitIsKeyword;
 
     ParserBase(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
                const char16_t* chars, size_t length, bool foldConstants,
                UsedNameTracker& usedNames);
     ~ParserBase();
 
+    bool checkOptions();
+
     const char* getFilename() const { return anyChars.getFilename(); }
     TokenPos pos() const { return anyChars.currentToken().pos; }
 
     // Determine whether |yield| is a valid name in the current context.
     bool yieldExpressionsSupported() const {
         return pc->isGenerator();
     }
 
@@ -510,22 +512,19 @@ class GeneralParser
     void prepareNodeForMutation(Node node) { handler.prepareNodeForMutation(node); }
     void freeTree(Node node) { handler.freeTree(node); }
 
   public:
     GeneralParser(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
                   const CharT* chars, size_t length, bool foldConstants,
                   UsedNameTracker& usedNames, SyntaxParser* syntaxParser,
                   LazyScript* lazyOuterFunction);
-    ~GeneralParser();
 
     inline void setAwaitHandling(AwaitHandling awaitHandling);
 
-    bool checkOptions();
-
     friend void js::frontend::TraceParser(JSTracer* trc, JS::AutoGCRooter* parser);
 
     /*
      * Parse a top-level JS script.
      */
     Node parse();
 
     FunctionBox* newFunctionBox(Node fn, JSFunction* fun, uint32_t toStringStart,