Bug 1166041 - Wait for nursery sweeping to finish before shutting down; r=jonco
☠☠ backed out by cb821c634326 ☠ ☠
authorTerrence Cole <terrence@mozilla.com>
Wed, 29 Jul 2015 08:57:14 -0700
changeset 281640 6eebf397a8c29941862a164d3c3209707ae1faec
parent 281639 a5c748f78e97f11a3354ce7142bad4a11c02fafc
child 281641 06156197d11dfc69f56f4b4ad370017ff2cf2701
push id3894
push usermconley@mozilla.com
push dateThu, 30 Jul 2015 00:27:47 +0000
reviewersjonco
bugs1166041
milestone42.0a1
Bug 1166041 - Wait for nursery sweeping to finish before shutting down; r=jonco
js/src/gc/Nursery.cpp
js/src/jsgc.cpp
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -633,16 +633,17 @@ js::Nursery::freeMallocedBuffers()
         freeMallocedBuffersTask->runFromMainThread(runtime());
 
     MOZ_ASSERT(mallocedBuffers.empty());
 }
 
 void
 js::Nursery::waitBackgroundFreeEnd()
 {
+    MOZ_ASSERT(freeMallocedBuffersTask);
     freeMallocedBuffersTask->join();
 }
 
 void
 js::Nursery::sweep()
 {
 #ifdef JS_GC_ZEAL
     /* Poison the nursery contents so touching a freed object will crash. */
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1313,16 +1313,20 @@ GCRuntime::init(uint32_t maxbytes, uint3
         return false;
 
     return true;
 }
 
 void
 GCRuntime::finish()
 {
+    /* Wait for the nursery sweeping to end. */
+    if (rt->gc.nursery.isEnabled())
+        rt->gc.nursery.waitBackgroundFreeEnd();
+
     /*
      * 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);