зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1631267 part 2 - Create MapIteratorProto, SetIteratorProto, FinalizationIteratorProto as singletons. r=jwalden
While working on the previous patch I noticed some builtin prototypes weren't tenured. Use createBlankPrototypeInheriting for consistency with similar code elsewhere. Depends on D73221 Differential Revision: https://phabricator.services.mozilla.com/D73222
This commit is contained in:
Родитель
4bee254594
Коммит
018c10c10c
|
@ -852,7 +852,8 @@ bool GlobalObject::initFinalizationIteratorProto(JSContext* cx,
|
||||||
if (!base) {
|
if (!base) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RootedPlainObject proto(cx, NewObjectWithGivenProto<PlainObject>(cx, base));
|
RootedPlainObject proto(
|
||||||
|
cx, GlobalObject::createBlankPrototypeInheriting<PlainObject>(cx, base));
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,8 @@ bool GlobalObject::initMapIteratorProto(JSContext* cx,
|
||||||
if (!base) {
|
if (!base) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RootedPlainObject proto(cx, NewObjectWithGivenProto<PlainObject>(cx, base));
|
RootedPlainObject proto(
|
||||||
|
cx, GlobalObject::createBlankPrototypeInheriting<PlainObject>(cx, base));
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -959,7 +960,8 @@ bool GlobalObject::initSetIteratorProto(JSContext* cx,
|
||||||
if (!base) {
|
if (!base) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RootedPlainObject proto(cx, NewObjectWithGivenProto<PlainObject>(cx, base));
|
RootedPlainObject proto(
|
||||||
|
cx, GlobalObject::createBlankPrototypeInheriting<PlainObject>(cx, base));
|
||||||
if (!proto) {
|
if (!proto) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,6 +298,12 @@ class GlobalObject : public NativeObject {
|
||||||
const JSClass* clasp,
|
const JSClass* clasp,
|
||||||
HandleObject proto);
|
HandleObject proto);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static T* createBlankPrototypeInheriting(JSContext* cx, HandleObject proto) {
|
||||||
|
NativeObject* res = createBlankPrototypeInheriting(cx, &T::class_, proto);
|
||||||
|
return res ? &res->template as<T>() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T* createBlankPrototype(JSContext* cx, Handle<GlobalObject*> global) {
|
static T* createBlankPrototype(JSContext* cx, Handle<GlobalObject*> global) {
|
||||||
NativeObject* res = createBlankPrototype(cx, global, &T::class_);
|
NativeObject* res = createBlankPrototype(cx, global, &T::class_);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче