Bug 1125389 - Fix NewReshapedObject to use the old shape's data, r=jandem.

This commit is contained in:
Brian Hackett 2015-01-29 11:50:43 -07:00
Родитель aa3b065ff1
Коммит 68cfb28171
2 изменённых файлов: 12 добавлений и 2 удалений

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

@ -4046,8 +4046,13 @@ TypeNewScript::maybeAnalyze(JSContext *cx, TypeObject *type, bool *regenerate, b
// For now, we require all preliminary objects to have only simple
// lineages of plain data properties.
Shape *shape = obj->lastProperty();
if (shape->inDictionary() || !OnlyHasDataProperties(shape))
if (shape->inDictionary() ||
!OnlyHasDataProperties(shape) ||
shape->getObjectFlags() != 0 ||
shape->getObjectMetadata() != nullptr)
{
return true;
}
maxSlotSpan = Max<size_t>(maxSlotSpan, obj->slotSpan());

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

@ -640,7 +640,12 @@ js::NewReshapedObject(JSContext *cx, HandleTypeObject type, JSObject *parent,
/* Construct the new shape, without updating type information. */
RootedId id(cx);
RootedShape newShape(cx, res->lastProperty());
RootedShape newShape(cx, EmptyShape::getInitialShape(cx, res->getClass(),
res->getTaggedProto(),
res->getMetadata(),
res->getParent(),
res->numFixedSlots(),
shape->getObjectFlags()));
for (unsigned i = 0; i < ids.length(); i++) {
id = ids[i];
MOZ_ASSERT(!res->contains(cx, id));