diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index b13729cb96f..a5dba7775f1 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1696,8 +1696,7 @@ GCRuntime::computeHeapGrowthFactor(size_t lastBytes) factor = lowFrequencyHeapGrowth; } else { JS_ASSERT(highFrequencyHighLimitBytes > highFrequencyLowLimitBytes); - uint64_t now = PRMJ_Now(); - if (lastGCTime && lastGCTime + highFrequencyTimeThreshold * PRMJ_USEC_PER_MSEC > now) { + if (highFrequencyGC) { if (lastBytes <= highFrequencyLowLimitBytes) { factor = highFrequencyHeapGrowthMax; } else if (lastBytes >= highFrequencyHighLimitBytes) { @@ -1710,10 +1709,8 @@ GCRuntime::computeHeapGrowthFactor(size_t lastBytes) JS_ASSERT(factor <= highFrequencyHeapGrowthMax && factor >= highFrequencyHeapGrowthMin); } - highFrequencyGC = true; } else { factor = lowFrequencyHeapGrowth; - highFrequencyGC = false; } } @@ -4476,6 +4473,10 @@ GCRuntime::endSweepPhase(JSGCInvocationKind gckind, bool lastGC) sweepZones(&fop, lastGC); } + uint64_t currentTime = PRMJ_Now(); + highFrequencyGC = dynamicHeapGrowth && lastGCTime && + lastGCTime + highFrequencyTimeThreshold * PRMJ_USEC_PER_MSEC > currentTime; + for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { zone->setGCLastBytes(zone->gcBytes, gckind); if (zone->isCollecting()) { @@ -4509,7 +4510,7 @@ GCRuntime::endSweepPhase(JSGCInvocationKind gckind, bool lastGC) finishMarkingValidation(); - lastGCTime = PRMJ_Now(); + lastGCTime = currentTime; } /* Start a new heap session. */