From 62aae1e86959f0d3b94ef65c4a41533ecbdb3ed7 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Thu, 14 Aug 2014 11:46:46 +0100 Subject: [PATCH] Bug 650161 - Use the invocation kind passed to the first slice for the whole GC r=terrence --- js/src/gc/GCRuntime.h | 10 ++++++---- js/src/jsgc.cpp | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index b9f7a03caa9..6d1d5dc88cd 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -424,7 +424,7 @@ class GCRuntime bool isGcNeeded() { return isNeeded; } 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; } void setGCMode(JSGCMode m) { @@ -475,8 +475,7 @@ class GCRuntime gcstats::ZoneGCStats scanZonesBeforeGC(); void budgetIncrementalGC(int64_t *budget); void resetIncrementalGC(const char *reason); - void incrementalCollectSlice(int64_t budget, JS::gcreason::Reason reason, - JSGCInvocationKind gckind); + void incrementalCollectSlice(int64_t budget, JS::gcreason::Reason reason); void pushZealSelectedObjects(); bool beginMarkPhase(JS::gcreason::Reason reason); bool shouldPreserveJITCode(JSCompartment *comp, int64_t currentTime, @@ -496,7 +495,7 @@ class GCRuntime bool shouldReleaseObservedTypes(); void endSweepingZoneGroup(); bool sweepPhase(SliceBudget &sliceBudget); - void endSweepPhase(JSGCInvocationKind gckind, bool lastGC); + void endSweepPhase(bool lastGC); void sweepZones(FreeOp *fop, bool lastGC); void decommitArenasFromAvailableList(Chunk **availableListHeadp); void decommitArenas(); @@ -612,6 +611,9 @@ class GCRuntime /* Whether all compartments are being collected in first GC slice. */ 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. */ JS::gcreason::Reason triggerReason; diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 706ba90584f..24c7a6b7b6b 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -4388,7 +4388,7 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget) } void -GCRuntime::endSweepPhase(JSGCInvocationKind gckind, bool lastGC) +GCRuntime::endSweepPhase(bool lastGC) { gcstats::AutoPhase ap(stats, gcstats::PHASE_SWEEP); FreeOp fop(rt); @@ -4460,7 +4460,7 @@ GCRuntime::endSweepPhase(JSGCInvocationKind gckind, bool lastGC) * Expire needs to unlock it for other callers. */ 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); 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()) { JS_ASSERT(zone->isGCFinished()); zone->setGCState(Zone::NoGC); @@ -4653,7 +4654,7 @@ GCRuntime::resetIncrementalGC(const char *reason) /* Finish sweeping the current zone group, then abort. */ 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); @@ -4751,8 +4752,7 @@ GCRuntime::pushZealSelectedObjects() void GCRuntime::incrementalCollectSlice(int64_t budget, - JS::gcreason::Reason reason, - JSGCInvocationKind gckind) + JS::gcreason::Reason reason) { JS_ASSERT(rt->currentThreadHasExclusiveAccess()); @@ -4865,10 +4865,10 @@ GCRuntime::incrementalCollectSlice(int64_t budget, if (!finished) break; - endSweepPhase(gckind, lastGC); + endSweepPhase(lastGC); if (sweepOnBackgroundThread) - helperState.startBackgroundSweep(gckind == GC_SHRINK); + helperState.startBackgroundSweep(invocationKind == GC_SHRINK); incrementalState = NO_INCREMENTAL; break; @@ -5031,7 +5031,11 @@ GCRuntime::gcCycle(bool incremental, int64_t budget, JSGCInvocationKind gckind, 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 nextFullGCTime = PRMJ_Now() + GC_IDLE_FULL_SPAN;