Bug 1188836 - Fix compacting GC zone selection by passing total arena count to ShouldRelocateZone() r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 30 Jul 2015 11:04:12 +0100
changeset 287111 92e183e5175e8c674ebe0a1e4d22cd41c993cb10
parent 287110 60b5a53aeb8f5f3bf65bb21f89f6f799980f6520
child 287112 031cc887765e9abbdc18add60c164cff685efdab
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1188836
milestone42.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 1188836 - Fix compacting GC zone selection by passing total arena count to ShouldRelocateZone() r=terrence
js/src/jsgc.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1940,25 +1940,29 @@ ArenaList::pickArenasToRelocate(size_t& 
     // tail of the arena list. All we need to do is find the point at which to
     // start relocating.
 
     check();
 
     if (isCursorAtEnd())
         return nullptr;
 
-    ArenaHeader** arenap = cursorp_;               // Next arena to consider
-    size_t previousFreeCells = 0;                  // Count of free cells before
-    size_t followingUsedCells = 0;                 // Count of used cells after arenap.
-    size_t arenaCount = 0;                         // Total number of arenas.
-    size_t arenaIndex = 0;                         // Index of the next arena to consider.
+    ArenaHeader** arenap = cursorp_;  // Next arena to consider for relocation.
+    size_t previousFreeCells = 0;     // Count of free cells before arenap.
+    size_t followingUsedCells = 0;    // Count of used cells after arenap.
+    size_t fullArenaCount = 0;        // Number of full arenas (not relocated).
+    size_t nonFullArenaCount = 0;     // Number of non-full arenas (considered for relocation).
+    size_t arenaIndex = 0;            // Index of the next arena to consider.
+
+    for (ArenaHeader* arena = head_; arena != *cursorp_; arena = arena->next)
+        fullArenaCount++;
 
     for (ArenaHeader* arena = *cursorp_; arena; arena = arena->next) {
         followingUsedCells += arena->countUsedCells();
-        arenaCount++;
+        nonFullArenaCount++;
     }
 
     mozilla::DebugOnly<size_t> lastFreeCells(0);
     size_t cellsPerArena = Arena::thingsPerArena((*arenap)->getThingSize());
 
     while (*arenap) {
         ArenaHeader* arena = *arenap;
         if (followingUsedCells <= previousFreeCells)
@@ -1971,20 +1975,20 @@ ArenaList::pickArenasToRelocate(size_t& 
         MOZ_ASSERT(freeCells >= lastFreeCells);
         lastFreeCells = freeCells;
 #endif
         previousFreeCells += freeCells;
         arenap = &arena->next;
         arenaIndex++;
     }
 
-    size_t relocCount = arenaCount - arenaIndex;
-    MOZ_ASSERT(relocCount < arenaCount);
+    size_t relocCount = nonFullArenaCount - arenaIndex;
+    MOZ_ASSERT(relocCount < nonFullArenaCount);
     MOZ_ASSERT((relocCount == 0) == (!*arenap));
-    arenaTotalOut += arenaCount;
+    arenaTotalOut += fullArenaCount + nonFullArenaCount;
     relocTotalOut += relocCount;
 
     return arenap;
 }
 
 #ifdef DEBUG
 inline bool
 PtrIsInRange(const void* ptr, const void* start, size_t length)