Bug 1278796, part 2 - Initialize PurpleBlock next pointers in a method. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Fri, 10 Jun 2016 09:17:57 -0700
changeset 301482 420531c2f7edb65fc12c0740f0c8fa0840e7fa97
parent 301481 ba19b6e0ea54dc61851028024e1d7857b251a7a2
child 301483 7e5c2c10d43b9ed7bf6a9228b190af7bf1994d7e
push id78340
push useramccreight@mozilla.com
push dateFri, 10 Jun 2016 16:18:16 +0000
treeherdermozilla-inbound@99582cfde7c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1278796
milestone50.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 1278796, part 2 - Initialize PurpleBlock next pointers in a method. r=smaug
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1007,16 +1007,27 @@ private:
       // Ensure PurpleBlock is the right size (see above).
       static_assert(
         sizeof(PurpleBlock) == 16384 ||       // 32-bit
         sizeof(PurpleBlock) == 32768,         // 64-bit
         "ill-sized nsPurpleBuffer::PurpleBlock"
       );
     }
 
+    // Put all the entries in the block on the free list.
+    void InitNextPointers()
+    {
+      for (uint32_t i = 1; i < ArrayLength(mEntries); ++i) {
+        mEntries[i - 1].mNextInFreeList =
+          (nsPurpleBufferEntry*)(uintptr_t(mEntries + i) | 1);
+      }
+      mEntries[ArrayLength(mEntries) - 1].mNextInFreeList =
+        (nsPurpleBufferEntry*)1;
+    }
+
     template<class PurpleVisitor>
     void VisitEntries(nsPurpleBuffer& aBuffer, PurpleVisitor& aVisitor)
     {
       nsPurpleBufferEntry* eEnd = ArrayEnd(mEntries);
       for (nsPurpleBufferEntry* e = mEntries; e != eEnd; ++e) {
         MOZ_ASSERT(e->mObject, "There should be no null mObject when we iterate over the purple buffer");
         if (!(uintptr_t(e->mObject) & uintptr_t(1)) && e->mObject) {
           aVisitor.Visit(aBuffer, e);
@@ -1055,25 +1066,18 @@ public:
     mCount = 0;
     mFreeList = nullptr;
     StartBlock(&mFirstBlock);
   }
 
   void StartBlock(PurpleBlock* aBlock)
   {
     MOZ_ASSERT(!mFreeList, "should not have free list");
-
-    // Put all the entries in the block on the free list.
     mFreeList = aBlock->mEntries;
-    for (uint32_t i = 1; i < ArrayLength(aBlock->mEntries); ++i) {
-      aBlock->mEntries[i - 1].mNextInFreeList =
-        (nsPurpleBufferEntry*)(uintptr_t(aBlock->mEntries + i) | 1);
-    }
-    aBlock->mEntries[ArrayLength(aBlock->mEntries) - 1].mNextInFreeList =
-      (nsPurpleBufferEntry*)1;
+    aBlock->InitNextPointers();
   }
 
   void FreeBlocks()
   {
     if (mCount > 0) {
       UnmarkRemainingPurple(&mFirstBlock);
     }
     PurpleBlock* b = mFirstBlock.mNext;