diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index 4ef098dcd0b3..b1b4befeb5ea 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -278,8 +278,8 @@ frontend::Emit3(JSContext *cx, BytecodeEmitter *bce, JSOp op, jsbytecode op1, jsbytecode op2) { /* These should filter through EmitVarOp. */ - JS_ASSERT(JOF_OPTYPE(op) != JOF_QARG); - JS_ASSERT(JOF_OPTYPE(op) != JOF_LOCAL); + JS_ASSERT(!IsArgOp(op)); + JS_ASSERT(!IsLocalOp(op)); ptrdiff_t offset = EmitCheck(cx, bce, 3); @@ -917,11 +917,11 @@ EmitAliasedVarOp(JSContext *cx, JSOp op, ParseNode *pn, BytecodeEmitter *bce) } ScopeCoordinate sc; - if (JOF_OPTYPE(pn->getOp()) == JOF_QARG) { + if (IsArgOp(pn->getOp())) { sc.hops = skippedScopes + ClonedBlockDepth(bceOfDef); sc.slot = bceOfDef->sc->bindings.formalIndexToSlot(pn->pn_cookie.slot()); } else { - JS_ASSERT(JOF_OPTYPE(pn->getOp()) == JOF_LOCAL || pn->isKind(PNK_FUNCTION)); + JS_ASSERT(IsLocalOp(pn->getOp()) || pn->isKind(PNK_FUNCTION)); unsigned local = pn->pn_cookie.slot(); if (local < bceOfDef->sc->bindings.numVars()) { sc.hops = skippedScopes + ClonedBlockDepth(bceOfDef); @@ -946,7 +946,7 @@ static bool EmitVarOp(JSContext *cx, ParseNode *pn, JSOp op, BytecodeEmitter *bce) { JS_ASSERT(pn->isKind(PNK_FUNCTION) || pn->isKind(PNK_NAME)); - JS_ASSERT_IF(pn->isKind(PNK_NAME), JOF_OPTYPE(op) == JOF_QARG || JOF_OPTYPE(op) == JOF_LOCAL); + JS_ASSERT_IF(pn->isKind(PNK_NAME), IsArgOp(op) || IsLocalOp(op)); JS_ASSERT(!pn->pn_cookie.isFree()); if (!bce->isAliasedName(pn)) { @@ -970,7 +970,7 @@ static bool EmitVarIncDec(JSContext *cx, ParseNode *pn, JSOp op, BytecodeEmitter *bce) { JS_ASSERT(pn->isKind(PNK_NAME)); - JS_ASSERT(JOF_OPTYPE(op) == JOF_QARG || JOF_OPTYPE(op) == JOF_LOCAL); + JS_ASSERT(IsArgOp(op) || IsLocalOp(op)); JS_ASSERT(js_CodeSpec[op].format & (JOF_INC | JOF_DEC)); JS_ASSERT(!pn->pn_cookie.isFree()); @@ -2697,7 +2697,7 @@ MaybeEmitVarDecl(JSContext *cx, BytecodeEmitter *bce, JSOp prologOp, ParseNode * } if (bce->sc->inFunction() && - JOF_OPTYPE(pn->getOp()) == JOF_LOCAL && + IsLocalOp(pn->getOp()) && !pn->isLet() && bce->shouldNoteClosedName(pn)) { @@ -6130,7 +6130,7 @@ frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) continue; if (!BindNameToSlot(cx, bce, pn2)) return false; - if (JOF_OPTYPE(pn2->getOp()) == JOF_QARG && bce->shouldNoteClosedName(pn2)) { + if (IsArgOp(pn2->getOp()) && bce->shouldNoteClosedName(pn2)) { if (!bce->noteClosedArg(pn2)) return false; } diff --git a/js/src/jsopcode.h b/js/src/jsopcode.h index c14c3aa9ecb4..3491fe260d6b 100644 --- a/js/src/jsopcode.h +++ b/js/src/jsopcode.h @@ -486,6 +486,18 @@ FlowsIntoNext(JSOp op) op != JSOP_GOTO && op != JSOP_RETSUB; } +inline bool +IsArgOp(JSOp op) +{ + return JOF_OPTYPE(op) == JOF_QARG; +} + +inline bool +IsLocalOp(JSOp op) +{ + return JOF_OPTYPE(op) == JOF_LOCAL; +} + /* * Counts accumulated for a single opcode in a script. The counts tracked vary * between opcodes, and this structure ensures that counts are accessed in a