Bug 650161 - Use the invocation kind passed to the first slice for the whole GC r=terrence

This commit is contained in:
Jon Coppeard 2014-08-14 11:46:46 +01:00
parent 7cfb3676af
commit 62aae1e869
2 changed files with 19 additions and 13 deletions

View File

@ -424,7 +424,7 @@ class GCRuntime
bool isGcNeeded() { return isNeeded; } bool isGcNeeded() { return isNeeded; }
double computeHeapGrowthFactor(size_t lastBytes); double computeHeapGrowthFactor(size_t lastBytes);
size_t computeTriggerBytes(double growthFactor, size_t lastBytes, JSGCInvocationKind gckind); size_t computeTriggerBytes(double growthFactor, size_t lastBytes);
JSGCMode gcMode() const { return mode; } JSGCMode gcMode() const { return mode; }
void setGCMode(JSGCMode m) { void setGCMode(JSGCMode m) {
@ -475,8 +475,7 @@ class GCRuntime
gcstats::ZoneGCStats scanZonesBeforeGC(); gcstats::ZoneGCStats scanZonesBeforeGC();
void budgetIncrementalGC(int64_t *budget); void budgetIncrementalGC(int64_t *budget);
void resetIncrementalGC(const char *reason); void resetIncrementalGC(const char *reason);
void incrementalCollectSlice(int64_t budget, JS::gcreason::Reason reason, void incrementalCollectSlice(int64_t budget, JS::gcreason::Reason reason);
JSGCInvocationKind gckind);
void pushZealSelectedObjects(); void pushZealSelectedObjects();
bool beginMarkPhase(JS::gcreason::Reason reason); bool beginMarkPhase(JS::gcreason::Reason reason);
bool shouldPreserveJITCode(JSCompartment *comp, int64_t currentTime, bool shouldPreserveJITCode(JSCompartment *comp, int64_t currentTime,
@ -496,7 +495,7 @@ class GCRuntime
bool shouldReleaseObservedTypes(); bool shouldReleaseObservedTypes();
void endSweepingZoneGroup(); void endSweepingZoneGroup();
bool sweepPhase(SliceBudget &sliceBudget); bool sweepPhase(SliceBudget &sliceBudget);
void endSweepPhase(JSGCInvocationKind gckind, bool lastGC); void endSweepPhase(bool lastGC);
void sweepZones(FreeOp *fop, bool lastGC); void sweepZones(FreeOp *fop, bool lastGC);
void decommitArenasFromAvailableList(Chunk **availableListHeadp); void decommitArenasFromAvailableList(Chunk **availableListHeadp);
void decommitArenas(); void decommitArenas();
@ -612,6 +611,9 @@ class GCRuntime
/* Whether all compartments are being collected in first GC slice. */ /* Whether all compartments are being collected in first GC slice. */
bool isFull; bool isFull;
/* The invocation kind of the current GC, taken from the first slice. */
JSGCInvocationKind invocationKind;
/* The reason that an interrupt-triggered GC should be called. */ /* The reason that an interrupt-triggered GC should be called. */
JS::gcreason::Reason triggerReason; JS::gcreason::Reason triggerReason;

View File

@ -4388,7 +4388,7 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget)
} }
void void
GCRuntime::endSweepPhase(JSGCInvocationKind gckind, bool lastGC) GCRuntime::endSweepPhase(bool lastGC)
{ {
gcstats::AutoPhase ap(stats, gcstats::PHASE_SWEEP); gcstats::AutoPhase ap(stats, gcstats::PHASE_SWEEP);
FreeOp fop(rt); FreeOp fop(rt);
@ -4460,7 +4460,7 @@ GCRuntime::endSweepPhase(JSGCInvocationKind gckind, bool lastGC)
* Expire needs to unlock it for other callers. * Expire needs to unlock it for other callers.
*/ */
AutoLockGC lock(rt); AutoLockGC lock(rt);
expireChunksAndArenas(gckind == GC_SHRINK); expireChunksAndArenas(invocationKind == GC_SHRINK);
} }
} }
@ -4502,7 +4502,8 @@ GCRuntime::endSweepPhase(JSGCInvocationKind gckind, bool lastGC)
schedulingState.updateHighFrequencyMode(lastGCTime, currentTime, tunables); schedulingState.updateHighFrequencyMode(lastGCTime, currentTime, tunables);
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
zone->threshold.updateAfterGC(zone->usage.gcBytes(), gckind, tunables, schedulingState); zone->threshold.updateAfterGC(zone->usage.gcBytes(), invocationKind, tunables,
schedulingState);
if (zone->isCollecting()) { if (zone->isCollecting()) {
JS_ASSERT(zone->isGCFinished()); JS_ASSERT(zone->isGCFinished());
zone->setGCState(Zone::NoGC); zone->setGCState(Zone::NoGC);
@ -4653,7 +4654,7 @@ GCRuntime::resetIncrementalGC(const char *reason)
/* Finish sweeping the current zone group, then abort. */ /* Finish sweeping the current zone group, then abort. */
abortSweepAfterCurrentGroup = true; abortSweepAfterCurrentGroup = true;
incrementalCollectSlice(SliceBudget::Unlimited, JS::gcreason::RESET, GC_NORMAL); incrementalCollectSlice(SliceBudget::Unlimited, JS::gcreason::RESET);
{ {
gcstats::AutoPhase ap(stats, gcstats::PHASE_WAIT_BACKGROUND_THREAD); gcstats::AutoPhase ap(stats, gcstats::PHASE_WAIT_BACKGROUND_THREAD);
@ -4751,8 +4752,7 @@ GCRuntime::pushZealSelectedObjects()
void void
GCRuntime::incrementalCollectSlice(int64_t budget, GCRuntime::incrementalCollectSlice(int64_t budget,
JS::gcreason::Reason reason, JS::gcreason::Reason reason)
JSGCInvocationKind gckind)
{ {
JS_ASSERT(rt->currentThreadHasExclusiveAccess()); JS_ASSERT(rt->currentThreadHasExclusiveAccess());
@ -4865,10 +4865,10 @@ GCRuntime::incrementalCollectSlice(int64_t budget,
if (!finished) if (!finished)
break; break;
endSweepPhase(gckind, lastGC); endSweepPhase(lastGC);
if (sweepOnBackgroundThread) if (sweepOnBackgroundThread)
helperState.startBackgroundSweep(gckind == GC_SHRINK); helperState.startBackgroundSweep(invocationKind == GC_SHRINK);
incrementalState = NO_INCREMENTAL; incrementalState = NO_INCREMENTAL;
break; break;
@ -5031,7 +5031,11 @@ GCRuntime::gcCycle(bool incremental, int64_t budget, JSGCInvocationKind gckind,
TraceMajorGCStart(); TraceMajorGCStart();
incrementalCollectSlice(budget, reason, gckind); /* Set the invocation kind in the first slice. */
if (incrementalState == NO_INCREMENTAL)
invocationKind = gckind;
incrementalCollectSlice(budget, reason);
#ifndef JS_MORE_DETERMINISTIC #ifndef JS_MORE_DETERMINISTIC
nextFullGCTime = PRMJ_Now() + GC_IDLE_FULL_SPAN; nextFullGCTime = PRMJ_Now() + GC_IDLE_FULL_SPAN;