Bug 1452982 part 9 - Remove/rename remaining ZoneGroup references. r=jonco

This commit is contained in:
Jan de Mooij 2018-04-14 09:03:47 +02:00
parent b997830888
commit 2dd36cfeae
14 changed files with 44 additions and 82 deletions

View File

@ -236,7 +236,7 @@ class ArenaLists
// Arena) so the JITs can fall back gracefully.
static FreeSpan placeholder;
ZoneGroupOrGCTaskData<AllAllocKindArray<ArenaList>> arenaLists_;
ZoneOrGCTaskData<AllAllocKindArray<ArenaList>> arenaLists_;
ArenaList& arenaLists(AllocKind i) { return arenaLists_.ref()[i]; }
const ArenaList& arenaLists(AllocKind i) const { return arenaLists_.ref()[i]; }
@ -256,8 +256,8 @@ class ArenaLists
Arena* arenaListsToSweep(AllocKind i) const { return arenaListsToSweep_.ref()[i]; }
/* During incremental sweeping, a list of the arenas already swept. */
ZoneGroupOrGCTaskData<AllocKind> incrementalSweptArenaKind;
ZoneGroupOrGCTaskData<ArenaList> incrementalSweptArenas;
ZoneOrGCTaskData<AllocKind> incrementalSweptArenaKind;
ZoneOrGCTaskData<ArenaList> incrementalSweptArenas;
// Arena lists which have yet to be swept, but need additional foreground
// processing before they are swept.

View File

@ -340,7 +340,7 @@ class GCSchedulingTunables
/*
* JSGC_MAX_NURSERY_BYTES
*
* Maximum nursery size for each zone group.
* Maximum nursery size for each runtime.
*/
ActiveThreadData<size_t> gcMaxNurseryBytes_;

View File

