зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1101561 - Fix %StringIteratorPrototype% initialization to be OOM-safe. r=jandem
--HG-- extra : rebase_source : 345fa7073d8fcbabcbd98bff8c5c7452f81ffa09
This commit is contained in:
Родитель
678917f7ca
Коммит
d551aa37b6
|
@ -1391,6 +1391,25 @@ GlobalObject::initArrayIteratorProto(JSContext* cx, Handle<GlobalObject*> global
|
|||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
GlobalObject::initStringIteratorProto(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
if (global->getReservedSlot(STRING_ITERATOR_PROTO).isObject())
|
||||
return true;
|
||||
|
||||
RootedObject iteratorProto(cx, GlobalObject::getOrCreateIteratorPrototype(cx, global));
|
||||
if (!iteratorProto)
|
||||
return false;
|
||||
|
||||
const Class* cls = &StringIteratorPrototypeClass;
|
||||
RootedObject proto(cx, global->createBlankPrototypeInheriting(cx, cls, iteratorProto));
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, string_iterator_methods))
|
||||
return false;
|
||||
|
||||
global->setReservedSlot(STRING_ITERATOR_PROTO, ObjectValue(*proto));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
GlobalObject::initIteratorClasses(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
|
@ -1426,15 +1445,6 @@ GlobalObject::initIteratorClasses(JSContext* cx, Handle<GlobalObject*> global)
|
|||
}
|
||||
}
|
||||
|
||||
RootedObject proto(cx);
|
||||
if (global->getSlot(STRING_ITERATOR_PROTO).isUndefined()) {
|
||||
const Class* cls = &StringIteratorPrototypeClass;
|
||||
proto = global->createBlankPrototype(cx, cls);
|
||||
if (!proto || !DefinePropertiesAndFunctions(cx, proto, nullptr, string_iterator_methods))
|
||||
return false;
|
||||
global->setReservedSlot(STRING_ITERATOR_PROTO, ObjectValue(*proto));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -542,9 +542,7 @@ class GlobalObject : public NativeObject
|
|||
static NativeObject* getOrCreateStringIteratorPrototype(JSContext* cx,
|
||||
Handle<GlobalObject*> global)
|
||||
{
|
||||
if (!ensureConstructor(cx, global, JSProto_Iterator))
|
||||
return nullptr;
|
||||
return &global->getSlot(STRING_ITERATOR_PROTO).toObject().as<NativeObject>();
|
||||
return MaybeNativeObject(global->getOrCreateObject(cx, STRING_ITERATOR_PROTO, initStringIteratorProto));
|
||||
}
|
||||
|
||||
static NativeObject* getOrCreateLegacyGeneratorObjectPrototype(JSContext* cx,
|
||||
|
@ -705,6 +703,7 @@ class GlobalObject : public NativeObject
|
|||
|
||||
// Implemented in jsiter.cpp.
|
||||
static bool initArrayIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initStringIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initIteratorClasses(JSContext* cx, Handle<GlobalObject*> global);
|
||||
|
||||
// Implemented in vm/GeneratorObject.cpp.
|
||||
|
|
Загрузка…
Ссылка в новой задаче