Bug 762324: write to the current address of the bytecode, r=jorendorff, a=akeybl
authorBenjamin Peterson <benjamin@python.org>
Mon, 09 Jul 2012 13:45:24 -0700
changeset 98358 3f11aed80c16eccbe471a2df640362594b3aa324
parent 98357 6e760e2a01a9d8daaa84d83fcd975affb7bb2b56
child 98359 b55b4ebc13267dfee9e9d947badc1c2068a00e52
push id1652
push usergkwong@mozilla.com
push dateMon, 09 Jul 2012 20:46:07 +0000
treeherdermozilla-aurora@3f11aed80c16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff, akeybl
bugs762324
milestone15.0a2
Bug 762324: write to the current address of the bytecode, r=jorendorff, a=akeybl
js/src/frontend/BytecodeEmitter.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -5830,32 +5830,32 @@ EmitDefaults(JSContext *cx, BytecodeEmit
     uint16_t ndefaults = bce->sc->funbox()->ndefaults;
     JSFunction *fun = bce->sc->fun();
     unsigned nformal = fun->nargs - fun->hasRest();
     EMIT_UINT16_IMM_OP(JSOP_ACTUALSFILLED, nformal - ndefaults);
     ptrdiff_t top = bce->offset();
     size_t tableSize = (size_t)(JUMP_OFFSET_LEN * (3 + ndefaults));
     if (EmitN(cx, bce, JSOP_TABLESWITCH, tableSize) < 0)
         return false;
-    jsbytecode *pc = bce->code(top + JUMP_OFFSET_LEN);
+    ptrdiff_t jumpoff = top + JUMP_OFFSET_LEN;
     JS_ASSERT(nformal >= ndefaults);
     uint16_t defstart = nformal - ndefaults;
-    SET_JUMP_OFFSET(pc, defstart);
-    pc += JUMP_OFFSET_LEN;
-    SET_JUMP_OFFSET(pc, nformal - 1);
-    pc += JUMP_OFFSET_LEN;
+    SET_JUMP_OFFSET(bce->code(jumpoff), defstart);
+    jumpoff += JUMP_OFFSET_LEN;
+    SET_JUMP_OFFSET(bce->code(jumpoff), nformal - 1);
+    jumpoff += JUMP_OFFSET_LEN;
 
     // Fill body of switch, which sets defaults where needed.
     unsigned i;
     ParseNode *arg, *pnlast = pn->last();
     for (arg = pn->pn_head, i = 0; arg != pnlast; arg = arg->pn_next, i++) {
         if (!(arg->pn_dflags & PND_DEFAULT))
             continue;
-        SET_JUMP_OFFSET(pc, bce->offset() - top);
-        pc += JUMP_OFFSET_LEN;
+        SET_JUMP_OFFSET(bce->code(jumpoff), bce->offset() - top);
+        jumpoff += JUMP_OFFSET_LEN;
         ParseNode *expr;
         if (arg->isKind(PNK_NAME)) {
             expr = arg->expr();
         } else {
             // The argument name is bound to a function. We still have to
             // evaluate the default in case it has side effects.
             JS_ASSERT(!arg->isDefn());
             JS_ASSERT(arg->isKind(PNK_ASSIGN));
@@ -5884,17 +5884,17 @@ EmitDefaults(JSContext *cx, BytecodeEmit
             // not. Only the decompiler is going to see it.
             if (!EmitUnaliasedVarOp(cx, JSOP_SETLOCAL, slot, bce))
                 return false;
             SET_JUMP_OFFSET(bce->code(hop), bce->offset() - hop);
         }
         if (Emit1(cx, bce, JSOP_POP) < 0)
             return false;
     }
-    JS_ASSERT(pc == bce->code(top + tableSize));
+    JS_ASSERT(jumpoff == top + ptrdiff_t(tableSize));
     SET_JUMP_OFFSET(bce->code(top), bce->offset() - top);
     return true;
 }
 
 JSBool
 frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
 {
     JS_CHECK_RECURSION(cx, return JS_FALSE);