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
Родитель 868306e7f4
Коммит 4113634f8c
4 изменённых файлов: 29 добавлений и 15 удалений

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

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

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

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

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

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

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

@ -208,12 +208,15 @@ JS::ShrinkingGC(JSRuntime *rt, gcreason::Reason reason)
} }
JS_FRIEND_API(void) 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);
rt->gc.startGC(GC_NORMAL, reason, millis); }
else
rt->gc.gcSlice(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) JS_FRIEND_API(void)