Bug 1467403 - Remove the source notes handling for prologue bytecode. r=jandem
authorTooru Fujisawa <arai_a@mac.com>
Mon, 11 Jun 2018 15:09:28 +0900
changeset 479015 09d892dcaca7f8700a08f14b3b075b769bd82c5d
parent 479014 29598a3b4cc09aef566178a33b3c5d7dbd36da17
child 479016 9941eb8c3b29d152851220b5d9791326c35e1c68
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1467403
milestone62.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 1467403 - Remove the source notes handling for prologue bytecode. r=jandem
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/BytecodeEmitter.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -11452,70 +11452,58 @@ BytecodeEmitter::setSrcNoteOffset(unsign
     return true;
 }
 
 bool
 BytecodeEmitter::finishTakingSrcNotes(uint32_t* out)
 {
     MOZ_ASSERT(current == &main);
 
-    unsigned prologueCount = prologue.notes.length();
-    if (prologueCount && prologue.currentLine != firstLine) {
-        switchToPrologue();
-        if (!newSrcNote2(SRC_SETLINE, ptrdiff_t(firstLine)))
-            return false;
-        switchToMain();
-    } else {
-        /*
-         * Either no prologue srcnotes, or no line number change over prologue.
-         * We don't need a SRC_SETLINE, but we may need to adjust the offset
-         * of the first main note, by adding to its delta and possibly even
-         * prepending SRC_XDELTA notes to it to account for prologue bytecodes
-         * that came at and after the last annotated bytecode.
-         */
-        ptrdiff_t offset = prologueOffset() - prologue.lastNoteOffset;
-        MOZ_ASSERT(offset >= 0);
-        if (offset > 0 && main.notes.length() != 0) {
-            /* NB: Use as much of the first main note's delta as we can. */
-            jssrcnote* sn = main.notes.begin();
-            ptrdiff_t delta = SN_IS_XDELTA(sn)
-                            ? SN_XDELTA_MASK - (*sn & SN_XDELTA_MASK)
-                            : SN_DELTA_MASK - (*sn & SN_DELTA_MASK);
-            if (offset < delta)
-                delta = offset;
-            for (;;) {
-                if (!addToSrcNoteDelta(sn, delta))
-                    return false;
-                offset -= delta;
-                if (offset == 0)
-                    break;
-                delta = Min(offset, SN_XDELTA_MASK);
-                sn = main.notes.begin();
-            }
-        }
-    }
-
-    // The prologue count might have changed, so we can't reuse prologueCount.
+    MOZ_ASSERT(prologue.notes.length() == 0);
+    MOZ_ASSERT(prologue.lastNoteOffset == 0);
+
+    // We may need to adjust the offset of the first main note, by adding to
+    // its delta and possibly even prepending SRC_XDELTA notes to it to account
+    // for prologue bytecodes.
+    ptrdiff_t offset = prologueOffset();
+    MOZ_ASSERT(offset >= 0);
+    if (offset > 0 && main.notes.length() != 0) {
+        // NB: Use as much of the first main note's delta as we can.
+        jssrcnote* sn = main.notes.begin();
+        ptrdiff_t delta = SN_IS_XDELTA(sn)
+                          ? SN_XDELTA_MASK - (*sn & SN_XDELTA_MASK)
+                          : SN_DELTA_MASK - (*sn & SN_DELTA_MASK);
+        if (offset < delta)
+            delta = offset;
+        for (;;) {
+            if (!addToSrcNoteDelta(sn, delta))
+                return false;
+            offset -= delta;
+            if (offset == 0)
+                break;
+            delta = Min(offset, SN_XDELTA_MASK);
+            sn = main.notes.begin();
+        }
+    }
+
     // The + 1 is to account for the final SN_MAKE_TERMINATOR that is appended
     // when the notes are copied to their final destination by copySrcNotes.
-    *out = prologue.notes.length() + main.notes.length() + 1;
+    *out = main.notes.length() + 1;
     return true;
 }
 
 void
 BytecodeEmitter::copySrcNotes(jssrcnote* destination, uint32_t nsrcnotes)
 {
-    unsigned prologueCount = prologue.notes.length();
+    MOZ_ASSERT(prologue.notes.length() == 0);
     unsigned mainCount = main.notes.length();
-    unsigned totalCount = prologueCount + mainCount;
-    MOZ_ASSERT(totalCount == nsrcnotes - 1);
-    if (prologueCount)
-        PodCopy(destination, prologue.notes.begin(), prologueCount);
-    PodCopy(destination + prologueCount, main.notes.begin(), mainCount);
-    SN_MAKE_TERMINATOR(&destination[totalCount]);
+    // nsrcnotes includes SN_MAKE_TERMINATOR in addition to main.notes.
+    MOZ_ASSERT(mainCount == nsrcnotes - 1);
+    PodCopy(destination, main.notes.begin(), mainCount);
+    SN_MAKE_TERMINATOR(&destination[mainCount]);
 }
 
 void
 CGConstList::finish(ConstArray* array)
 {
     MOZ_ASSERT(length() == array->length);
 
     for (unsigned i = 0; i < length(); i++)
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -433,17 +433,21 @@ struct MOZ_STACK_CLASS BytecodeEmitter
     BytecodeVector& code() const { return current->code; }
     jsbytecode* code(ptrdiff_t offset) const { return current->code.begin() + offset; }
     ptrdiff_t offset() const { return current->code.end() - current->code.begin(); }
     ptrdiff_t prologueOffset() const { return prologue.code.end() - prologue.code.begin(); }
     void switchToMain() { current = &main; }
     void switchToPrologue() { current = &prologue; }
     bool inPrologue() const { return current == &prologue; }
 
-    SrcNotesVector& notes() const { return current->notes; }
+    SrcNotesVector& notes() const {
+        // Prologue shouldn't have source notes.
+        MOZ_ASSERT(!inPrologue());
+        return current->notes;
+    }
     ptrdiff_t lastNoteOffset() const { return current->lastNoteOffset; }
     unsigned currentLine() const { return current->currentLine; }
 
     // Check if the last emitted opcode is a jump target.
     bool lastOpcodeIsJumpTarget() const {
         return offset() - current->lastTarget.offset == ptrdiff_t(JSOP_JUMPTARGET_LENGTH);
     }