Bug 1162986 - Allow objects to be turned into singletons dynamically, r=jandem.

This commit is contained in:
Brian Hackett
2015-06-14 08:02:44 -07:00
parent 97f80de102
commit b618ee3239
52 changed files with 421 additions and 619 deletions

View File

@@ -2392,6 +2392,22 @@ js::SetClassAndProto(JSContext* cx, HandleObject obj,
return true;
}
/* static */ bool
JSObject::changeToSingleton(JSContext* cx, HandleObject obj)
{
MOZ_ASSERT(!obj->isSingleton());
MarkObjectGroupUnknownProperties(cx, obj->group());
ObjectGroup* group = ObjectGroup::lazySingletonGroup(cx, obj->getClass(),
obj->getTaggedProto());
if (!group)
return false;
obj->group_ = group;
return true;
}
static bool
MaybeResolveConstructor(ExclusiveContext* cxArg, Handle<GlobalObject*> global, JSProtoKey key)
{