Bug 1517221, explicitly break down pending mutation record list, r=mccr8
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 02 Jan 2019 21:36:39 +0200
changeset 509412 64b2e707cdbd7780fa3dcf22c3e9aa35930811a6
parent 509411 291f284eed9ef10fce35ffe4c69abb1d6ff581d6
child 509413 b3acccbde849d18bf5302a545bc005a13e1a1432
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1517221
milestone66.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 1517221, explicitly break down pending mutation record list, r=mccr8
dom/base/nsDOMMutationObserver.cpp
dom/base/nsDOMMutationObserver.h
--- a/dom/base/nsDOMMutationObserver.cpp
+++ b/dom/base/nsDOMMutationObserver.cpp
@@ -51,20 +51,17 @@ nsINodeList* nsDOMMutationRecord::Remove
 }
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMMutationRecord)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMMutationRecord)
-// Break down the linked list so that cycle collector can delete the
-// objects sooner.
-NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(nsDOMMutationRecord,
-                                                   mNext = nullptr)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMMutationRecord)
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMMutationRecord, mTarget,
                                       mPreviousSibling, mNextSibling,
                                       mAddedNodes, mRemovedNodes,
                                       mAddedAnimations, mRemovedAnimations,
                                       mChangedAnimations, mNext, mOwner)
 
 // Observer
--- a/dom/base/nsDOMMutationObserver.h
+++ b/dom/base/nsDOMMutationObserver.h
@@ -497,19 +497,24 @@ class nsDOMMutationObserver final : publ
       MOZ_ASSERT(mFirstPendingMutation);
       mLastPendingMutation->mNext = record.forget();
       mLastPendingMutation = mLastPendingMutation->mNext;
     }
     ++mPendingMutationCount;
   }
 
   void ClearPendingRecords() {
-    mFirstPendingMutation = nullptr;
+    // Break down the pending mutation record list so that cycle collector
+    // can delete the objects sooner.
+    RefPtr<nsDOMMutationRecord> current = mFirstPendingMutation.forget();
     mLastPendingMutation = nullptr;
     mPendingMutationCount = 0;
+    while (current) {
+      current = current->mNext.forget();
+    }
   }
 
   // static methods
   static void QueueMutationObserverMicroTask();
 
   static void HandleMutations(mozilla::AutoSlowOperation& aAso);
 
   static bool AllScheduledMutationObserversAreSuppressed() {