1320408 - Part 6: Change JSObject::splicePrototype to static method.

This commit is contained in:
Gaming4JC 2019-06-08 19:26:40 -04:00 • committed by Roy Tam
commit a38594f890
5 changed files with 13 additions and 13 deletions

View file

@ -262,19 +262,18 @@ JSObject::shouldSplicePrototype(JSContext* cx)
return isSingleton();
}
bool
JSObject::splicePrototype(JSContext* cx, const Class* clasp, Handle<TaggedProto> proto)
/* static */ bool
JSObject::splicePrototype(JSContext* cx, HandleObject obj, const Class* clasp,
Handle<TaggedProto> proto)
{
MOZ_ASSERT(cx->compartment() == compartment());
RootedObject self(cx, this);
MOZ_ASSERT(cx->compartment() == obj->compartment());
/*
* For singleton groups representing only a single JSObject, the proto
* can be rearranged as needed without destroying type information for
* the old or new types.
*/
MOZ_ASSERT(self->isSingleton());
MOZ_ASSERT(obj->isSingleton());
// Windows may not appear on prototype chains.
MOZ_ASSERT_IF(proto.isObject(), !IsWindow(proto.toObject()));
@ -283,7 +282,7 @@ JSObject::splicePrototype(JSContext* cx, const Class* clasp, Handle<TaggedProto>
return false;
// Force type instantiation when splicing lazy group.
RootedObjectGroup group(cx, JSObject::getGroup(cx, self));
RootedObjectGroup group(cx, JSObject::getGroup(cx, obj));
if (!group)
return false;
RootedObjectGroup protoGroup(cx, nullptr);