Bug 852667 - Permit passing #fixed slots to getInitialShape (r=bhackett)

This commit is contained in:
Bill McCloskey 2013-03-18 17:27:09 -07:00
parent 7c3b1d3b99
commit 561ee16bc2
3 changed files with 13 additions and 5 deletions

View File

@ -1075,7 +1075,7 @@ JSObject::sealOrFreeze(JSContext *cx, HandleObject obj, ImmutabilityType it)
RootedShape last(cx, EmptyShape::getInitialShape(cx, obj->getClass(),
obj->getTaggedProto(),
obj->getParent(),
obj->getAllocKind(),
obj->numFixedSlots(),
obj->lastProperty()->getObjectFlags()));
if (!last)
return false;
@ -1808,7 +1808,7 @@ JSObject::ReserveForTradeGuts(JSContext *cx, JSObject *aArg, JSObject *bArg,
return false;
} else {
reserved.newbshape = EmptyShape::getInitialShape(cx, aClass, aProto, a->getParent(),
b->getAllocKind());
b->numFixedSlots());
if (!reserved.newbshape)
return false;
}
@ -1817,7 +1817,7 @@ JSObject::ReserveForTradeGuts(JSContext *cx, JSObject *aArg, JSObject *bArg,
return false;
} else {
reserved.newashape = EmptyShape::getInitialShape(cx, bClass, bProto, b->getParent(),
a->getAllocKind());
a->numFixedSlots());
if (!reserved.newashape)
return false;
}

View File

@ -1230,7 +1230,7 @@ InitialShapeEntry::match(const InitialShapeEntry &key, const Lookup &lookup)
/* static */ Shape *
EmptyShape::getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto, JSObject *parent,
AllocKind kind, uint32_t objectFlags)
size_t nfixed, uint32_t objectFlags)
{
JS_ASSERT_IF(proto.isObject(), cx->compartment == proto.toObject()->compartment());
JS_ASSERT_IF(parent, cx->compartment == parent->compartment());
@ -1240,7 +1240,6 @@ EmptyShape::getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto, JSOb
if (!table.initialized() && !table.init())
return NULL;
size_t nfixed = GetGCKindSlots(kind, clasp);
InitialShapeEntry::Lookup lookup(clasp, proto, parent, nfixed, objectFlags);
InitialShapeSet::AddPtr p = table.lookupForAdd(lookup);
@ -1270,6 +1269,13 @@ EmptyShape::getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto, JSOb
return shape;
}
/* static */ Shape *
EmptyShape::getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto, JSObject *parent,
AllocKind kind, uint32_t objectFlags)
{
return getInitialShape(cx, clasp, proto, parent, GetGCKindSlots(kind, clasp), objectFlags);
}
void
NewObjectCache::invalidateEntriesForShape(JSContext *cx, HandleShape shape, HandleObject proto)
{

View File

@ -898,6 +898,8 @@ struct EmptyShape : public js::Shape
* Lookup an initial shape matching the given parameters, creating an empty
* shape if none was found.
*/
static Shape *getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto,
JSObject *parent, size_t nfixed, uint32_t objectFlags = 0);
static Shape *getInitialShape(JSContext *cx, Class *clasp, TaggedProto proto,
JSObject *parent, gc::AllocKind kind, uint32_t objectFlags = 0);