Bug 1075572 - Join the alloc task when finishing the GC; r=bhackett
authorTerrence Cole <terrence@mozilla.com>
Mon, 26 Jan 2015 13:29:00 -0800
changeset 226366 9076fc40dad403b5d6203749af9404ac2bff6899
parent 226293 13dd7bfcb9b1864327c8b5c2b69c739ef92befa0
child 226367 6bda775985ab60184bba66966bffd177e9810b08
push id28194
push userkwierso@gmail.com
push dateThu, 29 Jan 2015 02:10:42 +0000
treeherdermozilla-central@ea54e6623f59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1075572
milestone38.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 1075572 - Join the alloc task when finishing the GC; r=bhackett
js/src/jsgc.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1282,20 +1282,22 @@ GCRuntime::init(uint32_t maxbytes, uint3
 
     return true;
 }
 
 void
 GCRuntime::finish()
 {
     /*
-     * Wait until the background finalization stops and the helper thread
-     * shuts down before we forcefully release any remaining GC memory.
+     * Wait until the background finalization and allocation stops and the
+     * helper thread shuts down before we forcefully release any remaining GC
+     * memory.
      */
     helperState.finish();
+    allocTask.cancel(GCParallelTask::CancelAndWait);
 
 #ifdef JS_GC_ZEAL
     /* Free memory associated with GC verification. */
     finishVerifier();
 #endif
 
     /* Delete all remaining zones. */
     if (rt->gcInitialized) {
@@ -2952,20 +2954,21 @@ GCRuntime::refillFreeListFromMainThread(
         }
 
         AutoMaybeStartBackgroundAllocation maybeStartBGAlloc;
         void *thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
         if (MOZ_LIKELY(thing))
             return thing;
 
         // Even if allocateFromArena failed due to OOM, a background
-        // finalization task may be running (freeing more memory); wait for it
-        // to finish, then try to allocate again in case it freed up the memory
-        // we need.
-        rt->gc.waitBackgroundSweepEnd();
+        // finalization or allocation task may be running freeing more memory
+        // or adding more available memory to our free pool; wait for them to
+        // finish, then try to allocate again in case they made more memory
+        // available.
+        rt->gc.waitBackgroundSweepOrAllocEnd();
 
         thing = arenas->allocateFromArena(zone, thingKind, maybeStartBGAlloc);
         if (MOZ_LIKELY(thing))
             return thing;
 
         // Retry after a last-ditch GC, unless we've already tried that.
         outOfMemory = true;
     } while (!ranGC);