Bug 1343986 - Fix setting of gray bits valid flag after GC r=sfink

This commit is contained in:
Jon Coppeard 2017-03-04 08:59:42 +00:00
Родитель a440da6b86
Коммит 4fe8b300d4
3 изменённых файлов: 38 добавлений и 3 удалений

Просмотреть файл

@ -987,6 +987,7 @@ class GCRuntime
void endSweepingZoneGroup();
IncrementalProgress sweepPhase(SliceBudget& sliceBudget, AutoLockForExclusiveAccess& lock);
void endSweepPhase(bool lastGC, AutoLockForExclusiveAccess& lock);
bool allCCVisibleZonesWereCollected() const;
void sweepZones(FreeOp* fop, ZoneGroup* group, bool lastGC);
void sweepZoneGroups(FreeOp* fop, bool destroyingRuntime);
void decommitAllWithoutUnlocking(const AutoLockGC& lock);

Просмотреть файл

@ -221,6 +221,9 @@ js::CheckTracedThing(JSTracer* trc, T* thing)
MOZ_ASSERT(zone->runtimeFromAnyThread() == trc->runtime());
// It shouldn't be possible to trace into zones used by helper threads.
MOZ_ASSERT(!zone->usedByHelperThread());
MOZ_ASSERT(thing->isAligned());
MOZ_ASSERT(MapTypeToTraceKind<typename mozilla::RemovePointer<T>::Type>::kind ==
thing->getTraceKind());

Просмотреть файл

@ -5440,6 +5440,36 @@ GCRuntime::sweepPhase(SliceBudget& sliceBudget, AutoLockForExclusiveAccess& lock
}
}
bool
GCRuntime::allCCVisibleZonesWereCollected() const
{
// Calculate whether the gray marking state is now valid.
//
// The gray bits change from invalid to valid if we finished a full GC from
// the point of view of the cycle collector. We ignore the following:
//
// - Helper thread zones, as these are not reachable from the main heap.
// - The atoms zone, since strings and symbols are never marked gray.
// - Empty zones.
//
// These exceptions ensure that when the CC requests a full GC the gray mark
// state ends up valid even it we don't collect all of the zones.
if (isFull)
return true;
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
if (!zone->isCollecting() &&
!zone->usedByHelperThread() &&
!zone->arenas.arenaListsAreEmpty())
{
return false;
}
}
return true;
}
void
GCRuntime::endSweepPhase(bool destroyingRuntime, AutoLockForExclusiveAccess& lock)
{
@ -5485,8 +5515,7 @@ GCRuntime::endSweepPhase(bool destroyingRuntime, AutoLockForExclusiveAccess& loc
gcstats::AutoPhase ap(stats(), gcstats::PHASE_FINALIZE_END);
callFinalizeCallbacks(&fop, JSFINALIZE_COLLECTION_END);
/* If we finished a full GC, then the gray bits are correct. */
if (isFull)
if (allCCVisibleZonesWereCollected())
grayBitsValid = true;
}
@ -7834,7 +7863,9 @@ js::gc::detail::CellIsMarkedGrayIfKnown(const Cell* cell)
return false;
auto tc = &cell->asTenured();
auto rt = tc->runtimeFromAnyThread();
MOZ_ASSERT(!tc->zoneFromAnyThread()->usedByHelperThread());
auto rt = tc->runtimeFromActiveCooperatingThread();
if (rt->gc.isIncrementalGCInProgress() && !tc->zone()->wasGCStarted())
return false;