Bug 1189156 (part 2) - Don't use enumeration style for nsTHashtable::SizeOf{In,Ex}cludingThis(). r=erahm.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 29 Jul 2015 01:50:52 -0700
changeset 289350 8296e64c47e82a33ac90b82d9bf4bde00f60e99b
parent 289349 ad6eae12a1957a900d2fd8a22cf3e7f8a74159cd
child 289351 a998270ed671cb5a11b983479a462c117c6a8fa6
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1189156
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 1189156 (part 2) - Don't use enumeration style for nsTHashtable::SizeOf{In,Ex}cludingThis(). r=erahm. After this change, we have ShallowSizeOf{In,Ex}cludingThis(), which don't do anything to measure children. (They can be combined with iteration to measure children.) And we still have the existing single-arg SizeOf{In,Ex}cluding() functions, which work if the entry type itself defines SizeOfExcludingThis().
dom/base/nsDocument.cpp
dom/base/nsGlobalWindow.cpp
dom/media/MediaCache.cpp
dom/media/webaudio/AudioContext.cpp
gfx/thebes/gfxFT2Fonts.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxGlyphExtents.cpp
gfx/thebes/gfxPlatformFontList.cpp
layout/base/nsPresShell.cpp
netwerk/dns/nsEffectiveTLDService.cpp
toolkit/components/telemetry/Telemetry.cpp
xpcom/components/nsCategoryManager.cpp
xpcom/ds/nsAtomTable.cpp
xpcom/glue/nsTHashtable.h
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -12630,17 +12630,17 @@ nsDocument::DocAddSizeOfExcludingThis(ns
 
   aWindowSizes->mDOMOtherSize +=
     mSVGAttrAnimationRuleProcessor ?
     mSVGAttrAnimationRuleProcessor->DOMSizeOfIncludingThis(
                                       aWindowSizes->mMallocSizeOf) :
     0;
 
   aWindowSizes->mDOMOtherSize +=
-    mStyledLinks.SizeOfExcludingThis(nullptr, aWindowSizes->mMallocSizeOf);
+    mStyledLinks.ShallowSizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
 
   aWindowSizes->mDOMOtherSize +=
     mIdentifierMap.SizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
 
   // Measurement of the following members may be added later if DMD finds it
   // is worthwhile:
   // - many!
 }
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -13593,22 +13593,18 @@ nsGlobalWindow::AddSizeOfIncludingThis(n
     }
   }
 
   if (mNavigator) {
     aWindowSizes->mDOMOtherSize +=
       mNavigator->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf);
   }
 
-  // The things pointed to by the entries will be measured below, so we
-  // use nullptr for the callback here.
   aWindowSizes->mDOMEventTargetsSize +=
