Bug 842419 (part 2) - Remove unnecessary SRC_CONTINUE notes, and kill off PNX_ENDCOMMA. r=jorendorff.

--HG--
extra : rebase_source : bd8c6665824d428aa7a01ff2d77ae872abaac282
This commit is contained in:
Nicholas Nethercote 2013-02-20 17:42:21 -08:00
parent 60cfd7d91a
commit dc67ecb627
4 changed files with 10 additions and 39 deletions

View File

@ -2823,12 +2823,7 @@ EmitDestructuringOpsHelper(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn,
index = 0;
for (pn2 = pn->pn_head; pn2; pn2 = pn2->pn_next) {
/*
* Duplicate the value being destructured to use as a reference base.
* If dup is not the first one, annotate it for the decompiler.
*/
if (pn2 != pn->pn_head && NewSrcNote(cx, bce, SRC_CONTINUE) < 0)
return false;
/* Duplicate the value being destructured to use as a reference base. */
if (Emit1(cx, bce, JSOP_DUP) < 0)
return false;
@ -4028,9 +4023,6 @@ EmitLet(JSContext *cx, BytecodeEmitter *bce, ParseNode *pnLet)
uint32_t alreadyPushed = unsigned(bce->stackDepth - letHeadDepth);
uint32_t blockObjCount = blockObj->slotCount();
for (uint32_t i = alreadyPushed; i < blockObjCount; ++i) {
/* Tell the decompiler not to print the decl in the let head. */
if (NewSrcNote(cx, bce, SRC_CONTINUE) < 0)
return false;
if (Emit1(cx, bce, JSOP_UNDEFINED) < 0)
return false;
}
@ -4262,12 +4254,8 @@ EmitForIn(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn, ptrdiff_t top)
if (Emit1(cx, bce, JSOP_ENDITER) < 0)
return false;
if (letDecl) {
/* Tell the decompiler to pop but not to print. */
if (NewSrcNote(cx, bce, SRC_CONTINUE) < 0)
return false;
if (letDecl)
EMIT_UINT16_IMM_OP(JSOP_POPN, blockObjCount);
}
return true;
}
@ -4513,8 +4501,6 @@ EmitFunc(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
JS_ASSERT(bi.frameIndex() < JS_BIT(20));
#endif
pn->pn_index = index;
if (NewSrcNote(cx, bce, SRC_CONTINUE) < 0)
return false;
if (!EmitIndexOp(cx, JSOP_LAMBDA, index, bce))
return false;
JS_ASSERT(pn->getOp() == JSOP_GETLOCAL || pn->getOp() == JSOP_GETARG);
@ -5470,18 +5456,10 @@ EmitArray(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
}
JS_ASSERT(atomIndex == pn->pn_count);
if (nspread) {
if (NewSrcNote(cx, bce, SRC_CONTINUE) < 0)
return false;
if (Emit1(cx, bce, JSOP_POP) < 0)
return false;
}
if (pn->pn_xflags & PNX_ENDCOMMA) {
/* Emit a source note so we know to decompile an extra comma. */
if (NewSrcNote(cx, bce, SRC_CONTINUE) < 0)
return false;
}
/* Emit an op to finish the array and aid in decompilation. */
return Emit1(cx, bce, JSOP_ENDINIT) >= 0;
}

View File

@ -267,11 +267,7 @@ enum SrcNoteType {
SRC_WHILE = 4, /* JSOP_GOTO to for or while loop condition
from before loop, else JSOP_NOP at top of
do-while loop */
SRC_CONTINUE = 5, /* JSOP_GOTO is a continue, not a break;
JSOP_ENDINIT needs extra comma at end of
array literal: [1,2,,];
JSOP_DUP continuing destructuring pattern;
JSOP_POP at end of for-in */
SRC_CONTINUE = 5, /* JSOP_GOTO is a continue, not a break */
SRC_PCDELTA = 7, /* distance forward from comma-operator to
next POP, or from CONDSWITCH to first CASE
opcode, etc. -- always a forward delta */

View File

@ -642,20 +642,19 @@ struct ParseNode {
needs popping */
#define PNX_FORINVAR 0x08 /* PNK_VAR is left kid of PNK_FORIN node
which is left kid of PNK_FOR */
#define PNX_ENDCOMMA 0x10 /* array literal has comma at end */
#define PNX_GROUPINIT 0x20 /* var [a, b] = [c, d]; unit list */
#define PNX_FUNCDEFS 0x40 /* contains top-level function statements */
#define PNX_SETCALL 0x80 /* call expression in lvalue context */
#define PNX_DESTRUCT 0x100 /* destructuring special cases:
#define PNX_GROUPINIT 0x10 /* var [a, b] = [c, d]; unit list */
#define PNX_FUNCDEFS 0x20 /* contains top-level function statements */
#define PNX_SETCALL 0x40 /* call expression in lvalue context */
#define PNX_DESTRUCT 0x80 /* destructuring special cases:
1. shorthand syntax used, at present
object destructuring ({x,y}) only;
2. code evaluating destructuring
arguments occurs before function
body */
#define PNX_SPECIALARRAYINIT 0x200 /* one or more of
#define PNX_SPECIALARRAYINIT 0x100 /* one or more of
1. array initialiser has holes
2. array initializer has spread node */
#define PNX_NONCONST 0x400 /* initialiser has non-constants */
#define PNX_NONCONST 0x200 /* initialiser has non-constants */
unsigned frameLevel() const {
JS_ASSERT(pn_arity == PN_CODE || pn_arity == PN_NAME);

View File

@ -5728,10 +5728,8 @@ Parser::primaryExpr(TokenKind tt)
}
tt = tokenStream.peekToken(TSF_OPERAND);
if (tt == TOK_RB) {
pn->pn_xflags |= PNX_ENDCOMMA;
if (tt == TOK_RB)
break;
}
if (tt == TOK_COMMA) {
/* So CURRENT_TOKEN gets TOK_COMMA and not TOK_LB. */