mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
1320408 - Part 6: Change JSObject::splicePrototype to static method.
This commit is contained in:
parent
6a21912a94
commit
a38594f890
5 changed files with 13 additions and 13 deletions
|
|
@ -1409,7 +1409,7 @@ FinishObjectClassInit(JSContext* cx, JS::HandleObject ctor, JS::HandleObject pro
|
|||
*/
|
||||
Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
|
||||
if (global->shouldSplicePrototype(cx)) {
|
||||
if (!global->splicePrototype(cx, global->getClass(), tagged))
|
||||
if (!JSObject::splicePrototype(cx, global, global->getClass(), tagged))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ JS_SplicePrototype(JSContext* cx, HandleObject obj, HandleObject proto)
|
|||
}
|
||||
|
||||
Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
|
||||
return obj->splicePrototype(cx, obj->getClass(), tagged);
|
||||
return JSObject::splicePrototype(cx, obj, obj->getClass(), tagged);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSObject*)
|
||||
|
|
|
|||
|
|
@ -884,7 +884,7 @@ CreateThisForFunctionWithGroup(JSContext* cx, HandleObjectGroup group,
|
|||
|
||||
if (newKind == SingletonObject) {
|
||||
Rooted<TaggedProto> proto(cx, TaggedProto(templateObject->staticPrototype()));
|
||||
if (!res->splicePrototype(cx, &PlainObject::class_, proto))
|
||||
if (!JSObject::splicePrototype(cx, res, &PlainObject::class_, proto))
|
||||
return nullptr;
|
||||
} else {
|
||||
res->setGroup(group);
|
||||
|
|
@ -1722,7 +1722,7 @@ DefineConstructorAndPrototype(JSContext* cx, HandleObject obj, JSProtoKey key, H
|
|||
|
||||
/* Bootstrap Function.prototype (see also JS_InitStandardClasses). */
|
||||
Rooted<TaggedProto> tagged(cx, TaggedProto(proto));
|
||||
if (ctor->getClass() == clasp && !ctor->splicePrototype(cx, clasp, tagged))
|
||||
if (ctor->getClass() == clasp && !JSObject::splicePrototype(cx, ctor, clasp, tagged))
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
|
@ -1862,7 +1862,7 @@ js::SetClassAndProto(JSContext* cx, HandleObject obj,
|
|||
* Just splice the prototype, but mark the properties as unknown for
|
||||
* consistent behavior.
|
||||
*/
|
||||
if (!obj->splicePrototype(cx, clasp, proto))
|
||||
if (!JSObject::splicePrototype(cx, obj, clasp, proto))
|
||||
return false;
|
||||
MarkObjectGroupUnknownProperties(cx, obj->group());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -439,7 +439,8 @@ class JSObject : public js::gc::Cell
|
|||
}
|
||||
|
||||
/* Set a new prototype for an object with a singleton type. */
|
||||
bool splicePrototype(JSContext* cx, const js::Class* clasp, js::Handle<js::TaggedProto> proto);
|
||||
static bool splicePrototype(JSContext* cx, js::HandleObject obj, const js::Class* clasp,
|
||||
js::Handle<js::TaggedProto> proto);
|
||||
|
||||
/*
|
||||
* For bootstrapping, whether to splice a prototype for Function.prototype
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue