forked from mirrors/gecko-dev
Bug 1894012 - Part 0: Add needsSweep method for GC hash tables r=sfink
This is follow on from bug 1894012. This allows hash tables to be used as keys and values in hash tables that are used with WeakCache as we'll do in these patches. Differential Revision: https://phabricator.services.mozilla.com/D210504
This commit is contained in:
parent
1f46481d6c
commit
7ce6e5a4f1
1 changed files with 19 additions and 0 deletions
|
|
@ -96,6 +96,16 @@ class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy> {
|
|||
}
|
||||
}
|
||||
|
||||
bool needsSweep(JSTracer* trc) const {
|
||||
for (auto r = this->all(); !r.empty(); r.popFront()) {
|
||||
if (MapEntryGCPolicy::needsSweep(trc, &r.front().key(),
|
||||
&r.front().value())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// GCHashMap is movable
|
||||
GCHashMap(GCHashMap&& rhs) : Base(std::move(rhs)) {}
|
||||
void operator=(GCHashMap&& rhs) {
|
||||
|
|
@ -274,6 +284,15 @@ class GCHashSet : public js::HashSet<T, HashPolicy, AllocPolicy> {
|
|||
}
|
||||
}
|
||||
|
||||
bool needsSweep(JSTracer* trc) const {
|
||||
for (auto r = this->all(); !r.empty(); r.popFront()) {
|
||||
if (GCPolicy<T>::needsSweep(trc, &r.front())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// GCHashSet is movable
|
||||
GCHashSet(GCHashSet&& rhs) : Base(std::move(rhs)) {}
|
||||
void operator=(GCHashSet&& rhs) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue