Bug 1075572 - Join the alloc task when finishing the GC. r=bhackett, a=sledru
authorTerrence Cole <terrence@mozilla.com>
Mon, 26 Jan 2015 13:29:00 -0800
changeset 243593 40c010f30f39
parent 243592 adbc58813581
child 243594 9ecb9e803a81
push id4406
push userryanvm@gmail.com
push date2015-01-29 21:23 +0000
treeherdermozilla-beta@cf270a9a66ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett, sledru
bugs1075572
milestone36.0
Bug 1075572 - Join the alloc task when finishing the GC. r=bhackett, a=sledru
js/src/jsgc.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1344,20 +1344,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) {
@@ -3056,20 +3058,21 @@ GCRuntime::refillFreeListFromMainThread(
         }
 
         AutoMaybeStartBackgroundAllocation maybeStartBGAlloc;
         void *thing = allocator->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.
-        cx->runtime()->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.
+        cx->runtime()->gc.waitBackgroundSweepOrAllocEnd();
 
         thing = allocator->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);