@ -269,7 +269,7 @@ struct Zone : public JS::shadow::Zone,
}
// Side map for storing a unique ids for cells, independent of address.
js::ZoneGroupOrGCTaskData<js::gc::UniqueIdMap> uniqueIds_;
js::ZoneOrGCTaskData<js::gc::UniqueIdMap> uniqueIds_;
js::gc::UniqueIdMap& uniqueIds() { return uniqueIds_.ref(); }
@ -299,7 +299,7 @@ struct Zone : public JS::shadow::Zone,
private:
/* Live weakmaps in this zone. */
js::ZoneGroupOrGCTaskData<mozilla::LinkedList<js::WeakMapBase>> gcWeakMapList_;
js::ZoneOrGCTaskData<mozilla::LinkedList<js::WeakMapBase>> gcWeakMapList_;
public:
mozilla::LinkedList<js::WeakMapBase>& gcWeakMapList() { return gcWeakMapList_.ref(); }
@ -314,7 +314,7 @@ struct Zone : public JS::shadow::Zone,
// This zone's gray roots.
typedef js::Vector<js::gc::Cell*, 0, js::SystemAllocPolicy> GrayRootVector;
private:
js::ZoneGroupOrGCTaskData<GrayRootVector> gcGrayRoots_;
js::ZoneOrGCTaskData<GrayRootVector> gcGrayRoots_;
public:
GrayRootVector& gcGrayRoots() { return gcGrayRoots_.ref(); }
@ -322,13 +322,13 @@ struct Zone : public JS::shadow::Zone,
// preserved for re-scanning during sweeping.
using WeakEdges = js::Vector<js::gc::TenuredCell**, 0, js::SystemAllocPolicy>;
private:
js::ZoneGroupOrGCTaskData<WeakEdges> gcWeakRefs_;
js::ZoneOrGCTaskData<WeakEdges> gcWeakRefs_;
public:
WeakEdges& gcWeakRefs() { return gcWeakRefs_.ref(); }
private:
// List of non-ephemeron weak containers to sweep during beginSweepingSweepGroup.
js::ZoneGroupOrGCTaskData<mozilla::LinkedList<detail::WeakCacheBase>> weakCaches_;
js::ZoneOrGCTaskData<mozilla::LinkedList<detail::WeakCacheBase>> weakCaches_;
public:
mozilla::LinkedList<detail::WeakCacheBase>& weakCaches() { return weakCaches_.ref(); }
void registerWeakCache(detail::WeakCacheBase* cachep) {
@ -340,7 +340,7 @@ struct Zone : public JS::shadow::Zone,
* Mapping from not yet marked keys to a vector of all values that the key
* maps to in any live weak map.
*/
js::ZoneGroupOrGCTaskData<js::gc::WeakKeyTable> gcWeakKeys_;
js::ZoneOrGCTaskData<js::gc::WeakKeyTable> gcWeakKeys_;
public:
js::gc::WeakKeyTable& gcWeakKeys() { return gcWeakKeys_.ref(); }
@ -440,16 +440,16 @@ struct Zone : public JS::shadow::Zone,
private:
// Bitmap of atoms marked by this zone.
js::ZoneGroupOrGCTaskData<js::SparseBitmap> markedAtoms_;
js::ZoneOrGCTaskData<js::SparseBitmap> markedAtoms_;
// Set of atoms recently used by this Zone. Purged on GC.
js::ZoneGroupOrGCTaskData<js::AtomSet> atomCache_;
js::ZoneOrGCTaskData<js::AtomSet> atomCache_;
// Cache storing allocated external strings. Purged on GC.
js::ZoneGroupOrGCTaskData<js::ExternalStringCache> externalStringCache_;
js::ZoneOrGCTaskData<js::ExternalStringCache> externalStringCache_;
// Cache for Function.prototype.toString. Purged on GC.
js::ZoneGroupOrGCTaskData<js::FunctionToStringCache> functionToStringCache_;
js::ZoneOrGCTaskData<js::FunctionToStringCache> functionToStringCache_;
public:
js::SparseBitmap& markedAtoms() { return markedAtoms_.ref(); }

View File

@ -1967,7 +1967,7 @@ AttachFinishedCompilations(JSContext* cx)
// Incorporate any off thread compilations for the runtime which have
// finished, failed or have been cancelled.
while (true) {
// Find a finished builder for the zone group.
// Find a finished builder for the runtime.
IonBuilder* builder = GetFinishedBuilder(rt, finished, lock);
if (!builder)
break;
@ -1977,7 +1977,7 @@ AttachFinishedCompilations(JSContext* cx)
script->baselineScript()->setPendingIonBuilder(rt, script, builder);
rt->jitRuntime()->ionLazyLinkListAdd(rt, builder);
// Don't keep more than 100 lazy link builders in a zone group.
// Don't keep more than 100 lazy link builders in a runtime.
// Link the oldest ones immediately.
while (rt->jitRuntime()->ionLazyLinkListSize() > 100) {
jit::IonBuilder* builder = rt->jitRuntime()->ionLazyLinkList(rt).getLast();

View File

@ -1534,12 +1534,6 @@ js::SetCompartmentValidAccessPtr(JSContext* cx, JS::HandleObject global, bool* a
global->compartment()->setValidAccessPtr(accessp);
}
JS_FRIEND_API(void)
js::SetCooperativeYieldCallback(JSContext* cx, YieldCallback callback)
{
cx->setYieldCallback(callback);
}
JS_FRIEND_API(bool)
js::SystemZoneAvailable(JSContext* cx)
{

View File

@ -3126,15 +3126,6 @@ EnableAccessValidation(JSContext* cx, bool enabled);
extern JS_FRIEND_API(void)
SetCompartmentValidAccessPtr(JSContext* cx, JS::HandleObject global, bool* accessp);
// If the JS engine wants to block so that other cooperative threads can run, it
// will call the yield callback. It may do this if it needs to access a ZoneGroup
// that is held by another thread (such as the system zone group).
typedef void
(* YieldCallback)(JSContext* cx);
extern JS_FRIEND_API(void)
SetCooperativeYieldCallback(JSContext* cx, YieldCallback callback);
// Returns true if the system zone is available (i.e., if no cooperative contexts
// are using it now).
extern JS_FRIEND_API(bool)

View File

@ -6557,8 +6557,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
" lineNumber: starting line number for error messages and debug info\n"
" columnNumber: starting column number for error messages and debug info\n"
" global: global in which to execute the code\n"
" zoneGroup: pick a global from another zone group with no current context\n"
" to execute the code in\n"
" newContext: if true, create and use a new cx (default: false)\n"
" catchTermination: if true, catch termination (failure without\n"
" an exception value, as for slow scripts or out-of-memory)\n"

View File

@ -143,15 +143,15 @@ class ProtectedDataNoCheckArgs : public ProtectedData<Check, T>
ThisType& operator=(const U& p) { this->ref() = p; return *this; }
};
// Intermediate class for protected data whose checks take a ZoneGroup constructor argument.
// Intermediate class for protected data whose checks take a Zone constructor argument.
template <typename Check, typename T>
class ProtectedDataZoneGroupArg : public ProtectedData<Check, T>
class ProtectedDataZoneArg : public ProtectedData<Check, T>
{
typedef ProtectedDataZoneGroupArg<Check, T> ThisType;
typedef ProtectedDataZoneArg<Check, T> ThisType;
public:
template <typename... Args>
explicit ProtectedDataZoneGroupArg(JS::Zone* zone, Args&&... args)
explicit ProtectedDataZoneArg(JS::Zone* zone, Args&&... args)
: ProtectedData<Check, T>(Check(zone), mozilla::Forward<Args>(args)...)
{}
@ -192,7 +192,7 @@ template <typename T>
using ThreadLocalData = ProtectedDataNoCheckArgs<CheckThreadLocal, T>;
// Enum describing which helper threads (GC tasks or Ion compilations) may
// access data even though they do not have exclusive access to any zone group.
// access data even though they do not have exclusive access to any zone.
enum class AllowedHelperThread
{
None,
@ -239,23 +239,23 @@ class CheckZone
};
// Data which may only be accessed by threads with exclusive access to the
// associated zone group, or by the runtime's cooperatively scheduled
// active thread for zone groups which are not in use by a helper thread.
// associated zone, or by the runtime's main thread for zones which are not in
// use by a helper thread.
template <typename T>
using ZoneData =
ProtectedDataZoneGroupArg<CheckZone<AllowedHelperThread::None>, T>;
ProtectedDataZoneArg<CheckZone<AllowedHelperThread::None>, T>;
// Data which may only be accessed by threads with exclusive access to the
// associated zone group, or by various helper thread tasks.
// associated zone, or by various helper thread tasks.
template <typename T>
using ZoneGroupOrGCTaskData =
ProtectedDataZoneGroupArg<CheckZone<AllowedHelperThread::GCTask>, T>;
using ZoneOrGCTaskData =
ProtectedDataZoneArg<CheckZone<AllowedHelperThread::GCTask>, T>;
template <typename T>
using ZoneGroupOrIonCompileData =
ProtectedDataZoneGroupArg<CheckZone<AllowedHelperThread::IonCompile>, T>;
using ZoneOrIonCompileData =
ProtectedDataZoneArg<CheckZone<AllowedHelperThread::IonCompile>, T>;
template <typename T>
using ZoneGroupOrGCTaskOrIonCompileData =
ProtectedDataZoneGroupArg<CheckZone<AllowedHelperThread::GCTaskOrIonCompile>, T>;
using ZoneOrGCTaskOrIonCompileData =
ProtectedDataZoneArg<CheckZone<AllowedHelperThread::GCTaskOrIonCompile>, T>;
// Runtime wide locks which might protect some data.
enum class GlobalLock

View File

@ -757,10 +757,10 @@ StartOffThreadParseTask(JSContext* cx, ParseTask* task, const ReadOnlyCompileOpt
if (!global)
return false;
// Mark the global's zone group as created for a helper thread. This
// prevents it from being collected until clearUsedByHelperThread() is
// called after parsing is complete. If this function exits due to error
// this state is cleared automatically.
// Mark the global's zone as created for a helper thread. This prevents it
// from being collected until clearUsedByHelperThread() is called after
// parsing is complete. If this function exits due to error this state is
// cleared automatically.
AutoSetCreatedForHelperThread createdForHelper(global);
if (!task->init(cx, options, global))

View File

@ -187,10 +187,8 @@ js::DestroyContext(JSContext* cx)
cx->checkNoGCRooters();
// Cancel all off thread Ion compiles before destroying a cooperative
// context. Completed Ion compiles may try to interrupt arbitrary
// cooperative contexts which they have read off the owner context of a
// zone group. See HelperThread::handleIonWorkload.
// Cancel all off thread Ion compiles. Completed Ion compiles may try to
// interrupt this context. See HelperThread::handleIonWorkload.
CancelOffThreadIonCompile(cx->runtime());
FreeJobQueueHandling(cx);

View File

@ -208,9 +208,7 @@ struct JSContext : public JS::RootingContext,
private:
// We distinguish between entering the atoms compartment and all other
// compartments. Entering the atoms compartment requires a lock. Also, we
// don't call enterZoneGroup when entering the atoms compartment since that
// can induce GC hazards.
// compartments. Entering the atoms compartment requires a lock.
inline void enterNonAtomsCompartment(JSCompartment* c);
inline void enterAtomsCompartment(JSCompartment* c,
const js::AutoLockForExclusiveAccess& lock);
@ -306,26 +304,10 @@ struct JSContext : public JS::RootingContext,
friend class js::jit::DebugModeOSRVolatileJitFrameIter;
friend void js::ReportOverRecursed(JSContext*, unsigned errorNumber);
// Returns to the embedding to allow other cooperative threads to run. We
// may do this if we need access to a ZoneGroup that is in use by another
// thread.
void yieldToEmbedding() {
(*yieldCallback_)(this);
}
void setYieldCallback(js::YieldCallback callback) {
yieldCallback_ = callback;
}
private:
static JS::Error reportedError;
static JS::OOM reportedOOM;
// This callback is used to ask the embedding to allow other cooperative
// threads to run. We may do this if we need access to a ZoneGroup that is
// in use by another thread.
js::ThreadLocalData<js::YieldCallback> yieldCallback_;
public:
inline JS::Result<> boolToResult(bool ok);

View File

@ -111,11 +111,11 @@ class Simulator;
//
// - Helper threads do not run JS, and are controlled or triggered by activity
// on the main thread (or main threads, since all runtimes in a process share
// helper threads). Helper threads may have exclusive access to zone groups
// created for them, for parsing and similar tasks, but their activities do
// not cause observable changes in script behaviors. Activity on helper
// threads may be referred to as happening 'off thread' or on a background
// thread in some parts of the VM.
// helper threads). Helper threads may have exclusive access to zones created
// for them, for parsing and similar tasks, but their activities do not cause
// observable changes in script behaviors. Activity on helper threads may be
// referred to as happening 'off thread' or on a background thread in some
// parts of the VM.
} /* namespace js */

View File

@ -1348,7 +1348,7 @@ class TypeZone
public:
// Current generation for sweeping.
ZoneGroupOrGCTaskOrIonCompileData<uint32_t> generation;
ZoneOrGCTaskOrIonCompileData<uint32_t> generation;
// During incremental sweeping, allocator holding the old type information
// for the zone.

View File

@ -685,7 +685,6 @@ SchedulerImpl::ThreadController::OnStartThread(size_t aIndex, const nsACString&
if (sPrefPreemption) {
JS_AddInterruptCallback(cx, SchedulerImpl::InterruptCallback);
}
js::SetCooperativeYieldCallback(cx, SchedulerImpl::YieldCallback);
Servo_InitializeCooperativeThread();
}