Bug 1143704 part 3 - Make EmitLoopHead return bool instead of ptrdiff_t. r=shu
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 21 Mar 2015 12:53:46 +0100
changeset 263762 a5b865279726ba669d0056280880ab8014807a3e
parent 263761 9afadd15061cff3ade5bfa862cb8679ea78ac655
child 263763 bf65c34bb34fab7771aefd9a0e656eef4d6952a4
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1143704
milestone39.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 1143704 part 3 - Make EmitLoopHead return bool instead of ptrdiff_t. r=shu
js/src/frontend/BytecodeEmitter.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -495,36 +495,33 @@ UpdateSourceCoordNotes(ExclusiveContext 
             return true;
         if (NewSrcNote2(cx, bce, SRC_COLSPAN, SN_COLSPAN_TO_OFFSET(colspan)) < 0)
             return false;
         bce->current->lastColumn = columnIndex;
     }
     return true;
 }
 
-static ptrdiff_t
+static bool
 EmitLoopHead(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *nextpn)
 {
     if (nextpn) {
         /*
          * Try to give the JSOP_LOOPHEAD the same line number as the next
          * instruction. nextpn is often a block, in which case the next
          * instruction typically comes from the first statement inside.
          */
         MOZ_ASSERT_IF(nextpn->isKind(PNK_STATEMENTLIST), nextpn->isArity(PN_LIST));
         if (nextpn->isKind(PNK_STATEMENTLIST) && nextpn->pn_head)
             nextpn = nextpn->pn_head;
         if (!UpdateSourceCoordNotes(cx, bce, nextpn->pn_pos.begin))
-            return -1;
-    }
-
-    ptrdiff_t offset = bce->offset();
-    if (!Emit1(cx, bce, JSOP_LOOPHEAD))
-        return -1;
-    return offset;
+            return false;
+    }
+
+    return Emit1(cx, bce, JSOP_LOOPHEAD);
 }
 
 static bool
 EmitLoopEntry(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *nextpn)
 {
     if (nextpn) {
         /* Update the line number, as for LOOPHEAD. */
         MOZ_ASSERT_IF(nextpn->isKind(PNK_STATEMENTLIST), nextpn->isArity(PN_LIST));
@@ -4975,17 +4972,17 @@ EmitForOf(ExclusiveContext *cx, Bytecode
     if (noteIndex < 0)
         return false;
     ptrdiff_t jmp = EmitJump(cx, bce, JSOP_GOTO, 0);
     if (jmp < 0)
         return false;
 
     top = bce->offset();
     SET_STATEMENT_TOP(&stmtInfo, top);
-    if (EmitLoopHead(cx, bce, nullptr) < 0)
+    if (!EmitLoopHead(cx, bce, nullptr))
         return false;
 
     if (type == STMT_SPREAD)
         bce->stackDepth++;
 
 #ifdef DEBUG
     int loopDepth = bce->stackDepth;
 #endif
@@ -5127,17 +5124,17 @@ EmitForIn(ExclusiveContext *cx, Bytecode
      * least one iteration, as the other loop forms do.
      */
     ptrdiff_t jmp = EmitJump(cx, bce, JSOP_GOTO, 0);
     if (jmp < 0)
         return false;
 
     top = bce->offset();
     SET_STATEMENT_TOP(&stmtInfo, top);
-    if (EmitLoopHead(cx, bce, nullptr) < 0)
+    if (!EmitLoopHead(cx, bce, nullptr))
         return false;
 
 #ifdef DEBUG
     int loopDepth = bce->stackDepth;
 #endif
 
     // Emit code to assign the enumeration value to the left hand side, but
     // also leave it on the stack.
@@ -5244,17 +5241,17 @@ EmitNormalFor(ExclusiveContext *cx, Byte
         if (op != JSOP_NOP && !Emit1(cx, bce, JSOP_NOP))
             return false;
     }
 
     top = bce->offset();
     SET_STATEMENT_TOP(&stmtInfo, top);
 
     /* Emit code for the loop body. */
-    if (EmitLoopHead(cx, bce, forBody) < 0)
+    if (!EmitLoopHead(cx, bce, forBody))
         return false;
     if (jmp == -1 && !EmitLoopEntry(cx, bce, forBody))
         return false;
     if (!EmitTree(cx, bce, forBody))
         return false;
 
     /* Set the second note offset so we can find the update part. */
     MOZ_ASSERT(noteIndex != -1);
@@ -5496,18 +5493,18 @@ EmitDo(ExclusiveContext *cx, BytecodeEmi
     if (noteIndex < 0 || !Emit1(cx, bce, JSOP_NOP))
         return false;
 
     ptrdiff_t noteIndex2 = NewSrcNote(cx, bce, SRC_WHILE);
     if (noteIndex2 < 0)
         return false;
 
     /* Compile the loop body. */
-    ptrdiff_t top = EmitLoopHead(cx, bce, pn->pn_left);
-    if (top < 0)
+    ptrdiff_t top = bce->offset();
+    if (!EmitLoopHead(cx, bce, pn->pn_left))
         return false;
 
     LoopStmtInfo stmtInfo(cx);
     PushLoopStatement(bce, &stmtInfo, STMT_DO_LOOP, top);
 
     if (!EmitLoopEntry(cx, bce, nullptr))
         return false;
 
@@ -5569,18 +5566,18 @@ EmitWhile(ExclusiveContext *cx, Bytecode
     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;
 
-    top = EmitLoopHead(cx, bce, pn->pn_right);
-    if (top < 0)
+    top = bce->offset();
+    if (!EmitLoopHead(cx, bce, pn->pn_right))
         return false;
 
     if (!EmitTree(cx, bce, pn->pn_right))
         return false;
 
     SetJumpOffsetAt(bce, jmp);
     if (!EmitLoopEntry(cx, bce, pn->pn_left))
         return false;