mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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().
This commit is contained in:
parent
66072fe326
commit
f23a15f104
@ -12635,7 +12635,7 @@ nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
|
||||
0;
|
||||
|
||||
aWindowSizes->mDOMOtherSize +=
|
||||
mStyledLinks.SizeOfExcludingThis(nullptr, aWindowSizes->mMallocSizeOf);
|
||||
mStyledLinks.ShallowSizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
|
||||
|
||||
aWindowSizes->mDOMOtherSize +=
|
||||
mIdentifierMap.SizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
|
||||
|
@ -13598,12 +13598,8 @@ nsGlobalWindow::AddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
|
||||
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();
|
||||
|
@ -403,8 +403,7 @@ size_t MediaCacheStream::SizeOfExcludingThis(
|
||||
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)
|
||||
|
@ -1040,8 +1040,8 @@ AudioContext::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ gfxFT2Font::AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
{
|
||||
gfxFont::AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
aSizes->mFontInstances +=
|
||||
mCharGlyphCache.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
mCharGlyphCache.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -312,30 +312,16 @@ gfxFontCache::FlushShapedWordCaches()
|
||||
}
|
||||
}
|
||||
|
||||
/*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
|
||||
|
@ -387,10 +387,6 @@ protected:
|
||||
gfxFont* mFont;
|
||||
};
|
||||
|
||||
static size_t AddSizeOfFontEntryExcludingThis(HashEntry* aHashEntry,
|
||||
mozilla::MallocSizeOf aMallocSizeOf,
|
||||
void* aUserArg);
|
||||
|
||||
nsTHashtable<HashEntry> mFonts;
|
||||
|
||||
static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache);
|
||||
|
@ -141,7 +141,7 @@ size_t
|
||||
gfxGlyphExtents::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return mContainedGlyphWidths.SizeOfExcludingThis(aMallocSizeOf) +
|
||||
mTightGlyphExtents.SizeOfExcludingThis(nullptr, aMallocSizeOf);
|
||||
mTightGlyphExtents.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -1095,21 +1095,6 @@ SizeOfPrefFontEntryExcludingThis
|
||||
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
|
||||
@ -1144,8 +1129,11 @@ gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
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
|
||||
|
@ -10726,12 +10726,8 @@ PresShell::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
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);
|
||||
|
@ -122,7 +122,7 @@ 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:
|
||||
|
@ -399,10 +399,12 @@ public:
|
||||
}
|
||||
|
||||
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);
|
||||
@ -451,13 +453,6 @@ private:
|
||||
*/
|
||||
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)
|
||||
@ -3584,8 +3579,8 @@ 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);
|
||||
|
@ -318,7 +318,7 @@ 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);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -517,9 +517,9 @@ NS_SizeOfAtomTablesIncludingThis(MallocSizeOf 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;
|
||||
}
|
||||
|
||||
|
@ -273,70 +273,47 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,14 +365,6 @@ private:
|
||||
*/
|
||||
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;
|
||||
};
|
||||
@ -436,16 +405,6 @@ nsTHashtable<EntryType>::Ops()
|
||||
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>
|
||||
|
Loading…
Reference in New Issue
Block a user