зеркало из https://github.com/mozilla/gecko-dev.git
Bug 538450 - Part 2: Remove JSRuntime::numActiveHelperThreadZones. r=jonco
* AtomsTable::AutoLock is removed in Part 3 * AutoLockAllAtoms is removed in Part 3 * GCRuntime::fullGCForAtomsRequested_ is removed in Part 6 * Zone::canCollect is removed in Part 7 Differential Revision: https://phabricator.services.mozilla.com/D131364
This commit is contained in:
Родитель
9108f6e646
Коммит
cb7cb2f084
|
@ -633,26 +633,6 @@ void Arena::arenaAllocatedDuringGC() {
|
|||
}
|
||||
}
|
||||
|
||||
void GCRuntime::setParallelAtomsAllocEnabled(bool enabled) {
|
||||
// This can only be changed on the main thread otherwise we could race.
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(rt));
|
||||
MOZ_ASSERT(enabled == rt->hasHelperThreadZones());
|
||||
|
||||
atomsZone->arenas.setParallelAllocEnabled(enabled);
|
||||
}
|
||||
|
||||
void ArenaLists::setParallelAllocEnabled(bool enabled) {
|
||||
MOZ_ASSERT(zone_->isAtomsZone());
|
||||
|
||||
static const ConcurrentUse states[2] = {ConcurrentUse::None,
|
||||
ConcurrentUse::ParallelAlloc};
|
||||
|
||||
for (auto kind : AllAllocKinds()) {
|
||||
MOZ_ASSERT(concurrentUse(kind) == states[!enabled]);
|
||||
concurrentUse(kind) = states[enabled];
|
||||
}
|
||||
}
|
||||
|
||||
void GCRuntime::setParallelUnmarkEnabled(bool enabled) {
|
||||
// This can only be changed on the main thread otherwise we could race.
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(rt));
|
||||
|
|
|
@ -258,7 +258,6 @@ class ArenaLists {
|
|||
enum class ConcurrentUse : uint32_t {
|
||||
None,
|
||||
BackgroundFinalize,
|
||||
ParallelAlloc,
|
||||
ParallelUnmark
|
||||
};
|
||||
|
||||
|
@ -346,7 +345,6 @@ class ArenaLists {
|
|||
void mergeFinalizedArenas(AllocKind thingKind,
|
||||
SortedArenaList& finalizedArenas);
|
||||
|
||||
void setParallelAllocEnabled(bool enabled);
|
||||
void setParallelUnmarkEnabled(bool enabled);
|
||||
|
||||
inline void mergeNewArenasInMarkPhase();
|
||||
|
|
|
@ -75,7 +75,6 @@ void AtomMarkingRuntime::unregisterArena(Arena* arena, const AutoLockGC& lock) {
|
|||
bool AtomMarkingRuntime::computeBitmapFromChunkMarkBits(JSRuntime* runtime,
|
||||
DenseBitmap& bitmap) {
|
||||
MOZ_ASSERT(CurrentThreadIsPerformingGC());
|
||||
MOZ_ASSERT(!runtime->hasHelperThreadZones());
|
||||
|
||||
if (!bitmap.ensureSpace(allocatedWords)) {
|
||||
return false;
|
||||
|
@ -129,7 +128,6 @@ static void BitwiseOrIntoChunkMarkBits(JSRuntime* runtime, Bitmap& bitmap) {
|
|||
|
||||
void AtomMarkingRuntime::markAtomsUsedByUncollectedZones(JSRuntime* runtime) {
|
||||
MOZ_ASSERT(CurrentThreadIsPerformingGC());
|
||||
MOZ_ASSERT(!runtime->hasHelperThreadZones());
|
||||
|
||||
// Try to compute a simple union of the zone atom bitmaps before updating
|
||||
// the chunk mark bitmaps. If this allocation fails then fall back to
|
||||
|
|
|
@ -1574,12 +1574,6 @@ bool GCRuntime::triggerZoneGC(Zone* zone, JS::GCReason reason, size_t used,
|
|||
#endif
|
||||
|
||||
if (zone->isAtomsZone()) {
|
||||
/* We can't do a zone GC of just the atoms zone. */
|
||||
if (rt->hasHelperThreadZones()) {
|
||||
/* We can't collect atoms while off-thread parsing is allocating. */
|
||||
fullGCForAtomsRequested_ = true;
|
||||
return false;
|
||||
}
|
||||
stats().recordTrigger(used, threshold);
|
||||
MOZ_RELEASE_ASSERT(triggerGC(reason));
|
||||
return true;
|
||||
|
@ -1642,7 +1636,6 @@ void GCRuntime::triggerFullGCForAtoms(JSContext* cx) {
|
|||
MOZ_ASSERT(fullGCForAtomsRequested_);
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(rt));
|
||||
MOZ_ASSERT(!JS::RuntimeHeapIsCollecting());
|
||||
MOZ_ASSERT(cx->canCollectAtoms());
|
||||
fullGCForAtomsRequested_ = false;
|
||||
MOZ_RELEASE_ASSERT(triggerGC(JS::GCReason::DELAYED_ATOMS_GC));
|
||||
}
|
||||
|
@ -2170,22 +2163,8 @@ static bool ShouldCollectZone(Zone* zone, JS::GCReason reason) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// If canCollectAtoms() is false then parsing is currently happening on
|
||||
// another thread, in which case we don't have information about which atoms
|
||||
// are roots, so we must skip collecting atoms.
|
||||
//
|
||||
// Note that only affects the first slice of an incremental GC since root
|
||||
// marking is completed before we return to the mutator.
|
||||
//
|
||||
// Off-thread parsing is inhibited after the start of GC which prevents
|
||||
// races between creating atoms during parsing and sweeping atoms on the
|
||||
// main thread.
|
||||
//
|
||||
// Otherwise, we always schedule a GC in the atoms zone so that atoms which
|
||||
// the other collected zones are using are marked, and we can update the
|
||||
// set of atoms in use by the other collected zones at the end of the GC.
|
||||
if (zone->isAtomsZone()) {
|
||||
return TlsContext.get()->canCollectAtoms();
|
||||
return true;
|
||||
}
|
||||
|
||||
return zone->canCollect();
|
||||
|
@ -4127,14 +4106,6 @@ bool GCRuntime::gcIfRequested() {
|
|||
}
|
||||
|
||||
if (majorGCRequested()) {
|
||||
if (majorGCTriggerReason == JS::GCReason::DELAYED_ATOMS_GC &&
|
||||
!rt->mainContextFromOwnThread()->canCollectAtoms()) {
|
||||
// A GC was requested to collect the atoms zone, but it's no longer
|
||||
// possible. Skip this collection.
|
||||
majorGCTriggerReason = JS::GCReason::NO_REASON;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isIncrementalGCInProgress()) {
|
||||
startGC(JS::GCOptions::Normal, majorGCTriggerReason);
|
||||
} else {
|
||||
|
|
|
@ -82,9 +82,6 @@ class MOZ_RAII AutoCheckCanAccessAtomsDuringGC {
|
|||
// Ensure we're only used from within the GC.
|
||||
MOZ_ASSERT(JS::RuntimeHeapIsMajorCollecting());
|
||||
|
||||
// Ensure there is no off-thread parsing running.
|
||||
MOZ_ASSERT(!rt->hasHelperThreadZones());
|
||||
|
||||
// Set up a check to assert if we try to start an off-thread parse.
|
||||
runtime->setOffThreadParsingBlocked(true);
|
||||
}
|
||||
|
|
|
@ -605,7 +605,6 @@ class GCRuntime {
|
|||
AllocKind kind);
|
||||
static TenuredCell* refillFreeListInGC(Zone* zone, AllocKind thingKind);
|
||||
|
||||
void setParallelAtomsAllocEnabled(bool enabled);
|
||||
void setParallelUnmarkEnabled(bool enabled);
|
||||
|
||||
/*
|
||||
|
|
|
@ -52,9 +52,6 @@ class GCZonesIter {
|
|||
public:
|
||||
explicit GCZonesIter(GCRuntime* gc) : zone(gc) {
|
||||
MOZ_ASSERT(JS::RuntimeHeapIsBusy());
|
||||
MOZ_ASSERT_IF(gc->atomsZone->wasGCStarted(),
|
||||
!gc->rt->hasHelperThreadZones());
|
||||
|
||||
if (!done() && !zone->wasGCStarted()) {
|
||||
next();
|
||||
}
|
||||
|
|
|
@ -209,8 +209,7 @@ void gc::GCRuntime::startVerifyPreBarriers() {
|
|||
|
||||
JSContext* cx = rt->mainContextFromOwnThread();
|
||||
|
||||
if (IsIncrementalGCUnsafe(rt) != GCAbortReason::None ||
|
||||
rt->hasHelperThreadZones()) {
|
||||
if (IsIncrementalGCUnsafe(rt) != GCAbortReason::None) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -374,8 +373,7 @@ void gc::GCRuntime::endVerifyPreBarriers() {
|
|||
MOZ_ASSERT(incrementalState == State::Mark);
|
||||
incrementalState = State::NotActive;
|
||||
|
||||
if (!compartmentCreated && IsIncrementalGCUnsafe(rt) == GCAbortReason::None &&
|
||||
!rt->hasHelperThreadZones()) {
|
||||
if (!compartmentCreated && IsIncrementalGCUnsafe(rt) == GCAbortReason::None) {
|
||||
CheckEdgeTracer cetrc(rt);
|
||||
|
||||
/* Start after the roots. */
|
||||
|
|
|
@ -568,15 +568,7 @@ bool Zone::hasMarkedRealms() {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Zone::canCollect() {
|
||||
// The atoms zone cannot be collected while off-thread parsing is taking
|
||||
// place.
|
||||
if (isAtomsZone()) {
|
||||
return !runtimeFromAnyThread()->hasHelperThreadZones();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool Zone::canCollect() { return true; }
|
||||
|
||||
void Zone::notifyObservingDebuggers() {
|
||||
AutoAssertNoGC nogc;
|
||||
|
|
|
@ -313,21 +313,9 @@ void JSRuntime::finishAtoms() {
|
|||
}
|
||||
|
||||
class AtomsTable::AutoLock {
|
||||
Mutex* lock = nullptr;
|
||||
|
||||
public:
|
||||
MOZ_ALWAYS_INLINE explicit AutoLock(JSRuntime* rt, Mutex& aLock) {
|
||||
if (rt->hasHelperThreadZones()) {
|
||||
lock = &aLock;
|
||||
lock->lock();
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE ~AutoLock() {
|
||||
if (lock) {
|
||||
lock->unlock();
|
||||
}
|
||||
}
|
||||
MOZ_ALWAYS_INLINE AutoLock(JSRuntime* rt, Mutex& aLock) {}
|
||||
MOZ_ALWAYS_INLINE ~AutoLock() {}
|
||||
};
|
||||
|
||||
AtomsTable::Partition::Partition(uint32_t index)
|
||||
|
@ -1211,14 +1199,8 @@ Handle<PropertyName*> js::ClassName(JSProtoKey key, JSContext* cx) {
|
|||
|
||||
js::AutoLockAllAtoms::AutoLockAllAtoms(JSRuntime* rt) : runtime(rt) {
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(runtime));
|
||||
if (runtime->hasHelperThreadZones()) {
|
||||
runtime->atoms().lockAll();
|
||||
}
|
||||
}
|
||||
|
||||
js::AutoLockAllAtoms::~AutoLockAllAtoms() {
|
||||
MOZ_ASSERT(CurrentThreadCanAccessRuntime(runtime));
|
||||
if (runtime->hasHelperThreadZones()) {
|
||||
runtime->atoms().unlockAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -634,12 +634,6 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext,
|
|||
// with AutoDisableCompactingGC which uses this counter.
|
||||
js::ContextData<unsigned> compactingDisabledCount;
|
||||
|
||||
bool canCollectAtoms() const {
|
||||
// TODO: We may be able to improve this by collecting if
|
||||
// !isOffThreadParseRunning() (bug 1468422).
|
||||
return !runtime()->hasHelperThreadZones();
|
||||
}
|
||||
|
||||
private:
|
||||
// Pools used for recycling name maps and vectors when parsing and
|
||||
// emitting bytecode. Purged on GC when there are no active script
|
||||
|
|
|
@ -124,7 +124,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
|
|||
activeThreadHasScriptDataAccess(false),
|
||||
#endif
|
||||
numParseTasks(0),
|
||||
numActiveHelperThreadZones(0),
|
||||
numRealms(0),
|
||||
numDebuggeeRealms_(0),
|
||||
numDebuggeeRealmsObservingCoverage_(0),
|
||||
|
@ -294,8 +293,6 @@ void JSRuntime::destroyRuntime() {
|
|||
|
||||
AutoNoteSingleThreadedRegion anstr;
|
||||
|
||||
MOZ_ASSERT(!hasHelperThreadZones());
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
AutoLockScriptData lock(this);
|
||||
|
|
|
@ -572,15 +572,10 @@ struct JSRuntime {
|
|||
// protect access to the bytecode table;
|
||||
mozilla::Atomic<size_t, mozilla::SequentiallyConsistent> numParseTasks;
|
||||
|
||||
// Number of zones which may be operated on by helper threads.
|
||||
mozilla::Atomic<size_t, mozilla::SequentiallyConsistent>
|
||||
numActiveHelperThreadZones;
|
||||
|
||||
friend class js::AutoLockScriptData;
|
||||
|
||||
public:
|
||||
bool hasParseTasks() const { return numParseTasks > 0; }
|
||||
bool hasHelperThreadZones() const { return numActiveHelperThreadZones > 0; }
|
||||
|
||||
void addParseTaskRef() { numParseTasks++; }
|
||||
void decParseTaskRef() { numParseTasks--; }
|
||||
|
|
Загрузка…
Ссылка в новой задаче