Bug 702681 - Remove the double chunk loop in DecommitFreePages; r=igor

In DecommitFreePages we iterate over the runtime's ChunkSet and inside that walk
over the list in the chunk info header.  The chunk set contains all chunks, so
we can ignore the internal list.

--HG--
extra : rebase_source : 3b1976fbf97308cc53b532a9e74b1871aa616079
This commit is contained in:
Terrence Cole 2011-11-15 15:13:13 -08:00
parent a578e01e91
commit b92b60928b

View File

@ -2400,36 +2400,32 @@ DecommitFreePages(JSContext *cx)
for (GCChunkSet::Range r(rt->gcChunkSet.all()); !r.empty(); r.popFront()) {
Chunk *chunk = r.front();
while (chunk) {
ArenaHeader *aheader = static_cast<ArenaHeader*>(chunk->info.freeArenasHead);
ArenaHeader *aheader = chunk->info.freeArenasHead;
/*
* In the non-failure case, the list will be gone at the end of
* the loop. In the case where we fail, we relink all failed
* decommits into a new list on freeArenasHead.
*/
chunk->info.freeArenasHead = NULL;
/*
* In the non-failure case, the list will be gone at the end of
* the loop. In the case where we fail, we relink all failed
* decommits into a new list on freeArenasHead.
*/
chunk->info.freeArenasHead = NULL;
while (aheader) {
/* Store aside everything we will need after decommit. */
ArenaHeader *next = aheader->next;
while (aheader) {
/* Store aside everything we will need after decommit. */
ArenaHeader *next = aheader->next;
bool success = DecommitMemory(aheader, ArenaSize);
if (!success) {
aheader->next = chunk->info.freeArenasHead;
chunk->info.freeArenasHead = aheader;
continue;
}
size_t arenaOffset = Chunk::arenaIndex(reinterpret_cast<uintptr_t>(aheader));
chunk->decommittedArenas.set(arenaOffset);
--chunk->info.numArenasFreeCommitted;
--rt->gcNumFreeArenas;
aheader = next;
bool success = DecommitMemory(aheader, ArenaSize);
if (!success) {
aheader->next = chunk->info.freeArenasHead;
chunk->info.freeArenasHead = aheader;
continue;
}
chunk = chunk->info.next;
size_t arenaIndex = Chunk::arenaIndex(aheader->arenaAddress());
chunk->decommittedArenas.set(arenaIndex);
--chunk->info.numArenasFreeCommitted;
--rt->gcNumFreeArenas;
aheader = next;
}
}
}