-    mEventTargetObjects.SizeOfExcludingThis(nullptr,
-                                            aWindowSizes->mMallocSizeOf);
-
+    mEventTargetObjects.ShallowSizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
 
   for (auto iter = mEventTargetObjects.ConstIter(); !iter.Done(); iter.Next()) {
     DOMEventTargetHelper* et = iter.Get()->GetKey();
     if (nsCOMPtr<nsISizeOfEventTarget> iSizeOf = do_QueryObject(et)) {
       aWindowSizes->mDOMEventTargetsSize +=
         iSizeOf->SizeOfEventTargetIncludingThis(aWindowSizes->mMallocSizeOf);
     }
     if (EventListenerManager* elm = et->GetExistingListenerManager()) {
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -398,18 +398,17 @@ size_t MediaCacheStream::SizeOfExcluding
   size += mPartialBlockBuffer.SizeOfExcludingThis(aMallocSizeOf);
 
   return size;
 }
 
 size_t MediaCacheStream::BlockList::SizeOfExcludingThis(
                                 MallocSizeOf aMallocSizeOf) const
 {
-  return mEntries.SizeOfExcludingThis(/* sizeOfEntryExcludingThis = */ nullptr,
-                                      aMallocSizeOf);
+  return mEntries.ShallowSizeOfExcludingThis(aMallocSizeOf);
 }
 
 void MediaCacheStream::BlockList::AddFirstBlock(int32_t aBlock)
 {
   NS_ASSERTION(!mEntries.GetEntry(aBlock), "Block already in list");
   Entry* entry = mEntries.PutEntry(aBlock);
 
   if (mFirstBlock < 0) {
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -1035,18 +1035,18 @@ AudioContext::SizeOfIncludingThis(mozill
   size_t amount = aMallocSizeOf(this);
   if (mListener) {
     amount += mListener->SizeOfIncludingThis(aMallocSizeOf);
   }
   amount += mDecodeJobs.ShallowSizeOfExcludingThis(aMallocSizeOf);
   for (uint32_t i = 0; i < mDecodeJobs.Length(); ++i) {
     amount += mDecodeJobs[i]->SizeOfIncludingThis(aMallocSizeOf);
   }
-  amount += mActiveNodes.SizeOfExcludingThis(nullptr, aMallocSizeOf);
-  amount += mPannerNodes.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+  amount += mActiveNodes.ShallowSizeOfExcludingThis(aMallocSizeOf);
+  amount += mPannerNodes.ShallowSizeOfExcludingThis(aMallocSizeOf);
   return amount;
 }
 
 NS_IMETHODIMP
 AudioContext::CollectReports(nsIHandleReportCallback* aHandleReport,
                              nsISupports* aData, bool aAnonymize)
 {
   int64_t amount = SizeOfIncludingThis(MallocSizeOf);
--- a/gfx/thebes/gfxFT2Fonts.cpp
+++ b/gfx/thebes/gfxFT2Fonts.cpp
@@ -213,17 +213,17 @@ gfxFT2Font::FillGlyphDataForChar(uint32_
 }
 
 void
 gfxFT2Font::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                    FontCacheSizes* aSizes) const
 {
     gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
     aSizes->mFontInstances +=
-        mCharGlyphCache.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+        mCharGlyphCache.ShallowSizeOfExcludingThis(aMallocSizeOf);
 }
 
 void
 gfxFT2Font::AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                    FontCacheSizes* aSizes) const
 {
     aSizes->mFontInstances += aMallocSizeOf(this);
     AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -307,40 +307,26 @@ gfxFontCache::WordCacheExpirationTimerCa
 void
 gfxFontCache::FlushShapedWordCaches()
 {
     for (auto it = mFonts.Iter(); !it.Done(); it.Next()) {
         it.Get()->mFont->ClearCachedWords();
     }
 }
 
-/*static*/
-size_t
-gfxFontCache::AddSizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
-                                              MallocSizeOf aMallocSizeOf,
-                                              void* aUserArg)
-{
-    HashEntry *entry = static_cast<HashEntry*>(aHashEntry);
-    FontCacheSizes *sizes = static_cast<FontCacheSizes*>(aUserArg);
-    entry->mFont->AddSizeOfExcludingThis(aMallocSizeOf, sizes);
-
-    // The entry's size is recorded in the |sizes| parameter, so we return zero
-    // here to the hashtable enumerator.
-    return 0;
-}
-
 void
 gfxFontCache::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
                                      FontCacheSizes* aSizes) const
 {
     // TODO: add the overhead of the expiration tracker (generation arrays)
 
-    aSizes->mFontInstances +=
-        mFonts.SizeOfExcludingThis(AddSizeOfFontEntryExcludingThis,
-                                   aMallocSizeOf, aSizes);
+    aSizes->mFontInstances += mFonts.ShallowSizeOfExcludingThis(aMallocSizeOf);
+    for (auto iter = mFonts.ConstIter(); !iter.Done(); iter.Next()) {
+        iter.Get()->mFont->AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
+    }
 }
 
 void
 gfxFontCache::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
                                      FontCacheSizes* aSizes) const
 {
     aSizes->mFontInstances += aMallocSizeOf(this);
     AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -382,20 +382,16 @@ protected:
             return mozilla::HashGeneric(aKey->mStyle->Hash(), aKey->mFontEntry,
                                         aKey->mUnicodeRangeMap);
         }
         enum { ALLOW_MEMMOVE = true };
 
         gfxFont* mFont;
     };
 
