Bug 1529442 - Move BinASTParserBase fields to BinASTParserPerTokenizer. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Sun, 24 Feb 2019 03:34:03 +0000
changeset 518663 b5889271779f
parent 518662 58e77ffe2a65
child 518664 6bbc695865c6
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1529442
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 1529442 - Move BinASTParserBase fields to BinASTParserPerTokenizer. r=Yoric Both BinASTParserBase.{lazyScript_,handler_} are not used in BinASTParserBase, but in BinASTParserPerTokenizer. Moved them to BinASTParserPerTokenizer. Differential Revision: https://phabricator.services.mozilla.com/D20775
js/src/frontend/BinASTParserBase.cpp
js/src/frontend/BinASTParserBase.h
js/src/frontend/BinASTParserPerTokenizer.cpp
js/src/frontend/BinASTParserPerTokenizer.h
--- a/js/src/frontend/BinASTParserBase.cpp
+++ b/js/src/frontend/BinASTParserBase.cpp
@@ -8,18 +8,13 @@
 
 #include "vm/JSContext-inl.h"
 
 namespace js {
 namespace frontend {
 
 BinASTParserBase::BinASTParserBase(JSContext* cx, LifoAlloc& alloc,
                                    UsedNameTracker& usedNames,
-                                   HandleScriptSourceObject sourceObject,
-                                   Handle<LazyScript*> lazyScript)
-    : ParserSharedBase(cx, alloc, usedNames, sourceObject),
-      lazyScript_(cx, lazyScript),
-      handler_(cx, alloc, nullptr, SourceKind::Binary) {
-  MOZ_ASSERT_IF(lazyScript, lazyScript->isBinAST());
-}
+                                   HandleScriptSourceObject sourceObject)
+    : ParserSharedBase(cx, alloc, usedNames, sourceObject) {}
 
 }  // namespace frontend
 }  // namespace js
--- a/js/src/frontend/BinASTParserBase.h
+++ b/js/src/frontend/BinASTParserBase.h
@@ -22,34 +22,24 @@
 #include "vm/JSScript.h"
 
 namespace js {
 namespace frontend {
 
 class BinASTParserBase : public ParserSharedBase {
  public:
   BinASTParserBase(JSContext* cx, LifoAlloc& alloc, UsedNameTracker& usedNames,
-                   HandleScriptSourceObject sourceObject,
-                   Handle<LazyScript*> lazyScript);
+                   HandleScriptSourceObject sourceObject);
   ~BinASTParserBase() = default;
 
  public:
-  // --- GC.
-
   virtual void doTrace(JSTracer* trc) {}
 
   void trace(JSTracer* trc) {
     TraceListNode::TraceList(trc, traceListHead_);
     doTrace(trc);
   }
-
-  // ---- Parsing-related stuff
- protected:
-  Rooted<LazyScript*> lazyScript_;
-  FullParseHandler handler_;
-
-  friend class BinParseContext;
 };
 
 }  // namespace frontend
 }  // namespace js
 
 #endif  // frontend_BinASTParserBase_h
--- a/js/src/frontend/BinASTParserPerTokenizer.cpp
+++ b/js/src/frontend/BinASTParserPerTokenizer.cpp
@@ -76,16 +76,30 @@
 namespace js {
 namespace frontend {
 
 using UsedNamePtr = UsedNameTracker::UsedNameMap::Ptr;
 
 // ------------- Toplevel constructions
 
 template <typename Tok>
+BinASTParserPerTokenizer<Tok>::BinASTParserPerTokenizer(
+    JSContext* cx, LifoAlloc& alloc, UsedNameTracker& usedNames,
+    const JS::ReadOnlyCompileOptions& options,
+    HandleScriptSourceObject sourceObject,
+    Handle<LazyScript*> lazyScript /* = nullptr */)
+    : BinASTParserBase(cx, alloc, usedNames, sourceObject),
+      options_(options),
+      lazyScript_(cx, lazyScript),
+      handler_(cx, alloc, nullptr, SourceKind::Binary),
+      variableDeclarationKind_(VariableDeclarationKind::Var) {
+  MOZ_ASSERT_IF(lazyScript_, lazyScript_->isBinAST());
+}
+
+template <typename Tok>
 JS::Result<ParseNode*> BinASTParserPerTokenizer<Tok>::parse(
     GlobalSharedContext* globalsc, const Vector<uint8_t>& data,
     BinASTSourceMetadata** metadataPtr) {
   return parse(globalsc, data.begin(), data.length(), metadataPtr);
 }
 
 template <typename Tok>
 JS::Result<ParseNode*> BinASTParserPerTokenizer<Tok>::parse(
--- a/js/src/frontend/BinASTParserPerTokenizer.h
+++ b/js/src/frontend/BinASTParserPerTokenizer.h
@@ -63,20 +63,17 @@ class BinASTParserPerTokenizer : public 
   using AssertedDeclaredKind = binast::AssertedDeclaredKind;
   using VariableDeclarationKind = binast::VariableDeclarationKind;
 
  public:
   BinASTParserPerTokenizer(JSContext* cx, LifoAlloc& alloc,
                            UsedNameTracker& usedNames,
                            const JS::ReadOnlyCompileOptions& options,
                            HandleScriptSourceObject sourceObject,
-                           Handle<LazyScript*> lazyScript = nullptr)
-      : BinASTParserBase(cx, alloc, usedNames, sourceObject, lazyScript),
-        options_(options),
-        variableDeclarationKind_(VariableDeclarationKind::Var) {}
+                           Handle<LazyScript*> lazyScript = nullptr);
   ~BinASTParserPerTokenizer() {}
 
   /**
    * Parse a buffer, returning a node (which may be nullptr) in case of success
    * or Nothing() in case of error.
    *
    * The instance of `ParseNode` MAY NOT survive the
    * `BinASTParserPerTokenizer`. Indeed, destruction of the
@@ -277,16 +274,19 @@ class BinASTParserPerTokenizer : public 
   virtual bool hasTokenizationStarted() const override {
     return tokenizer_.isSome();
   }
   virtual const char* getFilename() const override {
     return this->options_.filename();
   }
 
  protected:
+  Rooted<LazyScript*> lazyScript_;
+  FullParseHandler handler_;
+
   mozilla::Maybe<Tokenizer> tokenizer_;
   VariableDeclarationKind variableDeclarationKind_;
 
   friend class BinParseContext;
   friend class AutoVariableDeclarationKind;
 
   // Helper class: Restore field `variableDeclarationKind` upon leaving a scope.
   class MOZ_RAII AutoVariableDeclarationKind {