Bug 1473796 - Part 2: Do not use TokenPos in BytecodeEmitter::{setFunctionBodyEndPos,setScriptStartOffsetIfUnset}. r=jorendorff
authorTooru Fujisawa <arai_a@mac.com>
Tue, 12 Mar 2019 06:03:48 +0000
changeset 521489 d20d700c80d59dd1c4a7a31db50319227cf3ede7
parent 521488 f53c8cedef752e0aca5c0f4a848275267d94df7f
child 521490 7e1e3f35d7cf58e25bdc0753c0f5a235e55bf08f
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1473796
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 1473796 - Part 2: Do not use TokenPos in BytecodeEmitter::{setFunctionBodyEndPos,setScriptStartOffsetIfUnset}. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D19620
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/BytecodeEmitter.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -137,18 +137,18 @@ BytecodeEmitter::BytecodeEmitter(Bytecod
                                  Handle<LazyScript*> lazyScript,
                                  uint32_t lineNum, EmitterMode emitterMode)
     : BytecodeEmitter(parent, sc, script, lazyScript, lineNum, emitterMode) {
   ep_.emplace(parser);
   this->parser = ep_.ptr();
 }
 
 void BytecodeEmitter::initFromBodyPosition(TokenPos bodyPosition) {
-  setScriptStartOffsetIfUnset(bodyPosition);
-  setFunctionBodyEndPos(bodyPosition);
+  setScriptStartOffsetIfUnset(bodyPosition.begin);
+  setFunctionBodyEndPos(bodyPosition.end);
 }
 
 bool BytecodeEmitter::init() { return atomIndices.acquire(cx); }
 
 template <typename T>
 T* BytecodeEmitter::findInnermostNestableControl() const {
   return NestableControl::findNearest<T>(innermostNestableControl);
 }
@@ -2349,17 +2349,17 @@ bool BytecodeEmitter::defineHoistedTopLe
 
   return emitHoistedFunctionsInList(&body->as<ListNode>());
 }
 
 bool BytecodeEmitter::emitScript(ParseNode* body) {
   AutoFrontendTraceLog traceLog(cx, TraceLogger_BytecodeEmission,
                                 parser->errorReporter(), body);
 
-  setScriptStartOffsetIfUnset(body->pn_pos);
+  setScriptStartOffsetIfUnset(body->pn_pos.begin);
 
   MOZ_ASSERT(inPrologue());
 
   TDZCheckCache tdzCache(this);
   EmitterScope emitterScope(this);
   if (sc->isGlobalContext()) {
     if (!emitterScope.enterGlobal(this, sc->asGlobalContext())) {
       return false;
@@ -2370,17 +2370,17 @@ bool BytecodeEmitter::emitScript(ParseNo
     }
   } else {
     MOZ_ASSERT(sc->isModuleContext());
     if (!emitterScope.enterModule(this, sc->asModuleContext())) {
       return false;
     }
   }
 
-  setFunctionBodyEndPos(body->pn_pos);
+  setFunctionBodyEndPos(body->pn_pos.end);
 
   bool isSloppyEval = sc->isEvalContext() && !sc->strict();
   if (isSloppyEval && body->is<LexicalScopeNode>() &&
       !body->as<LexicalScopeNode>().isEmptyScope()) {
     // Sloppy eval scripts may need to emit DEFFUNs in the prologue. If there is
     // an immediately enclosed lexical scope, we need to enter the lexical
     // scope in the prologue for the DEFFUNs to pick up the right
     // environment chain.
@@ -2510,17 +2510,17 @@ bool BytecodeEmitter::emitFunctionScript
                                          TopLevelFunction isTopLevel) {
   MOZ_ASSERT(inPrologue());
   ParseNode* body = funNode->body();
   MOZ_ASSERT(body->isKind(ParseNodeKind::ParamsBody));
   FunctionBox* funbox = sc->asFunctionBox();
   AutoFrontendTraceLog traceLog(cx, TraceLogger_BytecodeEmission,
                                 parser->errorReporter(), funbox);
 
-  setScriptStartOffsetIfUnset(body->pn_pos);
+  setScriptStartOffsetIfUnset(body->pn_pos.begin);
 
   // The ordering of these EmitterScopes is important. The named lambda
   // scope needs to enclose the function scope needs to enclose the extra
   // var scope.
 
   Maybe<EmitterScope> namedLambdaEmitterScope;
   if (funbox->namedLambdaBindings()) {
     namedLambdaEmitterScope.emplace(this);
@@ -2533,17 +2533,17 @@ bool BytecodeEmitter::emitFunctionScript
    * Mark the script so that initializers created within it may be given more
    * precise types.
    */
   if (isRunOnceLambda()) {
     script->setTreatAsRunOnce();
     MOZ_ASSERT(!script->hasRunOnce());
   }
 
-  setFunctionBodyEndPos(body->pn_pos);
+  setFunctionBodyEndPos(body->pn_pos.end);
   if (!emitTree(body)) {
     return false;
   }
 
   if (!updateSourceCoordNotes(body->pn_pos.end)) {
     return false;
   }
 
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -424,23 +424,23 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
   // JumpTarget should not be part of the emitted statement, as they can be
   // aliased by multiple statements. If we included the jump target as part of
   // the statement we might have issues where the enclosing statement might
   // not contain all the opcodes of the enclosed statements.
   ptrdiff_t lastNonJumpTargetOffset() const {
     return lastOpcodeIsJumpTarget() ? lastTarget.offset : offset();
   }
 
-  void setFunctionBodyEndPos(TokenPos pos) {
-    functionBodyEndPos = mozilla::Some(pos.end);
+  void setFunctionBodyEndPos(uint32_t pos) {
+    functionBodyEndPos = mozilla::Some(pos);
   }
 
-  void setScriptStartOffsetIfUnset(TokenPos pos) {
+  void setScriptStartOffsetIfUnset(uint32_t pos) {
     if (scriptStartOffset.isNothing()) {
-      scriptStartOffset = mozilla::Some(pos.begin);
+      scriptStartOffset = mozilla::Some(pos);
     }
   }
 
   void reportError(ParseNode* pn, unsigned errorNumber, ...);
   void reportError(const mozilla::Maybe<uint32_t>& maybeOffset,
                    unsigned errorNumber, ...);
   bool reportExtraWarning(ParseNode* pn, unsigned errorNumber, ...);
   bool reportExtraWarning(const mozilla::Maybe<uint32_t>& maybeOffset,