bug 447762 - merging var and local JS bytecodes. r=brendan

This commit is contained in:
Igor Bukanov 2008-08-06 16:13:22 +02:00
Родитель 172e0f3f9f
Коммит 1acde4060e
7 изменённых файлов: 136 добавлений и 148 удалений

Просмотреть файл

@ -1971,14 +1971,14 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JS_ASSERT(localKind == JSLOCAL_VAR ||
localKind == JSLOCAL_CONST);
switch (op) {
case JSOP_NAME: op = JSOP_GETVAR; break;
case JSOP_SETNAME: op = JSOP_SETVAR; break;
case JSOP_SETCONST: op = JSOP_SETVAR; break;
case JSOP_INCNAME: op = JSOP_INCVAR; break;
case JSOP_NAMEINC: op = JSOP_VARINC; break;
case JSOP_DECNAME: op = JSOP_DECVAR; break;
case JSOP_NAMEDEC: op = JSOP_VARDEC; break;
case JSOP_FORNAME: op = JSOP_FORVAR; break;
case JSOP_NAME: op = JSOP_GETLOCAL; break;
case JSOP_SETNAME: op = JSOP_SETLOCAL; break;
case JSOP_SETCONST: op = JSOP_SETLOCAL; break;
case JSOP_INCNAME: op = JSOP_INCLOCAL; break;
case JSOP_NAMEINC: op = JSOP_LOCALINC; break;
case JSOP_DECNAME: op = JSOP_DECLOCAL; break;
case JSOP_NAMEDEC: op = JSOP_LOCALDEC; break;
case JSOP_FORNAME: op = JSOP_FORLOCAL; break;
case JSOP_DELNAME: op = JSOP_FALSE; break;
default: JS_ASSERT(0);
}
@ -2211,9 +2211,6 @@ EmitNameOp(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
case JSOP_NAME:
op = JSOP_CALLNAME;
break;
case JSOP_GETVAR:
op = JSOP_CALLVAR;
break;
case JSOP_GETGVAR:
op = JSOP_CALLGVAR;
break;
@ -2295,7 +2292,6 @@ EmitPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg,
* Try to optimize:
* - arguments.length into JSOP_ARGCNT
* - argname.prop into JSOP_GETARGPROP
* - varname.prop into JSOP_GETVARPROP
* - localname.prop into JSOP_GETLOCALPROP
*/
if (!BindNameToSlot(cx, cg, pn2))
@ -2309,9 +2305,6 @@ EmitPropOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg,
case JSOP_GETARG:
op = JSOP_GETARGPROP;
goto do_indexconst;
case JSOP_GETVAR:
op = JSOP_GETVARPROP;
goto do_indexconst;
case JSOP_GETLOCAL:
op = JSOP_GETLOCALPROP;
do_indexconst: {
@ -3311,7 +3304,6 @@ EmitDestructuringLHS(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
break;
case JSOP_SETARG:
case JSOP_SETVAR:
case JSOP_SETGVAR:
slot = (jsuint) pn->pn_slot;
EMIT_UINT16_IMM_OP(PN_OP(pn), slot);
@ -4350,8 +4342,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
switch (op) {
case JSOP_GETARG: /* FALL THROUGH */
case JSOP_SETARG: op = JSOP_FORARG; break;
case JSOP_GETVAR: /* FALL THROUGH */
case JSOP_SETVAR: op = JSOP_FORVAR; break;
case JSOP_GETGVAR: /* FALL THROUGH */
case JSOP_SETGVAR: op = JSOP_FORNAME; break;
case JSOP_GETLOCAL: /* FALL THROUGH */
@ -4366,7 +4356,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
}
if (pn3->pn_slot >= 0) {
if (pn3->pn_const) {
JS_ASSERT(op == JSOP_FORVAR);
JS_ASSERT(op == JSOP_FORLOCAL);
op = JSOP_FORCONST;
}
atomIndex = (jsatomid) pn3->pn_slot;
@ -5397,9 +5387,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
? JSOP_GETGVAR
: (pn2->pn_op == JSOP_SETARG)
? JSOP_GETARG
: (pn2->pn_op == JSOP_SETLOCAL)
? JSOP_GETLOCAL
: JSOP_GETVAR,
: JSOP_GETLOCAL,
atomIndex);
break;
}
@ -5718,7 +5706,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
/* Incrementing a declared const: just get its value. */
op = (JOF_OPTYPE(op) == JOF_ATOM)
? JSOP_GETGVAR
: JSOP_GETVAR;
: JSOP_GETLOCAL;
}
atomIndex = (jsatomid) pn2->pn_slot;
EMIT_UINT16_IMM_OP(op, atomIndex);

Просмотреть файл

@ -2468,7 +2468,7 @@ JS_STATIC_ASSERT(!CAN_DO_FAST_INC_DEC(INT_TO_JSVAL(JSVAL_INT_MAX)));
* is named by the JS_OPMETER_FILE envariable, and defaults to /tmp/ops.dot.
*
* Bonus feature: JS_OPMETER also enables counters for stack-addressing ops
* such as JSOP_GETVAR, JSOP_INCARG, via METER_SLOT_OP. The resulting counts
* such as JSOP_GETLOCAL, JSOP_INCARG, via METER_SLOT_OP. The resulting counts
* are written to JS_OPMETER_HIST, defaulting to /tmp/ops.hist.
*/
#ifndef JS_OPMETER
@ -2521,7 +2521,6 @@ JS_STATIC_ASSERT(JSOP_INTERRUPT == 0);
*/
JS_STATIC_ASSERT(JSOP_NAME_LENGTH == JSOP_CALLNAME_LENGTH);
JS_STATIC_ASSERT(JSOP_GETGVAR_LENGTH == JSOP_CALLGVAR_LENGTH);
JS_STATIC_ASSERT(JSOP_GETVAR_LENGTH == JSOP_CALLVAR_LENGTH);
JS_STATIC_ASSERT(JSOP_GETARG_LENGTH == JSOP_CALLARG_LENGTH);
JS_STATIC_ASSERT(JSOP_GETLOCAL_LENGTH == JSOP_CALLLOCAL_LENGTH);
JS_STATIC_ASSERT(JSOP_XMLNAME_LENGTH == JSOP_CALLXMLNAME_LENGTH);
@ -3170,13 +3169,12 @@ js_Interpret(JSContext *cx)
/* FALL THROUGH */
BEGIN_CASE(JSOP_FORARG)
BEGIN_CASE(JSOP_FORVAR)
BEGIN_CASE(JSOP_FORCONST)
BEGIN_CASE(JSOP_FORLOCAL)
/*
* JSOP_FORARG, JSOP_FORVAR, JSOP_FORLOCAL don't require any lval
* computation here, because they address slots on the stack (in
* fp->args and fp->slots, respectively).
* These bytecodes don't require any lval computation here,
* because they address slots on the stack (in fp->args or
* fp->slots).
*/
/* FALL THROUGH */
@ -3214,7 +3212,6 @@ js_Interpret(JSContext *cx)
break;
case JSOP_FORLOCAL:
case JSOP_FORVAR:
slot = GET_SLOTNO(regs.pc);
JS_ASSERT(slot < fp->script->nslots);
vp = &fp->slots[slot];
@ -4098,15 +4095,11 @@ js_Interpret(JSContext *cx)
goto do_int_fast_incop;
BEGIN_CASE(JSOP_DECLOCAL)
BEGIN_CASE(JSOP_DECVAR)
incr = -2; incr2 = -2; goto do_local_incop;
BEGIN_CASE(JSOP_LOCALDEC)
BEGIN_CASE(JSOP_VARDEC)
incr = -2; incr2 = 0; goto do_local_incop;
BEGIN_CASE(JSOP_INCLOCAL)
BEGIN_CASE(JSOP_INCVAR)
incr = 2; incr2 = 2; goto do_local_incop;
BEGIN_CASE(JSOP_VARINC)
BEGIN_CASE(JSOP_LOCALINC)
incr = 2; incr2 = 0;
@ -4224,7 +4217,6 @@ js_Interpret(JSContext *cx)
goto do_getprop_body;
BEGIN_CASE(JSOP_GETLOCALPROP)
BEGIN_CASE(JSOP_GETVARPROP)
i = SLOTNO_LEN;
slot = GET_SLOTNO(regs.pc);
JS_ASSERT(slot < script->nslots);
@ -5540,28 +5532,25 @@ js_Interpret(JSContext *cx)
END_SET_CASE(JSOP_SETARG)
BEGIN_CASE(JSOP_GETLOCAL)
BEGIN_CASE(JSOP_GETVAR)
slot = GET_SLOTNO(regs.pc);
JS_ASSERT(slot < script->nslots);
PUSH_OPND(fp->slots[slot]);
END_CASE(JSOP_GETVAR)
END_CASE(JSOP_GETLOCAL)
BEGIN_CASE(JSOP_CALLLOCAL)
BEGIN_CASE(JSOP_CALLVAR)
slot = GET_SLOTNO(regs.pc);
JS_ASSERT(slot < script->nslots);
PUSH_OPND(fp->slots[slot]);
PUSH_OPND(JSVAL_NULL);
END_CASE(JSOP_GETVAR)
END_CASE(JSOP_CALLLOCAL)
BEGIN_CASE(JSOP_SETLOCAL)
BEGIN_CASE(JSOP_SETVAR)
slot = GET_SLOTNO(regs.pc);
JS_ASSERT(slot < script->nslots);
vp = &fp->slots[slot];
GC_POKE(cx, *vp);
*vp = FETCH_OPND(-1);
END_SET_CASE(JSOP_SETVAR)
END_SET_CASE(JSOP_SETLOCAL)
BEGIN_CASE(JSOP_GETGVAR)
BEGIN_CASE(JSOP_CALLGVAR)
@ -6818,7 +6807,16 @@ js_Interpret(JSContext *cx)
# endif
L_JSOP_UNUSED186:
L_JSOP_UNUSED201:
L_JSOP_UNUSED202:
L_JSOP_UNUSED203:
L_JSOP_UNUSED204:
L_JSOP_UNUSED205:
L_JSOP_UNUSED206:
L_JSOP_UNUSED207:
L_JSOP_UNUSED213:
L_JSOP_UNUSED219:
L_JSOP_UNUSED226:
#else /* !JS_THREADED_INTERP */
default:

Просмотреть файл

@ -321,7 +321,6 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
break;
case JOF_UINT16:
case JOF_LOCAL:
i = (jsint)GET_UINT16(pc);
goto print_int;
@ -388,7 +387,7 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
fprintf(fp, " %u", GET_ARGNO(pc));
break;
case JOF_QVAR:
case JOF_LOCAL:
fprintf(fp, " %u", GET_SLOTNO(pc));
break;
@ -1177,20 +1176,12 @@ DecompileSwitch(SprintStack *ss, TableEntry *table, uintN tableLength,
JS_END_MACRO
static JSAtom *
GetSlotAtom(JSPrinter *jp, JSBool argument, uintN slot)
GetArgOrVarAtom(JSPrinter *jp, uintN slot)
{
JSFunction *fun;
JSAtom *name;
fun = jp->fun;
LOCAL_ASSERT_RV(jp->fun, NULL);
LOCAL_ASSERT_RV(jp->localNames, NULL);
if (argument) {
LOCAL_ASSERT_RV(slot < fun->nargs, NULL);
} else {
LOCAL_ASSERT_RV(slot < fun->u.i.nvars, NULL);
slot += fun->nargs;
}
LOCAL_ASSERT_RV(slot < JS_GET_LOCAL_NAME_COUNT(jp->fun), NULL);
name = JS_LOCAL_NAME_TO_ATOM(jp->localNames[slot]);
#if !JS_HAS_DESTRUCTURING
LOCAL_ASSERT_RV(name, NULL);
@ -1258,6 +1249,25 @@ GetLocal(SprintStack *ss, jsint i)
#define LOCAL_ASSERT(expr) LOCAL_ASSERT_RV(expr, NULL)
#define LOAD_OP_DATA(pc) (oplen = (cs = &js_CodeSpec[op=(JSOp)*pc])->length)
static JSBool
IsVarSlot(JSPrinter *jp, jsbytecode *pc, jsint *indexp)
{
uintN slot;
slot = GET_SLOTNO(pc);
if (slot < jp->script->nfixed) {
/* The slot refers to a variable with name stored in jp->localNames. */
*indexp = jp->fun->nargs + slot;
return JS_TRUE;
}
/* We have a local which index is relative to the stack base. */
slot -= jp->script->nfixed;
JS_ASSERT(slot < StackDepth(jp->script));
*indexp = slot;
return JS_FALSE;
}
static jsbytecode *
DecompileDestructuring(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc);
@ -1269,7 +1279,8 @@ DecompileDestructuringLHS(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc,
JSPrinter *jp;
JSOp op;
const JSCodeSpec *cs;
uintN oplen, i;
uintN oplen;
jsint i;
const char *lval, *xval;
ptrdiff_t todo;
JSAtom *atom;
@ -1300,23 +1311,24 @@ DecompileDestructuringLHS(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc,
break;
case JSOP_SETARG:
case JSOP_SETVAR:
case JSOP_SETGVAR:
case JSOP_SETLOCAL:
LOCAL_ASSERT(pc[oplen] == JSOP_POP || pc[oplen] == JSOP_POPN);
/* FALL THROUGH */
case JSOP_SETLOCALPOP:
i = GET_SLOTNO(pc);
atom = NULL;
lval = NULL;
if (op == JSOP_SETARG || op == JSOP_SETVAR) {
atom = GetSlotAtom(jp, op == JSOP_SETARG, i);
if (op == JSOP_SETARG) {
atom = GetArgOrVarAtom(jp, GET_SLOTNO(pc));
LOCAL_ASSERT(atom);
} else if (op == JSOP_SETGVAR) {
GET_ATOM_FROM_BYTECODE(jp->script, pc, 0, atom);
} else if (IsVarSlot(jp, pc, &i)) {
atom = GetArgOrVarAtom(jp, i);
LOCAL_ASSERT(atom);
} else {
lval = GetLocal(ss, i - jp->script->nfixed);
lval = GetLocal(ss, i);
}
if (atom)
lval = js_AtomToPrintableString(cx, atom);
@ -1846,14 +1858,12 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
/*
* JOF_NAME does not imply JOF_ATOM, so we must check for
* the QARG and QVAR format types, and translate those to
* JSOP_GETARG or JSOP_GETVAR appropriately, instead of to
* JSOP_NAME.
* JSOP_GETARG or JSOP_GETLOCAL appropriately, instead of
* to JSOP_NAME.
*/
type = JOF_TYPE(format);
op = (type == JOF_QARG)
? JSOP_GETARG
: (type == JOF_QVAR)
? JSOP_GETVAR
: (type == JOF_LOCAL)
? JSOP_GETLOCAL
: JSOP_NAME;
@ -1903,7 +1913,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
* of the property accessed via |this|, so do not
* rewrite op to JSOP_THIS.
*
* The next three cases should not change op if
* The next two cases should not change op if
* js_DecompileValueGenerator was called from the
* the property getter. They should rewrite only
* if the base object in the arg/var/local is null
@ -1913,9 +1923,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
case JSOP_GETARGPROP:
op = JSOP_GETARG;
break;
case JSOP_GETVARPROP:
op = JSOP_GETVAR;
break;
case JSOP_GETLOCALPROP:
op = JSOP_GETLOCAL;
break;
@ -2688,7 +2695,11 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
case JSOP_CALLLOCAL:
case JSOP_GETLOCAL:
i = GET_SLOTNO(pc) - jp->script->nfixed;
if (IsVarSlot(jp, pc, &i)) {
atom = GetArgOrVarAtom(jp, i);
LOCAL_ASSERT(atom);
goto do_name;
}
LOCAL_ASSERT((uintN)i < ss->top);
sn = js_GetSrcNote(jp->script, pc);
@ -2709,29 +2720,35 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
case JSOP_SETLOCAL:
case JSOP_SETLOCALPOP:
i = GET_SLOTNO(pc) - jp->script->nfixed;
if (IsVarSlot(jp, pc, &i)) {
atom = GetArgOrVarAtom(jp, i);
LOCAL_ASSERT(atom);
goto do_setname;
}
lval = GetStr(ss, i);
rval = POP_STR();
goto do_setlval;
case JSOP_INCLOCAL:
case JSOP_DECLOCAL:
i = GET_SLOTNO(pc) - jp->script->nfixed;
if (IsVarSlot(jp, pc, &i)) {
atom = GetArgOrVarAtom(jp, i);
LOCAL_ASSERT(atom);
goto do_incatom;
}
lval = GetLocal(ss, i);
goto do_inclval;
case JSOP_LOCALINC:
case JSOP_LOCALDEC:
i = GET_SLOTNO(pc) - jp->script->nfixed;
if (IsVarSlot(jp, pc, &i)) {
atom = GetArgOrVarAtom(jp, i);
LOCAL_ASSERT(atom);
goto do_atominc;
}
lval = GetLocal(ss, i);
goto do_lvalinc;
case JSOP_FORLOCAL:
i = GET_SLOTNO(pc) - jp->script->nfixed;
lval = GetStr(ss, i);
atom = NULL;
goto do_forlvalinloop;
case JSOP_RETRVAL:
todo = -2;
break;
@ -3079,15 +3096,21 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
goto do_logical_connective;
case JSOP_FORARG:
atom = GetSlotAtom(jp, JS_TRUE, GET_ARGNO(pc));
atom = GetArgOrVarAtom(jp, GET_ARGNO(pc));
LOCAL_ASSERT(atom);
goto do_fornameinloop;
case JSOP_FORVAR:
case JSOP_FORCONST:
atom = GetSlotAtom(jp, JS_FALSE, GET_SLOTNO(pc));
LOCAL_ASSERT(atom);
goto do_fornameinloop;
case JSOP_FORLOCAL:
if (IsVarSlot(jp, pc, &i)) {
atom = GetArgOrVarAtom(jp, i);
LOCAL_ASSERT(atom);
goto do_fornameinloop;
}
JS_ASSERT(op == JSOP_FORLOCAL);
lval = GetStr(ss, i);
atom = NULL;
goto do_forlvalinloop;
case JSOP_FORNAME:
LOAD_ATOM(0);
@ -3314,12 +3337,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
break;
case JSOP_SETARG:
atom = GetSlotAtom(jp, JS_TRUE, GET_ARGNO(pc));
LOCAL_ASSERT(atom);
goto do_setname;
case JSOP_SETVAR:
atom = GetSlotAtom(jp, JS_FALSE, GET_SLOTNO(pc));
atom = GetArgOrVarAtom(jp, GET_ARGNO(pc));
LOCAL_ASSERT(atom);
goto do_setname;
@ -3494,13 +3512,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
case JSOP_INCARG:
case JSOP_DECARG:
atom = GetSlotAtom(jp, JS_TRUE, GET_ARGNO(pc));
LOCAL_ASSERT(atom);
goto do_incatom;
case JSOP_INCVAR:
case JSOP_DECVAR:
atom = GetSlotAtom(jp, JS_FALSE, GET_SLOTNO(pc));
atom = GetArgOrVarAtom(jp, GET_ARGNO(pc));
LOCAL_ASSERT(atom);
goto do_incatom;
@ -3556,13 +3568,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
case JSOP_ARGINC:
case JSOP_ARGDEC:
atom = GetSlotAtom(jp, JS_TRUE, GET_ARGNO(pc));
LOCAL_ASSERT(atom);
goto do_atominc;
case JSOP_VARINC:
case JSOP_VARDEC:
atom = GetSlotAtom(jp, JS_FALSE, GET_SLOTNO(pc));
atom = GetArgOrVarAtom(jp, GET_ARGNO(pc));
LOCAL_ASSERT(atom);
goto do_atominc;
@ -3644,10 +3650,11 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
break;
case JSOP_GETARGPROP:
case JSOP_GETVARPROP:
/* Get the name of the argument or variable. */
atom = GetSlotAtom(ss->printer, op == JSOP_GETARGPROP,
GET_UINT16(pc));
i = GET_ARGNO(pc);
do_getarg_prop:
atom = GetArgOrVarAtom(ss->printer, i);
LOCAL_ASSERT(atom);
LOCAL_ASSERT(ATOM_IS_STRING(atom));
lval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom), 0);
@ -3659,8 +3666,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
goto do_getprop;
case JSOP_GETLOCALPROP:
LOAD_ATOM(2);
i = GET_SLOTNO(pc) - jp->script->nfixed;
if (IsVarSlot(jp, pc, &i))
goto do_getarg_prop;
LOCAL_ASSERT((uintN)i < ss->top);
lval = GetLocal(ss, i);
if (!lval)
@ -3668,6 +3675,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
todo = SprintCString(&ss->sprinter, lval);
if (todo < 0 || !PushOff(ss, todo, op))
return NULL;
LOAD_ATOM(2);
goto do_getprop;
case JSOP_SETPROP:
@ -3756,7 +3764,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
case JSOP_CALLARG:
case JSOP_GETARG:
i = GET_ARGNO(pc);
atom = GetSlotAtom(jp, JS_TRUE, i);
atom = GetArgOrVarAtom(jp, i);
#if JS_HAS_DESTRUCTURING
if (!atom) {
todo = Sprint(&ss->sprinter, "%s[%d]", js_arguments_str, i);
@ -3767,12 +3775,6 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
#endif
goto do_name;
case JSOP_CALLVAR:
case JSOP_GETVAR:
atom = GetSlotAtom(jp, JS_FALSE, GET_SLOTNO(pc));
LOCAL_ASSERT(atom);
goto do_name;
case JSOP_CALLNAME:
case JSOP_NAME:
case JSOP_GETGVAR:
@ -4842,7 +4844,7 @@ js_DecompileFunction(JSPrinter *jp)
if (i > 0)
js_puts(jp, ", ");
param = GetSlotAtom(jp, JS_TRUE, i);
param = GetArgOrVarAtom(jp, i);
#if JS_HAS_DESTRUCTURING
#define LOCAL_ASSERT(expr) LOCAL_ASSERT_RV(expr, JS_FALSE)

Просмотреть файл

@ -70,7 +70,7 @@ typedef enum JSOp {
#define JOF_TABLESWITCH 4 /* table switch */
#define JOF_LOOKUPSWITCH 5 /* lookup switch */
#define JOF_QARG 6 /* quickened get/set function argument ops */
#define JOF_QVAR 7 /* quickened get/set local variable ops */
#define JOF_LOCAL 7 /* var or block-local variable */
#define JOF_SLOTATOM 8 /* uint16 slot index + constant pool index */
#define JOF_JUMPX 9 /* signed 32-bit jump offset immediate */
#define JOF_TABLESWITCHX 10 /* extended (32-bit offset) table switch */
@ -78,12 +78,11 @@ typedef enum JSOp {
#define JOF_UINT24 12 /* extended unsigned 24-bit literal (index) */
#define JOF_2BYTE 13 /* 2-byte opcode, e.g., upper 8 bits of 24-bit
atom index */
#define JOF_LOCAL 14 /* block-local operand stack variable */
#define JOF_INT32 14 /* int32 immediate operand */
#define JOF_OBJECT 15 /* unsigned 16-bit object pool index */
#define JOF_SLOTOBJECT 16 /* uint16 slot index + object pool index */
#define JOF_REGEXP 17 /* unsigned 16-bit regexp pool index */
#define JOF_INT8 18 /* int8 immediate operand */
#define JOF_INT32 19 /* int32 immediate operand */
#define JOF_TYPEMASK 0x001f /* mask for above immediate types */
#define JOF_NAME (1U<<5) /* name operation */
@ -235,7 +234,7 @@ JS_STATIC_ASSERT(sizeof(uint32) * JS_BITS_PER_BYTE >= INDEX_LIMIT_LOG2 + 1);
#define GET_ARGC(pc) GET_UINT16(pc)
#define ARGC_LIMIT UINT16_LIMIT
/* Synonyms for quick JOF_QARG and JOF_QVAR bytecodes. */
/* Synonyms for quick JOF_QARG and JOF_LOCAL bytecodes. */
#define GET_ARGNO(pc) GET_UINT16(pc)
#define SET_ARGNO(pc,argno) SET_UINT16(pc,argno)
#define ARGNO_LEN 2

Просмотреть файл

@ -110,9 +110,9 @@ OPDEF(JSOP_IFNE, 8, "ifne", NULL, 3, 1, 0, 0, JOF_JUMP|J
/* Get the arguments object for the current, lightweight function activation. */
OPDEF(JSOP_ARGUMENTS, 9, js_arguments_str, js_arguments_str, 1, 0, 1, 18, JOF_BYTE)
/* ECMA-compliant for-in loop with argument or local variable loop control. */
/* ECMA-compliant for-in loop with argument or local loop control. */
OPDEF(JSOP_FORARG, 10, "forarg", NULL, 3, 0, 1, 19, JOF_QARG|JOF_NAME|JOF_FOR)
OPDEF(JSOP_FORVAR, 11, "forvar", NULL, 3, 0, 1, 19, JOF_QVAR|JOF_NAME|JOF_FOR)
OPDEF(JSOP_FORLOCAL, 11, "forlocal", NULL, 3, 0, 1, 19, JOF_LOCAL|JOF_NAME|JOF_FOR)
/* More longstanding bytecodes. */
OPDEF(JSOP_DUP, 12, "dup", NULL, 1, 1, 2, 0, JOF_BYTE)
@ -209,8 +209,8 @@ OPDEF(JSOP_TRAP, 83, "trap", NULL, 1, 0, 0, 0, JOF_BYTE)
/* Fast get/set ops for function arguments and local variables. */
OPDEF(JSOP_GETARG, 84, "getarg", NULL, 3, 0, 1, 19, JOF_QARG |JOF_NAME)
OPDEF(JSOP_SETARG, 85, "setarg", NULL, 3, 1, 1, 3, JOF_QARG |JOF_NAME|JOF_SET)
OPDEF(JSOP_GETVAR, 86, "getvar", NULL, 3, 0, 1, 19, JOF_QVAR |JOF_NAME)
OPDEF(JSOP_SETVAR, 87, "setvar", NULL, 3, 1, 1, 3, JOF_QVAR |JOF_NAME|JOF_SET|JOF_DETECTING)
OPDEF(JSOP_GETLOCAL, 86,"getlocal", NULL, 3, 0, 1, 19, JOF_LOCAL|JOF_NAME)
OPDEF(JSOP_SETLOCAL, 87,"setlocal", NULL, 3, 1, 1, 3, JOF_LOCAL|JOF_NAME|JOF_SET|JOF_DETECTING)
/* Push unsigned 16-bit int constant. */
OPDEF(JSOP_UINT16, 88, "uint16", NULL, 3, 0, 1, 16, JOF_UINT16)
@ -223,15 +223,16 @@ OPDEF(JSOP_INITELEM, 92, "initelem", NULL, 1, 2, 0, 3, JOF_BYTE |
OPDEF(JSOP_DEFSHARP, 93, "defsharp", NULL, 3, 0, 0, 0, JOF_UINT16)
OPDEF(JSOP_USESHARP, 94, "usesharp", NULL, 3, 0, 1, 0, JOF_UINT16)
/* Fast inc/dec ops for args and local vars. */
/* Fast inc/dec ops for args and locals. */
OPDEF(JSOP_INCARG, 95, "incarg", NULL, 3, 0, 1, 15, JOF_QARG |JOF_NAME|JOF_INC)
OPDEF(JSOP_INCVAR, 96, "incvar", NULL, 3, 0, 1, 15, JOF_QVAR |JOF_NAME|JOF_INC)
OPDEF(JSOP_DECARG, 97, "decarg", NULL, 3, 0, 1, 15, JOF_QARG |JOF_NAME|JOF_DEC)
OPDEF(JSOP_DECVAR, 98, "decvar", NULL, 3, 0, 1, 15, JOF_QVAR |JOF_NAME|JOF_DEC)
OPDEF(JSOP_ARGINC, 99, "arginc", NULL, 3, 0, 1, 15, JOF_QARG |JOF_NAME|JOF_INC|JOF_POST)
OPDEF(JSOP_VARINC, 100,"varinc", NULL, 3, 0, 1, 15, JOF_QVAR |JOF_NAME|JOF_INC|JOF_POST)
OPDEF(JSOP_ARGDEC, 101,"argdec", NULL, 3, 0, 1, 15, JOF_QARG |JOF_NAME|JOF_DEC|JOF_POST)
OPDEF(JSOP_VARDEC, 102,"vardec", NULL, 3, 0, 1, 15, JOF_QVAR |JOF_NAME|JOF_DEC|JOF_POST)
OPDEF(JSOP_DECARG, 96, "decarg", NULL, 3, 0, 1, 15, JOF_QARG |JOF_NAME|JOF_DEC)
OPDEF(JSOP_ARGINC, 97, "arginc", NULL, 3, 0, 1, 15, JOF_QARG |JOF_NAME|JOF_INC|JOF_POST)
OPDEF(JSOP_ARGDEC, 98, "argdec", NULL, 3, 0, 1, 15, JOF_QARG |JOF_NAME|JOF_DEC|JOF_POST)
OPDEF(JSOP_INCLOCAL, 99, "inclocal", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_INC)
OPDEF(JSOP_DECLOCAL, 100,"declocal", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_DEC)
OPDEF(JSOP_LOCALINC, 101,"localinc", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_INC|JOF_POST)
OPDEF(JSOP_LOCALDEC, 102,"localdec", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_DEC|JOF_POST)
/*
* Initialize for-in iterator using the JSITER_* flag bits in this op's uint8
@ -461,18 +462,18 @@ OPDEF(JSOP_TYPEOFEXPR, 198,"typeofexpr", NULL, 1, 1, 1, 15, JOF_BYTE|J
*/
OPDEF(JSOP_ENTERBLOCK, 199,"enterblock", NULL, 3, 0, 0, 0, JOF_OBJECT)
OPDEF(JSOP_LEAVEBLOCK, 200,"leaveblock", NULL, 3, 0, 0, 0, JOF_UINT16)
OPDEF(JSOP_GETLOCAL, 201,"getlocal", NULL, 3, 0, 1, 19, JOF_LOCAL|JOF_NAME)
OPDEF(JSOP_SETLOCAL, 202,"setlocal", NULL, 3, 1, 1, 3, JOF_LOCAL|JOF_NAME|JOF_SET)
OPDEF(JSOP_INCLOCAL, 203,"inclocal", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_INC)
OPDEF(JSOP_DECLOCAL, 204,"declocal", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_DEC)
OPDEF(JSOP_LOCALINC, 205,"localinc", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_INC|JOF_POST)
OPDEF(JSOP_LOCALDEC, 206,"localdec", NULL, 3, 0, 1, 15, JOF_LOCAL|JOF_NAME|JOF_DEC|JOF_POST)
OPDEF(JSOP_FORLOCAL, 207,"forlocal", NULL, 3, 0, 1, 19, JOF_LOCAL|JOF_NAME|JOF_FOR)
OPDEF(JSOP_UNUSED201, 201,"unused201", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED202, 202,"unused202", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED203, 203,"unused203", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED204, 204,"unused204", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED205, 205,"unused205", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED206, 206,"unused206", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_UNUSED207, 207,"unused207", NULL, 1, 0, 0, 0, JOF_BYTE)
/*
* Iterator, generator, and array comprehension support.
*/
OPDEF(JSOP_FORCONST, 208,"forconst", NULL, 3, 0, 1, 19, JOF_QVAR|JOF_NAME|JOF_FOR)
OPDEF(JSOP_FORCONST, 208,"forconst", NULL, 3, 0, 1, 19, JOF_LOCAL|JOF_NAME|JOF_FOR)
OPDEF(JSOP_ENDITER, 209,"enditer", NULL, 1, 1, 0, 0, JOF_BYTE|JOF_TMPSLOT)
OPDEF(JSOP_GENERATOR, 210,"generator", NULL, 1, 0, 0, 0, JOF_BYTE)
OPDEF(JSOP_YIELD, 211,"yield", NULL, 1, 1, 1, 1, JOF_BYTE)
@ -492,12 +493,12 @@ OPDEF(JSOP_ENUMCONSTELEM, 214,"enumconstelem",NULL, 1, 3, 0, 3, JOF_BYTE|J
OPDEF(JSOP_LEAVEBLOCKEXPR,215,"leaveblockexpr",NULL, 3, 0, 0, 1, JOF_UINT16)
/*
* Optimize common JSOP_{THIS,GET{ARG,VAR,LOCAL}} -> JSOP_GETPROP cliches.
* Optimize common JSOP_{THIS,GET{ARG,LOCAL}} -> JSOP_GETPROP cliches.
*/
OPDEF(JSOP_GETTHISPROP, 216,"getthisprop", NULL, 3, 0, 1, 18, JOF_ATOM|JOF_VARPROP)
OPDEF(JSOP_GETARGPROP, 217,"getargprop", NULL, 5, 0, 1, 18, JOF_SLOTATOM|JOF_VARPROP)
OPDEF(JSOP_GETVARPROP, 218,"getvarprop", NULL, 5, 0, 1, 18, JOF_SLOTATOM|JOF_VARPROP)
OPDEF(JSOP_GETLOCALPROP, 219,"getlocalprop", NULL, 5, 0, 1, 18, JOF_SLOTATOM|JOF_VARPROP)
OPDEF(JSOP_GETLOCALPROP, 218,"getlocalprop", NULL, 5, 0, 1, 18, JOF_SLOTATOM|JOF_VARPROP)
OPDEF(JSOP_UNUSED219, 219,"unused219", NULL, 1, 0, 0, 0, JOF_BYTE)
/*
* Optimize atom segments 1-3. These must be followed by JSOP_RESETBASE0 after
@ -508,9 +509,9 @@ OPDEF(JSOP_INDEXBASE2, 221,"atombase2", NULL, 1, 0, 0, 0, JOF_BYTE |
OPDEF(JSOP_INDEXBASE3, 222,"atombase3", NULL, 1, 0, 0, 0, JOF_BYTE |JOF_INDEXBASE)
OPDEF(JSOP_CALLGVAR, 223, "callgvar", NULL, 3, 0, 2, 19, JOF_ATOM|JOF_NAME|JOF_CALLOP)
OPDEF(JSOP_CALLVAR, 224, "callvar", NULL, 3, 0, 2, 19, JOF_QVAR |JOF_NAME|JOF_CALLOP)
OPDEF(JSOP_CALLLOCAL, 224, "calllocal", NULL, 3, 0, 2, 19, JOF_LOCAL|JOF_NAME|JOF_CALLOP)
OPDEF(JSOP_CALLARG, 225, "callarg", NULL, 3, 0, 2, 19, JOF_QARG |JOF_NAME|JOF_CALLOP)
OPDEF(JSOP_CALLLOCAL, 226, "calllocal", NULL, 3, 0, 2, 19, JOF_LOCAL|JOF_NAME|JOF_CALLOP)
OPDEF(JSOP_UNUSED226, 226, "unused226", NULL, 1, 0, 1, 1, JOF_BYTE)
/*
* Opcodes to hold 8-bit and 32-bit immediate integer operands.

Просмотреть файл

@ -649,8 +649,8 @@ js_CompileScript(JSContext *cx, JSObject *obj, JSPrincipals *principals,
if (JOF_TYPE(cs->format) == JOF_LOCAL ||
(JOF_TYPE(cs->format) == JOF_SLOTATOM)) {
/*
* JSOP_GETARGPROP and JSOP_GETVARPROP also have JOF_SLOTATOM
* type, but they may be emitted only for a function.
* JSOP_GETARGPROP also has JOF_SLOTATOM type, but it may be
* emitted only for a function.
*/
JS_ASSERT((JOF_TYPE(cs->format) == JOF_SLOTATOM) ==
(op == JSOP_GETLOCALPROP));
@ -1200,7 +1200,7 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
* object property (it might also need the activation property, if the
* outer function contains with statements, e.g., but the stack slot
* wins when jsemit.c's BindNameToSlot can optimize a JSOP_NAME into a
* JSOP_GETVAR bytecode).
* JSOP_GETLOCAL bytecode).
*/
if (AT_TOP_LEVEL(tc) && (tc->flags & TCF_IN_FUNCTION)) {
JSLocalKind localKind;

Просмотреть файл

@ -202,7 +202,7 @@ JS_XDRFindClassById(JSXDRState *xdr, uint32 id);
* before deserialization of bytecode. If the saved version does not match
* the current version, abort deserialization and invalidate the file.
*/
#define JSXDR_BYTECODE_VERSION (0xb973c0de - 28)
#define JSXDR_BYTECODE_VERSION (0xb973c0de - 29)
/*
* Library-private functions.