Bug 1119694 - remove Allocator. r=terrence

This commit is contained in:
Lars T Hansen 2015-01-14 09:22:00 +01:00
Родитель f5debc0939
Коммит 8dc276cac6
12 изменённых файлов: 68 добавлений и 103 удалений

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

@ -448,12 +448,11 @@ GetObjectAllocKindForCopy(const Nursery &nursery, JSObject *obj)
MOZ_ALWAYS_INLINE TenuredCell * MOZ_ALWAYS_INLINE TenuredCell *
js::Nursery::allocateFromTenured(Zone *zone, AllocKind thingKind) js::Nursery::allocateFromTenured(Zone *zone, AllocKind thingKind)
{ {
TenuredCell *t = TenuredCell *t = zone->arenas.allocateFromFreeList(thingKind, Arena::thingSize(thingKind));
zone->allocator.arenas.allocateFromFreeList(thingKind, Arena::thingSize(thingKind));
if (t) if (t)
return t; return t;
zone->allocator.arenas.checkEmptyFreeList(thingKind); zone->arenas.checkEmptyFreeList(thingKind);
return zone->allocator.arenas.allocateFromArena(zone, thingKind); return zone->arenas.allocateFromArena(zone, thingKind);
} }
void void

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

@ -254,7 +254,7 @@ gc::GCRuntime::startVerifyPreBarriers()
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
PurgeJITCaches(zone); PurgeJITCaches(zone);
zone->setNeedsIncrementalBarrier(true, Zone::UpdateJit); zone->setNeedsIncrementalBarrier(true, Zone::UpdateJit);
zone->allocator.arenas.purge(); zone->arenas.purge();
} }
return; return;

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

@ -23,7 +23,7 @@ Zone * const Zone::NotOnList = reinterpret_cast<Zone *>(1);
JS::Zone::Zone(JSRuntime *rt) JS::Zone::Zone(JSRuntime *rt)
: JS::shadow::Zone(rt, &rt->gc.marker), : JS::shadow::Zone(rt, &rt->gc.marker),
allocator(this), arenas(rt),
types(this), types(this),
compartments(), compartments(),
gcGrayRoots(), gcGrayRoots(),

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

@ -24,24 +24,6 @@ namespace jit {
class JitZone; 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 { namespace gc {
// This class encapsulates the data that determines when we need to do a zone 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: public:
js::Allocator allocator; js::gc::ArenaLists arenas;
js::types::TypeZone types; js::types::TypeZone types;

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

@ -198,13 +198,13 @@ CompileZone::addressOfNeedsIncrementalBarrier()
const void * const void *
CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind) CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind)
{ {
return zone()->allocator.arenas.getFreeList(allocKind)->addressOfFirst(); return zone()->arenas.getFreeList(allocKind)->addressOfFirst();
} }
const void * const void *
CompileZone::addressOfFreeListLast(gc::AllocKind allocKind) CompileZone::addressOfFreeListLast(gc::AllocKind allocKind)
{ {
return zone()->allocator.arenas.getFreeList(allocKind)->addressOfLast(); return zone()->arenas.getFreeList(allocKind)->addressOfLast();
} }
JSCompartment * JSCompartment *

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

@ -90,7 +90,7 @@ class CompileZone
const void *addressOfNeedsIncrementalBarrier(); const void *addressOfNeedsIncrementalBarrier();
// allocator.arenas.getFreeList(allocKind) // arenas.getFreeList(allocKind)
const void *addressOfFreeListFirst(gc::AllocKind allocKind); const void *addressOfFreeListFirst(gc::AllocKind allocKind);
const void *addressOfFreeListLast(gc::AllocKind allocKind); const void *addressOfFreeListLast(gc::AllocKind allocKind);
}; };

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

