Bug 751396 - Fire slice callbacks only for "outer" GCs. r=billm

--HG--
extra : rebase_source : d30a5157d0f87bbc691ddf1cd0598974d0e509fc
This commit is contained in:
Steve Fink 2012-05-03 12:32:37 -07:00
parent 3f838cafde
commit 5833257244
4 changed files with 18 additions and 16 deletions

View File

@ -3358,7 +3358,6 @@ jsdService::~jsdService()
mThrowHook = nsnull;
mTopLevelHook = nsnull;
mFunctionHook = nsnull;
gGCRunning = false;
Off();
gJsds = nsnull;
}

View File

@ -406,6 +406,7 @@ Statistics::Statistics(JSRuntime *rt)
startupTime(PRMJ_Now()),
fp(NULL),
fullFormat(false),
gcDepth(0),
collectedCount(0),
compartmentCount(0),
nonincrementalReason(NULL)
@ -532,9 +533,12 @@ Statistics::beginSlice(int collectedCount, int compartmentCount, gcreason::Reaso
if (JSAccumulateTelemetryDataCallback cb = runtime->telemetryCallback)
(*cb)(JS_TELEMETRY_GC_REASON, reason);
bool wasFullGC = collectedCount == compartmentCount;
if (GCSliceCallback cb = runtime->gcSliceCallback)
(*cb)(runtime, first ? GC_CYCLE_BEGIN : GC_SLICE_BEGIN, GCDescription(!wasFullGC));
// Slice callbacks should only fire for the outermost level
if (++gcDepth == 1) {
bool wasFullGC = collectedCount == compartmentCount;
if (GCSliceCallback cb = runtime->gcSliceCallback)
(*cb)(runtime, first ? GC_CYCLE_BEGIN : GC_SLICE_BEGIN, GCDescription(!wasFullGC));
}
}
void
@ -551,12 +555,11 @@ Statistics::endSlice()
if (last)
endGC();
bool wasFullGC = collectedCount == compartmentCount;
if (GCSliceCallback cb = runtime->gcSliceCallback) {
if (last)
(*cb)(runtime, GC_CYCLE_END, GCDescription(!wasFullGC));
else
(*cb)(runtime, GC_SLICE_END, GCDescription(!wasFullGC));
// Slice callbacks should only fire for the outermost level
if (--gcDepth == 0) {
bool wasFullGC = collectedCount == compartmentCount;
if (GCSliceCallback cb = runtime->gcSliceCallback)
(*cb)(runtime, last ? GC_CYCLE_END : GC_SLICE_END, GCDescription(!wasFullGC));
}
/* Do this after the slice callback since it uses these values. */

View File

@ -116,6 +116,12 @@ struct Statistics {
FILE *fp;
bool fullFormat;
/*
* GCs can't really nest, but a second GC can be triggered from within the
* JSGC_END callback.
*/
int gcDepth;
int collectedCount;
int compartmentCount;
const char *nonincrementalReason;

View File

@ -594,12 +594,6 @@ struct JSRuntime : js::RuntimeFriendFields
js::Vector<SavedGCRoot, 0, js::SystemAllocPolicy> gcSavedRoots;
#endif
/*
* We can pack these flags as only the GC thread writes to them. Atomic
* updates to packed bytes are not guaranteed, so stores issued by one
* thread may be lost due to unsynchronized read-modify-write cycles on
* other threads.
*/
bool gcPoke;
bool gcRunning;