mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 1188408 - Simplify ArenasToUpdate iteration r=terrence
This commit is contained in:
parent
81cbb1f051
commit
9322a5d071
@ -2346,18 +2346,18 @@ struct ArenasToUpdate
|
||||
ALL = FOREGROUND | BACKGROUND
|
||||
};
|
||||
ArenasToUpdate(Zone* zone, KindsToUpdate kinds);
|
||||
bool done() { return initialized && arena == nullptr; }
|
||||
ArenaHeader* next(AutoLockHelperThreadState& lock);
|
||||
bool done() { return kind == AllocKind::LIMIT; }
|
||||
ArenaHeader* getArenasToUpdate(AutoLockHelperThreadState& lock, unsigned max);
|
||||
|
||||
private:
|
||||
bool initialized;
|
||||
KindsToUpdate kinds;
|
||||
KindsToUpdate kinds; // Selects which thing kinds to iterate
|
||||
Zone* zone; // Zone to process
|
||||
AllocKind kind; // Current alloc kind to process
|
||||
ArenaHeader* arena; // Next arena to process
|
||||
|
||||
AllocKind nextAllocKind(AllocKind i) { return AllocKind(uint8_t(i) + 1); }
|
||||
bool shouldProcessKind(AllocKind kind);
|
||||
ArenaHeader* next(AutoLockHelperThreadState& lock);
|
||||
};
|
||||
|
||||
bool ArenasToUpdate::shouldProcessKind(AllocKind kind)
|
||||
@ -2389,7 +2389,7 @@ bool ArenasToUpdate::shouldProcessKind(AllocKind kind)
|
||||
}
|
||||
|
||||
ArenasToUpdate::ArenasToUpdate(Zone* zone, KindsToUpdate kinds)
|
||||
: initialized(false), kinds(kinds), zone(zone)
|
||||
: kinds(kinds), zone(zone), kind(AllocKind::FIRST), arena(nullptr)
|
||||
{
|
||||
MOZ_ASSERT(zone->isGCCompacting());
|
||||
MOZ_ASSERT(kinds && !(kinds & ~ALL));
|
||||
@ -2400,44 +2400,30 @@ ArenasToUpdate::next(AutoLockHelperThreadState& lock)
|
||||
{
|
||||
// Find the next arena to update.
|
||||
//
|
||||
// The first time this is called, we initialize the kind and arena and loop
|
||||
// over all alloc kinds, returning the first arena found. In subsequent
|
||||
// invocations we go through the remaining arenas first, then increment the
|
||||
// kind manually before looping over the remaining kinds.
|
||||
// This iterates through the GC thing kinds filtered by shouldProcessKind(),
|
||||
// and then through thea arenas of that kind. All state is held in the
|
||||
// object and we just return when we find an arena.
|
||||
|
||||
if (initialized) {
|
||||
MOZ_ASSERT(arena);
|
||||
MOZ_ASSERT(shouldProcessKind(kind));
|
||||
MOZ_ASSERT(zone);
|
||||
arena = arena->next;
|
||||
if (arena)
|
||||
return arena;
|
||||
kind = AllocKind(uint8_t(kind) + 1);
|
||||
} else {
|
||||
initialized = true;
|
||||
arena = nullptr;
|
||||
kind = AllocKind::FIRST;
|
||||
}
|
||||
|
||||
for (auto i : SomeAllocKinds(kind)) {
|
||||
if (shouldProcessKind(i)) {
|
||||
arena = zone->arenas.getFirstArena(i);
|
||||
if (arena) {
|
||||
kind = i;
|
||||
for (; kind < AllocKind::LIMIT; kind = nextAllocKind(kind)) {
|
||||
if (shouldProcessKind(kind)) {
|
||||
if (!arena)
|
||||
arena = zone->arenas.getFirstArena(kind);
|
||||
else
|
||||
arena = arena->next;
|
||||
if (arena)
|
||||
return arena;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kind = AllocKind::LIMIT;
|
||||
zone = nullptr;
|
||||
MOZ_ASSERT(!arena);
|
||||
MOZ_ASSERT(done());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ArenaHeader*
|
||||
ArenasToUpdate::getArenasToUpdate(AutoLockHelperThreadState& lock, unsigned count)
|
||||
{
|
||||
if (!zone)
|
||||
if (done())
|
||||
return nullptr;
|
||||
|
||||
ArenaHeader* head = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user