зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1382720 - Move zone state assertion into state update method r=sfink
This commit is contained in:
Родитель
13ee60d3e3
Коммит
1aa04fef20
|
@ -218,11 +218,12 @@ struct Zone : public JS::shadow::Zone,
|
|||
|
||||
void notifyObservingDebuggers();
|
||||
|
||||
void setGCState(GCState state) {
|
||||
void changeGCState(GCState prev, GCState next) {
|
||||
MOZ_ASSERT(CurrentThreadIsHeapBusy());
|
||||
MOZ_ASSERT_IF(state != NoGC, canCollect());
|
||||
gcState_ = state;
|
||||
if (state == Finished)
|
||||
MOZ_ASSERT(gcState() == prev);
|
||||
MOZ_ASSERT_IF(next != NoGC, canCollect());
|
||||
gcState_ = next;
|
||||
if (isGCFinished())
|
||||
notifyObservingDebuggers();
|
||||
}
|
||||
|
||||
|
|
|
@ -3876,7 +3876,7 @@ GCRuntime::prepareZonesForCollection(JS::gcreason::Reason reason, bool* isFullOu
|
|||
if (ShouldCollectZone(zone, reason)) {
|
||||
if (!zone->isAtomsZone()) {
|
||||
any = true;
|
||||
zone->setGCState(Zone::Mark);
|
||||
zone->changeGCState(Zone::NoGC, Zone::Mark);
|
||||
}
|
||||
} else {
|
||||
*isFullOut = false;
|
||||
|
@ -3924,7 +3924,7 @@ GCRuntime::prepareZonesForCollection(JS::gcreason::Reason reason, bool* isFullOu
|
|||
Zone* atomsZone = rt->atomsCompartment(lock)->zone();
|
||||
if (atomsZone->isGCScheduled()) {
|
||||
MOZ_ASSERT(!atomsZone->isCollecting());
|
||||
atomsZone->setGCState(Zone::Mark);
|
||||
atomsZone->changeGCState(Zone::NoGC, Zone::Mark);
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
|
@ -4390,20 +4390,16 @@ js::gc::MarkingValidator::nonIncrementalMark(AutoLockForExclusiveAccess& lock)
|
|||
gc->markAllWeakReferences(gcstats::PhaseKind::SWEEP_MARK_WEAK);
|
||||
|
||||
/* Update zone state for gray marking. */
|
||||
for (GCZonesIter zone(runtime); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(zone->isGCMarkingBlack());
|
||||
zone->setGCState(Zone::MarkGray);
|
||||
}
|
||||
for (GCZonesIter zone(runtime); !zone.done(); zone.next())
|
||||
zone->changeGCState(Zone::Mark, Zone::MarkGray);
|
||||
gc->marker.setMarkColorGray();
|
||||
|
||||
gc->markAllGrayReferences(gcstats::PhaseKind::SWEEP_MARK_GRAY);
|
||||
gc->markAllWeakReferences(gcstats::PhaseKind::SWEEP_MARK_GRAY_WEAK);
|
||||
|
||||
/* Restore zone state. */
|
||||
for (GCZonesIter zone(runtime); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(zone->isGCMarkingGray());
|
||||
zone->setGCState(Zone::Mark);
|
||||
}
|
||||
for (GCZonesIter zone(runtime); !zone.done(); zone.next())
|
||||
zone->changeGCState(Zone::MarkGray, Zone::Mark);
|
||||
MOZ_ASSERT(gc->marker.isDrained());
|
||||
gc->marker.setMarkColorBlack();
|
||||
}
|
||||
|
@ -4711,9 +4707,8 @@ GCRuntime::getNextSweepGroup()
|
|||
MOZ_ASSERT(!isIncremental);
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(!zone->gcNextGraphComponent);
|
||||
MOZ_ASSERT(zone->isGCMarking());
|
||||
zone->setNeedsIncrementalBarrier(false);
|
||||
zone->setGCState(Zone::NoGC);
|
||||
zone->changeGCState(Zone::Mark, Zone::NoGC);
|
||||
zone->gcGrayRoots().clearAndFree();
|
||||
}
|
||||
|
||||
|
@ -4984,10 +4979,8 @@ GCRuntime::endMarkingSweepGroup()
|
|||
* these will be marked through, as they are not marked with
|
||||
* MarkCrossCompartmentXXX.
|
||||
*/
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(zone->isGCMarkingBlack());
|
||||
zone->setGCState(Zone::MarkGray);
|
||||
}
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next())
|
||||
zone->changeGCState(Zone::Mark, Zone::MarkGray);
|
||||
marker.setMarkColorGray();
|
||||
|
||||
/* Mark incoming gray pointers from previously swept compartments. */
|
||||
|
@ -4998,10 +4991,8 @@ GCRuntime::endMarkingSweepGroup()
|
|||
markWeakReferencesInCurrentGroup(gcstats::PhaseKind::SWEEP_MARK_GRAY_WEAK);
|
||||
|
||||
/* Restore marking state. */
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(zone->isGCMarkingGray());
|
||||
zone->setGCState(Zone::Mark);
|
||||
}
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next())
|
||||
zone->changeGCState(Zone::MarkGray, Zone::Mark);
|
||||
MOZ_ASSERT(marker.isDrained());
|
||||
marker.setMarkColorBlack();
|
||||
}
|
||||
|
@ -5306,8 +5297,7 @@ GCRuntime::beginSweepingSweepGroup()
|
|||
bool sweepingAtoms = false;
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
/* Set the GC state to sweeping. */
|
||||
MOZ_ASSERT(zone->isGCMarking());
|
||||
zone->setGCState(Zone::Sweep);
|
||||
zone->changeGCState(Zone::Mark, Zone::Sweep);
|
||||
|
||||
/* Purge the ArenaLists before sweeping. */
|
||||
zone->arenas.purge();
|
||||
|
@ -5412,9 +5402,8 @@ GCRuntime::endSweepingSweepGroup()
|
|||
|
||||
/* Update the GC state for zones we have swept. */
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(zone->isGCSweeping());
|
||||
AutoLockGC lock(rt);
|
||||
zone->setGCState(Zone::Finished);
|
||||
zone->changeGCState(Zone::Sweep, Zone::Finished);
|
||||
zone->threshold.updateAfterGC(zone->usage.gcBytes(), invocationKind, tunables,
|
||||
schedulingState, lock);
|
||||
}
|
||||
|
@ -6086,14 +6075,13 @@ GCRuntime::compactPhase(JS::gcreason::Reason reason, SliceBudget& sliceBudget,
|
|||
zonesToMaybeCompact.ref().removeFront();
|
||||
|
||||
MOZ_ASSERT(zone->group()->nursery().isEmpty());
|
||||
MOZ_ASSERT(zone->isGCFinished());
|
||||
zone->setGCState(Zone::Compact);
|
||||
zone->changeGCState(Zone::Finished, Zone::Compact);
|
||||
|
||||
if (relocateArenas(zone, reason, relocatedArenas, sliceBudget)) {
|
||||
updateZonePointersToRelocatedCells(zone, lock);
|
||||
relocatedZones.append(zone);
|
||||
} else {
|
||||
zone->setGCState(Zone::Finished);
|
||||
zone->changeGCState(Zone::Compact, Zone::Finished);
|
||||
}
|
||||
|
||||
if (sliceBudget.isOverBudget())
|
||||
|
@ -6106,7 +6094,7 @@ GCRuntime::compactPhase(JS::gcreason::Reason reason, SliceBudget& sliceBudget,
|
|||
do {
|
||||
Zone* zone = relocatedZones.front();
|
||||
relocatedZones.removeFront();
|
||||
zone->setGCState(Zone::Finished);
|
||||
zone->changeGCState(Zone::Compact, Zone::Finished);
|
||||
}
|
||||
while (!relocatedZones.isEmpty());
|
||||
}
|
||||
|
@ -6148,8 +6136,7 @@ GCRuntime::finishCollection(JS::gcreason::Reason reason)
|
|||
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
if (zone->isCollecting()) {
|
||||
MOZ_ASSERT(zone->isGCFinished());
|
||||
zone->setGCState(Zone::NoGC);
|
||||
zone->changeGCState(Zone::Finished, Zone::NoGC);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!zone->isCollectingFromAnyThread());
|
||||
|
@ -6253,9 +6240,8 @@ GCRuntime::resetIncrementalGC(gc::AbortReason reason, AutoLockForExclusiveAccess
|
|||
ResetGrayList(c);
|
||||
|
||||
for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(zone->isGCMarking());
|
||||
zone->setNeedsIncrementalBarrier(false);
|
||||
zone->setGCState(Zone::NoGC);
|
||||
zone->changeGCState(Zone::Mark, Zone::NoGC);
|
||||
}
|
||||
|
||||
blocksToFreeAfterSweeping.ref().freeAll();
|
||||
|
|
Загрузка…
Ссылка в новой задаче