@ -973,7 +973,7 @@ ExclusiveContext::ExclusiveContext(JSRuntime *rt, PerThreadData *pt, ContextKind
helperThread_(nullptr), helperThread_(nullptr),
contextKind_(kind), contextKind_(kind),
perThreadData(pt), perThreadData(pt),
allocator_(nullptr), arenas_(nullptr),
enterCompartmentDepth_(0) enterCompartmentDepth_(0)
{ {
} }

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

@ -198,10 +198,10 @@ class ExclusiveContext : public ContextFriendFields,
} }
protected: protected:
Allocator *allocator_; js::gc::ArenaLists *arenas_;
public: public:
inline Allocator *allocator() const { return allocator_; } inline js::gc::ArenaLists *arenas() const { return arenas_; }
template <typename T> template <typename T>
bool isInsideCurrentZone(T thing) const { bool isInsideCurrentZone(T thing) const {

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

@ -439,7 +439,7 @@ js::ExclusiveContext::setCompartment(JSCompartment *comp)
compartment_ = comp; compartment_ = comp;
zone_ = comp ? comp->zone() : nullptr; zone_ = comp ? comp->zone() : nullptr;
allocator_ = zone_ ? &zone_->allocator : nullptr; arenas_ = zone_ ? &zone_->arenas : nullptr;
} }
inline JSScript * inline JSScript *

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

