Loading extensions/spellcheck/hunspell/src/mozHunspell.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -95,14 +95,18 @@ NS_IMPL_CYCLE_COLLECTION_3(mozHunspell, mEncoder, mDecoder) // Memory reporting stuff // Memory reporting stuff. static PRInt64 gHunspellAllocatedSize = 0; void HunspellReportMemoryAllocation(void* ptr) { gHunspellAllocatedSize += moz_malloc_usable_size(ptr); // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize += mozilla::MemoryReporterMallocSizeOfForCounterInc(ptr, 0); } void HunspellReportMemoryDeallocation(void* ptr) { gHunspellAllocatedSize -= moz_malloc_usable_size(ptr); // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize -= mozilla::MemoryReporterMallocSizeOfForCounterDec(ptr, 0); } static PRInt64 HunspellGetCurrentAllocatedSize() { return gHunspellAllocatedSize; Loading gfx/thebes/gfxFont.cpp +18 −16 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include "nsReadableUtils.h" #include "nsExpirationTracker.h" #include "nsILanguageAtomService.h" #include "nsIMemoryReporter.h" #include "gfxFont.h" #include "gfxPlatform.h" Loading Loading @@ -1182,8 +1183,8 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd, // synthetic-bold strikes are each offset one device pixel in run direction // (these values are only needed if IsSyntheticBold() is true) double synBoldOnePixelOffset; PRInt32 strikes; double synBoldOnePixelOffset = 0; PRInt32 strikes = 0; if (IsSyntheticBold()) { double xscale = CalcXScale(aContext); synBoldOnePixelOffset = direction * xscale; Loading Loading @@ -4480,21 +4481,15 @@ gfxTextRun::ClusterIterator::ClusterAdvance(PropertyProvider *aProvider) const return mTextRun->GetAdvanceWidth(mCurrentChar, ClusterLength(), aProvider); } PRUint64 gfxTextRun::ComputeSize() size_t gfxTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { PRUint64 total = moz_malloc_usable_size(this); if (total == 0) { total = sizeof(gfxTextRun); } PRUint64 glyphDataSize = moz_malloc_usable_size(mCharacterGlyphs); if (glyphDataSize == 0) { // calculate how much gfxTextRun::AllocateStorage would have allocated glyphDataSize = sizeof(CompressedGlyph) * GlyphStorageAllocCount(mCharacterCount, mFlags); } total += glyphDataSize; // The second arg is how much gfxTextRun::AllocateStorage would have // allocated. size_t total = aMallocSizeOf(mCharacterGlyphs, sizeof(CompressedGlyph) * GlyphStorageAllocCount(mCharacterCount, mFlags)); if (mDetailedGlyphs) { total += mDetailedGlyphs->SizeOf(); Loading @@ -4505,6 +4500,13 @@ gfxTextRun::ComputeSize() return total; } size_t gfxTextRun::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { return aMallocSizeOf(this, sizeof(gfxTextRun)) + SizeOfExcludingThis(aMallocSizeOf); } #ifdef DEBUG void Loading gfx/thebes/gfxFont.h +9 −5 Original line number Diff line number Diff line Loading @@ -2048,16 +2048,20 @@ public: // return storage used by this run, for memory reporter; // nsTransformedTextRun needs to override this as it holds additional data virtual PRUint64 ComputeSize(); virtual NS_MUST_OVERRIDE size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); virtual NS_MUST_OVERRIDE size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); void AccountForSize(PRUint64* aTotal) { // Get the size, if it hasn't already been gotten, marking as it goes. size_t MaybeSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { if (mFlags & gfxTextRunFactory::TEXT_RUN_SIZE_ACCOUNTED) { return; return 0; } mFlags |= gfxTextRunFactory::TEXT_RUN_SIZE_ACCOUNTED; *aTotal += ComputeSize(); return SizeOfIncludingThis(aMallocSizeOf); } void ClearSizeAccounted() { void ResetSizeOfAccountingFlags() { mFlags &= ~gfxTextRunFactory::TEXT_RUN_SIZE_ACCOUNTED; } Loading gfx/thebes/gfxTextRunWordCache.cpp +42 −21 Original line number Diff line number Diff line Loading @@ -135,7 +135,8 @@ public: #endif } void ComputeStorage(PRUint64 *aTotal); size_t MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); void ResetSizeOfAccountingFlags(); #ifdef DEBUG PRUint32 mGeneration; Loading Loading @@ -219,9 +220,9 @@ protected: PRUint32 aEnd, PRUint32 aHash); void Uninit(); static PLDHashOperator AccountForStorage(CacheHashEntry *aEntry, static PLDHashOperator MaybeSizeOfEntry(CacheHashEntry *aEntry, void *aUserData); static PLDHashOperator ClearSizeAccounted(CacheHashEntry *aEntry, static PLDHashOperator ResetSizeOfEntryAccountingFlags(CacheHashEntry *aEntry, void *aUserData); nsTHashtable<CacheHashEntry> mCache; Loading Loading @@ -914,36 +915,48 @@ TextRunWordCache::RemoveTextRun(gfxTextRun *aTextRun) #endif } struct SizeOfEntryData { nsMallocSizeOfFun mMallocSizeOf; size_t mTotal; SizeOfEntryData(nsMallocSizeOfFun mallocSizeOf) : mMallocSizeOf(mallocSizeOf), mTotal(0) { } }; /*static*/ PLDHashOperator TextRunWordCache::AccountForStorage(CacheHashEntry *aEntry, void *aUserData) TextRunWordCache::MaybeSizeOfEntry(CacheHashEntry *aEntry, void *aUserData) { gfxTextRun *run = aEntry->mTextRun; if (run) { PRUint64 *total = static_cast<PRUint64*>(aUserData); run->AccountForSize(total); SizeOfEntryData *data = static_cast<SizeOfEntryData*>(aUserData); data->mTotal += run->MaybeSizeOfIncludingThis(data->mMallocSizeOf); } return PL_DHASH_NEXT; } /*static*/ PLDHashOperator TextRunWordCache::ClearSizeAccounted(CacheHashEntry *aEntry, void *) TextRunWordCache::ResetSizeOfEntryAccountingFlags(CacheHashEntry *aEntry, void *) { gfxTextRun *run = aEntry->mTextRun; if (run) { run->ClearSizeAccounted(); run->ResetSizeOfAccountingFlags(); } return PL_DHASH_NEXT; } void TextRunWordCache::ComputeStorage(PRUint64 *aTotal) size_t TextRunWordCache::MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { if (aTotal) { *aTotal += mCache.SizeOf(); mCache.EnumerateEntries(AccountForStorage, aTotal); } else { mCache.EnumerateEntries(ClearSizeAccounted, nsnull); size_t total = mCache.ShallowSizeOfExcludingThis(aMallocSizeOf); SizeOfEntryData data(aMallocSizeOf); mCache.EnumerateEntries(MaybeSizeOfEntry, &data); total += data.mTotal; return total; } void TextRunWordCache::ResetSizeOfAccountingFlags() { mCache.EnumerateEntries(ResetSizeOfEntryAccountingFlags, nsnull); } static bool Loading Loading @@ -1101,12 +1114,20 @@ gfxTextRunWordCache::Flush() gTextRunWordCache->Flush(); } void gfxTextRunWordCache::ComputeStorage(PRUint64 *aTotal) size_t gfxTextRunWordCache::MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { if (!gTextRunWordCache) { return; return 0; } return gTextRunWordCache->MaybeSizeOfExcludingThis(aMallocSizeOf); } void gfxTextRunWordCache::ResetSizeOfAccountingFlags() { if (gTextRunWordCache) { gTextRunWordCache->ResetSizeOfAccountingFlags(); } gTextRunWordCache->ComputeStorage(aTotal); } gfx/thebes/gfxTextRunWordCache.h +9 −6 Original line number Diff line number Diff line Loading @@ -106,13 +106,16 @@ public: static void Flush(); /** * If aTotal is NULL, just clears the TEXT_RUN_MEMORY_ACCOUNTED flag * on each textRun found. * If aTotal is non-NULL, adds the storage used for each textRun to the * total, and sets the TEXT_RUN_MEMORY_ACCOUNTED flag to avoid double- * accounting. (Runs with this flag already set will be skipped.) * This adds the storage used for each textRun to the total, and sets the * TEXT_RUN_MEMORY_ACCOUNTED flag to avoid double- accounting. (Runs with * this flag already set will be skipped.) */ static void ComputeStorage(PRUint64 *aTotal); static size_t MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); /** * This clears the TEXT_RUN_MEMORY_ACCOUNTED flag on each textRun found. */ static void ResetSizeOfAccountingFlags(); protected: friend class gfxPlatform; Loading Loading
extensions/spellcheck/hunspell/src/mozHunspell.cpp +7 −3 Original line number Diff line number Diff line Loading @@ -95,14 +95,18 @@ NS_IMPL_CYCLE_COLLECTION_3(mozHunspell, mEncoder, mDecoder) // Memory reporting stuff // Memory reporting stuff. static PRInt64 gHunspellAllocatedSize = 0; void HunspellReportMemoryAllocation(void* ptr) { gHunspellAllocatedSize += moz_malloc_usable_size(ptr); // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize += mozilla::MemoryReporterMallocSizeOfForCounterInc(ptr, 0); } void HunspellReportMemoryDeallocation(void* ptr) { gHunspellAllocatedSize -= moz_malloc_usable_size(ptr); // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize -= mozilla::MemoryReporterMallocSizeOfForCounterDec(ptr, 0); } static PRInt64 HunspellGetCurrentAllocatedSize() { return gHunspellAllocatedSize; Loading
gfx/thebes/gfxFont.cpp +18 −16 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include "nsReadableUtils.h" #include "nsExpirationTracker.h" #include "nsILanguageAtomService.h" #include "nsIMemoryReporter.h" #include "gfxFont.h" #include "gfxPlatform.h" Loading Loading @@ -1182,8 +1183,8 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd, // synthetic-bold strikes are each offset one device pixel in run direction // (these values are only needed if IsSyntheticBold() is true) double synBoldOnePixelOffset; PRInt32 strikes; double synBoldOnePixelOffset = 0; PRInt32 strikes = 0; if (IsSyntheticBold()) { double xscale = CalcXScale(aContext); synBoldOnePixelOffset = direction * xscale; Loading Loading @@ -4480,21 +4481,15 @@ gfxTextRun::ClusterIterator::ClusterAdvance(PropertyProvider *aProvider) const return mTextRun->GetAdvanceWidth(mCurrentChar, ClusterLength(), aProvider); } PRUint64 gfxTextRun::ComputeSize() size_t gfxTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { PRUint64 total = moz_malloc_usable_size(this); if (total == 0) { total = sizeof(gfxTextRun); } PRUint64 glyphDataSize = moz_malloc_usable_size(mCharacterGlyphs); if (glyphDataSize == 0) { // calculate how much gfxTextRun::AllocateStorage would have allocated glyphDataSize = sizeof(CompressedGlyph) * GlyphStorageAllocCount(mCharacterCount, mFlags); } total += glyphDataSize; // The second arg is how much gfxTextRun::AllocateStorage would have // allocated. size_t total = aMallocSizeOf(mCharacterGlyphs, sizeof(CompressedGlyph) * GlyphStorageAllocCount(mCharacterCount, mFlags)); if (mDetailedGlyphs) { total += mDetailedGlyphs->SizeOf(); Loading @@ -4505,6 +4500,13 @@ gfxTextRun::ComputeSize() return total; } size_t gfxTextRun::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { return aMallocSizeOf(this, sizeof(gfxTextRun)) + SizeOfExcludingThis(aMallocSizeOf); } #ifdef DEBUG void Loading
gfx/thebes/gfxFont.h +9 −5 Original line number Diff line number Diff line Loading @@ -2048,16 +2048,20 @@ public: // return storage used by this run, for memory reporter; // nsTransformedTextRun needs to override this as it holds additional data virtual PRUint64 ComputeSize(); virtual NS_MUST_OVERRIDE size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); virtual NS_MUST_OVERRIDE size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); void AccountForSize(PRUint64* aTotal) { // Get the size, if it hasn't already been gotten, marking as it goes. size_t MaybeSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { if (mFlags & gfxTextRunFactory::TEXT_RUN_SIZE_ACCOUNTED) { return; return 0; } mFlags |= gfxTextRunFactory::TEXT_RUN_SIZE_ACCOUNTED; *aTotal += ComputeSize(); return SizeOfIncludingThis(aMallocSizeOf); } void ClearSizeAccounted() { void ResetSizeOfAccountingFlags() { mFlags &= ~gfxTextRunFactory::TEXT_RUN_SIZE_ACCOUNTED; } Loading
gfx/thebes/gfxTextRunWordCache.cpp +42 −21 Original line number Diff line number Diff line Loading @@ -135,7 +135,8 @@ public: #endif } void ComputeStorage(PRUint64 *aTotal); size_t MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); void ResetSizeOfAccountingFlags(); #ifdef DEBUG PRUint32 mGeneration; Loading Loading @@ -219,9 +220,9 @@ protected: PRUint32 aEnd, PRUint32 aHash); void Uninit(); static PLDHashOperator AccountForStorage(CacheHashEntry *aEntry, static PLDHashOperator MaybeSizeOfEntry(CacheHashEntry *aEntry, void *aUserData); static PLDHashOperator ClearSizeAccounted(CacheHashEntry *aEntry, static PLDHashOperator ResetSizeOfEntryAccountingFlags(CacheHashEntry *aEntry, void *aUserData); nsTHashtable<CacheHashEntry> mCache; Loading Loading @@ -914,36 +915,48 @@ TextRunWordCache::RemoveTextRun(gfxTextRun *aTextRun) #endif } struct SizeOfEntryData { nsMallocSizeOfFun mMallocSizeOf; size_t mTotal; SizeOfEntryData(nsMallocSizeOfFun mallocSizeOf) : mMallocSizeOf(mallocSizeOf), mTotal(0) { } }; /*static*/ PLDHashOperator TextRunWordCache::AccountForStorage(CacheHashEntry *aEntry, void *aUserData) TextRunWordCache::MaybeSizeOfEntry(CacheHashEntry *aEntry, void *aUserData) { gfxTextRun *run = aEntry->mTextRun; if (run) { PRUint64 *total = static_cast<PRUint64*>(aUserData); run->AccountForSize(total); SizeOfEntryData *data = static_cast<SizeOfEntryData*>(aUserData); data->mTotal += run->MaybeSizeOfIncludingThis(data->mMallocSizeOf); } return PL_DHASH_NEXT; } /*static*/ PLDHashOperator TextRunWordCache::ClearSizeAccounted(CacheHashEntry *aEntry, void *) TextRunWordCache::ResetSizeOfEntryAccountingFlags(CacheHashEntry *aEntry, void *) { gfxTextRun *run = aEntry->mTextRun; if (run) { run->ClearSizeAccounted(); run->ResetSizeOfAccountingFlags(); } return PL_DHASH_NEXT; } void TextRunWordCache::ComputeStorage(PRUint64 *aTotal) size_t TextRunWordCache::MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { if (aTotal) { *aTotal += mCache.SizeOf(); mCache.EnumerateEntries(AccountForStorage, aTotal); } else { mCache.EnumerateEntries(ClearSizeAccounted, nsnull); size_t total = mCache.ShallowSizeOfExcludingThis(aMallocSizeOf); SizeOfEntryData data(aMallocSizeOf); mCache.EnumerateEntries(MaybeSizeOfEntry, &data); total += data.mTotal; return total; } void TextRunWordCache::ResetSizeOfAccountingFlags() { mCache.EnumerateEntries(ResetSizeOfEntryAccountingFlags, nsnull); } static bool Loading Loading @@ -1101,12 +1114,20 @@ gfxTextRunWordCache::Flush() gTextRunWordCache->Flush(); } void gfxTextRunWordCache::ComputeStorage(PRUint64 *aTotal) size_t gfxTextRunWordCache::MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { if (!gTextRunWordCache) { return; return 0; } return gTextRunWordCache->MaybeSizeOfExcludingThis(aMallocSizeOf); } void gfxTextRunWordCache::ResetSizeOfAccountingFlags() { if (gTextRunWordCache) { gTextRunWordCache->ResetSizeOfAccountingFlags(); } gTextRunWordCache->ComputeStorage(aTotal); }
gfx/thebes/gfxTextRunWordCache.h +9 −6 Original line number Diff line number Diff line Loading @@ -106,13 +106,16 @@ public: static void Flush(); /** * If aTotal is NULL, just clears the TEXT_RUN_MEMORY_ACCOUNTED flag * on each textRun found. * If aTotal is non-NULL, adds the storage used for each textRun to the * total, and sets the TEXT_RUN_MEMORY_ACCOUNTED flag to avoid double- * accounting. (Runs with this flag already set will be skipped.) * This adds the storage used for each textRun to the total, and sets the * TEXT_RUN_MEMORY_ACCOUNTED flag to avoid double- accounting. (Runs with * this flag already set will be skipped.) */ static void ComputeStorage(PRUint64 *aTotal); static size_t MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); /** * This clears the TEXT_RUN_MEMORY_ACCOUNTED flag on each textRun found. */ static void ResetSizeOfAccountingFlags(); protected: friend class gfxPlatform; Loading