Bug 703645 - rm SRC_LOOPHEAD (r=waldo)
authorLuke Wagner <luke@mozilla.com>
Tue, 22 Nov 2011 11:37:57 -0800
changeset 82708 5c3c5e4db3ad622a5d9ca6f8b7185fd48ea24d3d
parent 82707 04f576b81e1a94f874eb4b1d1989506ef41d826d
child 82709 b3785a68149100626331ea2fa1126ec29db8abb8
push id4072
push userlwagner@mozilla.com
push dateThu, 15 Dec 2011 21:05:17 +0000
treeherdermozilla-inbound@5c3c5e4db3ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs703645
milestone11.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 703645 - rm SRC_LOOPHEAD (r=waldo)
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/BytecodeEmitter.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -5533,20 +5533,16 @@ EmitForIn(JSContext *cx, BytecodeEmitter
     /*
      * Jump down to the loop condition to minimize overhead assuming at
      * least one iteration, as the other loop forms do.
      */
     ptrdiff_t jmp = EmitJump(cx, bce, JSOP_GOTO, 0);
     if (jmp < 0)
         return false;
 
-    intN noteIndex2 = NewSrcNote(cx, bce, SRC_LOOPHEAD);
-    if (noteIndex2 < 0)
-        return false;
-
     top = bce->offset();
     SET_STATEMENT_TOP(&stmtInfo, top);
     if (EmitTraceOp(cx, bce, NULL) < 0)
         return false;
 
 #ifdef DEBUG
     intN loopDepth = bce->stackDepth;
 #endif
@@ -5587,22 +5583,16 @@ EmitForIn(JSContext *cx, BytecodeEmitter
      */
     CHECK_AND_SET_JUMP_OFFSET_AT(cx, bce, jmp);
     if (Emit1(cx, bce, JSOP_MOREITER) < 0)
         return false;
     ptrdiff_t beq = EmitJump(cx, bce, JSOP_IFNE, top - bce->offset());
     if (beq < 0)
         return false;
 
-    /*
-     * Be careful: We must set noteIndex2 before noteIndex in case the noteIndex
-     * note gets bigger.
-     */
-    if (!SetSrcNoteOffset(cx, bce, (uintN)noteIndex2, 0, beq - top))
-        return false;
     /* Set the first srcnote offset so we can find the start of the loop body. */
     if (!SetSrcNoteOffset(cx, bce, (uintN)noteIndex, 0, tmp2 - jmp))
         return false;
     /* Set the second srcnote offset so we can find the closing jump. */
     if (!SetSrcNoteOffset(cx, bce, (uintN)noteIndex, 1, beq - jmp))
         return false;
 
     /* Now fixup all breaks and continues (before the JSOP_ENDITER). */
@@ -5674,20 +5664,16 @@ EmitNormalFor(JSContext *cx, BytecodeEmi
         jmp = EmitJump(cx, bce, JSOP_GOTO, 0);
         if (jmp < 0)
             return false;
     }
 
     top = bce->offset();
     SET_STATEMENT_TOP(&stmtInfo, top);
 
-    intN noteIndex2 = NewSrcNote(cx, bce, SRC_LOOPHEAD);
-    if (noteIndex2 < 0)
-        return false;
-
     /* Emit code for the loop body. */
     if (EmitTraceOp(cx, bce, forBody) < 0)
         return false;
     if (!EmitTree(cx, bce, forBody))
         return false;
 
     /* Set the second note offset so we can find the update part. */
     JS_ASSERT(noteIndex != -1);
@@ -5732,22 +5718,16 @@ EmitNormalFor(JSContext *cx, BytecodeEmi
         /* Fix up the goto from top to target the loop condition. */
         JS_ASSERT(jmp >= 0);
         CHECK_AND_SET_JUMP_OFFSET_AT(cx, bce, jmp);
 
         if (!EmitTree(cx, bce, forHead->pn_kid2))
             return false;
     }
 
-    /*
-     * Be careful: We must set noteIndex2 before noteIndex in case the noteIndex
-     * note gets bigger.
-     */
-    if (!SetSrcNoteOffset(cx, bce, (uintN)noteIndex2, 0, bce->offset() - top))
-        return false;
     /* Set the first note offset so we can find the loop condition. */
     if (!SetSrcNoteOffset(cx, bce, (uintN)noteIndex, 0, tmp3 - tmp))
         return false;
     if (!SetSrcNoteOffset(cx, bce, (uintN)noteIndex, 1, tmp2 - tmp))
         return false;
     /* The third note offset helps us find the loop-closing jump. */
     if (!SetSrcNoteOffset(cx, bce, (uintN)noteIndex, 2, bce->offset() - tmp))
         return false;
@@ -5903,17 +5883,17 @@ EmitFunc(JSContext *cx, BytecodeEmitter 
 static bool
 EmitDo(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
 {
     /* Emit an annotated nop so we know to decompile a 'do' keyword. */
     ptrdiff_t noteIndex = NewSrcNote(cx, bce, SRC_WHILE);
     if (noteIndex < 0 || Emit1(cx, bce, JSOP_NOP) < 0)
         return false;
 
-    ptrdiff_t noteIndex2 = NewSrcNote(cx, bce, SRC_LOOPHEAD);
+    ptrdiff_t noteIndex2 = NewSrcNote(cx, bce, SRC_WHILE);
     if (noteIndex2 < 0)
         return false;
 
     /* Compile the loop body. */
     ptrdiff_t top = EmitTraceOp(cx, bce, pn->pn_left);
     if (top < 0)
         return false;
 
@@ -5976,41 +5956,31 @@ EmitWhile(JSContext *cx, BytecodeEmitter
     ptrdiff_t noteIndex = NewSrcNote(cx, bce, SRC_WHILE);
     if (noteIndex < 0)
         return false;
 
     ptrdiff_t jmp = EmitJump(cx, bce, JSOP_GOTO, 0);
     if (jmp < 0)
         return false;
 
-    ptrdiff_t noteIndex2 = NewSrcNote(cx, bce, SRC_LOOPHEAD);
-    if (noteIndex2 < 0)
-        return false;
-
     top = EmitTraceOp(cx, bce, pn->pn_right);
     if (top < 0)
         return false;
 
     if (!EmitTree(cx, bce, pn->pn_right))
         return false;
 
     CHECK_AND_SET_JUMP_OFFSET_AT(cx, bce, jmp);
     if (!EmitTree(cx, bce, pn->pn_left))
         return false;
 
     ptrdiff_t beq = EmitJump(cx, bce, JSOP_IFNE, top - bce->offset());
     if (beq < 0)
         return false;
 
-    /*
-     * Be careful: We must set noteIndex2 before noteIndex in case the noteIndex
-     * note gets bigger.
-     */
-    if (!SetSrcNoteOffset(cx, bce, noteIndex2, 0, beq - top))
-        return false;
     if (!SetSrcNoteOffset(cx, bce, noteIndex, 0, beq - jmp))
         return false;
 
     return PopStatementBCE(cx, bce);
 }
 
 static bool
 EmitBreak(JSContext *cx, BytecodeEmitter *bce, PropertyName *label)
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -942,17 +942,16 @@ enum SrcNoteType {
     SRC_GENEXP      = 1,        /* JSOP_LAMBDA from generator expression */
     SRC_IF_ELSE     = 2,        /* JSOP_IFEQ bytecode is from an if-then-else */
     SRC_FOR_IN      = 2,        /* JSOP_GOTO to for-in loop condition from
                                    before loop (same arity as SRC_IF_ELSE) */
     SRC_FOR         = 3,        /* JSOP_NOP or JSOP_POP in for(;;) loop head */
     SRC_WHILE       = 4,        /* JSOP_GOTO to for or while loop condition
                                    from before loop, else JSOP_NOP at top of
                                    do-while loop */
-    SRC_LOOPHEAD    = 4,        /* For JSOP_LOOPHEAD; includes distance to loop end */
     SRC_CONTINUE    = 5,        /* JSOP_GOTO is a continue, not a break;
                                    also used on JSOP_ENDINIT if extra comma
                                    at end of array literal: [1,2,,];
                                    JSOP_DUP continuing destructuring pattern */
     SRC_DECL        = 6,        /* type of a declaration (var, const, let*) */
     SRC_DESTRUCT    = 6,        /* JSOP_DUP starting a destructuring assignment
                                    operation, with SRC_DECL_* offset operand */
     SRC_PCDELTA     = 7,        /* distance forward from comma-operator to