Bug 922028 - Only intern iterator result object shapes in compileAndGo mode. r=jorendorff

This commit is contained in:
Andy Wingo 2013-09-30 12:53:20 +02:00
parent e50d55ac19
commit e5197f8a17

View File

@ -1798,9 +1798,30 @@ BytecodeEmitter::reportStrictModeError(ParseNode *pn, unsigned errorNumber, ...)
return result;
}
static bool
EmitNewInit(ExclusiveContext *cx, BytecodeEmitter *bce, JSProtoKey key)
{
const size_t len = 1 + UINT32_INDEX_LEN;
ptrdiff_t offset = EmitCheck(cx, bce, len);
if (offset < 0)
return false;
jsbytecode *code = bce->code(offset);
code[0] = JSOP_NEWINIT;
code[1] = jsbytecode(key);
code[2] = 0;
code[3] = 0;
code[4] = 0;
UpdateDepth(cx, bce, offset);
CheckTypeSet(cx, bce, JSOP_NEWINIT);
return true;
}
static bool
IteratorResultShape(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned *shape)
{
JS_ASSERT(bce->script->compileAndGo);
RootedObject obj(cx);
gc::AllocKind kind = GuessObjectGCKind(2);
obj = NewBuiltinClassInstance(cx, &JSObject::class_, kind);
@ -1829,10 +1850,14 @@ IteratorResultShape(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned *shape)
static bool
EmitPrepareIteratorResult(ExclusiveContext *cx, BytecodeEmitter *bce)
{
unsigned shape;
if (!IteratorResultShape(cx, bce, &shape))
return false;
return EmitIndex32(cx, JSOP_NEWOBJECT, shape, bce);
if (bce->script->compileAndGo) {
unsigned shape;
if (!IteratorResultShape(cx, bce, &shape))
return false;
return EmitIndex32(cx, JSOP_NEWOBJECT, shape, bce);
}
return EmitNewInit(cx, bce, JSProto_Object);
}
static bool
@ -3560,25 +3585,6 @@ EmitAssignment(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *lhs, JSOp
return true;
}
static bool
EmitNewInit(ExclusiveContext *cx, BytecodeEmitter *bce, JSProtoKey key, ParseNode *pn)
{
const size_t len = 1 + UINT32_INDEX_LEN;
ptrdiff_t offset = EmitCheck(cx, bce, len);
if (offset < 0)
return false;
jsbytecode *code = bce->code(offset);
code[0] = JSOP_NEWINIT;
code[1] = jsbytecode(key);
code[2] = 0;
code[3] = 0;
code[4] = 0;
UpdateDepth(cx, bce, offset);
CheckTypeSet(cx, bce, JSOP_NEWINIT);
return true;
}
bool
ParseNode::getConstantValue(ExclusiveContext *cx, bool strictChecks, MutableHandleValue vp)
{
@ -5635,7 +5641,7 @@ EmitObject(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
* property is added, as JSOP_SETELEM/JSOP_SETPROP would do.
*/
ptrdiff_t offset = bce->offset();
if (!EmitNewInit(cx, bce, JSProto_Object, pn))
if (!EmitNewInit(cx, bce, JSProto_Object))
return false;
/*
@ -5734,7 +5740,7 @@ EmitObject(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
static bool
EmitArrayComp(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
{
if (!EmitNewInit(cx, bce, JSProto_Array, pn))
if (!EmitNewInit(cx, bce, JSProto_Array))
return false;
/*