зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1320408 - Part 6: Change JSObject::splicePrototype to static method. r=jandem
This commit is contained in:
Родитель
3d774fe97b
Коммит
682e9b2d8b
|
@ -1315,7 +1315,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;
|
||||
|
|
|
@ -116,7 +116,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*)
|
||||
|
|
|
@ -883,7 +883,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);
|
||||
|
@ -1740,7 +1740,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;
|
||||
}
|
||||
|
||||
|
@ -1880,7 +1880,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;
|
||||
|
|
|
@ -437,7 +437,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
|
||||
|
|
|
@ -265,19 +265,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()));
|
||||
|
@ -286,7 +285,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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче