Bug 1601599 part 5 - Remove JSOP_LOOPHEAD source notes. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Sun, 15 Dec 2019 11:39:53 +0000
changeset 507025 ba6bf1f3c39192724b8e72137ef5403352042453
parent 507024 d9c1e44eb0addfc3e44ae299c86381128aa08e7f
child 507026 aed680826a1a7a7a49f31b6e3518d385611da831
push id36920
push userdluca@mozilla.com
push dateSun, 15 Dec 2019 21:49:48 +0000
treeherdermozilla-central@7e6a4e221495 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1601599
milestone73.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 1601599 part 5 - Remove JSOP_LOOPHEAD source notes. r=tcampbell IonBuilder no longer has to know the loop type. Depends on D56701 Differential Revision: https://phabricator.services.mozilla.com/D56702
js/src/frontend/BytecodeControlStructures.cpp
js/src/frontend/BytecodeControlStructures.h
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/CForEmitter.cpp
js/src/frontend/DoWhileEmitter.cpp
js/src/frontend/ForInEmitter.cpp
js/src/frontend/ForOfEmitter.cpp
js/src/frontend/SourceNotes.h
js/src/frontend/WhileEmitter.cpp
js/src/shell/js.cpp
--- a/js/src/frontend/BytecodeControlStructures.cpp
+++ b/js/src/frontend/BytecodeControlStructures.cpp
@@ -61,18 +61,17 @@ bool LoopControl::emitSpecialBreakForDon
   if (!bce->emitJump(JSOP_GOTO, &breaks)) {
     return false;
   }
 
   return true;
 }
 
 bool LoopControl::emitLoopHead(BytecodeEmitter* bce,
-                               const Maybe<uint32_t>& nextPos,
-                               SrcNoteType type) {
+                               const Maybe<uint32_t>& nextPos) {
   // Insert a NOP if needed to ensure the script does not start with a
   // JSOP_LOOPHEAD. This avoids JIT issues with prologue code + try notes
   // or OSR. See bug 1602390 and bug 1602681.
   if (bce->bytecodeSection().offset().toUint32() == 0) {
     if (!bce->emit1(JSOP_NOP)) {
       return false;
     }
   }
@@ -83,19 +82,16 @@ bool LoopControl::emitLoopHead(BytecodeE
     }
   }
 
   MOZ_ASSERT(loopDepth_ > 0);
 
   head_ = {bce->bytecodeSection().offset()};
 
   BytecodeOffset off;
-  if (!bce->newSrcNote(type)) {
-    return false;
-  }
   if (!bce->emitJumpTargetOp(JSOP_LOOPHEAD, &off)) {
     return false;
   }
   SetLoopHeadDepthHint(bce->bytecodeSection().code(off), loopDepth_);
 
   return true;
 }
 
--- a/js/src/frontend/BytecodeControlStructures.h
+++ b/js/src/frontend/BytecodeControlStructures.h
@@ -131,18 +131,17 @@ class LoopControl : public BreakableCont
 
   // Emit a jump to break target from the top level of the loop.
   MOZ_MUST_USE bool emitSpecialBreakForDone(BytecodeEmitter* bce);
 
   // `nextPos` is the offset in the source code for the character that
   // corresponds to the next instruction after JSOP_LOOPHEAD.
   // Can be Nothing() if not available.
   MOZ_MUST_USE bool emitLoopHead(BytecodeEmitter* bce,
-                                 const mozilla::Maybe<uint32_t>& nextPos,
-                                 SrcNoteType type);
+                                 const mozilla::Maybe<uint32_t>& nextPos);
 
   MOZ_MUST_USE bool emitLoopEnd(BytecodeEmitter* bce, JSOp op,
                                 JSTryNoteKind tryNoteKind);
 };
 template <>
 inline bool NestableControl::is<LoopControl>() const {
   return StatementKindIsLoop(kind_);
 }
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -5170,17 +5170,17 @@ bool BytecodeEmitter::emitAsyncIterator(
   }
 
   return true;
 }
 
 bool BytecodeEmitter::emitSpread(bool allowSelfHosted) {
   LoopControl loopInfo(this, StatementKind::Spread);
 
-  if (!loopInfo.emitLoopHead(this, Nothing(), SRC_FOR_OF)) {
+  if (!loopInfo.emitLoopHead(this, Nothing())) {
     //              [stack] NEXT ITER ARR I
     return false;
   }
 
   {
 #ifdef DEBUG
     auto loopDepth = bytecodeSection().stackDepth();
 #endif
--- a/js/src/frontend/CForEmitter.cpp
+++ b/js/src/frontend/CForEmitter.cpp
@@ -62,17 +62,17 @@ bool CForEmitter::emitCond(const Maybe<u
 
     if (headLexicalEmitterScopeForLet_->hasEnvironment()) {
       if (!bce_->emit1(JSOP_FRESHENLEXICALENV)) {
         return false;
       }
     }
   }
 
-  if (!loopInfo_->emitLoopHead(bce_, condPos, SRC_FOR)) {
+  if (!loopInfo_->emitLoopHead(bce_, condPos)) {
     //            [stack]
     return false;
   }
 
 #ifdef DEBUG
   state_ = State::Cond;
 #endif
   return true;
--- a/js/src/frontend/DoWhileEmitter.cpp
+++ b/js/src/frontend/DoWhileEmitter.cpp
@@ -31,17 +31,17 @@ bool DoWhileEmitter::emitBody(const Mayb
 
   // We need a nop here to make it possible to set a breakpoint on `do`.
   if (!bce_->emit1(JSOP_NOP)) {
     return false;
   }
 
   loopInfo_.emplace(bce_, StatementKind::DoLoop);
 
-  if (!loopInfo_->emitLoopHead(bce_, bodyPos, SRC_DO_WHILE)) {
+  if (!loopInfo_->emitLoopHead(bce_, bodyPos)) {
     return false;
   }
 
 #ifdef DEBUG
   state_ = State::Body;
 #endif
   return true;
 }
--- a/js/src/frontend/ForInEmitter.cpp
+++ b/js/src/frontend/ForInEmitter.cpp
@@ -38,17 +38,17 @@ bool ForInEmitter::emitInitialize() {
 
   if (!bce_->emit1(JSOP_ITER)) {
     //              [stack] ITER
     return false;
   }
 
   loopInfo_.emplace(bce_, StatementKind::ForInLoop);
 
-  if (!loopInfo_->emitLoopHead(bce_, Nothing(), SRC_FOR_IN)) {
+  if (!loopInfo_->emitLoopHead(bce_, Nothing())) {
     //              [stack] ITER
     return false;
   }
 
   if (!bce_->emit1(JSOP_MOREITER)) {
     //              [stack] ITER NEXTITERVAL?
     return false;
   }
--- a/js/src/frontend/ForOfEmitter.cpp
+++ b/js/src/frontend/ForOfEmitter.cpp
@@ -65,17 +65,17 @@ bool ForOfEmitter::emitInitialize(const 
   // Push an undefined to balance the stack.
   if (!bce_->emit1(JSOP_UNDEFINED)) {
     //              [stack] NEXT ITER UNDEF
     return false;
   }
 
   loopInfo_.emplace(bce_, iterDepth, allowSelfHostedIter_, iterKind_);
 
-  if (!loopInfo_->emitLoopHead(bce_, Nothing(), SRC_FOR_OF)) {
+  if (!loopInfo_->emitLoopHead(bce_, Nothing())) {
     //              [stack] NEXT ITER UNDEF
     return false;
   }
 
   // If the loop had an escaping lexical declaration, replace the current
   // environment with an dead zoned one to implement TDZ semantics.
   if (headLexicalEmitterScope_) {
     // The environment chain only includes an environment for the for-of
--- a/js/src/frontend/SourceNotes.h
+++ b/js/src/frontend/SourceNotes.h
@@ -67,31 +67,31 @@ class SrcNote {
       Count
     };
   };
 };
 
 // clang-format off
 #define FOR_EACH_SRC_NOTE_TYPE(M)                                                                  \
     M(SRC_NULL,         "null",        0)  /* Terminates a note vector. */                         \
-    M(SRC_FOR,          "for",         0)  /* JSOP_LOOPHEAD is for C-style for-loop. */            \
-    M(SRC_WHILE,        "while",       0)  /* JSOP_LOOPHEAD is for while loop. */                  \
-    M(SRC_DO_WHILE,     "do-while",    0)  /* JSOP_LOOPHEAD is for do-while loop. */               \
-    M(SRC_FOR_IN,       "for-in",      0)  /* JSOP_LOOPHEAD is for for-in loop. */                 \
-    M(SRC_FOR_OF,       "for-of",      0)  /* JSOP_LOOPHEAD is for for-of loop. */                 \
     M(SRC_ASSIGNOP,     "assignop",    0)  /* += or another assign-op follows. */                  \
     M(SRC_CLASS_SPAN,   "class",       2)  /* The starting and ending offsets for the class, used  \
                                               for toString correctness for default ctors. */       \
     M(SRC_TRY,          "try",         SrcNote::Try::Count) \
     /* All notes above here are "gettable".  See SN_IS_GETTABLE below. */                          \
     M(SRC_COLSPAN,      "colspan",     SrcNote::ColSpan::Count) \
     M(SRC_NEWLINE,      "newline",     0)  /* Bytecode follows a source newline. */                \
     M(SRC_SETLINE,      "setline",     SrcNote::SetLine::Count) \
     M(SRC_BREAKPOINT,   "breakpoint",  0)  /* Bytecode is a recommended breakpoint. */             \
     M(SRC_STEP_SEP,     "step-sep",    0)  /* Bytecode is the first in a new steppable area. */    \
+    M(SRC_UNUSED9,      "unused",      0) \
+    M(SRC_UNUSED10,     "unused",      0) \
+    M(SRC_UNUSED11,     "unused",      0) \
+    M(SRC_UNUSED12,     "unused",      0) \
+    M(SRC_UNUSED13,     "unused",      0) \
     M(SRC_UNUSED14,     "unused",      0) \
     M(SRC_UNUSED15,     "unused",      0) \
     M(SRC_UNUSED16,     "unused",      0) \
     M(SRC_UNUSED17,     "unused",      0) \
     M(SRC_UNUSED18,     "unused",      0) \
     M(SRC_UNUSED19,     "unused",      0) \
     M(SRC_UNUSED20,     "unused",      0) \
     M(SRC_UNUSED21,     "unused",      0) \
--- a/js/src/frontend/WhileEmitter.cpp
+++ b/js/src/frontend/WhileEmitter.cpp
@@ -37,17 +37,17 @@ bool WhileEmitter::emitCond(const Maybe<
     // Emit a NOP to ensure the source position is not part of the loop.
     if (!bce_->emit1(JSOP_NOP)) {
       return false;
     }
   }
 
   loopInfo_.emplace(bce_, StatementKind::WhileLoop);
 
-  if (!loopInfo_->emitLoopHead(bce_, condPos, SRC_WHILE)) {
+  if (!loopInfo_->emitLoopHead(bce_, condPos)) {
     return false;
   }
 
 #ifdef DEBUG
   state_ = State::Cond;
 #endif
   return true;
 }
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3047,21 +3047,16 @@ static MOZ_MUST_USE bool SrcNotes(JSCont
     }
 
     switch (type) {
       case SRC_NULL:
       case SRC_ASSIGNOP:
       case SRC_BREAKPOINT:
       case SRC_STEP_SEP:
       case SRC_XDELTA:
-      case SRC_FOR:
-      case SRC_DO_WHILE:
-      case SRC_WHILE:
-      case SRC_FOR_IN:
-      case SRC_FOR_OF:
         break;
 
       case SRC_COLSPAN:
         colspan =
             SN_OFFSET_TO_COLSPAN(GetSrcNoteOffset(sn, SrcNote::ColSpan::Span));
         if (!sp->jsprintf("%d", colspan)) {
           return false;
         }