@ -423,7 +423,7 @@ ArenaHeader::checkSynchronizedWithFreeList() const
FreeSpan firstSpan = firstFreeSpan.decompact(arenaAddress()); FreeSpan firstSpan = firstFreeSpan.decompact(arenaAddress());
if (firstSpan.isEmpty()) if (firstSpan.isEmpty())
return; return;
const FreeList *freeList = zone->allocator.arenas.getFreeList(getAllocKind()); const FreeList *freeList = zone->arenas.getFreeList(getAllocKind());
if (freeList->isEmpty() || firstSpan.arenaAddress() != freeList->arenaAddress()) if (freeList->isEmpty() || firstSpan.arenaAddress() != freeList->arenaAddress())
return; return;
@ -1809,11 +1809,6 @@ ZoneHeapThreshold::updateForRemovedArena(const GCSchedulingTunables &tunables)
gcTriggerBytes_ -= amount; gcTriggerBytes_ -= amount;
} }
Allocator::Allocator(Zone *zone)
: arenas(zone->runtimeFromMainThread()),
zone_(zone)
{}
inline void inline void
GCMarker::delayMarkingArena(ArenaHeader *aheader) GCMarker::delayMarkingArena(ArenaHeader *aheader)
{ {
@ -2106,7 +2101,7 @@ RelocateCell(Zone *zone, TenuredCell *src, AllocKind thingKind, size_t thingSize
{ {
// Allocate a new cell. // Allocate a new cell.
MOZ_ASSERT(zone == src->zone()); MOZ_ASSERT(zone == src->zone());
void *dstAlloc = zone->allocator.arenas.allocateFromFreeList(thingKind, thingSize); void *dstAlloc = zone->arenas.allocateFromFreeList(thingKind, thingSize);
if (!dstAlloc) if (!dstAlloc)
dstAlloc = GCRuntime::refillFreeListInGC(zone, thingKind); dstAlloc = GCRuntime::refillFreeListInGC(zone, thingKind);
if (!dstAlloc) if (!dstAlloc)
@ -2241,7 +2236,7 @@ GCRuntime::relocateArenas()
if (CanRelocateZone(rt, zone)) { if (CanRelocateZone(rt, zone)) {
zone->setGCState(Zone::Compact); 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 (; !zone.done(); zone.next()) {
for (kind = 0; kind < FINALIZE_LIMIT; ++kind) { for (kind = 0; kind < FINALIZE_LIMIT; ++kind) {
if (shouldProcessKind(kind)) { if (shouldProcessKind(kind)) {
for (arena = zone.get()->allocator.arenas.getFirstArena(AllocKind(kind)); for (arena = zone.get()->arenas.getFirstArena(AllocKind(kind));
arena; arena;
arena = arena->next) arena = arena->next)
{ {
@ -2840,7 +2835,7 @@ ArenaLists::backgroundFinalize(FreeOp *fop, ArenaHeader *listHead, ArenaHeader *
// to arenaListsToSweep[], leaving the arenaLists[] empty. However, new // to arenaListsToSweep[], leaving the arenaLists[] empty. However, new
// arenas may be allocated before background finalization finishes; now that // arenas may be allocated before background finalization finishes; now that
// finalization is complete, we want to merge these lists back together. // 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]; ArenaList *al = &lists->arenaLists[thingKind];
// Flatten |finalizedSorted| into a regular ArenaList. // Flatten |finalizedSorted| into a regular ArenaList.
@ -2948,7 +2943,7 @@ RunLastDitchGC(JSContext *cx, JS::Zone *zone, AllocKind thingKind)
* return that list head. * return that list head.
*/ */
size_t thingSize = Arena::thingSize(thingKind); size_t thingSize = Arena::thingSize(thingKind);
return zone->allocator.arenas.allocateFromFreeList(thingKind, thingSize); return zone->arenas.allocateFromFreeList(thingKind, thingSize);
} }
template <AllowGC allowGC> template <AllowGC allowGC>
@ -2959,8 +2954,8 @@ GCRuntime::refillFreeListFromMainThread(JSContext *cx, AllocKind thingKind)
MOZ_ASSERT(!rt->isHeapBusy(), "allocating while under GC"); MOZ_ASSERT(!rt->isHeapBusy(), "allocating while under GC");
MOZ_ASSERT_IF(allowGC, !rt->currentThreadHasExclusiveAccess()); MOZ_ASSERT_IF(allowGC, !rt->currentThreadHasExclusiveAccess());
Allocator *allocator = cx->allocator(); ArenaLists *arenas = cx->arenas();
Zone *zone = allocator->zone_; Zone *zone = cx->zone();
// If we have grown past our GC heap threshold while in the middle of an // 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 // 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; AutoMaybeStartBackgroundAllocation maybeStartBGAlloc;
void *thing = allocator->arenas.allocateFromArena(zone, thingKind, maybeStartBGAlloc); void *thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
if (MOZ_LIKELY(thing)) if (MOZ_LIKELY(thing))
return thing; return thing;
@ -2995,7 +2990,7 @@ GCRuntime::refillFreeListFromMainThread(JSContext *cx, AllocKind thingKind)
// we need. // we need.
rt->gc.waitBackgroundSweepEnd(); rt->gc.waitBackgroundSweepEnd();
thing = allocator->arenas.allocateFromArena(zone, thingKind, maybeStartBGAlloc); thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
if (MOZ_LIKELY(thing)) if (MOZ_LIKELY(thing))
return thing; return thing;
@ -3011,8 +3006,8 @@ GCRuntime::refillFreeListFromMainThread(JSContext *cx, AllocKind thingKind)
/* static */ void * /* static */ void *
GCRuntime::refillFreeListOffMainThread(ExclusiveContext *cx, AllocKind thingKind) GCRuntime::refillFreeListOffMainThread(ExclusiveContext *cx, AllocKind thingKind)
{ {
Allocator *allocator = cx->allocator(); ArenaLists *arenas = cx->arenas();
Zone *zone = allocator->zone_; Zone *zone = cx->zone();
JSRuntime *rt = zone->runtimeFromAnyThread(); JSRuntime *rt = zone->runtimeFromAnyThread();
AutoMaybeStartBackgroundAllocation maybeStartBGAlloc; AutoMaybeStartBackgroundAllocation maybeStartBGAlloc;
@ -3024,7 +3019,7 @@ GCRuntime::refillFreeListOffMainThread(ExclusiveContext *cx, AllocKind thingKind
while (rt->isHeapBusy()) while (rt->isHeapBusy())
HelperThreadState().wait(GlobalHelperThreadState::PRODUCER); HelperThreadState().wait(GlobalHelperThreadState::PRODUCER);
void *thing = allocator->arenas.allocateFromArena(zone, thingKind, maybeStartBGAlloc); void *thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
if (thing) if (thing)
return thing; return thing;
@ -3036,7 +3031,7 @@ template <AllowGC allowGC>
/* static */ void * /* static */ void *
GCRuntime::refillFreeListFromAnyThread(ExclusiveContext *cx, AllocKind thingKind) GCRuntime::refillFreeListFromAnyThread(ExclusiveContext *cx, AllocKind thingKind)
{ {
MOZ_ASSERT(cx->allocator()->arenas.freeLists[thingKind].isEmpty()); MOZ_ASSERT(cx->arenas()->freeLists[thingKind].isEmpty());
if (cx->isJSContext()) if (cx->isJSContext())
return refillFreeListFromMainThread<allowGC>(cx->asJSContext(), thingKind); 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. * Called by compacting GC to refill a free list while we are in a GC.
*/ */
Allocator &allocator = zone->allocator; MOZ_ASSERT(zone->arenas.freeLists[thingKind].isEmpty());
MOZ_ASSERT(allocator.arenas.freeLists[thingKind].isEmpty());
mozilla::DebugOnly<JSRuntime *> rt = zone->runtimeFromMainThread(); mozilla::DebugOnly<JSRuntime *> rt = zone->runtimeFromMainThread();
MOZ_ASSERT(rt->isHeapMajorCollecting()); MOZ_ASSERT(rt->isHeapMajorCollecting());
MOZ_ASSERT(!rt->gc.isBackgroundSweeping()); MOZ_ASSERT(!rt->gc.isBackgroundSweeping());
return allocator.arenas.allocateFromArena(zone, thingKind); return zone->arenas.allocateFromArena(zone, thingKind);
} }
SliceBudget::SliceBudget() SliceBudget::SliceBudget()
@ -3355,7 +3349,7 @@ GCRuntime::sweepBackgroundThings(ZoneList &zones, ThreadType threadType)
for (Zone *zone = zones.front(); zone; zone = zone->nextZone()) { for (Zone *zone = zones.front(); zone; zone = zone->nextZone()) {
for (unsigned index = 0 ; index < BackgroundFinalizePhases[phase].length ; ++index) { for (unsigned index = 0 ; index < BackgroundFinalizePhases[phase].length ; ++index) {
AllocKind kind = BackgroundFinalizePhases[phase].kinds[index]; AllocKind kind = BackgroundFinalizePhases[phase].kinds[index];
ArenaHeader *arenas = zone->allocator.arenas.arenaListsToSweep[kind]; ArenaHeader *arenas = zone->arenas.arenaListsToSweep[kind];
if (arenas) if (arenas)
ArenaLists::backgroundFinalize(&fop, arenas, &emptyArenas); ArenaLists::backgroundFinalize(&fop, arenas, &emptyArenas);
} }
@ -3376,8 +3370,8 @@ GCRuntime::assertBackgroundSweepingFinished()
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
MOZ_ASSERT(!zone->isOnList()); MOZ_ASSERT(!zone->isOnList());
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i) { for (unsigned i = 0; i < FINALIZE_LIMIT; ++i) {
MOZ_ASSERT(!zone->allocator.arenas.arenaListsToSweep[i]); MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
MOZ_ASSERT(zone->allocator.arenas.doneBackgroundFinalize(AllocKind(i))); MOZ_ASSERT(zone->arenas.doneBackgroundFinalize(AllocKind(i)));
} }
} }
MOZ_ASSERT(freeLifoAlloc.computedSizeOfExcludingThis() == 0); MOZ_ASSERT(freeLifoAlloc.computedSizeOfExcludingThis() == 0);
@ -3697,10 +3691,10 @@ GCRuntime::sweepZones(FreeOp *fop, bool lastGC)
if (zone->wasGCStarted()) { if (zone->wasGCStarted()) {
if ((!zone->isQueuedForBackgroundSweep() && if ((!zone->isQueuedForBackgroundSweep() &&
zone->allocator.arenas.arenaListsAreEmpty() && zone->arenas.arenaListsAreEmpty() &&
!zone->hasMarkedCompartments()) || lastGC) !zone->hasMarkedCompartments()) || lastGC)
{ {
zone->allocator.arenas.checkEmptyFreeLists(); zone->arenas.checkEmptyFreeLists();
AutoUnlockGC unlock(lock); AutoUnlockGC unlock(lock);
if (callback) if (callback)
@ -3874,7 +3868,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason)
MOZ_ASSERT(!zone->isCollecting()); MOZ_ASSERT(!zone->isCollecting());
MOZ_ASSERT(!zone->compartments.empty()); MOZ_ASSERT(!zone->compartments.empty());
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i) 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. */ /* Set up which zones will be collected. */
if (zone->isGCScheduled()) { if (zone->isGCScheduled()) {
@ -3934,7 +3928,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason)
*/ */
if (isIncremental) { if (isIncremental) {
for (GCZonesIter zone(rt); !zone.done(); zone.next()) for (GCZonesIter zone(rt); !zone.done(); zone.next())
zone->allocator.arenas.purge(); zone->arenas.purge();
} }
marker.start(); marker.start();
@ -3977,7 +3971,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason)
for (GCZonesIter zone(rt); !zone.done(); zone.next()) { for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
/* Unmark everything in the zones being collected. */ /* Unmark everything in the zones being collected. */
zone->allocator.arenas.unmarkAll(); zone->arenas.unmarkAll();
} }
for (GCCompartmentsIter c(rt); !c.done(); c.next()) { for (GCCompartmentsIter c(rt); !c.done(); c.next()) {
@ -4930,7 +4924,7 @@ GCRuntime::beginSweepingZoneGroup()
zone->setGCState(Zone::Sweep); zone->setGCState(Zone::Sweep);
/* Purge the ArenaLists before sweeping. */ /* Purge the ArenaLists before sweeping. */
zone->allocator.arenas.purge(); zone->arenas.purge();
if (rt->isAtomsZone(zone)) if (rt->isAtomsZone(zone))
sweepingAtoms = true; sweepingAtoms = true;
@ -5060,21 +5054,21 @@ GCRuntime::beginSweepingZoneGroup()
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) { for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
gcstats::AutoSCC scc(stats, zoneGroupIndex); gcstats::AutoSCC scc(stats, zoneGroupIndex);
zone->allocator.arenas.queueForegroundObjectsForSweep(&fop); zone->arenas.queueForegroundObjectsForSweep(&fop);
} }
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) { for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
gcstats::AutoSCC scc(stats, zoneGroupIndex); gcstats::AutoSCC scc(stats, zoneGroupIndex);
for (unsigned i = 0; i < ArrayLength(IncrementalFinalizePhases); ++i) 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()) { for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
gcstats::AutoSCC scc(stats, zoneGroupIndex); gcstats::AutoSCC scc(stats, zoneGroupIndex);
for (unsigned i = 0; i < ArrayLength(BackgroundFinalizePhases); ++i) 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()) { for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
gcstats::AutoSCC scc(stats, zoneGroupIndex); gcstats::AutoSCC scc(stats, zoneGroupIndex);
zone->allocator.arenas.queueForegroundThingsForSweep(&fop); zone->arenas.queueForegroundThingsForSweep(&fop);
} }
sweepingTypes = true; sweepingTypes = true;
@ -5240,7 +5234,7 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget)
gcstats::AutoPhase ap2(stats, gcstats::PHASE_SWEEP_TYPES); gcstats::AutoPhase ap2(stats, gcstats::PHASE_SWEEP_TYPES);
for (; sweepZone; sweepZone = sweepZone->nextNodeInGroup()) { for (; sweepZone; sweepZone = sweepZone->nextNodeInGroup()) {
ArenaLists &al = sweepZone->allocator.arenas; ArenaLists &al = sweepZone->arenas;
types::AutoClearTypeInferenceStateOnOOM oom(sweepZone); types::AutoClearTypeInferenceStateOnOOM oom(sweepZone);
@ -5300,8 +5294,8 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget)
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(kind)); size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(kind));
incrementalSweepList.setThingsPerArena(thingsPerArena); incrementalSweepList.setThingsPerArena(thingsPerArena);
if (!zone->allocator.arenas.foregroundFinalize(&fop, kind, sliceBudget, if (!zone->arenas.foregroundFinalize(&fop, kind, sliceBudget,
incrementalSweepList)) incrementalSweepList))
return false; /* Yield to the mutator. */ return false; /* Yield to the mutator. */
/* Reset the slots of the sweep list that we used. */ /* Reset the slots of the sweep list that we used. */
@ -5320,12 +5314,9 @@ GCRuntime::sweepPhase(SliceBudget &sliceBudget)
for (; sweepZone; sweepZone = sweepZone->nextNodeInGroup()) { for (; sweepZone; sweepZone = sweepZone->nextNodeInGroup()) {
Zone *zone = sweepZone; Zone *zone = sweepZone;
if (!SweepShapes(&zone->allocator.arenas.gcShapeArenasToUpdate, if (!SweepShapes(&zone->arenas.gcShapeArenasToUpdate, FINALIZE_SHAPE, sliceBudget))
FINALIZE_SHAPE, sliceBudget))
{
return false; /* Yield to the mutator. */ return false; /* Yield to the mutator. */
} if (!SweepShapes(&zone->arenas.gcAccessorShapeArenasToUpdate,
if (!SweepShapes(&zone->allocator.arenas.gcAccessorShapeArenasToUpdate,
FINALIZE_ACCESSOR_SHAPE, sliceBudget)) FINALIZE_ACCESSOR_SHAPE, sliceBudget))
{ {
return false; /* Yield to the mutator. */ return false; /* Yield to the mutator. */
@ -5372,7 +5363,7 @@ GCRuntime::endSweepPhase(bool lastGC)
if (foundBlackGrayEdges) { if (foundBlackGrayEdges) {
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
if (!zone->isCollecting()) 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) { for (unsigned i = 0 ; i < FINALIZE_LIMIT ; ++i) {
MOZ_ASSERT_IF(!IsBackgroundFinalized(AllocKind(i)) || MOZ_ASSERT_IF(!IsBackgroundFinalized(AllocKind(i)) ||
!sweepOnBackgroundThread, !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()) { for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
if (CanRelocateZone(rt, zone)) { if (CanRelocateZone(rt, zone)) {
MOZ_ASSERT(!zone->isPreservingCode()); MOZ_ASSERT(!zone->isPreservingCode());
zone->allocator.arenas.checkEmptyFreeLists(); zone->arenas.checkEmptyFreeLists();
// Check that we did as much compaction as we should have. There // Check that we did as much compaction as we should have. There
// should always be less than one arena's worth of free cells. // should always be less than one arena's worth of free cells.
for (size_t i = 0; i < FINALIZE_LIMIT; i++) { for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(AllocKind(i))); size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(AllocKind(i)));
if (CanRelocateAllocKind(AllocKind(i))) { if (CanRelocateAllocKind(AllocKind(i))) {
ArenaList &al = zone->allocator.arenas.arenaLists[i]; ArenaList &al = zone->arenas.arenaLists[i];
size_t freeCells = 0; size_t freeCells = 0;
for (ArenaHeader *arena = al.arenaAfterCursor(); arena; arena = arena->next) for (ArenaHeader *arena = al.arenaAfterCursor(); arena; arena = arena->next)
freeCells += arena->countFreeCells(); freeCells += arena->countFreeCells();
@ -5609,13 +5600,13 @@ AutoCopyFreeListToArenas::AutoCopyFreeListToArenas(JSRuntime *rt, ZoneSelector s
selector(selector) selector(selector)
{ {
for (ZonesIter zone(rt, selector); !zone.done(); zone.next()) for (ZonesIter zone(rt, selector); !zone.done(); zone.next())
zone->allocator.arenas.copyFreeListsToArenas(); zone->arenas.copyFreeListsToArenas();
} }
AutoCopyFreeListToArenas::~AutoCopyFreeListToArenas() AutoCopyFreeListToArenas::~AutoCopyFreeListToArenas()
{ {
for (ZonesIter zone(runtime, selector); !zone.done(); zone.next()) for (ZonesIter zone(runtime, selector); !zone.done(); zone.next())
zone->allocator.arenas.clearFreeListsInArenas(); zone->arenas.clearFreeListsInArenas();
} }
class AutoCopyFreeListToArenasForGC class AutoCopyFreeListToArenasForGC
@ -5626,11 +5617,11 @@ class AutoCopyFreeListToArenasForGC
explicit AutoCopyFreeListToArenasForGC(JSRuntime *rt) : runtime(rt) { explicit AutoCopyFreeListToArenasForGC(JSRuntime *rt) : runtime(rt) {
MOZ_ASSERT(rt->currentThreadHasExclusiveAccess()); MOZ_ASSERT(rt->currentThreadHasExclusiveAccess());
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next())
zone->allocator.arenas.copyFreeListsToArenas(); zone->arenas.copyFreeListsToArenas();
} }
~AutoCopyFreeListToArenasForGC() { ~AutoCopyFreeListToArenasForGC() {
for (ZonesIter zone(runtime, WithAtoms); !zone.done(); zone.next()) 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()) { for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
MOZ_ASSERT(!zone->needsIncrementalBarrier()); MOZ_ASSERT(!zone->needsIncrementalBarrier());
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i) for (unsigned i = 0; i < FINALIZE_LIMIT; ++i)
MOZ_ASSERT(!zone->allocator.arenas.arenaListsToSweep[i]); MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
} }
#endif #endif
} }
@ -5763,7 +5754,7 @@ AutoGCSlice::~AutoGCSlice()
for (ZonesIter zone(runtime, WithAtoms); !zone.done(); zone.next()) { for (ZonesIter zone(runtime, WithAtoms); !zone.done(); zone.next()) {
if (zone->isGCMarking()) { if (zone->isGCMarking()) {
zone->setNeedsIncrementalBarrier(true, Zone::UpdateJit); zone->setNeedsIncrementalBarrier(true, Zone::UpdateJit);
zone->allocator.arenas.prepareForIncrementalGC(runtime); zone->arenas.prepareForIncrementalGC(runtime);
haveBarriers = true; haveBarriers = true;
} else { } else {
zone->setNeedsIncrementalBarrier(false, Zone::UpdateJit); zone->setNeedsIncrementalBarrier(false, Zone::UpdateJit);
@ -6581,7 +6572,7 @@ gc::MergeCompartments(JSCompartment *source, JSCompartment *target)
MOZ_ASSERT(c.get() == source); MOZ_ASSERT(c.get() == source);
// Merge the allocator in source's zone into target's zone. // 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); target->zone()->usage.adopt(source->zone()->usage);
// Merge other info in source's zone into target's zone. // Merge other info in source's zone into target's zone.

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

@ -75,10 +75,10 @@ class ArenaIter
init(zone, kind); init(zone, kind);
} }
void init(Allocator *allocator, AllocKind kind) { void init(JS::Zone *zone, AllocKind kind) {
aheader = allocator->arenas.getFirstArena(kind); aheader = zone->arenas.getFirstArena(kind);
unsweptHeader = allocator->arenas.getFirstArenaToSweep(kind); unsweptHeader = zone->arenas.getFirstArenaToSweep(kind);
sweptHeader = allocator->arenas.getFirstSweptArena(kind); sweptHeader = zone->arenas.getFirstSweptArena(kind);
if (!unsweptHeader) { if (!unsweptHeader) {
unsweptHeader = sweptHeader; unsweptHeader = sweptHeader;
sweptHeader = nullptr; sweptHeader = nullptr;
@ -90,10 +90,6 @@ class ArenaIter
} }
} }
void init(JS::Zone *zone, AllocKind kind) {
init(&zone->allocator, kind);
}
bool done() const { bool done() const {
return !aheader; return !aheader;
} }
@ -163,7 +159,7 @@ class ArenaCellIterImpl
void init(ArenaHeader *aheader) { void init(ArenaHeader *aheader) {
#ifdef DEBUG #ifdef DEBUG
AllocKind kind = aheader->getAllocKind(); AllocKind kind = aheader->getAllocKind();
MOZ_ASSERT(aheader->zone->allocator.arenas.isSynchronizedFreeList(kind)); MOZ_ASSERT(aheader->zone->arenas.isSynchronizedFreeList(kind));
#endif #endif
initUnsynchronized(aheader); initUnsynchronized(aheader);
} }
@ -231,7 +227,7 @@ class ZoneCellIterImpl
ZoneCellIterImpl() {} ZoneCellIterImpl() {}
void init(JS::Zone *zone, AllocKind kind) { void init(JS::Zone *zone, AllocKind kind) {
MOZ_ASSERT(zone->allocator.arenas.isSynchronizedFreeList(kind)); MOZ_ASSERT(zone->arenas.isSynchronizedFreeList(kind));
arenaIter.init(zone, kind); arenaIter.init(zone, kind);
if (!arenaIter.done()) if (!arenaIter.done())
cellIter.init(arenaIter.get()); cellIter.init(arenaIter.get());
@ -282,7 +278,7 @@ class ZoneCellIter : public ZoneCellIterImpl
public: public:
ZoneCellIter(JS::Zone *zone, AllocKind kind) ZoneCellIter(JS::Zone *zone, AllocKind kind)
: lists(&zone->allocator.arenas), : lists(&zone->arenas),
kind(kind) kind(kind)
{ {
JSRuntime *rt = zone->runtimeFromMainThread(); JSRuntime *rt = zone->runtimeFromMainThread();
@ -294,7 +290,7 @@ class ZoneCellIter : public ZoneCellIterImpl
* currently active. * currently active.
*/ */
if (IsBackgroundFinalized(kind) && if (IsBackgroundFinalized(kind) &&
zone->allocator.arenas.needBackgroundFinalizeWait(kind)) zone->arenas.needBackgroundFinalizeWait(kind))
{ {
rt->gc.waitBackgroundSweepEnd(); rt->gc.waitBackgroundSweepEnd();
} }
@ -515,8 +511,7 @@ AllocateObject(ExclusiveContext *cx, AllocKind kind, size_t nDynamicSlots, Initi
js::Debug_SetSlotRangeToCrashOnTouch(slots, nDynamicSlots); js::Debug_SetSlotRangeToCrashOnTouch(slots, nDynamicSlots);
} }
JSObject *obj = reinterpret_cast<JSObject *>( JSObject *obj = reinterpret_cast<JSObject *>(cx->arenas()->allocateFromFreeList(kind, thingSize));
cx->allocator()->arenas.allocateFromFreeList(kind, thingSize));
if (!obj) if (!obj)
obj = reinterpret_cast<JSObject *>(GCRuntime::refillFreeListFromAnyThread<allowGC>(cx, kind)); obj = reinterpret_cast<JSObject *>(GCRuntime::refillFreeListFromAnyThread<allowGC>(cx, kind));
@ -544,7 +539,7 @@ AllocateNonObject(ExclusiveContext *cx)
if (!CheckAllocatorState<allowGC>(cx, kind)) if (!CheckAllocatorState<allowGC>(cx, kind))
return nullptr; 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) if (!t)
t = static_cast<T *>(GCRuntime::refillFreeListFromAnyThread<allowGC>(cx, kind)); 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 ExclusiveContext;
class Allocator;
enum ThingRootKind enum ThingRootKind
{ {
THING_ROOT_OBJECT, THING_ROOT_OBJECT,