-    static size_t AddSizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
-                                                  mozilla::MallocSizeOf aMallocSizeOf,
-                                                  void* aUserArg);
-
     nsTHashtable<HashEntry> mFonts;
 
     static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache);
     nsCOMPtr<nsITimer>      mWordCacheExpirationTimer;
 };
 
 class gfxTextPerfMetrics {
 public:
--- a/gfx/thebes/gfxGlyphExtents.cpp
+++ b/gfx/thebes/gfxGlyphExtents.cpp
@@ -136,16 +136,16 @@ gfxGlyphExtents::SetTightGlyphExtents(ui
     entry->width = aExtentsAppUnits.Width();
     entry->height = aExtentsAppUnits.Height();
 }
 
 size_t
 gfxGlyphExtents::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
 {
     return mContainedGlyphWidths.SizeOfExcludingThis(aMallocSizeOf) +
-        mTightGlyphExtents.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+        mTightGlyphExtents.ShallowSizeOfExcludingThis(aMallocSizeOf);
 }
 
 size_t
 gfxGlyphExtents::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
 }
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -1090,31 +1090,16 @@ SizeOfPrefFontEntryExcludingThis
      void*                                     aUserArg)
 {
     // again, we only care about the size of the array itself; we don't follow
     // the refPtrs stored in it, because they point to entries already owned
     // and accounted-for by the main font list
     return aList.ShallowSizeOfExcludingThis(aMallocSizeOf);
 }
 
-static size_t
-SizeOfSharedCmapExcludingThis(CharMapHashKey*   aHashEntry,
-                              MallocSizeOf      aMallocSizeOf,
-                              void*             aUserArg)
-{
-    FontListSizes *sizes = static_cast<FontListSizes*>(aUserArg);
-
-    uint32_t size = aHashEntry->GetKey()->SizeOfIncludingThis(aMallocSizeOf);
-    sizes->mCharMapsSize += size;
-
-    // we return zero here because the measurements have been added directly
-    // to the relevant fields of the FontListSizes record
-    return 0;
-}
-
 void
 gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
                                             FontListSizes* aSizes) const
 {
     aSizes->mFontListSize +=
         mFontFamilies.SizeOfExcludingThis(SizeOfFamilyEntryExcludingThis,
                                           aMallocSizeOf, aSizes);
 
@@ -1139,18 +1124,21 @@ gfxPlatformFontList::AddSizeOfExcludingT
     aSizes->mFontListSize +=
         mPrefFonts.SizeOfExcludingThis(SizeOfPrefFontEntryExcludingThis,
                                        aMallocSizeOf);
 
     aSizes->mFontListSize +=
         mBadUnderlineFamilyNames.SizeOfExcludingThis(aMallocSizeOf);
 
     aSizes->mFontListSize +=
-        mSharedCmaps.SizeOfExcludingThis(SizeOfSharedCmapExcludingThis,
-                                         aMallocSizeOf, aSizes);
+        mSharedCmaps.ShallowSizeOfExcludingThis(aMallocSizeOf);
+    for (auto iter = mSharedCmaps.ConstIter(); !iter.Done(); iter.Next()) {
+        aSizes->mCharMapsSize +=
+            iter.Get()->GetKey()->SizeOfIncludingThis(aMallocSizeOf);
+    }
 }
 
 void
 gfxPlatformFontList::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
                                             FontListSizes* aSizes) const
 {
     aSizes->mFontListSize += aMallocSizeOf(this);
     AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -10721,22 +10721,18 @@ PresShell::AddSizeOfIncludingThis(Malloc
                                   size_t *aTextRunsSize,
                                   size_t *aPresContextSize)
 {
   mFrameArena.AddSizeOfExcludingThis(aMallocSizeOf, aArenaObjectsSize);
   *aPresShellSize += aMallocSizeOf(this);
   if (mCaret) {
     *aPresShellSize += mCaret->SizeOfIncludingThis(aMallocSizeOf);
   }
-  *aPresShellSize += mVisibleImages.SizeOfExcludingThis(nullptr,
-                                                        aMallocSizeOf,
-                                                        nullptr);
-  *aPresShellSize += mFramesToDirty.SizeOfExcludingThis(nullptr,
-                                                        aMallocSizeOf,
-                                                        nullptr);
+  *aPresShellSize += mVisibleImages.ShallowSizeOfExcludingThis(aMallocSizeOf);
+  *aPresShellSize += mFramesToDirty.ShallowSizeOfExcludingThis(aMallocSizeOf);
   *aPresShellSize += aArenaObjectsSize->mOther;
 
   *aStyleSetsSize += StyleSet()->SizeOfIncludingThis(aMallocSizeOf);
 
   *aTextRunsSize += SizeOfTextRuns(aMallocSizeOf);
 
   *aPresContextSize += mPresContext->SizeOfIncludingThis(aMallocSizeOf);
 }
--- a/netwerk/dns/nsEffectiveTLDService.cpp
+++ b/netwerk/dns/nsEffectiveTLDService.cpp
@@ -117,17 +117,17 @@ nsEffectiveTLDService::CollectReports(ns
     SizeOfIncludingThis(EffectiveTLDServiceMallocSizeOf),
     "Memory used by the effective TLD service.");
 }
 
 size_t
 nsEffectiveTLDService::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
 {
   size_t n = aMallocSizeOf(this);
-  n += mHash.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+  n += mHash.ShallowSizeOfExcludingThis(aMallocSizeOf);
 
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
   // - mIDNService
 
   return n;
 }
 
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -394,20 +394,22 @@ public:
   /**
    * Get size of hash table with file stats
    */
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
 
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
-    size_t size;
-    size = mFileStats.SizeOfExcludingThis(SizeOfFileIOEntryTypeExcludingThis,
-                                          aMallocSizeOf) +
-           mSafeDirs.ShallowSizeOfExcludingThis(aMallocSizeOf);
+    size_t size = 0;
+    size += mFileStats.ShallowSizeOfExcludingThis(aMallocSizeOf);
+    for (auto iter = mFileStats.ConstIter(); !iter.Done(); iter.Next()) {
+      size += iter.Get()->GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
+    }
+    size += mSafeDirs.ShallowSizeOfExcludingThis(aMallocSizeOf);
     uint32_t safeDirsLen = mSafeDirs.Length();
     for (uint32_t i = 0; i < safeDirsLen; ++i) {
       size += mSafeDirs[i].SizeOfExcludingThis(aMallocSizeOf);
     }
     return size;
   }
 
 private:
