mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1201051 - Add ObjectWeakMap::init() rather than crashing in constructor on OOM r=terrence
This commit is contained in:
parent
2b6fac45c5
commit
69e5e253e9
@ -2189,7 +2189,7 @@ InlineTransparentTypedObject::getOrCreateBuffer(JSContext* cx)
|
||||
ObjectWeakMap*& table = cx->compartment()->lazyArrayBuffers;
|
||||
if (!table) {
|
||||
table = cx->new_<ObjectWeakMap>(cx);
|
||||
if (!table)
|
||||
if (!table || !table->init())
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ JSCompartment::setNewObjectMetadata(JSContext* cx, JSObject* obj)
|
||||
assertSameCompartment(cx, metadata);
|
||||
if (!objectMetadataTable) {
|
||||
objectMetadataTable = cx->new_<ObjectWeakMap>(cx);
|
||||
if (!objectMetadataTable)
|
||||
if (!objectMetadataTable || !objectMetadataTable->init())
|
||||
CrashAtUnhandlableOOM("setNewObjectMetadata");
|
||||
}
|
||||
if (!objectMetadataTable->add(cx, obj, metadata))
|
||||
|
@ -683,9 +683,12 @@ js::InitBareWeakMapCtor(JSContext* cx, HandleObject obj)
|
||||
|
||||
ObjectWeakMap::ObjectWeakMap(JSContext* cx)
|
||||
: map(cx, nullptr)
|
||||
{}
|
||||
|
||||
bool
|
||||
ObjectWeakMap::init()
|
||||
{
|
||||
if (!map.init())
|
||||
CrashAtUnhandlableOOM("ObjectWeakMap");
|
||||
return map.init();
|
||||
}
|
||||
|
||||
ObjectWeakMap::~ObjectWeakMap()
|
||||
@ -696,6 +699,7 @@ ObjectWeakMap::~ObjectWeakMap()
|
||||
JSObject*
|
||||
ObjectWeakMap::lookup(const JSObject* obj)
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
if (ObjectValueMap::Ptr p = map.lookup(const_cast<JSObject*>(obj)))
|
||||
return &p->value().toObject();
|
||||
return nullptr;
|
||||
@ -705,6 +709,7 @@ bool
|
||||
ObjectWeakMap::add(JSContext* cx, JSObject* obj, JSObject* target)
|
||||
{
|
||||
MOZ_ASSERT(obj && target);
|
||||
MOZ_ASSERT(map.initialized());
|
||||
|
||||
MOZ_ASSERT(!map.has(obj));
|
||||
if (!map.put(obj, ObjectValue(*target))) {
|
||||
@ -720,18 +725,21 @@ ObjectWeakMap::add(JSContext* cx, JSObject* obj, JSObject* target)
|
||||
void
|
||||
ObjectWeakMap::clear()
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
map.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ObjectWeakMap::trace(JSTracer* trc)
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
map.trace(trc);
|
||||
}
|
||||
|
||||
size_t
|
||||
ObjectWeakMap::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
return map.sizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
@ -739,6 +747,7 @@ ObjectWeakMap::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
|
||||
void
|
||||
ObjectWeakMap::checkAfterMovingGC()
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
for (ObjectValueMap::Range r = map.all(); !r.empty(); r.popFront()) {
|
||||
CheckGCThingAfterMovingGC(r.front().key().get());
|
||||
CheckGCThingAfterMovingGC(&r.front().value().toObject());
|
||||
|
@ -1921,7 +1921,7 @@ DebugScopes::~DebugScopes()
|
||||
bool
|
||||
DebugScopes::init()
|
||||
{
|
||||
return liveScopes.init() && missingScopes.init();
|
||||
return proxiedScopes.init() && missingScopes.init() && liveScopes.init();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -38,6 +38,7 @@ class ObjectWeakMap
|
||||
|
||||
public:
|
||||
explicit ObjectWeakMap(JSContext* cx);
|
||||
bool init();
|
||||
~ObjectWeakMap();
|
||||
|
||||
JSObject* lookup(const JSObject* obj);
|
||||
|
Loading…
Reference in New Issue
Block a user