Bug 650161 - Assert we compacted as much as we could r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 17 Dec 2014 18:04:01 +0000
changeset 220214 d5492cfe712787e17912a9d5ce69b59339e35270
parent 220213 e6351a5baa95ae87d09bf96a461a870167bd3000
child 220215 9b6c6da118929429c05830655bdc5c4b0ddcbbaf
push id10457
push userryanvm@gmail.com
push dateThu, 18 Dec 2014 01:54:25 +0000
treeherderfx-team@0e441ff66c5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs650161
milestone37.0a1
Bug 650161 - Assert we compacted as much as we could r=terrence
js/src/jsgc.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -5589,18 +5589,33 @@ GCRuntime::compactPhase(bool lastGC)
         relocatedArenasToRelease = relocatedList;
     else
         releaseRelocatedArenas(relocatedList);
 #endif
 
 #ifdef DEBUG
     CheckHashTablesAfterMovingGC(rt);
     for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
-        if (CanRelocateZone(rt, zone) && !zone->isPreservingCode())
+        if (CanRelocateZone(rt, zone)) {
+            MOZ_ASSERT(!zone->isPreservingCode());
             zone->allocator.arenas.checkEmptyFreeLists();
+
+            // Check that we did as much compaction as we should have. There
+            // should always be less than one arena's worth of free cells.
+            for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
+                size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(AllocKind(i)));
+                if (CanRelocateAllocKind(AllocKind(i))) {
+                    ArenaList &al = zone->allocator.arenas.arenaLists[i];
+                    size_t freeCells = 0;
+                    for (ArenaHeader *arena = al.arenaAfterCursor(); arena; arena = arena->next)
+                        freeCells += arena->countFreeCells();
+                    MOZ_ASSERT(freeCells < thingsPerArena);
+                }
+            }
+        }
     }
 #endif
 
 #endif // JSGC_COMPACTING
     return true;
 }
 
 void