@@ -446,23 +448,16 @@ private:
 
   /**
    * Reflect a FileIOEntryType object to a Javascript property on obj with
    * filename as key containing array:
    * [totalTime, creates, reads, writes, fsyncs, stats]
    */
   static bool ReflectFileStats(FileIOEntryType* entry, JSContext *cx,
                                JS::Handle<JSObject*> obj);
-
-  static size_t SizeOfFileIOEntryTypeExcludingThis(FileIOEntryType* aEntry,
-                                                   mozilla::MallocSizeOf mallocSizeOf,
-                                                   void*)
-  {
-    return aEntry->GetKey().SizeOfExcludingThisIfUnshared(mallocSizeOf);
-  }
 };
 
 TelemetryIOInterposeObserver::TelemetryIOInterposeObserver(nsIFile* aXreDir)
   : mCurStage(STAGE_STARTUP)
 {
   nsAutoString xreDirPath;
   nsresult rv = aXreDir->GetPath(xreDirPath);
   if (NS_SUCCEEDED(rv)) {
@@ -3579,18 +3574,18 @@ TelemetryImpl::MsSinceProcessStart(doubl
 }
 
 size_t
 TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
 {
   size_t n = aMallocSizeOf(this);
 
   // Ignore the hashtables in mAddonMap; they are not significant.
-  n += mAddonMap.SizeOfExcludingThis(nullptr, aMallocSizeOf);
-  n += mHistogramMap.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+  n += mAddonMap.ShallowSizeOfExcludingThis(aMallocSizeOf);
+  n += mHistogramMap.ShallowSizeOfExcludingThis(aMallocSizeOf);
   { // Scope for mHashMutex lock
     MutexAutoLock lock(mHashMutex);
     n += mPrivateSQL.SizeOfExcludingThis(aMallocSizeOf);
     n += mSanitizedSQL.SizeOfExcludingThis(aMallocSizeOf);
   }
   { // Scope for mHangReportsMutex lock
     MutexAutoLock lock(mHangReportsMutex);
     n += mHangReports.SizeOfExcludingThis(aMallocSizeOf);
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -313,17 +313,17 @@ CategoryNode::Enumerate(nsISimpleEnumera
   return NS_OK;
 }
 
 size_t
 CategoryNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf)
 {
   // We don't measure the strings pointed to by the entries because the
   // pointers are non-owning.
-  return mTable.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+  return mTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
 }
 
 //
 // CategoryEnumerator class
 //
 
 class CategoryEnumerator
   : public BaseStringEnumerator
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -512,19 +512,19 @@ NS_SizeOfAtomTablesIncludingThis(MallocS
     *aMain += gAtomTable->ShallowSizeOfIncludingThis(aMallocSizeOf);
     for (auto iter = gAtomTable->Iter(); !iter.Done(); iter.Next()) {
       auto entry = static_cast<AtomTableEntry*>(iter.Get());
       *aMain += entry->mAtom->SizeOfIncludingThis(aMallocSizeOf);
     }
   }
 
   // The atoms in the this table are almost certainly stored in static data, so
-  // we don't need a SizeOfEntry function.
+  // we don't need to measure entries separately.
   *aStatic = gStaticAtomTable
-           ? gStaticAtomTable->SizeOfIncludingThis(nullptr, aMallocSizeOf)
+           ? gStaticAtomTable->ShallowSizeOfIncludingThis(aMallocSizeOf)
            : 0;
 }
 
 #define ATOM_HASHTABLE_INITIAL_LENGTH  2048
 
 static inline void
 EnsureTableExists()
 {
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -268,80 +268,57 @@ public:
    * constructor.
    */
   void Clear()
   {
     mTable.Clear();
   }
 
   /**
-   * client must provide a <code>SizeOfEntryExcludingThisFun</code> function for
-   *   SizeOfExcludingThis.
-   * @param     aEntry the entry being enumerated
-   * @param     mallocSizeOf the function used to measure heap-allocated blocks
-   * @param     arg passed unchanged from <code>SizeOf{In,Ex}cludingThis</code>
-   * @return    summed size of the things pointed to by the entries
+   * Measure the size of the table's entry storage. Does *not* measure anything
+   * hanging off table entries; hence the "Shallow" prefix. To measure that,
+   * either use SizeOfExcludingThis() or iterate manually over the entries,
+   * calling SizeOfExcludingThis() on each one.
+   *
+   * @param     aMallocSizeOf the function used to measure heap-allocated blocks
+   * @return    the measured shallow size of the table
    */
-  typedef size_t (*SizeOfEntryExcludingThisFun)(EntryType* aEntry,
-                                                mozilla::MallocSizeOf aMallocSizeOf,
-                                                void* aArg);
+  size_t ShallowSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
+  {
+    return mTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
+  }
 
   /**
-   * Measure the size of the table's entry storage, and if
-   * |aSizeOfEntryExcludingThis| is non-nullptr, measure the size of things
-   * pointed to by entries.
-   *
-   * @param     sizeOfEntryExcludingThis the
-   *            <code>SizeOfEntryExcludingThisFun</code> function to call
-   * @param     mallocSizeOf the function used to measure heap-allocated blocks
-   * @param     userArg a pointer to pass to the
-   *            <code>SizeOfEntryExcludingThisFun</code> function
-   * @return    the summed size of all the entries
+   * Like ShallowSizeOfExcludingThis, but includes sizeof(*this).
    */
-  size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun aSizeOfEntryExcludingThis,
-                             mozilla::MallocSizeOf aMallocSizeOf,
-                             void* aUserArg = nullptr) const
+  size_t ShallowSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
   {
-    size_t n = 0;
-    n += mTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
-    if (aSizeOfEntryExcludingThis) {
-      for (auto iter = ConstIter(); !iter.Done(); iter.Next()) {
-        n += aSizeOfEntryExcludingThis(iter.Get(), aMallocSizeOf, aUserArg);
-      }
+    return aMallocSizeOf(this) + ShallowSizeOfExcludingThis(aMallocSizeOf);
+  }
+
+  /**
+   * This is a "deep" measurement of the table. To use it, |EntryType| must
+   * define SizeOfExcludingThis, and that method will be called on all live
+   * entries.
+   */
+  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
+  {
+    size_t n = ShallowSizeOfExcludingThis(aMallocSizeOf);
+    for (auto iter = ConstIter(); !iter.Done(); iter.Next()) {
+      n += (*iter.Get()).SizeOfExcludingThis(aMallocSizeOf);
     }
     return n;
   }
 
   /**
-   * If the EntryType defines SizeOfExcludingThis, there's no need to define a new
-   * SizeOfEntryExcludingThisFun.
-   */
-  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
-  {
-    return SizeOfExcludingThis(BasicSizeOfEntryExcludingThisFun, aMallocSizeOf);
-  }
-
-  /**
    * Like SizeOfExcludingThis, but includes sizeof(*this).
    */
-  size_t SizeOfIncludingThis(SizeOfEntryExcludingThisFun aSizeOfEntryExcludingThis,
-                             mozilla::MallocSizeOf aMallocSizeOf,
-                             void* aUserArg = nullptr) const
-  {
-    return aMallocSizeOf(this) +
-      SizeOfExcludingThis(aSizeOfEntryExcludingThis, aMallocSizeOf, aUserArg);
-  }
-
-  /**
-   * If the EntryType defines SizeOfExcludingThis, there's no need to define a new
-   * SizeOfEntryExcludingThisFun.
-   */
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
   {
-    return SizeOfIncludingThis(BasicSizeOfEntryExcludingThisFun, aMallocSizeOf);
+    return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
 
   /**
    * Swap the elements in this hashtable with the elements in aOther.
    */
   void SwapElements(nsTHashtable<EntryType>& aOther)
   {
     MOZ_ASSERT_IF(this->mTable.Ops() && aOther.mTable.Ops(),
@@ -383,24 +360,16 @@ private:
   // copy constructor, not implemented
   nsTHashtable(nsTHashtable<EntryType>& aToCopy) = delete;
 
   /**
    * Gets the table's ops.
    */
   static const PLDHashTableOps* Ops();
 
-  /**
-   * An implementation of SizeOfEntryExcludingThisFun that calls SizeOfExcludingThis()
-   * on each entry.
-   */
-  static size_t BasicSizeOfEntryExcludingThisFun(EntryType* aEntry,
-                                                 mozilla::MallocSizeOf aMallocSizeOf,
-                                                 void*);
-
   // assignment operator, not implemented
   nsTHashtable<EntryType>& operator=(nsTHashtable<EntryType>& aToEqual) = delete;
 };
 
 //
 // template definitions
 //
 
@@ -431,26 +400,16 @@ nsTHashtable<EntryType>::Ops()
     s_MatchEntry,
     EntryType::ALLOW_MEMMOVE ? ::PL_DHashMoveEntryStub : s_CopyEntry,
     s_ClearEntry,
     s_InitEntry
   };
   return &sOps;
 }
 
-// static
-template<class EntryType>
-size_t
-nsTHashtable<EntryType>::BasicSizeOfEntryExcludingThisFun(EntryType* aEntry,
-                                                          mozilla::MallocSizeOf aMallocSizeOf,
-                                                          void*)
-{
-  return aEntry->SizeOfExcludingThis(aMallocSizeOf);
-}
-
 // static definitions
 
 template<class EntryType>
 PLDHashNumber
 nsTHashtable<EntryType>::s_HashKey(PLDHashTable* aTable, const void* aKey)
 {
   return EntryType::HashKey(reinterpret_cast<const KeyTypePointer>(aKey));
 }