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