Bug 1263572 - Wait for background sweeping to finish before checking base shapes r=terrence a=ritu
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 25 Apr 2016 13:41:25 +0100
changeset 332665 8ba304b4b4c6460871a0fa7a703023c1b1618dba
parent 332664 43fd203f3c5ff3b73971eb08c2fda54141e350a0
child 332666 5eab0f59fd9e36b5875ab97cfce10e32f1a96e35
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence, ritu
bugs1263572
milestone48.0a2
Bug 1263572 - Wait for background sweeping to finish before checking base shapes r=terrence a=ritu
js/src/jsgcinlines.h
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -188,18 +188,26 @@ class ArenaCellIterUnderFinalize : publi
 
 class ZoneCellIterImpl
 {
     ArenaIter arenaIter;
     ArenaCellIterImpl cellIter;
 
   public:
     ZoneCellIterImpl(JS::Zone* zone, AllocKind kind) {
+        JSRuntime* rt = zone->runtimeFromAnyThread();
         MOZ_ASSERT(zone);
-        MOZ_ASSERT(zone->runtimeFromAnyThread()->gc.nursery.isEmpty());
+        MOZ_ASSERT(rt->gc.nursery.isEmpty());
+
+        // We have a single-threaded runtime, so there's no need to protect
+        // against other threads iterating or allocating. However, we do have
+        // background finalization; we may have to wait for this to finish if
+        // it's currently active.
+        if (IsBackgroundFinalized(kind) && zone->arenas.needBackgroundFinalizeWait(kind))
+            rt->gc.waitBackgroundSweepEnd();
 
         arenaIter.init(zone, kind);
         if (!arenaIter.done())
             cellIter.init(arenaIter.get());
     }
 
     bool done() const {
         return arenaIter.done();
@@ -243,23 +251,16 @@ class ZoneCellIter
     JS::AutoAssertNoAlloc noAlloc;
 
   public:
     ZoneCellIter(JS::Zone* zone, AllocKind kind) {
         // If called from outside a GC, ensure that the heap is in a state
         // that allows us to iterate.
         JSRuntime* rt = zone->runtimeFromMainThread();
         if (!rt->isHeapBusy()) {
-            // We have a single-threaded runtime, so there's no need to protect
-            // against other threads iterating or allocating. However, we do
-            // have background finalization; we have to wait for this to finish
-            // if it's currently active.
-            if (IsBackgroundFinalized(kind) && zone->arenas.needBackgroundFinalizeWait(kind))
-                rt->gc.waitBackgroundSweepEnd();
-
             // Evict the nursery before iterating so we can see all things.
             rt->gc.evictNursery();
 
             // Assert that no GCs can occur while a ZoneCellIter is live.
             noAlloc.disallowAlloc(rt);
         }
 
         impl.emplace(zone, kind);