Bug 1550616 - Make FunctionBox::setEnd take the actual uint32_t end, not TokenStreamAnyChars&, and add ParserBase::setFunctionEndFromCurrentToken that calls it passing the correct value, to eliminate another SharedContext.h dependency on... r=tcampbell
authorJeff Walden <jwalden@mit.edu>
Sun, 12 May 2019 22:14:11 +0000
changeset 532375 c706eab3c639f68720b3f3d634b29424da7f6360
parent 532374 703783d5484d173508e8a13d41fde8d121149211
child 532376 78749757be96d07200e582ff178b1d1d1686fae6
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1550616
milestone68.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 1550616 - Make FunctionBox::setEnd take the actual uint32_t end, not TokenStreamAnyChars&, and add ParserBase::setFunctionEndFromCurrentToken that calls it passing the correct value, to eliminate another SharedContext.h dependency on... r=tcampbell ...TokenStream.h. r=tcampbell Depends on D30574 Differential Revision: https://phabricator.services.mozilla.com/D30575
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
js/src/frontend/SharedContext.h
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2907,16 +2907,20 @@ FunctionNode* Parser<FullParseHandler, U
       return null();
     }
   }
   funNode = &node->as<FunctionNode>();
 
   return funNode;
 }
 
+void ParserBase::setFunctionEndFromCurrentToken(FunctionBox* funbox) const {
+  funbox->setEnd(anyChars.currentToken().pos.end);
+}
+
 template <class ParseHandler, typename Unit>
 bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
     InHandling inHandling, YieldHandling yieldHandling,
     FunctionNodeType* funNode, FunctionSyntaxKind kind,
     const Maybe<uint32_t>& parameterListEnd /* = Nothing() */,
     bool isStandaloneFunction /* = false */) {
   // Given a properly initialized parse context, try to parse an actual
   // function without concern for conversion to strict mode, use of lazy
@@ -3047,25 +3051,25 @@ bool GeneralParser<ParseHandler, Unit>::
       return false;
     }
     if (actual != TokenKind::RightCurly) {
       reportMissingClosing(JSMSG_CURLY_AFTER_BODY, JSMSG_CURLY_OPENED,
                            openedPos);
       return false;
     }
 
-    funbox->setEnd(anyChars);
+    setFunctionEndFromCurrentToken(funbox);
   } else {
     MOZ_ASSERT(kind == FunctionSyntaxKind::Arrow);
 
     if (anyChars.hadError()) {
       return false;
     }
 
-    funbox->setEnd(anyChars);
+    setFunctionEndFromCurrentToken(funbox);
 
     if (kind == FunctionSyntaxKind::Statement) {
       if (!matchOrInsertSemicolon()) {
         return false;
       }
     }
   }
 
@@ -7156,17 +7160,17 @@ GeneralParser<ParseHandler, Unit>::synth
   FunctionBox* funbox = newFunctionBox(funNode, fun, classNameOffset,
                                        directives, GeneratorKind::NotGenerator,
                                        FunctionAsyncKind::SyncFunction);
   if (!funbox) {
     return null();
   }
   funbox->initWithEnclosingParseContext(pc_, functionSyntaxKind);
   handler_.setFunctionBox(funNode, funbox);
-  funbox->setEnd(anyChars);
+  setFunctionEndFromCurrentToken(funbox);
 
   // Push a SourceParseContext on to the stack.
   SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
   if (!funpc.init()) {
     return null();
   }
 
   TokenPos synthesizedBodyPos = TokenPos(classNameOffset, classNameOffset + 1);
@@ -7347,17 +7351,17 @@ GeneralParser<ParseHandler, Unit>::field
     if (!initializerExpr) {
       return null();
     }
     wholeInitializerPos = firstTokenPos;
   }
 
   // Update the end position of the parse node.
   handler_.setEndPosition(funNode, wholeInitializerPos.end);
-  funbox->setEnd(anyChars);
+  setFunctionEndFromCurrentToken(funbox);
 
   // Create a ListNode for the parameters + body (there are no parameters).
   ListNodeType argsbody =
       handler_.newList(ParseNodeKind::ParamsBody, wholeInitializerPos);
   if (!argsbody) {
     return null();
   }
   handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -452,16 +452,18 @@ class MOZ_STACK_CLASS ParserBase : publi
 
   bool checkAndMarkSuperScope();
 
   bool leaveInnerFunction(ParseContext* outerpc);
 
   JSAtom* prefixAccessorName(PropertyType propType, HandleAtom propAtom);
 
   MOZ_MUST_USE bool setSourceMapInfo();
+
+  void setFunctionEndFromCurrentToken(FunctionBox* funbox) const;
 };
 
 enum FunctionCallBehavior {
   PermitAssignmentToFunctionCalls,
   ForbidAssignmentToFunctionCalls
 };
 
 template <class ParseHandler>
@@ -819,16 +821,17 @@ class MOZ_STACK_CLASS GeneralParser : pu
   using Base::newThisName;
   using Base::nextTokenContinuesLetDeclaration;
   using Base::noSubstitutionTaggedTemplate;
   using Base::noteDestructuredPositionalFormalParameter;
   using Base::noteUsedName;
   using Base::prefixAccessorName;
   using Base::processExport;
   using Base::processExportFrom;
+  using Base::setFunctionEndFromCurrentToken;
 
  private:
   inline FinalParser* asFinalParser();
   inline const FinalParser* asFinalParser() const;
 
   /*
    * A class for temporarily stashing errors while parsing continues.
    *
--- a/js/src/frontend/SharedContext.h
+++ b/js/src/frontend/SharedContext.h
@@ -550,23 +550,21 @@ class FunctionBox : public ObjectBox, pu
   bool useAsmOrInsideUseAsm() const { return useAsm; }
 
   void setStart(uint32_t offset, uint32_t line, uint32_t column) {
     bufStart = offset;
     startLine = line;
     startColumn = column;
   }
 
-  void setEnd(const TokenStreamAnyChars& anyChars) {
+  void setEnd(uint32_t end) {
     // For all functions except class constructors, the buffer and
     // toString ending positions are the same. Class constructors override
     // the toString ending position with the end of the class definition.
-    uint32_t offset = anyChars.currentToken().pos.end;
-    bufEnd = offset;
-    toStringEnd = offset;
+    bufEnd = toStringEnd = end;
   }
 
   void trace(JSTracer* trc) override;
 };
 
 inline FunctionBox* SharedContext::asFunctionBox() {
   MOZ_ASSERT(isFunctionBox());
   return static_cast<FunctionBox*>(this);