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

This commit is contained in:
Steve Fink
2012-05-03 12:32:37 -07:00
parent 8da7619c49
commit 586d117fc9
4 changed files with 18 additions and 16 deletions

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. */