Bug 1192304 - Common up the checks when entering GC API; r=jonco

--HG--
extra : rebase_source : 54b0d9cd8add99515ac48369cf6d74ea6dbf36a2
This commit is contained in:
Terrence Cole 2015-08-10 14:14:09 -07:00
Родитель 938df396a8
Коммит d86a2b0456
2 изменённых файлов: 36 добавлений и 13 удалений

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

@ -887,12 +887,22 @@ class GCRuntime
void requestMajorGC(JS::gcreason::Reason reason);
SliceBudget defaultBudget(JS::gcreason::Reason reason, int64_t millis);
void collect(bool incremental, SliceBudget budget, JS::gcreason::Reason reason);
bool gcCycle(bool incremental, SliceBudget& budget, JS::gcreason::Reason reason);
gcstats::ZoneGCStats scanZonesBeforeGC();
void budgetIncrementalGC(SliceBudget& budget);
void resetIncrementalGC(const char* reason);
// Assert if the system state is such that we should never
// receive a request to do GC work.
void checkCanCallAPI();
// Check if the system state is such that GC has been supressed
// or otherwise delayed.
bool checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason);
gcstats::ZoneGCStats scanZonesBeforeGC();
void collect(bool incremental, SliceBudget budget, JS::gcreason::Reason reason);
bool gcCycle(bool incremental, SliceBudget& budget, JS::gcreason::Reason reason);
void incrementalCollectSlice(SliceBudget& budget, JS::gcreason::Reason reason);
void pushZealSelectedObjects();
void purgeRuntime();
bool beginMarkPhase(JS::gcreason::Reason reason);

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

@ -6133,7 +6133,7 @@ GCRuntime::scanZonesBeforeGC()
}
void
GCRuntime::collect(bool incremental, SliceBudget budget, JS::gcreason::Reason reason)
GCRuntime::checkCanCallAPI()
{
JS_AbortIfWrongThread(rt);
@ -6144,18 +6144,34 @@ GCRuntime::collect(bool incremental, SliceBudget budget, JS::gcreason::Reason re
MOZ_ASSERT(!rt->currentThreadHasExclusiveAccess());
MOZ_ASSERT(isAllocAllowed());
}
bool
GCRuntime::checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason)
{
if (rt->mainThread.suppressGC)
return;
TraceLoggerThread* logger = TraceLoggerForMainThread(rt);
AutoTraceLog logGC(logger, TraceLogger_GC);
return false;
#ifdef JS_GC_ZEAL
if (deterministicOnly && !IsDeterministicGCReason(reason))
return;
return false;
#endif
return true;
}
void
GCRuntime::collect(bool incremental, SliceBudget budget, JS::gcreason::Reason reason)
{
// Checks run for each request, even if we do not actually GC.
checkCanCallAPI();
// Check if we are allowed to GC at this time before proceeding.
if (!checkIfGCAllowedInCurrentState(reason))
return;
AutoTraceLog logGC(TraceLoggerForMainThread(rt), TraceLogger_GC);
AutoStopVerifyingBarriers av(rt, reason == JS::gcreason::SHUTDOWN_CC ||
reason == JS::gcreason::DESTROY_RUNTIME);
@ -6276,10 +6292,7 @@ GCRuntime::finishGC(JS::gcreason::Reason reason)
void
GCRuntime::abortGC()
{
JS_AbortIfWrongThread(rt);
MOZ_RELEASE_ASSERT(!rt->isHeapBusy());
MOZ_ASSERT(!rt->currentThreadHasExclusiveAccess());
checkCanCallAPI();
MOZ_ASSERT(!rt->mainThread.suppressGC);
AutoStopVerifyingBarriers av(rt, false);