Bug 1309615 - Don't skip shrinking the nursery when it's not being used r=sfink
☠☠ backed out by 3d23af9b2710 ☠ ☠
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 13 Oct 2016 11:11:41 +0100
changeset 317860 4e4969c65834d0a4ec5f3b9c01fc01b6f2d6dc8e
parent 317859 3e30051824704f61374030a645c5be6219d2e201
child 317861 2c20fcfa07f7c66c075ada0e9554749c1f3dfd3e
push id33170
push usercbook@mozilla.com
push dateFri, 14 Oct 2016 10:37:07 +0000
treeherderautoland@0d101ebfd95c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1309615
milestone52.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 1309615 - Don't skip shrinking the nursery when it's not being used r=sfink
js/src/gc/Nursery.cpp
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -543,25 +543,25 @@ js::Nursery::maybeEndProfile(ProfileKey 
 
 void
 js::Nursery::collect(JSRuntime* rt, JS::gcreason::Reason reason)
 {
     MOZ_ASSERT(!rt->mainThread.suppressGC);
     MOZ_RELEASE_ASSERT(CurrentThreadCanAccessRuntime(rt));
 
     if (!isEnabled() || isEmpty()) {
-        /*
-         * Our barriers are not always exact, and there may be entries in the
-         * storebuffer even when the nursery is disabled or empty. It's not
-         * safe to keep these entries as they may refer to tenured cells which
-         * may be freed after this point.
-         */
+        // Our barriers are not always exact, and there may be entries in the
+        // storebuffer even when the nursery is disabled or empty. It's not safe
+        // to keep these entries as they may refer to tenured cells which may be
+        // freed after this point.
         rt->gc.storeBuffer.clear();
+    }
+
+    if (!isEnabled())
         return;
-    }
 
     rt->gc.incMinorGcNumber();
 
 #ifdef JS_GC_ZEAL
     if (rt->gc.hasZealMode(ZealMode::CheckNursery)) {
         for (auto canary = lastCanary_; canary; canary = canary->next)
             MOZ_ASSERT(canary->magicValue == CanaryMagicValue);
     }
@@ -573,17 +573,24 @@ js::Nursery::collect(JSRuntime* rt, JS::
 
     startProfile(ProfileKey::Total);
 
     // The hazard analysis thinks doCollection can invalidate pointers in
     // tenureCounts below.
     JS::AutoSuppressGCAnalysis nogc;
 
     TenureCountCache tenureCounts;
-    double promotionRate = doCollection(rt, reason, tenureCounts);
+    double promotionRate = 0;
+    if (!isEmpty())
+        promotionRate = doCollection(rt, reason, tenureCounts);
+
+    // Resize the nursery.
+    maybeStartProfile(ProfileKey::Resize);
+    maybeResizeNursery(reason, promotionRate);
+    maybeEndProfile(ProfileKey::Resize);
 
     // If we are promoting the nursery, or exhausted the store buffer with
     // pointers to nursery things, which will force a collection well before
     // the nursery is full, look for object groups that are getting promoted
     // excessively and try to pretenure them.
     maybeStartProfile(ProfileKey::Pretenure);
     uint32_t pretenureCount = 0;
     if (promotionRate > 0.8 || reason == JS::gcreason::FULL_STORE_BUFFER) {
@@ -744,23 +751,18 @@ js::Nursery::doCollection(JSRuntime* rt,
     // Make sure hashtables have been updated after the collection.
     maybeStartProfile(ProfileKey::CheckHashTables);
 #ifdef JS_GC_ZEAL
     if (rt->hasZealMode(ZealMode::CheckHashTablesOnMinorGC))
         CheckHashTablesAfterMovingGC(rt);
 #endif
     maybeEndProfile(ProfileKey::CheckHashTables);
 
-    // Resize the nursery.
-    maybeStartProfile(ProfileKey::Resize);
-    double promotionRate = mover.tenuredSize / double(initialNurserySize);
-    maybeResizeNursery(reason, promotionRate);
-    maybeEndProfile(ProfileKey::Resize);
-
-    return promotionRate;
+    // Calculate and return the promotion rate.
+    return mover.tenuredSize / double(initialNurserySize);
 }
 
 void
 js::Nursery::FreeMallocedBuffersTask::transferBuffersToFree(MallocedBuffersSet& buffersToFree,
                                                             const AutoLockHelperThreadState& lock)
 {
     // Transfer the contents of the source set to the task's buffers_ member by
     // swapping the sets, which also clears the source.