Bug 1146472 part 2. Use JSOP_NEWOBJECT as needed even if the script is not compile-and-go. r=luke

This commit is contained in:
Boris Zbarsky 2015-03-23 20:37:31 -04:00
Родитель 64eb476fc9
Коммит da29ffd385
1 изменённых файлов: 10 добавлений и 18 удалений

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

@ -2223,8 +2223,6 @@ BytecodeEmitter::emitNewInit(JSProtoKey key)
static bool
IteratorResultShape(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned *shape)
{
MOZ_ASSERT(bce->script->compileAndGo());
RootedPlainObject obj(cx);
// No need to do any guessing for the object kind, since we know exactly how
// many properties we plan to have.
@ -2258,14 +2256,10 @@ IteratorResultShape(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned *shape)
bool
BytecodeEmitter::emitPrepareIteratorResult()
{
if (script->compileAndGo()) {
unsigned shape;
if (!IteratorResultShape(cx, this, &shape))
return false;
return emitIndex32(JSOP_NEWOBJECT, shape);
}
return emitNewInit(JSProto_Object);
unsigned shape;
if (!IteratorResultShape(cx, this, &shape))
return false;
return emitIndex32(JSOP_NEWOBJECT, shape);
}
bool
@ -6587,14 +6581,12 @@ BytecodeEmitter::emitObject(ParseNode *pn)
* JSOP_NEWOBJECT with the final shape instead.
*/
RootedPlainObject obj(cx);
if (script->compileAndGo()) {
// No need to do any guessing for the object kind, since we know exactly
// how many properties we plan to have.
gc::AllocKind kind = gc::GetGCObjectKind(pn->pn_count);
obj = NewBuiltinClassInstance<PlainObject>(cx, kind, TenuredObject);
if (!obj)
return false;
}
// No need to do any guessing for the object kind, since we know exactly
// how many properties we plan to have.
gc::AllocKind kind = gc::GetGCObjectKind(pn->pn_count);
obj = NewBuiltinClassInstance<PlainObject>(cx, kind, TenuredObject);
if (!obj)
return false;
if (!emitPropertyList(pn, &obj, ObjectLiteral))
return false;