Bug 887030 - Allow inlining of heapState checks from outside JSAPI; r=jonco

This commit is contained in:
Terrence Cole
2015-06-02 11:47:08 -07:00
parent bba77f436f
commit 0b34f01cdc
11 changed files with 53 additions and 54 deletions

View File

@@ -1068,7 +1068,7 @@ GCRuntime::allocateArena(Chunk* chunk, Zone* zone, AllocKind thingKind, const Au
MOZ_ASSERT(chunk->hasAvailableArenas());
// Fail the allocation if we are over our heap size limits.
if (!isHeapMinorCollecting() &&
if (!rt->isHeapMinorCollecting() &&
!isHeapCompacting() &&
usage.gcBytes() >= tunables.gcMaxBytes())
{
@@ -1079,7 +1079,7 @@ GCRuntime::allocateArena(Chunk* chunk, Zone* zone, AllocKind thingKind, const Au
zone->usage.addGCArena();
// Trigger an incremental slice if needed.
if (!isHeapMinorCollecting() && !isHeapCompacting())
if (!rt->isHeapMinorCollecting() && !isHeapCompacting())
maybeAllocTriggerZoneGC(zone, lock);
return aheader;
@@ -1152,7 +1152,6 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
manipulatingDeadZones(false),
objectsMarkedInDeadZones(0),
poked(false),
heapState(Idle),
#ifdef JS_GC_ZEAL
zealMode(0),
zealFrequency(0),
@@ -1530,7 +1529,7 @@ GCRuntime::getParameter(JSGCParamKey key, const AutoLockGC& lock)
void
GCRuntime::setMarkStackLimit(size_t limit)
{
MOZ_ASSERT(!isHeapBusy());
MOZ_ASSERT(!rt->isHeapBusy());
AutoStopVerifyingBarriers pauseVerification(rt, false);
marker.setMaxCapacity(limit);
}
@@ -2127,7 +2126,7 @@ ArenaLists::relocateArenas(ArenaHeader*& relocatedListOut, JS::gcreason::Reason
// This is only called from the main thread while we are doing a GC, so
// there is no need to lock.
MOZ_ASSERT(CurrentThreadCanAccessRuntime(runtime_));
MOZ_ASSERT(runtime_->isHeapCompacting());
MOZ_ASSERT(runtime_->gc.isHeapCompacting());
MOZ_ASSERT(!runtime_->gc.isBackgroundSweeping());
// Flush all the freeLists back into the arena headers
@@ -3450,7 +3449,7 @@ GCRuntime::queueZonesForBackgroundSweep(ZoneList& zones)
void
GCRuntime::freeUnusedLifoBlocksAfterSweeping(LifoAlloc* lifo)
{
MOZ_ASSERT(isHeapBusy());
MOZ_ASSERT(rt->isHeapBusy());
AutoLockGC lock(rt);
freeLifoAlloc.transferUnusedFrom(lifo);
}
@@ -3458,7 +3457,7 @@ GCRuntime::freeUnusedLifoBlocksAfterSweeping(LifoAlloc* lifo)
void
GCRuntime::freeAllLifoBlocksAfterSweeping(LifoAlloc* lifo)
{
MOZ_ASSERT(isHeapBusy());
MOZ_ASSERT(rt->isHeapBusy());
AutoLockGC lock(rt);
freeLifoAlloc.transferFrom(lifo);
}
@@ -5519,15 +5518,15 @@ GCRuntime::finishCollection(JS::gcreason::Reason reason)
}
/* Start a new heap session. */
AutoTraceSession::AutoTraceSession(JSRuntime* rt, js::HeapState heapState)
AutoTraceSession::AutoTraceSession(JSRuntime* rt, JS::HeapState heapState)
: lock(rt),
runtime(rt),
prevState(rt->gc.heapState)
prevState(rt->heapState_)
{
MOZ_ASSERT(rt->gc.isAllocAllowed());
MOZ_ASSERT(rt->gc.heapState == Idle);
MOZ_ASSERT(heapState != Idle);
MOZ_ASSERT_IF(heapState == MajorCollecting, rt->gc.nursery.isEmpty());
MOZ_ASSERT(rt->heapState_ == JS::HeapState::Idle);
MOZ_ASSERT(heapState != JS::HeapState::Idle);
MOZ_ASSERT_IF(heapState == JS::HeapState::MajorCollecting, rt->gc.nursery.isEmpty());
// Threads with an exclusive context can hit refillFreeList while holding
// the exclusive access lock. To avoid deadlocking when we try to acquire
@@ -5539,9 +5538,9 @@ AutoTraceSession::AutoTraceSession(JSRuntime* rt, js::HeapState heapState)
// Lock the helper thread state when changing the heap state in the
// presence of exclusive threads, to avoid racing with refillFreeList.
AutoLockHelperThreadState lock;
rt->gc.heapState = heapState;
rt->heapState_ = heapState;
} else {
rt->gc.heapState = heapState;
rt->heapState_ = heapState;
}
}
@@ -5551,12 +5550,12 @@ AutoTraceSession::~AutoTraceSession()
if (runtime->exclusiveThreadsPresent()) {
AutoLockHelperThreadState lock;
runtime->gc.heapState = prevState;
runtime->heapState_ = prevState;
// Notify any helper threads waiting for the trace session to end.
HelperThreadState().notifyAll(GlobalHelperThreadState::PRODUCER);
} else {
runtime->gc.heapState = prevState;
runtime->heapState_ = prevState;
}
}
@@ -6005,7 +6004,7 @@ GCRuntime::gcCycle(bool incremental, SliceBudget& budget, JS::gcreason::Reason r
*/
AutoDisableStoreBuffer adsb(this);
AutoTraceSession session(rt, MajorCollecting);
AutoTraceSession session(rt, JS::HeapState::MajorCollecting);
majorGCTriggerReason = JS::gcreason::NO_REASON;
interFrameGC = true;
@@ -6273,7 +6272,7 @@ GCRuntime::abortGC()
evictNursery(JS::gcreason::ABORT_GC);
AutoDisableStoreBuffer adsb(this);
AutoTraceSession session(rt, MajorCollecting);
AutoTraceSession session(rt, JS::HeapState::MajorCollecting);
number++;
resetIncrementalGC("abort");
@@ -6660,14 +6659,14 @@ GCRuntime::runDebugGC()
void
GCRuntime::setValidate(bool enabled)
{
MOZ_ASSERT(!isHeapMajorCollecting());
MOZ_ASSERT(!rt->isHeapMajorCollecting());
validate = enabled;
}
void
GCRuntime::setFullCompartmentChecks(bool enabled)
{
MOZ_ASSERT(!isHeapMajorCollecting());
MOZ_ASSERT(!rt->isHeapMajorCollecting());
fullCompartmentChecks = enabled;
}
@@ -6675,7 +6674,7 @@ GCRuntime::setFullCompartmentChecks(bool enabled)
bool
GCRuntime::selectForMarking(JSObject* object)
{
MOZ_ASSERT(!isHeapMajorCollecting());
MOZ_ASSERT(!rt->isHeapMajorCollecting());
return selectedForMarking.append(object);
}
@@ -6688,7 +6687,7 @@ GCRuntime::clearSelectedForMarking()
void
GCRuntime::setDeterministic(bool enabled)
{
MOZ_ASSERT(!isHeapMajorCollecting());
MOZ_ASSERT(!rt->isHeapMajorCollecting());
deterministicOnly = enabled;
}
#endif