Bug 1099152 - Separate out external APIs to start and continute an incremental GC r=terrence r=mccr8

This commit is contained in:
Jon Coppeard 2015-01-02 17:19:43 +00:00
parent ae4c53dcda
commit 0bd9ea358c
4 changed files with 29 additions and 15 deletions

View File

@ -1459,7 +1459,7 @@ nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
if (sCCLockedOut && aIncremental == IncrementalGC) {
// We're in the middle of incremental GC. Do another slice.
JS::PrepareForIncrementalGC(sRuntime);
JS::IncrementalGC(sRuntime, aReason, aSliceMillis);
JS::IncrementalGCSlice(sRuntime, aReason, aSliceMillis);
return;
}
@ -1472,7 +1472,7 @@ nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
if (aIncremental == IncrementalGC) {
MOZ_ASSERT(aShrinking == NonShrinkingGC);
JS::IncrementalGC(sRuntime, aReason, aSliceMillis);
JS::StartIncrementalGC(sRuntime, aReason, aSliceMillis);
} else if (aShrinking == ShrinkingGC) {
JS::ShrinkingGC(sRuntime, aReason);
} else {

View File

@ -207,16 +207,27 @@ ShrinkingGC(JSRuntime *rt, gcreason::Reason reason);
*/
/*
* Begin an incremental collection and perform one slice worth of work or
* perform a slice of an ongoing incremental collection. When this function
* returns, the collection is not complete. This function must be called
* repeatedly until !IsIncrementalGCInProgress(rt).
* Begin an incremental collection and perform one slice worth of work. When
* this function returns, the collection may not be complete.
* IncrementalGCSlice() must be called repeatedly until
* !IsIncrementalGCInProgress(rt).
*
* Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
* shorter than the requested interval.
*/
extern JS_FRIEND_API(void)
IncrementalGC(JSRuntime *rt, gcreason::Reason reason, int64_t millis = 0);
StartIncrementalGC(JSRuntime *rt, gcreason::Reason reason, int64_t millis = 0);
/*
* Perform a slice of an ongoing incremental collection. When this function
* returns, the collection may not be complete. It must be called repeatedly
* until !IsIncrementalGCInProgress(rt).
*
* Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
* shorter than the requested interval.
*/
extern JS_FRIEND_API(void)
IncrementalGCSlice(JSRuntime *rt, gcreason::Reason reason, int64_t millis = 0);
/*
* If IsIncrementalGCInProgress(rt), this call finishes the ongoing collection

View File

@ -24,7 +24,7 @@ BEGIN_TEST(testGCFinalizeCallback)
/* Full GC, incremental. */
FinalizeCalls = 0;
JS::PrepareForFullGC(rt);
JS::IncrementalGC(rt, JS::gcreason::API, 1000000);
JS::StartIncrementalGC(rt, JS::gcreason::API, 1000000);
CHECK(!rt->gc.isIncrementalGCInProgress());
CHECK(rt->gc.isFullGc());
CHECK(checkMultipleGroups());
@ -61,7 +61,7 @@ BEGIN_TEST(testGCFinalizeCallback)
/* Compartment GC, incremental, single compartment. */
FinalizeCalls = 0;
JS::PrepareZoneForGC(global1->zone());
JS::IncrementalGC(rt, JS::gcreason::API, 1000000);
JS::StartIncrementalGC(rt, JS::gcreason::API, 1000000);
CHECK(!rt->gc.isIncrementalGCInProgress());
CHECK(!rt->gc.isFullGc());
CHECK(checkSingleGroup());
@ -73,7 +73,7 @@ BEGIN_TEST(testGCFinalizeCallback)
JS::PrepareZoneForGC(global1->zone());
JS::PrepareZoneForGC(global2->zone());
JS::PrepareZoneForGC(global3->zone());
JS::IncrementalGC(rt, JS::gcreason::API, 1000000);
JS::StartIncrementalGC(rt, JS::gcreason::API, 1000000);
CHECK(!rt->gc.isIncrementalGCInProgress());
CHECK(!rt->gc.isFullGc());
CHECK(checkMultipleGroups());

View File

@ -208,12 +208,15 @@ JS::ShrinkingGC(JSRuntime *rt, gcreason::Reason reason)
}
JS_FRIEND_API(void)
JS::IncrementalGC(JSRuntime *rt, gcreason::Reason reason, int64_t millis)
JS::StartIncrementalGC(JSRuntime *rt, gcreason::Reason reason, int64_t millis)
{
if (!rt->gc.isIncrementalGCInProgress())
rt->gc.startGC(GC_NORMAL, reason, millis);
else
rt->gc.gcSlice(reason, millis);
rt->gc.startGC(GC_NORMAL, reason, millis);
}
JS_FRIEND_API(void)
JS::IncrementalGCSlice(JSRuntime *rt, gcreason::Reason reason, int64_t millis)
{
rt->gc.gcSlice(reason, millis);
}
JS_FRIEND_API(void)