Bug 1487237. Add some content lists stored in DOM slots to memory reporting. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 01 Sep 2018 14:55:47 +0000
changeset 434408 d718fc7c16e6d3db5e8a9fa3afae83727ea1e395
parent 434407 cd5cb85fa128eefd6bff9e3e40710d27e5b16ed0
child 434422 8284cddccf78566ca4dc45272940ccae4b1150df
push id34554
push usernbeleuzu@mozilla.com
push dateSat, 01 Sep 2018 21:55:14 +0000
treeherdermozilla-central@d718fc7c16e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1487237
milestone63.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 1487237. Add some content lists stored in DOM slots to memory reporting. r=smaug This reports the memory as part of element-nodes, but I think that's OK for now. If we want to, we can try to add more nsWindowSizes buckets for this stuff. Differential Revision: https://phabricator.services.mozilla.com/D4811
dom/base/FragmentOrElement.cpp
dom/base/nsContentList.cpp
dom/base/nsContentList.h
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -742,24 +742,25 @@ FragmentOrElement::nsDOMSlots::SizeOfInc
 
     n += extendedSlots->SizeOfExcludingThis(aMallocSizeOf);
   }
 
   if (mAttributeMap) {
     n += mAttributeMap->SizeOfIncludingThis(aMallocSizeOf);
   }
 
+  if (mChildrenList) {
+    n += mChildrenList->SizeOfIncludingThis(aMallocSizeOf);
+  }
+
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
   // - Superclass members (nsINode::nsSlots)
   // - mStyle
   // - mDataSet
-  // - mSMILOverrideStyle
-  // - mSMILOverrideStyleDeclaration
-  // - mChildrenList
   // - mClassList
 
   // The following member are not measured:
   // - mControllers: because it is non-owning
   // - mBindingParent: because it is some ancestor element.
   return n;
 }
 
@@ -830,20 +831,18 @@ FragmentOrElement::nsExtendedDOMSlots::S
   // it.
 
   // We don't seem to have memory reporting for nsXULControllers.  At least
   // report the memory it's using directly.
   if (mControllers) {
     n += aMallocSizeOf(mControllers);
   }
 
-  // We don't seem to have memory reporting for nsLabelsNodeList.  At least
-  // report the memory it's using directly.
   if (mLabelsList) {
-    n += aMallocSizeOf(mLabelsList);
+    n += mLabelsList->SizeOfIncludingThis(aMallocSizeOf);
   }
 
   // mShadowRoot should be handled during normal DOM tree memory reporting, just
   // like kids, siblings, etc.
 
   // We don't seem to have memory reporting for nsXBLBinding.  At least
   // report the memory it's using directly.
   if (mXBLBinding) {
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -100,16 +100,24 @@ nsBaseContentList::IndexOf(nsIContent *a
 }
 
 int32_t
 nsBaseContentList::IndexOf(nsIContent* aContent)
 {
   return IndexOf(aContent, true);
 }
 
+size_t
+nsBaseContentList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  size_t n = aMallocSizeOf(this);
+  n += mElements.ShallowSizeOfExcludingThis(aMallocSizeOf);
+  return n;
+}
+
 NS_IMPL_CYCLE_COLLECTION_INHERITED(nsSimpleContentList, nsBaseContentList,
                                    mRoot)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSimpleContentList)
 NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList)
 
 
 NS_IMPL_ADDREF_INHERITED(nsSimpleContentList, nsBaseContentList)
--- a/dom/base/nsContentList.h
+++ b/dom/base/nsContentList.h
@@ -22,16 +22,17 @@
 #include "nsINodeList.h"
 #include "nsStubMutationObserver.h"
 #include "nsAtom.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsNameSpaceManager.h"
 #include "nsWrapperCache.h"
 #include "nsHashKeys.h"
 #include "mozilla/HashFunctions.h"
+#include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/NameSpaceConstants.h"
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
@@ -89,16 +90,21 @@ public:
 
   void SetCapacity(uint32_t aCapacity)
   {
     mElements.SetCapacity(aCapacity);
   }
 
   virtual void LastRelease() {}
 
+  // Memory reporting.  For now, subclasses of nsBaseContentList don't really
+  // need to report any members that are not part of the object itself, so we
+  // don't need to make this virtual.
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+
 protected:
   virtual ~nsBaseContentList();
 
   /**
    * To be called from non-destructor locations (e.g. unlink) that want to
    * remove from caches.  Cacheable subclasses should override.
    */
   virtual void RemoveFromCaches()