mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1372569 - Skip sweeping empty weak caches r=sfink
This commit is contained in:
parent
52665ac9e7
commit
995284e0a4
@ -69,6 +69,10 @@ class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy>
|
||||
}
|
||||
}
|
||||
|
||||
bool needsSweep() const {
|
||||
return this->initialized() && !this->empty();
|
||||
}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
@ -246,6 +250,10 @@ class GCHashSet : public js::HashSet<T, HashPolicy, AllocPolicy>
|
||||
GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element");
|
||||
}
|
||||
|
||||
bool needsSweep() const {
|
||||
return this->initialized() && !this->empty();
|
||||
}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
|
@ -135,6 +135,10 @@ class GCVector
|
||||
GCPolicy<T>::trace(trc, &elem, "vector element");
|
||||
}
|
||||
|
||||
bool needsSweep() const {
|
||||
return !this->empty();
|
||||
}
|
||||
|
||||
void sweep() {
|
||||
uint32_t src, dst = 0;
|
||||
for (src = 0; src < length(); src++) {
|
||||
|
@ -38,6 +38,7 @@ class WeakCacheBase : public mozilla::LinkedListElement<WeakCacheBase>
|
||||
virtual ~WeakCacheBase() {}
|
||||
|
||||
virtual void sweep() = 0;
|
||||
virtual bool needsSweep() = 0;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@ -69,6 +70,10 @@ class WeakCache : protected detail::WeakCacheBase,
|
||||
void sweep() override {
|
||||
GCPolicy<T>::sweep(&cache);
|
||||
}
|
||||
|
||||
bool needsSweep() override {
|
||||
return cache.needsSweep();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace JS
|
||||
|
@ -5233,6 +5233,9 @@ PrepareWeakCacheTasks(JSRuntime* rt)
|
||||
// Build a vector of sweep tasks to run on a helper thread.
|
||||
WeakCacheTaskVector tasks;
|
||||
bool ok = IterateWeakCaches(rt, [&] (JS::detail::WeakCacheBase* cache) {
|
||||
if (!cache->needsSweep())
|
||||
return true;
|
||||
|
||||
return tasks.emplaceBack(rt, *cache);
|
||||
});
|
||||
|
||||
|
@ -599,6 +599,10 @@ class InnerViewTable
|
||||
void sweep();
|
||||
void sweepAfterMinorGC();
|
||||
|
||||
bool needsSweep() const {
|
||||
return map.needsSweep();
|
||||
}
|
||||
|
||||
bool needsSweepAfterMinorGC() const {
|
||||
return !nurseryKeys.empty() || !nurseryKeysValid;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user