Bug 1099152 - Separate out external APIs to start and continute an incremental GC r=terrence r=mccr8
☠☠ backed out by 2a7cd513b565 ☠ ☠
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 02 Jan 2015 17:19:43 +0000
changeset 247722 969965f4c893fa3afa33521f1bbdb3f57e6aa080
parent 247721 1e4e3b85c620896a9022d19886f0a69e50abaa66
child 247723 e5a903979b5fcc8b7d7b4406fcaea2889edfa01f
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence, mccr8
bugs1099152
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1099152 - Separate out external APIs to start and continute an incremental GC r=terrence r=mccr8
dom/base/nsJSEnvironment.cpp
js/public/GCAPI.h
js/src/jsapi-tests/testGCFinalizeCallback.cpp
js/src/jsfriendapi.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1454,30 +1454,30 @@ nsJSContext::GarbageCollectNow(JS::gcrea
 
   if (!nsContentUtils::XPConnect() || !sRuntime) {
     return;
   }
 
   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;
   }
 
   if (sNeedsFullGC || aReason != JS::gcreason::CC_WAITING) {
     sNeedsFullGC = false;
     JS::PrepareForFullGC(sRuntime);
   } else {
     CycleCollectedJSRuntime::Get()->PrepareWaitingZonesForGC();
   }
 
   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 {
     JS::GCForReason(sRuntime, aReason);
   }
 }
 
 //static
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -202,26 +202,37 @@ ShrinkingGC(JSRuntime *rt, gcreason::Rea
  *    implement read and write barriers with the JSCLASS_IMPLEMENTS_BARRIERS
  *    flag.
  *
  * Note: Even if incremental GC is enabled and working correctly,
  *       non-incremental collections can still happen when low on memory.
  */
 
 /*
- * 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
  * by performing an arbitrarily long slice. If !IsIncrementalGCInProgress(rt),
  * this is equivalent to GCForReason. When this function returns,
  * IsIncrementalGCInProgress(rt) will always be false.
  */
 extern JS_FRIEND_API(void)
--- a/js/src/jsapi-tests/testGCFinalizeCallback.cpp
+++ b/js/src/jsapi-tests/testGCFinalizeCallback.cpp
@@ -19,17 +19,17 @@ BEGIN_TEST(testGCFinalizeCallback)
     CHECK(rt->gc.isFullGc());
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(false));
 
     /* 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());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(false));
 
     JS::RootedObject global1(cx, createTestGlobal());
     JS::RootedObject global2(cx, createTestGlobal());
@@ -56,29 +56,29 @@ BEGIN_TEST(testGCFinalizeCallback)
     CHECK(!rt->gc.isFullGc());
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
     /* 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());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
     /* Compartment GC, incremental, multiple compartments. */
     FinalizeCalls = 0;
     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());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
 #ifdef JS_GC_ZEAL
 
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -203,22 +203,25 @@ JS::GCForReason(JSRuntime *rt, gcreason:
 
 JS_FRIEND_API(void)
 JS::ShrinkingGC(JSRuntime *rt, gcreason::Reason reason)
 {
     rt->gc.gc(GC_SHRINK, 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)
 JS::FinishIncrementalGC(JSRuntime *rt, gcreason::Reason reason)
 {
     rt->gc.finishGC(reason);
 }