зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1119694 - remove Allocator. r=terrence
This commit is contained in:
Родитель
f5debc0939
Коммит
8dc276cac6
|
@ -448,12 +448,11 @@ GetObjectAllocKindForCopy(const Nursery &nursery, JSObject *obj)
|
|||
MOZ_ALWAYS_INLINE TenuredCell *
|
||||
js::Nursery::allocateFromTenured(Zone *zone, AllocKind thingKind)
|
||||
{
|
||||
TenuredCell *t =
|
||||
zone->allocator.arenas.allocateFromFreeList(thingKind, Arena::thingSize(thingKind));
|
||||
TenuredCell *t = zone->arenas.allocateFromFreeList(thingKind, Arena::thingSize(thingKind));
|
||||
if (t)
|
||||
return t;
|
||||
zone->allocator.arenas.checkEmptyFreeList(thingKind);
|
||||
return zone->allocator.arenas.allocateFromArena(zone, thingKind);
|
||||
zone->arenas.checkEmptyFreeList(thingKind);
|
||||
return zone->arenas.allocateFromArena(zone, thingKind);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -254,7 +254,7 @@ gc::GCRuntime::startVerifyPreBarriers()
|
|||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
PurgeJITCaches(zone);
|
||||
zone->setNeedsIncrementalBarrier(true, Zone::UpdateJit);
|
||||
zone->allocator.arenas.purge();
|
||||
zone->arenas.purge();
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -23,7 +23,7 @@ Zone * const Zone::NotOnList = reinterpret_cast<Zone *>(1);
|
|||
|
||||
JS::Zone::Zone(JSRuntime *rt)
|
||||
: JS::shadow::Zone(rt, &rt->gc.marker),
|
||||
allocator(this),
|
||||
arenas(rt),
|
||||
types(this),
|
||||
compartments(),
|
||||
gcGrayRoots(),
|
||||
|
|
|
@ -24,24 +24,6 @@ namespace jit {
|
|||
class JitZone;
|
||||
}
|
||||
|
||||
// Encapsulates the data needed to perform allocation. There is
|
||||
// precisely one of these per zone (|cx->zone().allocator|).
|
||||
class Allocator
|
||||
{
|
||||
public:
|
||||
explicit Allocator(JS::Zone *zone);
|
||||
|
||||
js::gc::ArenaLists arenas;
|
||||
|
||||
private:
|
||||
// Since allocators can be accessed from worker threads, the parent zone_
|
||||
// should not be accessed in general. GCRuntime is allowed to actually do
|
||||
// the allocation, however.
|
||||
friend class js::gc::GCRuntime;
|
||||
|
||||
JS::Zone *zone_;
|
||||
};
|
||||
|
||||
namespace gc {
|
||||
|
||||
// This class encapsulates the data that determines when we need to do a zone GC.
|
||||
|
@ -255,7 +237,7 @@ struct Zone : public JS::shadow::Zone,
|
|||
}
|
||||
|
||||
public:
|
||||
js::Allocator allocator;
|
||||
js::gc::ArenaLists arenas;
|
||||
|
||||
js::types::TypeZone types;
|
||||
|
||||
|
|
|
@ -198,13 +198,13 @@ CompileZone::addressOfNeedsIncrementalBarrier()
|
|||
const void *
|
||||
CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind)
|
||||
{
|
||||
return zone()->allocator.arenas.getFreeList(allocKind)->addressOfFirst();
|
||||
return zone()->arenas.getFreeList(allocKind)->addressOfFirst();
|
||||
}
|
||||
|
||||
const void *
|
||||
CompileZone::addressOfFreeListLast(gc::AllocKind allocKind)
|
||||
{
|
||||
return zone()->allocator.arenas.getFreeList(allocKind)->addressOfLast();
|
||||
return zone()->arenas.getFreeList(allocKind)->addressOfLast();
|
||||
}
|
||||
|
||||
JSCompartment *
|
||||
|
|
|
@ -90,7 +90,7 @@ class CompileZone
|
|||
|
||||
const void *addressOfNeedsIncrementalBarrier();
|
||||
|
||||
// allocator.arenas.getFreeList(allocKind)
|
||||
// arenas.getFreeList(allocKind)
|
||||
const void *addressOfFreeListFirst(gc::AllocKind allocKind);
|
||||
const void *addressOfFreeListLast(gc::AllocKind allocKind);
|
||||
};
|
||||
|
|
|
@ -973,7 +973,7 @@ ExclusiveContext::ExclusiveContext(JSRuntime *rt, PerThreadData *pt, ContextKind
|
|||
helperThread_(nullptr),
|
||||
contextKind_(kind),
|
||||
perThreadData(pt),
|
||||
allocator_(nullptr),
|
||||
arenas_(nullptr),
|
||||
enterCompartmentDepth_(0)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -198,10 +198,10 @@ class ExclusiveContext : public ContextFriendFields,
|
|||
}
|
||||
|
||||
protected:
|
||||
Allocator *allocator_;
|
||||
js::gc::ArenaLists *arenas_;
|
||||
|
||||
public:
|
||||
inline Allocator *allocator() const { return allocator_; }
|
||||
inline js::gc::ArenaLists *arenas() const { return arenas_; }
|
||||
|
||||
template <typename T>
|
||||
bool isInsideCurrentZone(T thing) const {
|
||||
|
|
|
@ -439,7 +439,7 @@ js::ExclusiveContext::setCompartment(JSCompartment *comp)
|
|||
|
||||
compartment_ = comp;
|
||||
zone_ = comp ? comp->zone() : nullptr;
|
||||
allocator_ = zone_ ? &zone_->allocator : nullptr;
|
||||
arenas_ = zone_ ? &zone_->arenas : nullptr;
|
||||
}
|
||||
|
||||
inline JSScript *
|
||||
|
|
|
@ -423,7 +423,7 @@ ArenaHeader::checkSynchronizedWithFreeList() const
|
|||
FreeSpan firstSpan = firstFreeSpan.decompact(arenaAddress());
|
||||
if (firstSpan.isEmpty())
|
||||
return;
|
||||
const FreeList *freeList = zone->allocator.arenas.getFreeList(getAllocKind());
|
||||
const FreeList *freeList = zone->arenas.getFreeList(getAllocKind());
|
||||
if (freeList->isEmpty() || firstSpan.arenaAddress() != freeList->arenaAddress())
|
||||
return;
|
||||
|
||||
|
@ -1809,11 +1809,6 @@ ZoneHeapThreshold::updateForRemovedArena(const GCSchedulingTunables &tunables)
|
|||
gcTriggerBytes_ -= amount;
|
||||
}
|
||||
|
||||
Allocator::Allocator(Zone *zone)
|
||||
: arenas(zone->runtimeFromMainThread()),
|
||||
zone_(zone)
|
||||
{}
|
||||
|
||||
inline void
|
||||
GCMarker::delayMarkingArena(ArenaHeader *aheader)
|
||||
{
|
||||
|
@ -2106,7 +2101,7 @@ RelocateCell(Zone *zone, TenuredCell *src, AllocKind thingKind, size_t thingSize
|
|||
{
|
||||
// Allocate a new cell.
|
||||
MOZ_ASSERT(zone == src->zone());
|
||||
void *dstAlloc = zone->allocator.arenas.allocateFromFreeList(thingKind, thingSize);
|
||||
void *dstAlloc = zone->arenas.allocateFromFreeList(thingKind, thingSize);
|
||||
if (!dstAlloc)
|
||||
dstAlloc = GCRuntime::refillFreeListInGC(zone, thingKind);
|
||||
if (!dstAlloc)
|
||||
|
@ -2241,7 +2236,7 @@ GCRuntime::relocateArenas()
|
|||
|
||||
if (CanRelocateZone(rt, zone)) {
|
||||
zone->setGCState(Zone::Compact);
|
||||
relocatedList = zone->allocator.arenas.relocateArenas(relocatedList);
|
||||
relocatedList = zone->arenas.relocateArenas(relocatedList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2429,7 +2424,7 @@ ArenasToUpdate::next()
|
|||
for (; !zone.done(); zone.next()) {
|
||||
for (kind = 0; kind < FINALIZE_LIMIT; ++kind) {
|
||||
if (shouldProcessKind(kind)) {
|
||||
for (arena = zone.get()->allocator.arenas.getFirstArena(AllocKind(kind));
|
||||
for (arena = zone.get()->arenas.getFirstArena(AllocKind(kind));
|
||||
arena;
|
||||
arena = arena->next)
|
||||
{
|
||||
|
@ -2840,7 +2835,7 @@ ArenaLists::backgroundFinalize(FreeOp *fop, ArenaHeader *listHead, ArenaHeader *
|
|||
// to arenaListsToSweep[], leaving the arenaLists[] empty. However, new
|
||||
// arenas may be allocated before background finalization finishes; now that
|
||||
// finalization is complete, we want to merge these lists back together.
|
||||
ArenaLists *lists = &zone->allocator.arenas;
|
||||
ArenaLists *lists = &zone->arenas;
|
||||
ArenaList *al = &lists->arenaLists[thingKind];
|
||||
|
||||
// Flatten |finalizedSorted| into a regular ArenaList.
|
||||
|
@ -2948,7 +2943,7 @@ RunLastDitchGC(JSContext *cx, JS::Zone *zone, AllocKind thingKind)
|
|||
* return that list head.
|
||||
*/
|
||||
size_t thingSize = Arena::thingSize(thingKind);
|
||||
return zone->allocator.arenas.allocateFromFreeList(thingKind, thingSize);
|
||||
return zone->arenas.allocateFromFreeList(thingKind, thingSize);
|
||||
}
|
||||
|
||||
template <AllowGC allowGC>
|
||||
|
@ -2959,8 +2954,8 @@ GCRuntime::refillFreeListFromMainThread(JSContext *cx, AllocKind thingKind)
|
|||
MOZ_ASSERT(!rt->isHeapBusy(), "allocating while under GC");
|
||||
MOZ_ASSERT_IF(allowGC, !rt->currentThreadHasExclusiveAccess());
|
||||
|
||||
Allocator *allocator = cx->allocator();
|
||||
Zone *zone = allocator->zone_;
|
||||
ArenaLists *arenas = cx->arenas();
|
||||
Zone *zone = cx->zone();
|
||||
|
||||
// If we have grown past our GC heap threshold while in the middle of an
|
||||
// incremental GC, we're growing faster than we're GCing, so stop the world
|
||||
|
@ -2985,7 +2980,7 @@ GCRuntime::refillFreeListFromMainThread(JSContext *cx, AllocKind thingKind)
|
|||
}
|
||||
|
||||
AutoMaybeStartBackgroundAllocation maybeStartBGAlloc;
|
||||
void *thing = allocator->arenas.allocateFromArena(zone, thingKind, maybeStartBGAlloc);
|
||||
void *thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
|
||||
if (MOZ_LIKELY(thing))
|
||||
return thing;
|
||||
|
||||
|
@ -2995,7 +2990,7 @@ GCRuntime::refillFreeListFromMainThread(JSContext *cx, AllocKind thingKind)
|
|||
// we need.
|
||||
rt->gc.waitBackgroundSweepEnd();
|
||||
|
||||
thing = allocator->arenas.allocateFromArena(zone, thingKind, maybeStartBGAlloc);
|
||||
thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
|
||||
if (MOZ_LIKELY(thing))
|
||||
return thing;
|
||||
|
||||
|
@ -3011,8 +3006,8 @@ GCRuntime::refillFreeListFromMainThread(JSContext *cx, AllocKind thingKind)
|
|||
/* static */ void *
|
||||
GCRuntime::refillFreeListOffMainThread(ExclusiveContext *cx, AllocKind thingKind)
|
||||
{
|
||||
Allocator *allocator = cx->allocator();
|
||||
Zone *zone = allocator->zone_;
|
||||
ArenaLists *arenas = cx->arenas();
|
||||
Zone *zone = cx->zone();
|
||||
JSRuntime *rt = zone->runtimeFromAnyThread();
|
||||
|
||||
AutoMaybeStartBackgroundAllocation maybeStartBGAlloc;
|
||||
|
@ -3024,7 +3019,7 @@ GCRuntime::refillFreeListOffMainThread(ExclusiveContext *cx, AllocKind thingKind
|
|||
while (rt->isHeapBusy())
|
||||
HelperThreadState().wait(GlobalHelperThreadState::PRODUCER);
|
||||
|
||||
void *thing = allocator->arenas.allocateFromArena(zone, thingKind, maybeStartBGAlloc);
|
||||
void *thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
|
||||
if (thing)
|
||||
return thing;
|
||||
|
||||
|
@ -3036,7 +3031,7 @@ template <AllowGC allowGC>
|
|||
/* static */ void *
|
||||
GCRuntime::refillFreeListFromAnyThread(ExclusiveContext *cx, AllocKind thingKind)
|
||||
{
|
||||
MOZ_ASSERT(cx->allocator()->arenas.freeLists[thingKind].isEmpty());
|
||||
MOZ_ASSERT(cx->arenas()->freeLists[thingKind].isEmpty());
|
||||
|
||||
if (cx->isJSContext())
|
||||
return refillFreeListFromMainThread<allowGC>(cx->asJSContext(), thingKind);
|
||||
|
@ -3057,13 +3052,12 @@ GCRuntime::refillFreeListInGC(Zone *zone, AllocKind thingKind)
|
|||
* Called by compacting GC to refill a free list while we are in a GC.
|
||||
*/
|
||||
|
||||
Allocator &allocator = zone->allocator;
|
||||
MOZ_ASSERT(allocator.arenas.freeLists[thingKind].isEmpty());
|
||||
MOZ_ASSERT(zone->arenas.freeLists[thingKind].isEmpty());
|
||||
mozilla::DebugOnly<JSRuntime *> rt = zone->runtimeFromMainThread();
|
||||
MOZ_ASSERT(rt->isHeapMajorCollecting());
|
||||
MOZ_ASSERT(!rt->gc.isBackgroundSweeping());
|
||||
|
||||
return allocator.arenas.allocateFromArena(zone, thingKind);
|
||||
return zone->arenas.allocateFromArena(zone, thingKind);
|
||||
}
|
||||
|
||||
SliceBudget::SliceBudget()
|
||||
|
@ -3355,7 +3349,7 @@ GCRuntime::sweepBackgroundThings(ZoneList &zones, ThreadType threadType)
|
|||
for (Zone *zone = zones.front(); zone; zone = zone->nextZone()) {
|
||||
for (unsigned index = 0 ; index < BackgroundFinalizePhases[phase].length ; ++index) {
|
||||
AllocKind kind = BackgroundFinalizePhases[phase].kinds[index];
|
||||
ArenaHeader *arenas = zone->allocator.arenas.arenaListsToSweep[kind];
|
||||
ArenaHeader *arenas = zone->arenas.arenaListsToSweep[kind];
|
||||
if (arenas)
|
||||
ArenaLists::backgroundFinalize(&fop, arenas, &emptyArenas);
|
||||
}
|
||||
|
@ -3376,8 +3370,8 @@ GCRuntime::assertBackgroundSweepingFinished()
|
|||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(!zone->isOnList());
|
||||
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i) {
|
||||
MOZ_ASSERT(!zone->allocator.arenas.arenaListsToSweep[i]);
|
||||
MOZ_ASSERT(zone->allocator.arenas.doneBackgroundFinalize(AllocKind(i)));
|
||||
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
||||
MOZ_ASSERT(zone->arenas.doneBackgroundFinalize(AllocKind(i)));
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(freeLifoAlloc.computedSizeOfExcludingThis() == 0);
|
||||
|
@ -3697,10 +3691,10 @@ GCRuntime::sweepZones(FreeOp *fop, bool lastGC)
|
|||
|
||||
if (zone->wasGCStarted()) {
|
||||
if ((!zone->isQueuedForBackgroundSweep() &&
|
||||
zone->allocator.arenas.arenaListsAreEmpty() &&
|
||||
zone->arenas.arenaListsAreEmpty() &&
|
||||
!zone->hasMarkedCompartments()) || lastGC)
|
||||
{
|
||||
zone->allocator.arenas.checkEmptyFreeLists();
|
||||
zone->arenas.checkEmptyFreeLists();
|
||||
AutoUnlockGC unlock(lock);
|
||||
|
||||
if (callback)
|
||||
|
@ -3874,7 +3868,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason)
|
|||
MOZ_ASSERT(!zone->isCollecting());
|
||||
MOZ_ASSERT(!zone->compartments.empty());
|
||||
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i)
|
||||
MOZ_ASSERT(!zone->allocator.arenas.arenaListsToSweep[i]);
|
||||
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
||||
|
||||
/* Set up which zones will be collected. */
|
||||
if (zone->isGCScheduled()) {
|
||||
|
@ -3934,7 +3928,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason)
|
|||
*/
|
||||
if (isIncremental) {
|
||||
for (GCZonesIter zone(rt); !zone.done(); zone.next())
|
||||
zone->allocator.arenas.purge();
|
||||
zone->arenas.purge();
|
||||
}
|
||||
|
||||
marker.start();
|
||||
|
@ -3977,7 +3971,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason)
|
|||
|
||||
for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
|
||||
/* Unmark everything in the zones being collected. */
|
||||
zone->allocator.arenas.unmarkAll();
|
||||
zone->arenas.unmarkAll();
|
||||
}
|
||||
|
||||
for (GCCompartmentsIter c(rt); !c.done(); c.next()) {
|
||||
|
@ -4930,7 +4924,7 @@ GCRuntime::beginSweepingZoneGroup()
|
|||
zone->setGCState(Zone::Sweep);
|
||||
|
||||
/* Purge the ArenaLists before sweeping. */
|
||||
zone->allocator.arenas.purge();
|
||||
zone->arenas.purge();
|
||||
|
||||
if (rt->isAtomsZone(zone))
|
||||
sweepingAtoms = true;
|
||||
|
@ -5060,21 +5054,21 @@ GCRuntime::beginSweepingZoneGroup()
|
|||
|
||||
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
gcstats::AutoSCC scc(stats, zoneGroupIndex);
|
||||
zone->allocator.arenas.queueForegroundObjectsForSweep(&fop);
|
||||
zone->arenas.queueForegroundObjectsForSweep(&fop);
|
||||
}
|
||||
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
gcstats::AutoSCC scc(stats, zoneGroupIndex);
|
||||
for (unsigned i = 0; i < ArrayLength(IncrementalFinalizePhases); ++i)
|
||||
zone->allocator.arenas.queueForForegroundSweep(&fop, IncrementalFinalizePhases[i]);
|
||||
zone->arenas.queueForForegroundSweep(&fop, IncrementalFinalizePhases[i]);
|
||||
}
|
||||
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
gcstats::AutoSCC scc(stats, zoneGroupIndex);
|
||||
for (unsigned i = 0; i < ArrayLength(BackgroundFinalizePhases); ++i)
|
||||
zone->allocator.arenas.queueForBackgroundSweep(&fop, BackgroundFinalizePhases[i]);
|
||||
zone->arenas.queueForBackgroundSweep(&fop, BackgroundFinalizePhases[i]);
|
||||
}
|
||||
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
gcstats::AutoSCC scc(stats, zoneGroupIndex);
|
||||
zone->allocator.arenas.queueForegroundThingsForSweep(&fop);
|
||||
zone->arenas.queueForegroundThingsForSweep(&fop);
|
||||
}
|
||||
|
||||
sweepingTypes = true;
|
||||
|
@ -5240,7 +5234,7 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget)
|
|||
gcstats::AutoPhase ap2(stats, gcstats::PHASE_SWEEP_TYPES);
|
||||
|
||||
for (; sweepZone; sweepZone = sweepZone->nextNodeInGroup()) {
|
||||
ArenaLists &al = sweepZone->allocator.arenas;
|
||||
ArenaLists &al = sweepZone->arenas;
|
||||
|
||||
types::AutoClearTypeInferenceStateOnOOM oom(sweepZone);
|
||||
|
||||
|
@ -5300,7 +5294,7 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget)
|
|||
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(kind));
|
||||
incrementalSweepList.setThingsPerArena(thingsPerArena);
|
||||
|
||||
if (!zone->allocator.arenas.foregroundFinalize(&fop, kind, sliceBudget,
|
||||
if (!zone->arenas.foregroundFinalize(&fop, kind, sliceBudget,
|
||||
incrementalSweepList))
|
||||
return false; /* Yield to the mutator. */
|
||||
|
||||
|
@ -5320,12 +5314,9 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget)
|
|||
|
||||
for (; sweepZone; sweepZone = sweepZone->nextNodeInGroup()) {
|
||||
Zone *zone = sweepZone;
|
||||
if (!SweepShapes(&zone->allocator.arenas.gcShapeArenasToUpdate,
|
||||
FINALIZE_SHAPE, sliceBudget))
|
||||
{
|
||||
if (!SweepShapes(&zone->arenas.gcShapeArenasToUpdate, FINALIZE_SHAPE, sliceBudget))
|
||||
return false; /* Yield to the mutator. */
|
||||
}
|
||||
if (!SweepShapes(&zone->allocator.arenas.gcAccessorShapeArenasToUpdate,
|
||||
if (!SweepShapes(&zone->arenas.gcAccessorShapeArenasToUpdate,
|
||||
FINALIZE_ACCESSOR_SHAPE, sliceBudget))
|
||||
{
|
||||
return false; /* Yield to the mutator. */
|
||||
|
@ -5372,7 +5363,7 @@ GCRuntime::endSweepPhase(bool lastGC)
|
|||
if (foundBlackGrayEdges) {
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
if (!zone->isCollecting())
|
||||
zone->allocator.arenas.unmarkAll();
|
||||
zone->arenas.unmarkAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5447,7 +5438,7 @@ GCRuntime::endSweepPhase(bool lastGC)
|
|||
for (unsigned i = 0 ; i < FINALIZE_LIMIT ; ++i) {
|
||||
MOZ_ASSERT_IF(!IsBackgroundFinalized(AllocKind(i)) ||
|
||||
!sweepOnBackgroundThread,
|
||||
!zone->allocator.arenas.arenaListsToSweep[i]);
|
||||
!zone->arenas.arenaListsToSweep[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5515,14 +5506,14 @@ GCRuntime::compactPhase(bool lastGC)
|
|||
for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
|
||||
if (CanRelocateZone(rt, zone)) {
|
||||
MOZ_ASSERT(!zone->isPreservingCode());
|
||||
zone->allocator.arenas.checkEmptyFreeLists();
|
||||
zone->arenas.checkEmptyFreeLists();
|
||||
|
||||
// Check that we did as much compaction as we should have. There
|
||||
// should always be less than one arena's worth of free cells.
|
||||
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
|
||||
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(AllocKind(i)));
|
||||
if (CanRelocateAllocKind(AllocKind(i))) {
|
||||
ArenaList &al = zone->allocator.arenas.arenaLists[i];
|
||||
ArenaList &al = zone->arenas.arenaLists[i];
|
||||
size_t freeCells = 0;
|
||||
for (ArenaHeader *arena = al.arenaAfterCursor(); arena; arena = arena->next)
|
||||
freeCells += arena->countFreeCells();
|
||||
|
@ -5609,13 +5600,13 @@ AutoCopyFreeListToArenas::AutoCopyFreeListToArenas(JSRuntime *rt, ZoneSelector s
|
|||
selector(selector)
|
||||
{
|
||||
for (ZonesIter zone(rt, selector); !zone.done(); zone.next())
|
||||
zone->allocator.arenas.copyFreeListsToArenas();
|
||||
zone->arenas.copyFreeListsToArenas();
|
||||
}
|
||||
|
||||
AutoCopyFreeListToArenas::~AutoCopyFreeListToArenas()
|
||||
{
|
||||
for (ZonesIter zone(runtime, selector); !zone.done(); zone.next())
|
||||
zone->allocator.arenas.clearFreeListsInArenas();
|
||||
zone->arenas.clearFreeListsInArenas();
|
||||
}
|
||||
|
||||
class AutoCopyFreeListToArenasForGC
|
||||
|
@ -5626,11 +5617,11 @@ class AutoCopyFreeListToArenasForGC
|
|||
explicit AutoCopyFreeListToArenasForGC(JSRuntime *rt) : runtime(rt) {
|
||||
MOZ_ASSERT(rt->currentThreadHasExclusiveAccess());
|
||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next())
|
||||
zone->allocator.arenas.copyFreeListsToArenas();
|
||||
zone->arenas.copyFreeListsToArenas();
|
||||
}
|
||||
~AutoCopyFreeListToArenasForGC() {
|
||||
for (ZonesIter zone(runtime, WithAtoms); !zone.done(); zone.next())
|
||||
zone->allocator.arenas.clearFreeListsInArenas();
|
||||
zone->arenas.clearFreeListsInArenas();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -5708,7 +5699,7 @@ GCRuntime::resetIncrementalGC(const char *reason)
|
|||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||
MOZ_ASSERT(!zone->needsIncrementalBarrier());
|
||||
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i)
|
||||
MOZ_ASSERT(!zone->allocator.arenas.arenaListsToSweep[i]);
|
||||
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5763,7 +5754,7 @@ AutoGCSlice::~AutoGCSlice()
|
|||
for (ZonesIter zone(runtime, WithAtoms); !zone.done(); zone.next()) {
|
||||
if (zone->isGCMarking()) {
|
||||
zone->setNeedsIncrementalBarrier(true, Zone::UpdateJit);
|
||||
zone->allocator.arenas.prepareForIncrementalGC(runtime);
|
||||
zone->arenas.prepareForIncrementalGC(runtime);
|
||||
haveBarriers = true;
|
||||
} else {
|
||||
zone->setNeedsIncrementalBarrier(false, Zone::UpdateJit);
|
||||
|
@ -6581,7 +6572,7 @@ gc::MergeCompartments(JSCompartment *source, JSCompartment *target)
|
|||
MOZ_ASSERT(c.get() == source);
|
||||
|
||||
// Merge the allocator in source's zone into target's zone.
|
||||
target->zone()->allocator.arenas.adoptArenas(rt, &source->zone()->allocator.arenas);
|
||||
target->zone()->arenas.adoptArenas(rt, &source->zone()->arenas);
|
||||
target->zone()->usage.adopt(source->zone()->usage);
|
||||
|
||||
// Merge other info in source's zone into target's zone.
|
||||
|
|
|
@ -75,10 +75,10 @@ class ArenaIter
|
|||
init(zone, kind);
|
||||
}
|
||||
|
||||
void init(Allocator *allocator, AllocKind kind) {
|
||||
aheader = allocator->arenas.getFirstArena(kind);
|
||||
unsweptHeader = allocator->arenas.getFirstArenaToSweep(kind);
|
||||
sweptHeader = allocator->arenas.getFirstSweptArena(kind);
|
||||
void init(JS::Zone *zone, AllocKind kind) {
|
||||
aheader = zone->arenas.getFirstArena(kind);
|
||||
unsweptHeader = zone->arenas.getFirstArenaToSweep(kind);
|
||||
sweptHeader = zone->arenas.getFirstSweptArena(kind);
|
||||
if (!unsweptHeader) {
|
||||
unsweptHeader = sweptHeader;
|
||||
sweptHeader = nullptr;
|
||||
|
@ -90,10 +90,6 @@ class ArenaIter
|
|||
}
|
||||
}
|
||||
|
||||
void init(JS::Zone *zone, AllocKind kind) {
|
||||
init(&zone->allocator, kind);
|
||||
}
|
||||
|
||||
bool done() const {
|
||||
return !aheader;
|
||||
}
|
||||
|
@ -163,7 +159,7 @@ class ArenaCellIterImpl
|
|||
void init(ArenaHeader *aheader) {
|
||||
#ifdef DEBUG
|
||||
AllocKind kind = aheader->getAllocKind();
|
||||
MOZ_ASSERT(aheader->zone->allocator.arenas.isSynchronizedFreeList(kind));
|
||||
MOZ_ASSERT(aheader->zone->arenas.isSynchronizedFreeList(kind));
|
||||
#endif
|
||||
initUnsynchronized(aheader);
|
||||
}
|
||||
|
@ -231,7 +227,7 @@ class ZoneCellIterImpl
|
|||
ZoneCellIterImpl() {}
|
||||
|
||||
void init(JS::Zone *zone, AllocKind kind) {
|
||||
MOZ_ASSERT(zone->allocator.arenas.isSynchronizedFreeList(kind));
|
||||
MOZ_ASSERT(zone->arenas.isSynchronizedFreeList(kind));
|
||||
arenaIter.init(zone, kind);
|
||||
if (!arenaIter.done())
|
||||
cellIter.init(arenaIter.get());
|
||||
|
@ -282,7 +278,7 @@ class ZoneCellIter : public ZoneCellIterImpl
|
|||
|
||||
public:
|
||||
ZoneCellIter(JS::Zone *zone, AllocKind kind)
|
||||
: lists(&zone->allocator.arenas),
|
||||
: lists(&zone->arenas),
|
||||
kind(kind)
|
||||
{
|
||||
JSRuntime *rt = zone->runtimeFromMainThread();
|
||||
|
@ -294,7 +290,7 @@ class ZoneCellIter : public ZoneCellIterImpl
|
|||
* currently active.
|
||||
*/
|
||||
if (IsBackgroundFinalized(kind) &&
|
||||
zone->allocator.arenas.needBackgroundFinalizeWait(kind))
|
||||
zone->arenas.needBackgroundFinalizeWait(kind))
|
||||
{
|
||||
rt->gc.waitBackgroundSweepEnd();
|
||||
}
|
||||
|
@ -515,8 +511,7 @@ AllocateObject(ExclusiveContext *cx, AllocKind kind, size_t nDynamicSlots, Initi
|
|||
js::Debug_SetSlotRangeToCrashOnTouch(slots, nDynamicSlots);
|
||||
}
|
||||
|
||||
JSObject *obj = reinterpret_cast<JSObject *>(
|
||||
cx->allocator()->arenas.allocateFromFreeList(kind, thingSize));
|
||||
JSObject *obj = reinterpret_cast<JSObject *>(cx->arenas()->allocateFromFreeList(kind, thingSize));
|
||||
if (!obj)
|
||||
obj = reinterpret_cast<JSObject *>(GCRuntime::refillFreeListFromAnyThread<allowGC>(cx, kind));
|
||||
|
||||
|
@ -544,7 +539,7 @@ AllocateNonObject(ExclusiveContext *cx)
|
|||
if (!CheckAllocatorState<allowGC>(cx, kind))
|
||||
return nullptr;
|
||||
|
||||
T *t = static_cast<T *>(cx->allocator()->arenas.allocateFromFreeList(kind, thingSize));
|
||||
T *t = static_cast<T *>(cx->arenas()->allocateFromFreeList(kind, thingSize));
|
||||
if (!t)
|
||||
t = static_cast<T *>(GCRuntime::refillFreeListFromAnyThread<allowGC>(cx, kind));
|
||||
|
||||
|
|
|
@ -290,8 +290,6 @@ enum ParallelResult { TP_SUCCESS, TP_RETRY_SEQUENTIALLY, TP_RETRY_AFTER_GC, TP_F
|
|||
|
||||
class ExclusiveContext;
|
||||
|
||||
class Allocator;
|
||||
|
||||
enum ThingRootKind
|
||||
{
|
||||
THING_ROOT_OBJECT,
|
||||
|
|
Загрузка…
Ссылка в новой задаче