author | Jan de Mooij <jdemooij@mozilla.com> |
Tue, 17 Apr 2018 10:47:33 +0200 | |
changeset 414076 | 7cb5e6101f4a788d162e8aa7e8002f0f8c6d080e |
parent 414075 | 44662c81a04d0e0f5a2f10f98bdf1b9ffbcdf19f |
child 414077 | d46b75deaae586798e885c3e61f8efb0bfdb3069 |
push id | 33858 |
push user | ncsoregi@mozilla.com |
push date | Tue, 17 Apr 2018 21:55:44 +0000 |
treeherder | mozilla-central@d6eb5597d744 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jonco |
bugs | 1452982 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/gc/ArenaList.h +++ b/js/src/gc/ArenaList.h @@ -246,17 +246,17 @@ class ArenaLists BackgroundFinalizeState; /* The current background finalization state, accessed atomically. */ UnprotectedData<AllAllocKindArray<BackgroundFinalizeState>> backgroundFinalizeState_; BackgroundFinalizeState& backgroundFinalizeState(AllocKind i) { return backgroundFinalizeState_.ref()[i]; } const BackgroundFinalizeState& backgroundFinalizeState(AllocKind i) const { return backgroundFinalizeState_.ref()[i]; } /* For each arena kind, a list of arenas remaining to be swept. */ - ActiveThreadOrGCTaskData<AllAllocKindArray<Arena*>> arenaListsToSweep_; + MainThreadOrGCTaskData<AllAllocKindArray<Arena*>> arenaListsToSweep_; Arena*& arenaListsToSweep(AllocKind i) { return arenaListsToSweep_.ref()[i]; } Arena* arenaListsToSweep(AllocKind i) const { return arenaListsToSweep_.ref()[i]; } /* During incremental sweeping, a list of the arenas already swept. */ ZoneOrGCTaskData<AllocKind> incrementalSweptArenaKind; ZoneOrGCTaskData<ArenaList> incrementalSweptArenas; // Arena lists which have yet to be swept, but need additional foreground
--- a/js/src/gc/GCHelperState.h +++ b/js/src/gc/GCHelperState.h @@ -37,17 +37,17 @@ class GCHelperState JSRuntime* const rt; // Condvar for notifying the active thread when work has finished. This is // associated with the runtime's GC lock --- the worker thread state // condvars can't be used here due to lock ordering issues. ConditionVariable done; // Activity for the helper to do, protected by the GC lock. - ActiveThreadOrGCTaskData<State> state_; + MainThreadOrGCTaskData<State> state_; // Whether work is being performed on some thread. GCLockData<bool> hasThread; void startBackgroundThread(State newState, const AutoLockGC& lock, const AutoLockHelperThreadState& helperLock); void waitForBackgroundThread(js::AutoLockGC& lock);
--- a/js/src/gc/GCMarker.h +++ b/js/src/gc/GCMarker.h @@ -169,23 +169,23 @@ class MarkStack MOZ_MUST_USE bool ensureSpace(size_t count); /* Grow the stack, ensuring there is space for at least count elements. */ MOZ_MUST_USE bool enlarge(size_t count); const TaggedPtr& peekPtr() const; MOZ_MUST_USE bool pushTaggedPtr(Tag tag, Cell* ptr); - ActiveThreadData<TaggedPtr*> stack_; - ActiveThreadData<TaggedPtr*> tos_; - ActiveThreadData<TaggedPtr*> end_; + MainThreadData<TaggedPtr*> stack_; + MainThreadData<TaggedPtr*> tos_; + MainThreadData<TaggedPtr*> end_; // The capacity we start with and reset() to. - ActiveThreadData<size_t> baseCapacity_; - ActiveThreadData<size_t> maxCapacity_; + MainThreadData<size_t> baseCapacity_; + MainThreadData<size_t> maxCapacity_; #ifdef DEBUG mutable size_t iteratorCount_; #endif friend class MarkStackIter; }; @@ -344,39 +344,39 @@ class GCMarker : public JSTracer HeapSlot** vpp, HeapSlot** endp); void saveValueRanges(); inline void processMarkStackTop(SliceBudget& budget); /* The mark stack. Pointers in this stack are "gray" in the GC sense. */ gc::MarkStack stack; /* The color is only applied to objects and functions. */ - ActiveThreadData<gc::MarkColor> color; + MainThreadData<gc::MarkColor> color; /* Pointer to the top of the stack of arenas we are delaying marking on. */ - ActiveThreadData<js::gc::Arena*> unmarkedArenaStackTop; + MainThreadData<js::gc::Arena*> unmarkedArenaStackTop; /* * If the weakKeys table OOMs, disable the linear algorithm and fall back * to iterating until the next GC. */ - ActiveThreadData<bool> linearWeakMarkingDisabled_; + MainThreadData<bool> linearWeakMarkingDisabled_; #ifdef DEBUG /* Count of arenas that are currently in the stack. */ - ActiveThreadData<size_t> markLaterArenas; + MainThreadData<size_t> markLaterArenas; /* Assert that start and stop are called with correct ordering. */ - ActiveThreadData<bool> started; + MainThreadData<bool> started; /* * If this is true, all marked objects must belong to a compartment being * GCed. This is used to look for compartment bugs. */ - ActiveThreadData<bool> strictCompartmentChecking; + MainThreadData<bool> strictCompartmentChecking; #endif // DEBUG }; } /* namespace js */ // Exported for Tracer.cpp inline bool ThingIsPermanentAtomOrWellKnownSymbol(js::gc::Cell* thing) { return false; } bool ThingIsPermanentAtomOrWellKnownSymbol(JSString*);
--- a/js/src/gc/GCParallelTask.h +++ b/js/src/gc/GCParallelTask.h @@ -23,17 +23,17 @@ class GCParallelTask enum TaskState { NotStarted, Dispatched, Finished, }; UnprotectedData<TaskState> state; // Amount of time this task took to execute. - ActiveThreadOrGCTaskData<mozilla::TimeDuration> duration_; + MainThreadOrGCTaskData<mozilla::TimeDuration> duration_; explicit GCParallelTask(const GCParallelTask&) = delete; protected: // A flag to signal a request for early completion of the off-thread task. mozilla::Atomic<bool> cancel_; virtual void run() = 0;
--- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -129,34 +129,34 @@ class BackgroundDecommitTask : public GC explicit BackgroundDecommitTask(JSRuntime *rt) : GCParallelTask(rt) {} void setChunksToScan(ChunkVector &chunks); protected: void run() override; private: - ActiveThreadOrGCTaskData<ChunkVector> toDecommit; + MainThreadOrGCTaskData<ChunkVector> toDecommit; }; template<typename F> struct Callback { - ActiveThreadOrGCTaskData<F> op; - ActiveThreadOrGCTaskData<void*> data; + MainThreadOrGCTaskData<F> op; + MainThreadOrGCTaskData<void*> data; Callback() : op(nullptr), data(nullptr) {} Callback(F op, void* data) : op(op), data(data) {} }; template<typename F> -using CallbackVector = ActiveThreadData<Vector<Callback<F>, 4, SystemAllocPolicy>>; +using CallbackVector = MainThreadData<Vector<Callback<F>, 4, SystemAllocPolicy>>; template <typename T, typename Iter0, typename Iter1> class ChainedIter { Iter0 iter0_; Iter1 iter1_; public: @@ -640,17 +640,17 @@ class GCRuntime public: JSRuntime* const rt; /* Embedders can use this zone and group however they wish. */ UnprotectedData<JS::Zone*> systemZone; // All zones in the runtime, except the atoms zone. private: - ActiveThreadOrGCTaskData<ZoneVector> zones_; + MainThreadOrGCTaskData<ZoneVector> zones_; public: ZoneVector& zones() { return zones_.ref(); } // The unique atoms zone. WriteOnceData<Zone*> atomsZone; private: UnprotectedData<gcstats::Statistics> stats_; @@ -687,55 +687,55 @@ class GCRuntime // is moved back to the emptyChunks pool and scheduled for eventual // release. GCLockData<ChunkPool> availableChunks_; // When all arenas in a chunk are used, it is moved to the fullChunks pool // so as to reduce the cost of operations on the available lists. GCLockData<ChunkPool> fullChunks_; - ActiveThreadData<RootedValueMap> rootsHash; + MainThreadData<RootedValueMap> rootsHash; // An incrementing id used to assign unique ids to cells that require one. mozilla::Atomic<uint64_t, mozilla::ReleaseAcquire> nextCellUniqueId_; /* * Number of the committed arenas in all GC chunks including empty chunks. */ mozilla::Atomic<uint32_t, mozilla::ReleaseAcquire> numArenasFreeCommitted; - ActiveThreadData<VerifyPreTracer*> verifyPreData; + MainThreadData<VerifyPreTracer*> verifyPreData; private: UnprotectedData<bool> chunkAllocationSinceLastGC; - ActiveThreadData<int64_t> lastGCTime; + MainThreadData<int64_t> lastGCTime; /* * JSGC_MODE * prefs: javascript.options.mem.gc_per_zone and * javascript.options.mem.gc_incremental. */ - ActiveThreadData<JSGCMode> mode; + MainThreadData<JSGCMode> mode; mozilla::Atomic<size_t, mozilla::ReleaseAcquire> numActiveZoneIters; /* During shutdown, the GC needs to clean up every possible object. */ - ActiveThreadData<bool> cleanUpEverything; + MainThreadData<bool> cleanUpEverything; // Gray marking must be done after all black marking is complete. However, // we do not have write barriers on XPConnect roots. Therefore, XPConnect // roots must be accumulated in the first slice of incremental GC. We // accumulate these roots in each zone's gcGrayRoots vector and then mark // them later, after black marking is complete for each compartment. This // accumulation can fail, but in that case we switch to non-incremental GC. enum class GrayBufferState { Unused, Okay, Failed }; - ActiveThreadOrGCTaskData<GrayBufferState> grayBufferState; + MainThreadOrGCTaskData<GrayBufferState> grayBufferState; bool hasValidGrayRootsBuffer() const { return grayBufferState == GrayBufferState::Okay; } // Clear each zone's gray buffers, but do not change the current state. void resetBufferedGrayRoots() const; // Reset the gray buffering state to Unused. void clearBufferedGrayRoots() { grayBufferState = GrayBufferState::Unused; @@ -747,133 +747,133 @@ class GCRuntime * full GC will reset this bit, since it fills in all the gray bits. */ UnprotectedData<bool> grayBitsValid; mozilla::Atomic<JS::gcreason::Reason, mozilla::Relaxed> majorGCTriggerReason; private: /* Perform full GC if rt->keepAtoms() becomes false. */ - ActiveThreadData<bool> fullGCForAtomsRequested_; + MainThreadData<bool> fullGCForAtomsRequested_; /* Incremented at the start of every minor GC. */ - ActiveThreadData<uint64_t> minorGCNumber; + MainThreadData<uint64_t> minorGCNumber; /* Incremented at the start of every major GC. */ - ActiveThreadData<uint64_t> majorGCNumber; + MainThreadData<uint64_t> majorGCNumber; /* The major GC number at which to release observed type information. */ - ActiveThreadData<uint64_t> jitReleaseNumber; + MainThreadData<uint64_t> jitReleaseNumber; /* Incremented on every GC slice. */ - ActiveThreadData<uint64_t> number; + MainThreadData<uint64_t> number; /* Whether the currently running GC can finish in multiple slices. */ - ActiveThreadData<bool> isIncremental; + MainThreadData<bool> isIncremental; /* Whether all zones are being collected in first GC slice. */ - ActiveThreadData<bool> isFull; + MainThreadData<bool> isFull; /* Whether the heap will be compacted at the end of GC. */ - ActiveThreadData<bool> isCompacting; + MainThreadData<bool> isCompacting; /* The invocation kind of the current GC, taken from the first slice. */ - ActiveThreadData<JSGCInvocationKind> invocationKind; + MainThreadData<JSGCInvocationKind> invocationKind; /* The initial GC reason, taken from the first slice. */ - ActiveThreadData<JS::gcreason::Reason> initialReason; + MainThreadData<JS::gcreason::Reason> initialReason; /* * The current incremental GC phase. This is also used internally in * non-incremental GC. */ - ActiveThreadOrGCTaskData<State> incrementalState; + MainThreadOrGCTaskData<State> incrementalState; /* The incremental state at the start of this slice. */ - ActiveThreadData<State> initialState; + MainThreadData<State> initialState; #ifdef JS_GC_ZEAL /* Whether to pay attention the zeal settings in this incremental slice. */ - ActiveThreadData<bool> useZeal; + MainThreadData<bool> useZeal; #endif /* Indicates that the last incremental slice exhausted the mark stack. */ - ActiveThreadData<bool> lastMarkSlice; + MainThreadData<bool> lastMarkSlice; /* Whether it's currently safe to yield to the mutator in an incremental GC. */ - ActiveThreadData<bool> safeToYield; + MainThreadData<bool> safeToYield; /* Whether any sweeping will take place in the separate GC helper thread. */ - ActiveThreadData<bool> sweepOnBackgroundThread; + MainThreadData<bool> sweepOnBackgroundThread; /* Whether observed type information is being released in the current GC. */ - ActiveThreadData<bool> releaseObservedTypes; + MainThreadData<bool> releaseObservedTypes; /* Singly linked list of zones to be swept in the background. */ - ActiveThreadOrGCTaskData<ZoneList> backgroundSweepZones; + MainThreadOrGCTaskData<ZoneList> backgroundSweepZones; /* * Free LIFO blocks are transferred to this allocator before being freed on * the background GC thread after sweeping. */ - ActiveThreadOrGCTaskData<LifoAlloc> blocksToFreeAfterSweeping; + MainThreadOrGCTaskData<LifoAlloc> blocksToFreeAfterSweeping; private: /* Index of current sweep group (for stats). */ - ActiveThreadData<unsigned> sweepGroupIndex; + MainThreadData<unsigned> sweepGroupIndex; /* * Incremental sweep state. */ - ActiveThreadData<JS::Zone*> sweepGroups; - ActiveThreadOrGCTaskData<JS::Zone*> currentSweepGroup; - ActiveThreadData<UniquePtr<SweepAction<GCRuntime*, FreeOp*, SliceBudget&>>> sweepActions; - ActiveThreadOrGCTaskData<JS::Zone*> sweepZone; - ActiveThreadData<mozilla::Maybe<AtomSet::Enum>> maybeAtomsToSweep; - ActiveThreadOrGCTaskData<JS::detail::WeakCacheBase*> sweepCache; - ActiveThreadData<bool> abortSweepAfterCurrentGroup; + MainThreadData<JS::Zone*> sweepGroups; + MainThreadOrGCTaskData<JS::Zone*> currentSweepGroup; + MainThreadData<UniquePtr<SweepAction<GCRuntime*, FreeOp*, SliceBudget&>>> sweepActions; + MainThreadOrGCTaskData<JS::Zone*> sweepZone; + MainThreadData<mozilla::Maybe<AtomSet::Enum>> maybeAtomsToSweep; + MainThreadOrGCTaskData<JS::detail::WeakCacheBase*> sweepCache; + MainThreadData<bool> abortSweepAfterCurrentGroup; friend class SweepGroupsIter; friend class WeakCacheSweepIterator; /* * Incremental compacting state. */ - ActiveThreadData<bool> startedCompacting; - ActiveThreadData<ZoneList> zonesToMaybeCompact; - ActiveThreadData<Arena*> relocatedArenasToRelease; + MainThreadData<bool> startedCompacting; + MainThreadData<ZoneList> zonesToMaybeCompact; + MainThreadData<Arena*> relocatedArenasToRelease; #ifdef JS_GC_ZEAL - ActiveThreadData<MarkingValidator*> markingValidator; + MainThreadData<MarkingValidator*> markingValidator; #endif /* * Default budget for incremental GC slice. See js/SliceBudget.h. * * JSGC_SLICE_TIME_BUDGET * pref: javascript.options.mem.gc_incremental_slice_ms, */ - ActiveThreadData<int64_t> defaultTimeBudget_; + MainThreadData<int64_t> defaultTimeBudget_; /* * We disable incremental GC if we encounter a Class with a trace hook * that does not implement write barriers. */ - ActiveThreadData<bool> incrementalAllowed; + MainThreadData<bool> incrementalAllowed; /* * Whether compacting GC can is enabled globally. * * JSGC_COMPACTING_ENABLED * pref: javascript.options.mem.gc_compacting */ - ActiveThreadData<bool> compactingEnabled; + MainThreadData<bool> compactingEnabled; - ActiveThreadData<bool> rootsRemoved; + MainThreadData<bool> rootsRemoved; /* * These options control the zealousness of the GC. At every allocation, * nextScheduled is decremented. When it reaches zero we do a full GC. * * At this point, if zeal_ is one of the types that trigger periodic * collection, then nextScheduled is reset to the value of zealFrequency. * Otherwise, no additional GCs take place. @@ -893,28 +893,28 @@ class GCRuntime * zeal_ values from 8 to 10 periodically run different types of * incremental GC. * * zeal_ value 14 performs periodic shrinking collections. */ #ifdef JS_GC_ZEAL static_assert(size_t(ZealMode::Count) <= 32, "Too many zeal modes to store in a uint32_t"); - ActiveThreadData<uint32_t> zealModeBits; - ActiveThreadData<int> zealFrequency; - ActiveThreadData<int> nextScheduled; - ActiveThreadData<bool> deterministicOnly; - ActiveThreadData<int> incrementalLimit; + MainThreadData<uint32_t> zealModeBits; + MainThreadData<int> zealFrequency; + MainThreadData<int> nextScheduled; + MainThreadData<bool> deterministicOnly; + MainThreadData<int> incrementalLimit; - ActiveThreadData<Vector<JSObject*, 0, SystemAllocPolicy>> selectedForMarking; + MainThreadData<Vector<JSObject*, 0, SystemAllocPolicy>> selectedForMarking; #endif - ActiveThreadData<bool> fullCompartmentChecks; + MainThreadData<bool> fullCompartmentChecks; - ActiveThreadData<uint32_t> gcCallbackDepth; + MainThreadData<uint32_t> gcCallbackDepth; Callback<JSGCCallback> gcCallback; Callback<JS::DoCycleCollectionCallback> gcDoCycleCollectionCallback; Callback<JSObjectsTenuredCallback> tenuredCallback; CallbackVector<JSFinalizeCallback> finalizeCallbacks; CallbackVector<JSWeakPointerZonesCallback> updateWeakPointerZonesCallbacks; CallbackVector<JSWeakPointerCompartmentCallback> updateWeakPointerCompartmentCallbacks; @@ -925,48 +925,48 @@ class GCRuntime * tracing through black roots and the other is for tracing through gray * roots. The black/gray distinction is only relevant to the cycle * collector. */ CallbackVector<JSTraceDataOp> blackRootTracers; Callback<JSTraceDataOp> grayRootTracer; /* Always preserve JIT code during GCs, for testing. */ - ActiveThreadData<bool> alwaysPreserveCode; + MainThreadData<bool> alwaysPreserveCode; #ifdef DEBUG - ActiveThreadData<bool> arenasEmptyAtShutdown; + MainThreadData<bool> arenasEmptyAtShutdown; #endif /* Synchronize GC heap access among GC helper threads and active threads. */ friend class js::AutoLockGC; friend class js::AutoLockGCBgAlloc; js::Mutex lock; BackgroundAllocTask allocTask; BackgroundDecommitTask decommitTask; js::GCHelperState helperState; /* * During incremental sweeping, this field temporarily holds the arenas of * the current AllocKind being swept in order of increasing free space. */ - ActiveThreadData<SortedArenaList> incrementalSweepList; + MainThreadData<SortedArenaList> incrementalSweepList; private: - ActiveThreadData<Nursery> nursery_; - ActiveThreadData<gc::StoreBuffer> storeBuffer_; + MainThreadData<Nursery> nursery_; + MainThreadData<gc::StoreBuffer> storeBuffer_; public: Nursery& nursery() { return nursery_.ref(); } gc::StoreBuffer& storeBuffer() { return storeBuffer_.ref(); } // Free LIFO blocks are transferred to this allocator before being freed // after minor GC. - ActiveThreadData<LifoAlloc> blocksToFreeAfterMinorGC; + MainThreadData<LifoAlloc> blocksToFreeAfterMinorGC; const void* addressOfNurseryPosition() { return nursery_.refNoCheck().addressOfPosition(); } const void* addressOfNurseryCurrentEnd() { return nursery_.refNoCheck().addressOfCurrentEnd(); } const void* addressOfStringNurseryCurrentEnd() {
--- a/js/src/gc/Scheduling.h +++ b/js/src/gc/Scheduling.h @@ -337,26 +337,26 @@ class GCSchedulingTunables */ UnprotectedData<size_t> maxMallocBytes_; /* * JSGC_MAX_NURSERY_BYTES * * Maximum nursery size for each runtime. */ - ActiveThreadData<size_t> gcMaxNurseryBytes_; + MainThreadData<size_t> gcMaxNurseryBytes_; /* * JSGC_ALLOCATION_THRESHOLD * * The base value used to compute zone->threshold.gcTriggerBytes(). When * usage.gcBytes() surpasses threshold.gcTriggerBytes() for a zone, the * zone may be scheduled for a GC, depending on the exact circumstances. */ - ActiveThreadOrGCTaskData<size_t> gcZoneAllocThresholdBase_; + MainThreadOrGCTaskData<size_t> gcZoneAllocThresholdBase_; /* * JSGC_ALLOCATION_THRESHOLD_FACTOR * * Fraction of threshold.gcBytes() which triggers an incremental GC. */ UnprotectedData<double> allocThresholdFactor_; @@ -376,54 +376,54 @@ class GCSchedulingTunables UnprotectedData<size_t> zoneAllocDelayBytes_; /* * JSGC_DYNAMIC_HEAP_GROWTH * * Totally disables |highFrequencyGC|, the HeapGrowthFactor, and other * tunables that make GC non-deterministic. */ - ActiveThreadData<bool> dynamicHeapGrowthEnabled_; + MainThreadData<bool> dynamicHeapGrowthEnabled_; /* * JSGC_HIGH_FREQUENCY_TIME_LIMIT * * We enter high-frequency mode if we GC a twice within this many * microseconds. This value is stored directly in microseconds. */ - ActiveThreadData<uint64_t> highFrequencyThresholdUsec_; + MainThreadData<uint64_t> highFrequencyThresholdUsec_; /* * JSGC_HIGH_FREQUENCY_LOW_LIMIT * JSGC_HIGH_FREQUENCY_HIGH_LIMIT * JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX * JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN * * When in the |highFrequencyGC| mode, these parameterize the per-zone * "HeapGrowthFactor" computation. */ - ActiveThreadData<uint64_t> highFrequencyLowLimitBytes_; - ActiveThreadData<uint64_t> highFrequencyHighLimitBytes_; - ActiveThreadData<double> highFrequencyHeapGrowthMax_; - ActiveThreadData<double> highFrequencyHeapGrowthMin_; + MainThreadData<uint64_t> highFrequencyLowLimitBytes_; + MainThreadData<uint64_t> highFrequencyHighLimitBytes_; + MainThreadData<double> highFrequencyHeapGrowthMax_; + MainThreadData<double> highFrequencyHeapGrowthMin_; /* * JSGC_LOW_FREQUENCY_HEAP_GROWTH * * When not in |highFrequencyGC| mode, this is the global (stored per-zone) * "HeapGrowthFactor". */ - ActiveThreadData<double> lowFrequencyHeapGrowth_; + MainThreadData<double> lowFrequencyHeapGrowth_; /* * JSGC_DYNAMIC_MARK_SLICE * * Doubles the length of IGC slices when in the |highFrequencyGC| mode. */ - ActiveThreadData<bool> dynamicMarkSliceEnabled_; + MainThreadData<bool> dynamicMarkSliceEnabled_; /* * JSGC_MIN_EMPTY_CHUNK_COUNT * JSGC_MAX_EMPTY_CHUNK_COUNT * * Controls the number of empty chunks reserved for future allocation. */ UnprotectedData<uint32_t> minEmptyChunkCount_; @@ -468,17 +468,17 @@ private: class GCSchedulingState { /* * Influences how we schedule and run GC's in several subtle ways. The most * important factor is in how it controls the "HeapGrowthFactor". The * growth factor is a measure of how large (as a percentage of the last GC) * the heap is allowed to grow before we try to schedule another GC. */ - ActiveThreadData<bool> inHighFrequencyGCMode_; + MainThreadData<bool> inHighFrequencyGCMode_; public: GCSchedulingState() : inHighFrequencyGCMode_(false) {} bool inHighFrequencyGCMode() const { return inHighFrequencyGCMode_; } @@ -495,17 +495,17 @@ class MemoryCounter // Bytes counter to measure memory pressure for GC scheduling. It counts // upwards from zero. mozilla::Atomic<size_t, mozilla::ReleaseAcquire> bytes_; // GC trigger threshold for memory allocations. size_t maxBytes_; // The counter value at the start of a GC. - ActiveThreadData<size_t> bytesAtStartOfGC_; + MainThreadData<size_t> bytesAtStartOfGC_; // Which kind of GC has been triggered if any. mozilla::Atomic<TriggerKind, mozilla::ReleaseAcquire> triggered_; public: MemoryCounter(); size_t bytes() const { return bytes_; }
--- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -302,17 +302,17 @@ struct Zone : public JS::shadow::Zone, js::ZoneOrGCTaskData<mozilla::LinkedList<js::WeakMapBase>> gcWeakMapList_; public: mozilla::LinkedList<js::WeakMapBase>& gcWeakMapList() { return gcWeakMapList_.ref(); } typedef js::Vector<JSCompartment*, 1, js::SystemAllocPolicy> CompartmentVector; private: // The set of compartments in this zone. - js::ActiveThreadOrGCTaskData<CompartmentVector> compartments_; + js::MainThreadOrGCTaskData<CompartmentVector> compartments_; public: CompartmentVector& compartments() { return compartments_.ref(); } // This zone's gray roots. typedef js::Vector<js::gc::Cell*, 0, js::SystemAllocPolicy> GrayRootVector; private: js::ZoneOrGCTaskData<GrayRootVector> gcGrayRoots_; public: @@ -344,17 +344,17 @@ struct Zone : public JS::shadow::Zone, public: js::gc::WeakKeyTable& gcWeakKeys() { return gcWeakKeys_.ref(); } private: // A set of edges from this zone to other zones. // // This is used during GC while calculating sweep groups to record edges // that can't be determined by examining this zone by itself. - js::ActiveThreadData<ZoneSet> gcSweepGroupEdges_; + js::MainThreadData<ZoneSet> gcSweepGroupEdges_; public: ZoneSet& gcSweepGroupEdges() { return gcSweepGroupEdges_.ref(); } // Keep track of all TypeDescr and related objects in this compartment. // This is used by the GC to trace them all first when compacting, since the // TypedObject trace hook may access these objects. // @@ -700,25 +700,25 @@ struct Zone : public JS::shadow::Zone, return nullptr; updateMallocCounter(bytes); return p; } private: js::ZoneData<js::jit::JitZone*> jitZone_; - js::ActiveThreadData<bool> gcScheduled_; - js::ActiveThreadData<bool> gcScheduledSaved_; + js::MainThreadData<bool> gcScheduled_; + js::MainThreadData<bool> gcScheduledSaved_; js::ZoneData<bool> gcPreserveCode_; js::ZoneData<bool> keepShapeTables_; // Allow zones to be linked into a list friend class js::gc::ZoneList; static Zone * const NotOnList; - js::ActiveThreadOrGCTaskData<Zone*> listNext_; + js::MainThreadOrGCTaskData<Zone*> listNext_; bool isOnList() const; Zone* nextZone() const; friend bool js::CurrentThreadCanAccessZone(Zone* zone); friend class js::gc::GCRuntime; }; } // namespace JS
--- a/js/src/jit/JitCompartment.h +++ b/js/src/jit/JitCompartment.h @@ -57,19 +57,19 @@ typedef void (*EnterJitCode)(void* code, class JitcodeGlobalTable; class JitRuntime { private: friend class JitCompartment; // Executable allocator for all code except wasm code. - ActiveThreadData<ExecutableAllocator> execAlloc_; + MainThreadData<ExecutableAllocator> execAlloc_; - ActiveThreadData<uint64_t> nextCompilationId_; + MainThreadData<uint64_t> nextCompilationId_; // Shared exception-handler tail. ExclusiveAccessLockWriteOnceData<uint32_t> exceptionTailOffset_; // Shared post-bailout-handler tail. ExclusiveAccessLockWriteOnceData<uint32_t> bailoutTailOffset_; // Shared profiler exit frame tail. @@ -133,28 +133,28 @@ class JitRuntime ExclusiveAccessLockWriteOnceData<VMWrapperMap*> functionWrappers_; // Global table of jitcode native address => bytecode address mappings. UnprotectedData<JitcodeGlobalTable*> jitcodeGlobalTable_; #ifdef DEBUG // The number of possible bailing places encounters before forcefully bailing // in that place. Zero means inactive. - ActiveThreadData<uint32_t> ionBailAfter_; + MainThreadData<uint32_t> ionBailAfter_; #endif // Number of Ion compilations which were finished off thread and are // waiting to be lazily linked. This is only set while holding the helper // thread state lock, but may be read from at other times. mozilla::Atomic<size_t> numFinishedBuilders_; // List of Ion compilation waiting to get linked. using IonBuilderList = mozilla::LinkedList<js::jit::IonBuilder>; - ActiveThreadData<IonBuilderList> ionLazyLinkList_; - ActiveThreadData<size_t> ionLazyLinkListSize_; + MainThreadData<IonBuilderList> ionLazyLinkList_; + MainThreadData<size_t> ionLazyLinkListSize_; private: void generateLazyLinkStub(MacroAssembler& masm); void generateInterpreterStub(MacroAssembler& masm); void generateProfilerExitFrameTailStub(MacroAssembler& masm, Label* profilerExitTail); void generateExceptionTailStub(MacroAssembler& masm, void* handler, Label* profilerExitTail); void generateBailoutTailStub(MacroAssembler& masm, Label* bailoutTail); void generateEnterJIT(JSContext* cx, MacroAssembler& masm);
--- a/js/src/threading/ProtectedData.cpp +++ b/js/src/threading/ProtectedData.cpp @@ -45,28 +45,28 @@ CheckThreadLocal::check() const if (cx->isCooperativelyScheduled()) MOZ_ASSERT(CurrentThreadCanAccessRuntime(cx->runtime())); else MOZ_ASSERT(id == ThisThread::GetId()); } template <AllowedHelperThread Helper> void -CheckActiveThread<Helper>::check() const +CheckMainThread<Helper>::check() const { if (OnHelperThread<Helper>()) return; JSContext* cx = TlsContext.get(); MOZ_ASSERT(CurrentThreadCanAccessRuntime(cx->runtime())); } -template class CheckActiveThread<AllowedHelperThread::None>; -template class CheckActiveThread<AllowedHelperThread::GCTask>; -template class CheckActiveThread<AllowedHelperThread::IonCompile>; +template class CheckMainThread<AllowedHelperThread::None>; +template class CheckMainThread<AllowedHelperThread::GCTask>; +template class CheckMainThread<AllowedHelperThread::IonCompile>; template <AllowedHelperThread Helper> void CheckZone<Helper>::check() const { if (OnHelperThread<Helper>()) return;
--- a/js/src/threading/ProtectedData.h +++ b/js/src/threading/ProtectedData.h @@ -197,36 +197,35 @@ enum class AllowedHelperThread { None, GCTask, IonCompile, GCTaskOrIonCompile }; template <AllowedHelperThread Helper> -class CheckActiveThread +class CheckMainThread { public: void check() const; }; -// Data which may only be accessed by the runtime's cooperatively scheduled -// active thread. +// Data which may only be accessed by the runtime's main thread. template <typename T> -using ActiveThreadData = - ProtectedDataNoCheckArgs<CheckActiveThread<AllowedHelperThread::None>, T>; +using MainThreadData = + ProtectedDataNoCheckArgs<CheckMainThread<AllowedHelperThread::None>, T>; -// Data which may only be accessed by the runtime's cooperatively scheduled -// active thread, or by various helper thread tasks. +// Data which may only be accessed by the runtime's main thread or by various +// helper thread tasks. template <typename T> -using ActiveThreadOrGCTaskData = - ProtectedDataNoCheckArgs<CheckActiveThread<AllowedHelperThread::GCTask>, T>; +using MainThreadOrGCTaskData = + ProtectedDataNoCheckArgs<CheckMainThread<AllowedHelperThread::GCTask>, T>; template <typename T> -using ActiveThreadOrIonCompileData = - ProtectedDataNoCheckArgs<CheckActiveThread<AllowedHelperThread::IonCompile>, T>; +using MainThreadOrIonCompileData = + ProtectedDataNoCheckArgs<CheckMainThread<AllowedHelperThread::IonCompile>, T>; template <AllowedHelperThread Helper> class CheckZone { #ifdef JS_HAS_PROTECTED_DATA_CHECKS JS::Zone* zone; public:
--- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -296,20 +296,20 @@ struct JSRuntime : public js::MallocProv uint64_t rangeStart = profilerSampleBufferRangeStart_; return mozilla::Some(rangeStart); } void setProfilerSampleBufferRangeStart(uint64_t rangeStart) { profilerSampleBufferRangeStart_ = rangeStart; } /* Call this to accumulate telemetry data. */ - js::ActiveThreadData<JSAccumulateTelemetryDataCallback> telemetryCallback; + js::MainThreadData<JSAccumulateTelemetryDataCallback> telemetryCallback; /* Call this to accumulate use counter data. */ - js::ActiveThreadData<JSSetUseCounterCallback> useCounterCallback; + js::MainThreadData<JSSetUseCounterCallback> useCounterCallback; public: // Accumulates data for Firefox telemetry. |id| is the ID of a JS_TELEMETRY_* // histogram. |key| provides an additional key to identify the histogram. // |sample| is the data to add to the histogram. void addTelemetry(int id, uint32_t sample, const char* key = nullptr); void setTelemetryCallback(JSRuntime* rt, JSAccumulateTelemetryDataCallback callback); @@ -340,54 +340,54 @@ struct JSRuntime : public js::MallocProv /* Had an out-of-memory error which did not populate an exception. */ mozilla::Atomic<bool> hadOutOfMemory; /* * Allow relazifying functions in compartments that are active. This is * only used by the relazifyFunctions() testing function. */ - js::ActiveThreadData<bool> allowRelazificationForTesting; + js::MainThreadData<bool> allowRelazificationForTesting; /* Compartment destroy callback. */ - js::ActiveThreadData<JSDestroyCompartmentCallback> destroyCompartmentCallback; + js::MainThreadData<JSDestroyCompartmentCallback> destroyCompartmentCallback; /* Compartment memory reporting callback. */ - js::ActiveThreadData<JSSizeOfIncludingThisCompartmentCallback> sizeOfIncludingThisCompartmentCallback; + js::MainThreadData<JSSizeOfIncludingThisCompartmentCallback> sizeOfIncludingThisCompartmentCallback; /* Call this to get the name of a compartment. */ - js::ActiveThreadData<JSCompartmentNameCallback> compartmentNameCallback; + js::MainThreadData<JSCompartmentNameCallback> compartmentNameCallback; /* Realm destroy callback. */ - js::ActiveThreadData<JS::DestroyRealmCallback> destroyRealmCallback; + js::MainThreadData<JS::DestroyRealmCallback> destroyRealmCallback; /* Call this to get the name of a realm. */ - js::ActiveThreadData<JS::RealmNameCallback> realmNameCallback; + js::MainThreadData<JS::RealmNameCallback> realmNameCallback; /* Callback for doing memory reporting on external strings. */ - js::ActiveThreadData<JSExternalStringSizeofCallback> externalStringSizeofCallback; + js::MainThreadData<JSExternalStringSizeofCallback> externalStringSizeofCallback; - js::ActiveThreadData<mozilla::UniquePtr<js::SourceHook>> sourceHook; + js::MainThreadData<mozilla::UniquePtr<js::SourceHook>> sourceHook; - js::ActiveThreadData<const JSSecurityCallbacks*> securityCallbacks; - js::ActiveThreadData<const js::DOMCallbacks*> DOMcallbacks; - js::ActiveThreadData<JSDestroyPrincipalsOp> destroyPrincipals; - js::ActiveThreadData<JSReadPrincipalsOp> readPrincipals; + js::MainThreadData<const JSSecurityCallbacks*> securityCallbacks; + js::MainThreadData<const js::DOMCallbacks*> DOMcallbacks; + js::MainThreadData<JSDestroyPrincipalsOp> destroyPrincipals; + js::MainThreadData<JSReadPrincipalsOp> readPrincipals; /* Optional warning reporter. */ - js::ActiveThreadData<JS::WarningReporter> warningReporter; + js::MainThreadData<JS::WarningReporter> warningReporter; private: /* Gecko profiling metadata */ js::UnprotectedData<js::GeckoProfilerRuntime> geckoProfiler_; public: js::GeckoProfilerRuntime& geckoProfiler() { return geckoProfiler_.ref(); } // Heap GC roots for PersistentRooted pointers. - js::ActiveThreadData<mozilla::EnumeratedArray<JS::RootKind, JS::RootKind::Limit, + js::MainThreadData<mozilla::EnumeratedArray<JS::RootKind, JS::RootKind::Limit, mozilla::LinkedList<JS::PersistentRooted<void*>>>> heapRoots; void tracePersistentRoots(JSTracer* trc); void finishPersistentRoots(); void finishRoots(); public: @@ -397,37 +397,37 @@ struct JSRuntime : public js::MallocProv js::UnprotectedData<JS::AsmJSCacheOps> asmJSCacheOps; private: js::UnprotectedData<const JSPrincipals*> trustedPrincipals_; public: void setTrustedPrincipals(const JSPrincipals* p) { trustedPrincipals_ = p; } const JSPrincipals* trustedPrincipals() const { return trustedPrincipals_; } - js::ActiveThreadData<const JSWrapObjectCallbacks*> wrapObjectCallbacks; - js::ActiveThreadData<js::PreserveWrapperCallback> preserveWrapperCallback; + js::MainThreadData<const JSWrapObjectCallbacks*> wrapObjectCallbacks; + js::MainThreadData<js::PreserveWrapperCallback> preserveWrapperCallback; - js::ActiveThreadData<js::ScriptEnvironmentPreparer*> scriptEnvironmentPreparer; + js::MainThreadData<js::ScriptEnvironmentPreparer*> scriptEnvironmentPreparer; - js::ActiveThreadData<js::CTypesActivityCallback> ctypesActivityCallback; + js::MainThreadData<js::CTypesActivityCallback> ctypesActivityCallback; private: js::WriteOnceData<const js::Class*> windowProxyClass_; public: const js::Class* maybeWindowProxyClass() const { return windowProxyClass_; } void setWindowProxyClass(const js::Class* clasp) { windowProxyClass_ = clasp; } private: // List of non-ephemeron weak containers to sweep during beginSweepingSweepGroup. - js::ActiveThreadData<mozilla::LinkedList<JS::detail::WeakCacheBase>> weakCaches_; + js::MainThreadData<mozilla::LinkedList<JS::detail::WeakCacheBase>> weakCaches_; public: mozilla::LinkedList<JS::detail::WeakCacheBase>& weakCaches() { return weakCaches_.ref(); } void registerWeakCache(JS::detail::WeakCacheBase* cachep) { weakCaches().insertBack(cachep); } template <typename T> struct GlobalObjectWatchersLinkAccess { @@ -439,24 +439,24 @@ struct JSRuntime : public js::MallocProv using WatchersList = mozilla::DoublyLinkedList<js::Debugger, GlobalObjectWatchersLinkAccess<js::Debugger>>; private: /* * List of all enabled Debuggers that have onNewGlobalObject handler * methods established. */ - js::ActiveThreadData<WatchersList> onNewGlobalObjectWatchers_; + js::MainThreadData<WatchersList> onNewGlobalObjectWatchers_; public: WatchersList& onNewGlobalObjectWatchers() { return onNewGlobalObjectWatchers_.ref(); } private: /* Linked list of all Debugger objects in the runtime. */ - js::ActiveThreadData<mozilla::LinkedList<js::Debugger>> debuggerList_; + js::MainThreadData<mozilla::LinkedList<js::Debugger>> debuggerList_; public: mozilla::LinkedList<js::Debugger>& debuggerList() { return debuggerList_.ref(); } private: /* * Lock taken when using per-runtime or per-zone data that could otherwise * be accessed simultaneously by multiple threads. * @@ -511,29 +511,29 @@ struct JSRuntime : public js::MallocProv return scriptDataLock.ownedByCurrentThread(); } #endif // How many compartments there are across all zones. This number includes // off thread context compartments, so it isn't necessarily equal to the // number of compartments visited by CompartmentsIter. - js::ActiveThreadData<size_t> numCompartments; + js::MainThreadData<size_t> numCompartments; /* Locale-specific callbacks for string conversion. */ - js::ActiveThreadData<const JSLocaleCallbacks*> localeCallbacks; + js::MainThreadData<const JSLocaleCallbacks*> localeCallbacks; /* Default locale for Internationalization API */ - js::ActiveThreadData<char*> defaultLocale; + js::MainThreadData<char*> defaultLocale; /* If true, new scripts must be created with PC counter information. */ - js::ActiveThreadOrIonCompileData<bool> profilingScripts; + js::MainThreadOrIonCompileData<bool> profilingScripts; /* Strong references on scripts held for PCCount profiling API. */ - js::ActiveThreadData<JS::PersistentRooted<js::ScriptAndCountsVector>*> scriptAndCountsVector; + js::MainThreadData<JS::PersistentRooted<js::ScriptAndCountsVector>*> scriptAndCountsVector; private: /* Code coverage output. */ js::UnprotectedData<js::coverage::LCovRuntime> lcovOutput_; public: js::coverage::LCovRuntime& lcovOutput() { return lcovOutput_.ref(); } private: @@ -784,17 +784,17 @@ struct JSRuntime : public js::MallocProv bool transformToPermanentAtoms(JSContext* cx); // Cached well-known symbols (ES6 rev 24 6.1.5.1). Like permanent atoms, // these are shared with the parentRuntime, if any. js::WriteOnceData<js::WellKnownSymbols*> wellKnownSymbols; /* Shared Intl data for this runtime. */ - js::ActiveThreadData<js::intl::SharedIntlData> sharedIntlData; + js::MainThreadData<js::intl::SharedIntlData> sharedIntlData; void traceSharedIntlData(JSTracer* trc); // Table of bytecode and other data that may be shared across scripts // within the runtime. This may be modified by threads using // AutoLockForExclusiveAccess. private: js::ScriptDataLockData<js::ScriptDataTable> scriptDataTable_; @@ -857,17 +857,17 @@ struct JSRuntime : public js::MallocProv void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes* runtime); private: // Settings for how helper threads can be used. mozilla::Atomic<bool> offthreadIonCompilationEnabled_; mozilla::Atomic<bool> parallelParsingEnabled_; - js::ActiveThreadData<bool> autoWritableJitCodeActive_; + js::MainThreadData<bool> autoWritableJitCodeActive_; public: // Note: these values may be toggled dynamically (in response to about:config // prefs changing). void setOffthreadIonCompilationEnabled(bool value) { offthreadIonCompilationEnabled_ = value; } @@ -882,30 +882,30 @@ struct JSRuntime : public js::MallocProv } void toggleAutoWritableJitCodeActive(bool b) { MOZ_ASSERT(autoWritableJitCodeActive_ != b, "AutoWritableJitCode should not be nested."); autoWritableJitCodeActive_ = b; } /* See comment for JS::SetOutOfMemoryCallback in jsapi.h. */ - js::ActiveThreadData<JS::OutOfMemoryCallback> oomCallback; - js::ActiveThreadData<void*> oomCallbackData; + js::MainThreadData<JS::OutOfMemoryCallback> oomCallback; + js::MainThreadData<void*> oomCallbackData; /* * Debugger.Memory functions like takeCensus use this embedding-provided * function to assess the size of malloc'd blocks of memory. */ - js::ActiveThreadData<mozilla::MallocSizeOf> debuggerMallocSizeOf; + js::MainThreadData<mozilla::MallocSizeOf> debuggerMallocSizeOf; /* Last time at which an animation was played for this runtime. */ mozilla::Atomic<int64_t> lastAnimationTime; private: - js::ActiveThreadData<js::PerformanceMonitoring> performanceMonitoring_; + js::MainThreadData<js::PerformanceMonitoring> performanceMonitoring_; public: js::PerformanceMonitoring& performanceMonitoring() { return performanceMonitoring_.ref(); } private: /* The stack format for the current runtime. Only valid on non-child * runtimes. */ mozilla::Atomic<js::StackFormat, mozilla::ReleaseAcquire> stackFormat_; @@ -925,17 +925,17 @@ struct JSRuntime : public js::MallocProv stackFormat_ = format; } // For inherited heap state accessors. friend class js::gc::AutoTraceSession; friend class JS::AutoEnterCycleCollection; private: - js::ActiveThreadData<js::RuntimeCaches> caches_; + js::MainThreadData<js::RuntimeCaches> caches_; public: js::RuntimeCaches& caches() { return caches_.ref(); } // List of all the live wasm::Instances in the runtime. Equal to the union // of all instances registered in all JSCompartments. Accessed from watchdog // threads for purposes of wasm::InterruptRunningCode(). js::ExclusiveData<js::wasm::InstanceVector> wasmInstances;