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:
Jan de Mooij 2020-05-01 03:15:45 +00:00
Родитель 4bee254594
Коммит 018c10c10c
3 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -852,7 +852,8 @@ bool GlobalObject::initFinalizationIteratorProto(JSContext* cx,
if (!base) {
return false;
}
RootedPlainObject proto(cx, NewObjectWithGivenProto<PlainObject>(cx, base));
RootedPlainObject proto(
cx, GlobalObject::createBlankPrototypeInheriting<PlainObject>(cx, base));
if (!proto) {
return false;
}

Просмотреть файл

@ -177,7 +177,8 @@ bool GlobalObject::initMapIteratorProto(JSContext* cx,
if (!base) {
return false;
}
RootedPlainObject proto(cx, NewObjectWithGivenProto<PlainObject>(cx, base));
RootedPlainObject proto(
cx, GlobalObject::createBlankPrototypeInheriting<PlainObject>(cx, base));
if (!proto) {
return false;
}
@ -959,7 +960,8 @@ bool GlobalObject::initSetIteratorProto(JSContext* cx,
if (!base) {
return false;
}
RootedPlainObject proto(cx, NewObjectWithGivenProto<PlainObject>(cx, base));
RootedPlainObject proto(
cx, GlobalObject::createBlankPrototypeInheriting<PlainObject>(cx, base));
if (!proto) {
return false;
}

Просмотреть файл

@ -298,6 +298,12 @@ class GlobalObject : public NativeObject {
const JSClass* clasp,
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>
static T* createBlankPrototype(JSContext* cx, Handle<GlobalObject*> global) {
NativeObject* res = createBlankPrototype(cx, global, &T::class_);