Bug 1125101 - Check budget in incremental compaction r=terrence

This commit is contained in:
Jon Coppeard 2015-02-26 12:35:59 +00:00
parent ae6f5e923d
commit d4ac6a02c6
3 changed files with 18 additions and 15 deletions

View File

@ -909,11 +909,11 @@ class GCRuntime
void assertBackgroundSweepingFinished();
bool shouldCompact();
IncrementalProgress beginCompactPhase();
IncrementalProgress compactPhase(JS::gcreason::Reason reason);
IncrementalProgress compactPhase(JS::gcreason::Reason reason, SliceBudget &sliceBudget);
void endCompactPhase(JS::gcreason::Reason reason);
void sweepTypesAfterCompacting(Zone *zone);
void sweepZoneAfterCompacting(Zone *zone);
bool relocateArenas(Zone *zone, JS::gcreason::Reason reason);
bool relocateArenas(Zone *zone, JS::gcreason::Reason reason, SliceBudget &sliceBudget);
void updateAllCellPointersParallel(MovingTracer *trc, Zone *zone);
void updateAllCellPointersSerial(MovingTracer *trc, Zone *zone);
void updatePointersToRelocatedCells(Zone *zone);

View File

@ -2112,7 +2112,7 @@ RelocateCell(Zone *zone, TenuredCell *src, AllocKind thingKind, size_t thingSize
}
static void
RelocateArena(ArenaHeader *aheader)
RelocateArena(ArenaHeader *aheader, SliceBudget &sliceBudget)
{
MOZ_ASSERT(aheader->allocated());
MOZ_ASSERT(!aheader->hasDelayedMarking);
@ -2131,6 +2131,7 @@ RelocateArena(ArenaHeader *aheader)
// for.
CrashAtUnhandlableOOM("Could not allocate new arena while compacting");
}
sliceBudget.step();
}
#ifdef DEBUG
@ -2149,14 +2150,14 @@ RelocateArena(ArenaHeader *aheader)
* relocate each cell within it, then add it to a list of relocated arenas.
*/
ArenaHeader *
ArenaList::relocateArenas(ArenaHeader *toRelocate, ArenaHeader *relocated,
ArenaList::relocateArenas(ArenaHeader *toRelocate, ArenaHeader *relocated, SliceBudget &sliceBudget,
gcstats::Statistics& stats)
{
check();
while (ArenaHeader *arena = toRelocate) {
toRelocate = arena->next;
RelocateArena(arena);
RelocateArena(arena, sliceBudget);
// Prepend to list of relocated arenas
arena->next = relocated;
relocated = arena;
@ -2185,7 +2186,7 @@ static bool ShouldRelocateZone(size_t arenaCount, size_t relocCount, JS::gcreaso
bool
ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason reason,
gcstats::Statistics& stats)
SliceBudget &sliceBudget, gcstats::Statistics& stats)
{
// This is only called from the main thread while we are doing a GC, so
@ -2204,7 +2205,7 @@ ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason
ArenaList &al = arenaLists[i];
ArenaHeader *allArenas = al.head();
al.clear();
relocatedListOut = al.relocateArenas(allArenas, relocatedListOut, stats);
relocatedListOut = al.relocateArenas(allArenas, relocatedListOut, sliceBudget, stats);
}
}
} else {
@ -2224,7 +2225,7 @@ ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason
if (toRelocate[i]) {
ArenaList &al = arenaLists[i];
ArenaHeader *arenas = al.removeRemainingArenas(toRelocate[i]);
relocatedListOut = al.relocateArenas(arenas, relocatedListOut, stats);
relocatedListOut = al.relocateArenas(arenas, relocatedListOut, sliceBudget, stats);
}
}
}
@ -2240,7 +2241,7 @@ ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason
}
bool
GCRuntime::relocateArenas(Zone *zone, JS::gcreason::Reason reason)
GCRuntime::relocateArenas(Zone *zone, JS::gcreason::Reason reason, SliceBudget &sliceBudget)
{
gcstats::AutoPhase ap(stats, gcstats::PHASE_COMPACT_MOVE);
@ -2249,7 +2250,7 @@ GCRuntime::relocateArenas(Zone *zone, JS::gcreason::Reason reason)
jit::StopAllOffThreadCompilations(zone);
if (!zone->arenas.relocateArenas(relocatedArenasToRelease, reason, stats))
if (!zone->arenas.relocateArenas(relocatedArenasToRelease, reason, sliceBudget, stats))
return false;
#ifdef DEBUG
@ -5520,7 +5521,7 @@ GCRuntime::beginCompactPhase()
}
GCRuntime::IncrementalProgress
GCRuntime::compactPhase(JS::gcreason::Reason reason)
GCRuntime::compactPhase(JS::gcreason::Reason reason, SliceBudget &sliceBudget)
{
MOZ_ASSERT(rt->gc.nursery.isEmpty());
assertBackgroundSweepingFinished();
@ -5531,12 +5532,14 @@ GCRuntime::compactPhase(JS::gcreason::Reason reason)
while (!zonesToMaybeCompact.isEmpty()) {
Zone *zone = zonesToMaybeCompact.front();
MOZ_ASSERT(zone->isGCFinished());
if (relocateArenas(zone, reason)) {
if (relocateArenas(zone, reason, sliceBudget)) {
zone->setGCState(Zone::Compact);
updatePointersToRelocatedCells(zone);
zone->setGCState(Zone::Finished);
}
zonesToMaybeCompact.removeFront();
if (sliceBudget.isOverBudget())
break;
}
#ifdef DEBUG
@ -5974,7 +5977,7 @@ GCRuntime::incrementalCollectSlice(SliceBudget &budget, JS::gcreason::Reason rea
if (!startedCompacting && beginCompactPhase() == NotFinished)
break;
if (compactPhase(reason) == NotFinished)
if (compactPhase(reason, budget) == NotFinished)
break;
endCompactPhase(reason);

View File

@ -477,7 +477,7 @@ class ArenaList {
ArenaHeader *removeRemainingArenas(ArenaHeader **arenap);
ArenaHeader **pickArenasToRelocate(size_t &arenaTotalOut, size_t &relocTotalOut);
ArenaHeader *relocateArenas(ArenaHeader *toRelocate, ArenaHeader *relocated,
gcstats::Statistics& stats);
SliceBudget &sliceBudget, gcstats::Statistics& stats);
};
/*
@ -805,7 +805,7 @@ class ArenaLists
}
bool relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason reason,
gcstats::Statistics& stats);
SliceBudget &sliceBudget, gcstats::Statistics& stats);
void queueForegroundObjectsForSweep(FreeOp *fop);
void queueForegroundThingsForSweep(FreeOp *fop);