diff --git a/js/src/ds/OrderedHashTable.h b/js/src/ds/OrderedHashTable.h index c99272129761..a7c8d3452392 100644 --- a/js/src/ds/OrderedHashTable.h +++ b/js/src/ds/OrderedHashTable.h @@ -702,16 +702,19 @@ class OrderedHashMap typedef typename Impl::Range Range; explicit OrderedHashMap(AllocPolicy ap = AllocPolicy()) : impl(ap) {} - bool init() { return impl.init(); } + MOZ_WARN_UNUSED_RESULT bool init() { return impl.init(); } uint32_t count() const { return impl.count(); } bool has(const Key& key) const { return impl.has(key); } Range all() { return impl.all(); } const Entry* get(const Key& key) const { return impl.get(key); } Entry* get(const Key& key) { return impl.get(key); } - template - bool put(const Key& key, V&& value) { return impl.put(Entry(key, Forward(value))); } bool remove(const Key& key, bool* foundp) { return impl.remove(key, foundp); } - bool clear() { return impl.clear(); } + MOZ_WARN_UNUSED_RESULT bool clear() { return impl.clear(); } + + template + MOZ_WARN_UNUSED_RESULT bool put(const Key& key, V&& value) { + return impl.put(Entry(key, Forward(value))); + } void rekeyOneEntry(const Key& current, const Key& newKey) { const Entry* e = get(current); @@ -739,13 +742,13 @@ class OrderedHashSet typedef typename Impl::Range Range; explicit OrderedHashSet(AllocPolicy ap = AllocPolicy()) : impl(ap) {} - bool init() { return impl.init(); } + MOZ_WARN_UNUSED_RESULT bool init() { return impl.init(); } uint32_t count() const { return impl.count(); } bool has(const T& value) const { return impl.has(value); } Range all() { return impl.all(); } - bool put(const T& value) { return impl.put(value); } + MOZ_WARN_UNUSED_RESULT bool put(const T& value) { return impl.put(value); } bool remove(const T& value, bool* foundp) { return impl.remove(value, foundp); } - bool clear() { return impl.clear(); } + MOZ_WARN_UNUSED_RESULT bool clear() { return impl.clear(); } void rekeyOneEntry(const T& current, const T& newKey) { return impl.rekeyOneEntry(current, newKey, newKey); diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 13a6754915c2..8df3c3c6d226 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -1764,8 +1764,11 @@ GCMarker::stop() /* Free non-ballast stack memory. */ stack.reset(); - for (GCZonesIter zone(runtime()); !zone.done(); zone.next()) - zone->gcWeakKeys.clear(); + AutoEnterOOMUnsafeRegion oomUnsafe; + for (GCZonesIter zone(runtime()); !zone.done(); zone.next()) { + if (!zone->gcWeakKeys.clear()) + oomUnsafe.crash("clearing weak keys in GCMarker::stop()"); + } } void @@ -1820,8 +1823,11 @@ GCMarker::leaveWeakMarkingMode() // Table is expensive to maintain when not in weak marking mode, so we'll // rebuild it upon entry rather than allow it to contain stale data. - for (GCZonesIter zone(runtime()); !zone.done(); zone.next()) - zone->gcWeakKeys.clear(); + AutoEnterOOMUnsafeRegion oomUnsafe; + for (GCZonesIter zone(runtime()); !zone.done(); zone.next()) { + if (!zone->gcWeakKeys.clear()) + oomUnsafe.crash("clearing weak keys in GCMarker::leaveWeakMarkingMode()"); + } } void diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 60d93ef26a79..f9586c0c4076 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -4310,13 +4310,14 @@ js::gc::MarkingValidator::nonIncrementalMark() if (!WeakMapBase::saveZoneMarkedWeakMaps(zone, markedWeakMaps)) return; + AutoEnterOOMUnsafeRegion oomUnsafe; for (gc::WeakKeyTable::Range r = zone->gcWeakKeys.all(); !r.empty(); r.popFront()) { - AutoEnterOOMUnsafeRegion oomUnsafe; if (!savedWeakKeys.put(Move(r.front().key), Move(r.front().value))) oomUnsafe.crash("saving weak keys table for validator"); } - zone->gcWeakKeys.clear(); + if (!zone->gcWeakKeys.clear()) + oomUnsafe.crash("clearing weak keys table for validator"); } /* @@ -4387,7 +4388,9 @@ js::gc::MarkingValidator::nonIncrementalMark() for (GCZonesIter zone(runtime); !zone.done(); zone.next()) { WeakMapBase::unmarkZone(zone); - zone->gcWeakKeys.clear(); + AutoEnterOOMUnsafeRegion oomUnsafe; + if (!zone->gcWeakKeys.clear()) + oomUnsafe.crash("clearing weak keys table for validator"); } WeakMapBase::restoreMarkedWeakMaps(markedWeakMaps); @@ -5074,7 +5077,9 @@ GCRuntime::beginSweepingZoneGroup() zone->gcWeakRefs.clear(); /* No need to look up any more weakmap keys from this zone group. */ - zone->gcWeakKeys.clear(); + AutoEnterOOMUnsafeRegion oomUnsafe; + if (!zone->gcWeakKeys.clear()) + oomUnsafe.crash("clearing weak keys in beginSweepingZoneGroup()"); } FreeOp fop(rt);