Bug 1146472 part 1. Don't do object-kind guessing for object literal templates in scripts, since we in fact know exactly how many slots we want them to have and hence what the kind should be. r=terrence

This commit is contained in:
Boris Zbarsky 2015-03-23 20:37:30 -04:00
parent 5c46210c18
commit 444260de07
2 changed files with 7 additions and 3 deletions

View File

@ -2226,7 +2226,9 @@ IteratorResultShape(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned *shape)
MOZ_ASSERT(bce->script->compileAndGo());
RootedPlainObject obj(cx);
gc::AllocKind kind = GuessObjectGCKind(2);
// 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(2);
obj = NewBuiltinClassInstance<PlainObject>(cx, kind);
if (!obj)
return false;
@ -6586,7 +6588,9 @@ BytecodeEmitter::emitObject(ParseNode *pn)
*/
RootedPlainObject obj(cx);
if (script->compileAndGo()) {
gc::AllocKind kind = GuessObjectGCKind(pn->pn_count);
// 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;

View File

@ -2107,7 +2107,7 @@ JSObject *
js::CloneObjectLiteral(JSContext *cx, HandleObject srcObj)
{
if (srcObj->is<PlainObject>()) {
AllocKind kind = GetBackgroundAllocKind(GuessObjectGCKind(srcObj->as<PlainObject>().numFixedSlots()));
AllocKind kind = GetBackgroundAllocKind(gc::GetGCObjectKind(srcObj->as<PlainObject>().numFixedSlots()));
MOZ_ASSERT_IF(srcObj->isTenured(), kind == srcObj->asTenured().getAllocKind());
RootedObject proto(cx, cx->global()->getOrCreateObjectPrototype(cx));