Bug 1400520 - VisitEntries should decrease the length of mEntries the optimal amount, r=mccr8
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 20 Sep 2017 13:15:19 +0300
changeset 381865 0ff539e59fb14f92c2990d0742f5f1f16aa82ff1
parent 381864 eab55565955de81c880c31c1e1c37506b5b042e0
child 381866 6985520d35f0eab6edf367866c4698bbf1daa975
push id95213
push useropettay@mozilla.com
push dateWed, 20 Sep 2017 10:16:58 +0000
treeherdermozilla-inbound@0ff539e59fb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1400520
milestone57.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 1400520 - VisitEntries should decrease the length of mEntries the optimal amount, r=mccr8
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1075,17 +1075,17 @@ public:
       ClearNurseryPurpleBuffer();
     }
 
     if (mEntries.IsEmpty()) {
       return;
     }
 
     uint32_t oldLength = mEntries.Length();
-    uint32_t newLength = 0;
+    uint32_t keptLength = 0;
     auto revIter = mEntries.IterFromLast();
     auto iter = mEntries.Iter();
      // After iteration this points to the first empty entry.
     auto firstEmptyIter = mEntries.Iter();
     auto iterFromLastEntry = mEntries.IterFromLast();
     for (; !iter.Done(); iter.Next()) {
       nsPurpleBufferEntry& e = iter.Get();
       if (e.mObject) {
@@ -1116,44 +1116,43 @@ public:
           }
         }
       }
 
       // Entry is non-empty even after the Visit call, ensure it is kept
       // in mEntries.
       if (e.mObject) {
         firstEmptyIter.Next();
-        ++newLength;
+        ++keptLength;
       }
 
       if (&e == &revIter.Get()) {
         break;
       }
     }
 
     // There were some empty entries.
-    if (oldLength != newLength) {
+    if (oldLength != keptLength) {
 
       // While visiting entries, some new ones were possibly added. This can
       // happen during CanSkip. Move all such new entries to be after other
       // entries. Note, we don't call Visit on newly added entries!
       if (&iterFromLastEntry.Get() != &mEntries.GetLast()) {
         iterFromLastEntry.Next(); // Now pointing to the first added entry.
         auto& iterForNewEntries = iterFromLastEntry;
         while (!iterForNewEntries.Done()) {
           MOZ_ASSERT(!firstEmptyIter.Done());
           MOZ_ASSERT(!firstEmptyIter.Get().mObject);
           firstEmptyIter.Get().Swap(iterForNewEntries.Get());
           firstEmptyIter.Next();
           iterForNewEntries.Next();
-          ++newLength; // We keep all the new entries.
         }
       }
 
-      mEntries.PopLastN(oldLength - newLength);
+      mEntries.PopLastN(oldLength - keptLength);
     }
   }
 
   void FreeBlocks()
   {
     mCount = 0;
     mEntries.Clear();
   }