Bug 1608069 - Move sweeping of finalization groups to main thread so the browser doesn't get confused when called from our helper threads r=sfink

Differential Revision: https://phabricator.services.mozilla.com/D59374

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jon Coppeard 2020-01-10 17:22:25 +00:00
parent c7b5617848
commit 7cddbcdb64
2 changed files with 8 additions and 9 deletions

View File

@ -4912,10 +4912,12 @@ static void SweepUniqueIds(GCParallelTask* task) {
} }
} }
void js::gc::SweepFinalizationGroups(GCParallelTask* task) { void GCRuntime::sweepFinalizationGroupsOnMainThread() {
for (SweepGroupZonesIter zone(task->gc); !zone.done(); zone.next()) { // This calls back into the browser which expects to be called from the main
AutoSetThreadIsSweeping threadIsSweeping(zone); // thread.
task->gc->sweepFinalizationGroups(zone); gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::SWEEP_FINALIZATION_GROUPS);
for (SweepGroupZonesIter zone(this); !zone.done(); zone.next()) {
sweepFinalizationGroups(zone);
} }
} }
@ -5194,9 +5196,6 @@ IncrementalProgress GCRuntime::beginSweepingSweepGroup(JSFreeOp* fop,
PhaseKind::SWEEP_WEAKMAPS, lock); PhaseKind::SWEEP_WEAKMAPS, lock);
AutoRunParallelTask sweepUniqueIds(this, SweepUniqueIds, AutoRunParallelTask sweepUniqueIds(this, SweepUniqueIds,
PhaseKind::SWEEP_UNIQUEIDS, lock); PhaseKind::SWEEP_UNIQUEIDS, lock);
AutoRunParallelTask sweepFinalizationGroups(
this, SweepFinalizationGroups, PhaseKind::SWEEP_FINALIZATION_GROUPS,
lock);
AutoRunParallelTask sweepWeakRefs(this, SweepWeakRefs, AutoRunParallelTask sweepWeakRefs(this, SweepWeakRefs,
PhaseKind::SWEEP_WEAKREFS, lock); PhaseKind::SWEEP_WEAKREFS, lock);
@ -5212,6 +5211,7 @@ IncrementalProgress GCRuntime::beginSweepingSweepGroup(JSFreeOp* fop,
{ {
AutoUnlockHelperThreadState unlock(lock); AutoUnlockHelperThreadState unlock(lock);
sweepJitDataOnMainThread(fop); sweepJitDataOnMainThread(fop);
sweepFinalizationGroupsOnMainThread();
} }
for (auto& task : sweepCacheTasks) { for (auto& task : sweepCacheTasks) {

View File

@ -248,7 +248,6 @@ class ZoneList {
ZoneList& operator=(const ZoneList& other) = delete; ZoneList& operator=(const ZoneList& other) = delete;
}; };
void SweepFinalizationGroups(GCParallelTask* task);
void SweepWeakRefs(GCParallelTask* task); void SweepWeakRefs(GCParallelTask* task);
class GCRuntime { class GCRuntime {
@ -701,8 +700,8 @@ class GCRuntime {
void updateAtomsBitmap(); void updateAtomsBitmap();
void sweepDebuggerOnMainThread(JSFreeOp* fop); void sweepDebuggerOnMainThread(JSFreeOp* fop);
void sweepJitDataOnMainThread(JSFreeOp* fop); void sweepJitDataOnMainThread(JSFreeOp* fop);
void sweepFinalizationGroupsOnMainThread();
void sweepFinalizationGroups(Zone* zone); void sweepFinalizationGroups(Zone* zone);
friend void SweepFinalizationGroups(GCParallelTask* task);
void queueFinalizationGroupForCleanup(FinalizationGroupObject* group); void queueFinalizationGroupForCleanup(FinalizationGroupObject* group);
void sweepWeakRefs(Zone* zone); void sweepWeakRefs(Zone* zone);
friend void SweepWeakRefs(GCParallelTask* task); friend void SweepWeakRefs(GCParallelTask* task);