Bug 720316 - Introduce GET_UINT8 and SET_UINT8 helpers for bytecode immediate examination/setting. r=luke

--HG--
extra : rebase_source : 7413b96b2e1b048b78c37d6a7b0700d6b1d84874
This commit is contained in:
Jeff Walden 2012-01-17 17:55:27 -08:00
Родитель 321306d0cd
Коммит cc5c77dbed
6 изменённых файлов: 32 добавлений и 22 удалений

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

@ -3235,7 +3235,7 @@ EmitDestructuringOpsHelper(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn,
JS_ASSERT((bce->stackDepth - bce->stackDepth) >= -1);
uintN pickDistance = (uintN)((bce->stackDepth + 1) - depthBefore);
if (pickDistance > 0) {
if (pickDistance > jsbytecode(-1)) {
if (pickDistance > UINT8_MAX) {
ReportCompileErrorNumber(cx, bce->tokenStream(), pn3, JSREPORT_ERROR,
JSMSG_TOO_MANY_LOCALS);
return JS_FALSE;

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

@ -3257,7 +3257,7 @@ GetInitializerType(JSContext *cx, JSScript *script, jsbytecode *pc)
JSOp op = JSOp(*pc);
JS_ASSERT(op == JSOP_NEWARRAY || op == JSOP_NEWOBJECT || op == JSOP_NEWINIT);
bool isArray = (op == JSOP_NEWARRAY || (op == JSOP_NEWINIT && pc[1] == JSProto_Array));
bool isArray = (op == JSOP_NEWARRAY || (op == JSOP_NEWINIT && GET_UINT8(pc) == JSProto_Array));
return TypeScript::InitObject(cx, script, pc, isArray ? JSProto_Array : JSProto_Object);
}
@ -3562,7 +3562,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset,
case JSOP_SWAP:
case JSOP_PICK: {
unsigned pickedDepth = (op == JSOP_SWAP ? 1 : pc[1]);
unsigned pickedDepth = (op == JSOP_SWAP ? 1 : GET_UINT8(pc));
/* The last popped value is the last pushed. */
poppedTypes(pc, pickedDepth)->addSubset(cx, &pushed[pickedDepth]);
for (unsigned i = 0; i < pickedDepth; i++)
@ -4025,7 +4025,7 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset,
return false;
}
if (pc[1] & JSITER_FOREACH)
if (GET_UINT8(pc) & JSITER_FOREACH)
state.forTypes->addType(cx, Type::UnknownType());
else
state.forTypes->addType(cx, Type::StringType());

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

@ -2047,7 +2047,7 @@ END_CASE(JSOP_AND)
#define TRY_BRANCH_AFTER_COND(cond,spdec) \
JS_BEGIN_MACRO \
JS_ASSERT(js_CodeSpec[op].length == 1); \
uintN diff_ = (uintN) regs.pc[1] - (uintN) JSOP_IFEQ; \
uintN diff_ = (uintN) GET_UINT8(regs.pc) - (uintN) JSOP_IFEQ; \
if (diff_ <= 1) { \
regs.sp -= spdec; \
if (cond == (diff_ != 0)) { \
@ -2084,7 +2084,7 @@ END_CASE(JSOP_IN)
BEGIN_CASE(JSOP_ITER)
{
JS_ASSERT(regs.sp > regs.fp()->base());
uintN flags = regs.pc[1];
uint8_t flags = GET_UINT8(regs.pc);
if (!js_ValueToIterator(cx, flags, &regs.sp[-1]))
goto error;
CHECK_INTERRUPT_HANDLER();
@ -2155,10 +2155,10 @@ END_CASE(JSOP_SWAP)
BEGIN_CASE(JSOP_PICK)
{
jsint i = regs.pc[1];
JS_ASSERT(regs.sp - (i+1) >= regs.fp()->base());
Value lval = regs.sp[-(i+1)];
memmove(regs.sp - (i+1), regs.sp - i, sizeof(Value)*i);
unsigned i = GET_UINT8(regs.pc);
JS_ASSERT(regs.sp - (i + 1) >= regs.fp()->base());
Value lval = regs.sp[-int(i + 1)];
memmove(regs.sp - (i + 1), regs.sp - i, sizeof(Value) * i);
regs.sp[-1] = lval;
}
END_CASE(JSOP_PICK)
@ -3772,18 +3772,16 @@ END_CASE(JSOP_HOLE)
BEGIN_CASE(JSOP_NEWINIT)
{
jsint i = regs.pc[1];
uint8_t i = GET_UINT8(regs.pc);
JS_ASSERT(i == JSProto_Array || i == JSProto_Object);
JSObject *obj;
JSObject *obj;
if (i == JSProto_Array) {
obj = NewDenseEmptyArray(cx);
} else {
gc::AllocKind kind = GuessObjectGCKind(0);
obj = NewBuiltinClassInstance(cx, &ObjectClass, kind);
}
if (!obj)
goto error;

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

@ -695,7 +695,7 @@ js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc,
goto print_int;
case JOF_UINT8:
i = pc[1];
i = GET_UINT8(pc);
goto print_int;
case JOF_INT8:
@ -3868,7 +3868,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
break;
case JSOP_ITER:
foreach = (pc[1] & (JSITER_FOREACH | JSITER_KEYVALUE)) ==
foreach = (GET_UINT8(pc) & (JSITER_FOREACH | JSITER_KEYVALUE)) ==
JSITER_FOREACH;
todo = -2;
break;
@ -5150,7 +5150,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
case JSOP_NEWINIT:
{
i = pc[1];
i = GET_UINT8(pc);
LOCAL_ASSERT(i == JSProto_Array || i == JSProto_Object);
todo = ss->sprinter.getOffset();

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

@ -151,6 +151,18 @@ typedef enum JSOp {
* Immediate operand getters, setters, and bounds.
*/
static JS_ALWAYS_INLINE uint8_t
GET_UINT8(jsbytecode *pc)
{
return (uint8_t) pc[1];
}
static JS_ALWAYS_INLINE void
SET_UINT8(jsbytecode *pc, uint8_t u)
{
pc[1] = (jsbytecode) u;
}
/* Common uint16_t immediate format helpers. */
#define UINT16_LEN 2
#define UINT16_HI(i) ((jsbytecode)((i) >> 8))

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

@ -2259,12 +2259,12 @@ mjit::Compiler::generateMethod()
BEGIN_CASE(JSOP_PICK)
{
int32_t amt = GET_INT8(PC);
uint32_t amt = GET_UINT8(PC);
// Push -(amt + 1), say amt == 2
// Stack before: X3 X2 X1
// Stack after: X3 X2 X1 X3
frame.dupAt(-(amt + 1));
frame.dupAt(-int32_t(amt + 1));
// For each item X[i...1] push it then move it down.
// The above would transition like so:
@ -2272,7 +2272,7 @@ mjit::Compiler::generateMethod()
// X2 X2 X1 X3 (shift)
// X2 X2 X1 X3 X1 (dupAt)
// X2 X1 X1 X3 (shift)
for (int32_t i = -amt; i < 0; i++) {
for (int32_t i = -int32_t(amt); i < 0; i++) {
frame.dupAt(i - 1);
frame.shift(i - 2);
}
@ -2731,7 +2731,7 @@ mjit::Compiler::generateMethod()
END_CASE(JSOP_STRICTEQ)
BEGIN_CASE(JSOP_ITER)
if (!iter(PC[1]))
if (!iter(GET_UINT8(PC)))
return Compile_Error;
END_CASE(JSOP_ITER)
@ -6777,7 +6777,7 @@ mjit::Compiler::jsop_newinit()
JSObject *baseobj = NULL;
switch (*PC) {
case JSOP_NEWINIT:
isArray = (PC[1] == JSProto_Array);
isArray = (GET_UINT8(PC) == JSProto_Array);
break;
case JSOP_NEWARRAY:
isArray = true;