Bug 1466083 part 2 - Replace JSRuntime::numCompartments with JSRuntime::numRealms. r=luke

This commit is contained in:
Jan de Mooij 2018-06-02 11:58:28 +02:00
Родитель e1029c5394
Коммит 030c2bbfd2
6 изменённых файлов: 13 добавлений и 17 удалений

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

@ -678,13 +678,12 @@ js::RemapAllWrappersForObject(JSContext* cx, JSObject* oldTargetArg,
RootedObject newTarget(cx, newTargetArg);
AutoWrapperVector toTransplant(cx);
if (!toTransplant.reserve(cx->runtime()->numCompartments))
return false;
for (CompartmentsIter c(cx->runtime()); !c.done(); c.next()) {
if (WrapperMap::Ptr wp = c->lookupWrapper(origv)) {
// We found a wrapper. Remember and root it.
toTransplant.infallibleAppend(WrapperValue(wp));
if (!toTransplant.append(WrapperValue(wp)))
return false;
}
}

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

@ -44,9 +44,7 @@ using mozilla::PodArrayZero;
JSCompartment::JSCompartment(Zone* zone)
: zone_(zone),
runtime_(zone->runtimeFromAnyThread())
{
runtime_->numCompartments++;
}
{}
ObjectRealm::ObjectRealm(JS::Zone* zone)
: innerViews(zone)
@ -69,6 +67,8 @@ Realm::Realm(JS::Zone* zone, const JS::RealmOptions& options)
{
MOZ_ASSERT_IF(creationOptions_.mergeable(),
creationOptions_.invisibleToDebugger());
runtime_->numRealms++;
}
Realm::~Realm()
@ -84,11 +84,9 @@ Realm::~Realm()
if (!runtime_->gc.shutdownCollectedEverything())
objectGroups_.unboxedLayouts.clear();
#endif
}
JSCompartment::~JSCompartment()
{
runtime_->numCompartments--;
MOZ_ASSERT(runtime_->numRealms > 0);
runtime_->numRealms--;
}
bool

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

@ -618,7 +618,6 @@ struct JSCompartment
protected:
explicit JSCompartment(JS::Zone* zone);
~JSCompartment();
MOZ_MUST_USE bool init(JSContext* cx);

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

@ -762,7 +762,7 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
bool anonymize, IterateCellCallback statsCellCallback)
{
JSRuntime* rt = cx->runtime();
if (!rtStats->realmStatsVector.reserve(rt->numCompartments))
if (!rtStats->realmStatsVector.reserve(rt->numRealms))
return false;
size_t totalZones = rt->gc.zones().length() + 1; // + 1 for the atoms zone.

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

@ -133,7 +133,7 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
activeThreadHasScriptDataAccess(false),
#endif
numActiveHelperThreadZones(0),
numCompartments(0),
numRealms(0),
localeCallbacks(nullptr),
defaultLocale(nullptr),
profilingScripts(false),

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

@ -511,10 +511,10 @@ struct JSRuntime : public js::MallocProvider<JSRuntime>
}
#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::MainThreadData<size_t> numCompartments;
// How many realms there are across all zones. This number includes
// off-thread context realms, so it isn't necessarily equal to the
// number of realms visited by RealmsIter.
js::MainThreadData<size_t> numRealms;
/* Locale-specific callbacks for string conversion. */
js::MainThreadData<const JSLocaleCallbacks*> localeCallbacks;