зеркало из https://github.com/mozilla/gecko-dev.git
Bug 707865 - Convert nsTArray::SizeOf() to nsTArray::SizeOfExcludingThis(). r=jlebar.
--HG-- extra : rebase_source : d802d58bc7dedda2490878793923adc0ab55f779
This commit is contained in:
Родитель
0bed04673f
Коммит
0089711fa7
|
@ -4509,10 +4509,10 @@ gfxTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
|||
GlyphStorageAllocCount(mCharacterCount, mFlags));
|
||||
|
||||
if (mDetailedGlyphs) {
|
||||
total += mDetailedGlyphs->SizeOf();
|
||||
total += mDetailedGlyphs->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
total += mGlyphRuns.SizeOf();
|
||||
total += mGlyphRuns.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
|
|
@ -2273,9 +2273,10 @@ private:
|
|||
return details;
|
||||
}
|
||||
|
||||
PRUint32 SizeOf() {
|
||||
return sizeof(DetailedGlyphStore) +
|
||||
mDetails.SizeOf() + mOffsetToIndex.SizeOf();
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) {
|
||||
return aMallocSizeOf(this, sizeof(DetailedGlyphStore)) +
|
||||
mDetails.SizeOfExcludingThis(aMallocSizeOf) +
|
||||
mOffsetToIndex.SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -220,8 +220,9 @@ protected:
|
|||
PRUint32 aEnd, PRUint32 aHash);
|
||||
void Uninit();
|
||||
|
||||
static PLDHashOperator MaybeSizeOfEntry(CacheHashEntry *aEntry,
|
||||
void *aUserData);
|
||||
static size_t MaybeSizeOfEntryExcludingThis(CacheHashEntry *aEntry,
|
||||
nsMallocSizeOfFun aMallocSizeOf,
|
||||
void *aUserData);
|
||||
static PLDHashOperator ResetSizeOfEntryAccountingFlags(CacheHashEntry *aEntry,
|
||||
void *aUserData);
|
||||
|
||||
|
@ -915,22 +916,16 @@ TextRunWordCache::RemoveTextRun(gfxTextRun *aTextRun)
|
|||
#endif
|
||||
}
|
||||
|
||||
struct SizeOfEntryData {
|
||||
nsMallocSizeOfFun mMallocSizeOf;
|
||||
size_t mTotal;
|
||||
SizeOfEntryData(nsMallocSizeOfFun mallocSizeOf)
|
||||
: mMallocSizeOf(mallocSizeOf), mTotal(0) { }
|
||||
};
|
||||
|
||||
/*static*/ PLDHashOperator
|
||||
TextRunWordCache::MaybeSizeOfEntry(CacheHashEntry *aEntry, void *aUserData)
|
||||
/*static*/ size_t
|
||||
TextRunWordCache::MaybeSizeOfEntryExcludingThis(CacheHashEntry *aEntry,
|
||||
nsMallocSizeOfFun aMallocSizeOf,
|
||||
void *)
|
||||
{
|
||||
gfxTextRun *run = aEntry->mTextRun;
|
||||
if (run) {
|
||||
SizeOfEntryData *data = static_cast<SizeOfEntryData*>(aUserData);
|
||||
data->mTotal += run->MaybeSizeOfIncludingThis(data->mMallocSizeOf);
|
||||
return run->MaybeSizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
return PL_DHASH_NEXT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*static*/ PLDHashOperator
|
||||
|
@ -946,11 +941,7 @@ TextRunWordCache::ResetSizeOfEntryAccountingFlags(CacheHashEntry *aEntry, void *
|
|||
size_t
|
||||
TextRunWordCache::MaybeSizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
{
|
||||
size_t total = mCache.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
SizeOfEntryData data(aMallocSizeOf);
|
||||
mCache.EnumerateEntries(MaybeSizeOfEntry, &data);
|
||||
total += data.mTotal;
|
||||
return total;
|
||||
return mCache.SizeOfExcludingThis(MaybeSizeOfEntryExcludingThis, aMallocSizeOf);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -785,47 +785,51 @@ JS_DHashTableEnumerate(JSDHashTable *table, JSDHashEnumerator etor, void *arg)
|
|||
return i;
|
||||
}
|
||||
|
||||
struct SizeOfEntryEnumeratorArg
|
||||
struct SizeOfEntryExcludingThisArg
|
||||
{
|
||||
size_t total;
|
||||
JSDHashSizeOfEntryFun sizeOfEntry;
|
||||
JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis;
|
||||
JSMallocSizeOfFun mallocSizeOf;
|
||||
void *arg; // the arg passed by the user
|
||||
};
|
||||
|
||||
static JSDHashOperator
|
||||
SizeOfEntryEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32_t number,
|
||||
void *arg)
|
||||
SizeOfEntryExcludingThisEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr,
|
||||
uint32_t number, void *arg)
|
||||
{
|
||||
SizeOfEntryEnumeratorArg *e = (SizeOfEntryEnumeratorArg *)arg;
|
||||
e->total += e->sizeOfEntry(hdr, e->mallocSizeOf);
|
||||
SizeOfEntryExcludingThisArg *e = (SizeOfEntryExcludingThisArg *)arg;
|
||||
e->total += e->sizeOfEntryExcludingThis(hdr, e->mallocSizeOf, e->arg);
|
||||
return JS_DHASH_NEXT;
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
JS_DHashTableSizeOfExcludingThis(const JSDHashTable *table,
|
||||
JSDHashSizeOfEntryFun sizeOfEntry,
|
||||
JSMallocSizeOfFun mallocSizeOf)
|
||||
JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
JSMallocSizeOfFun mallocSizeOf,
|
||||
void *arg /* = NULL */)
|
||||
{
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(table->entryStore,
|
||||
JS_DHASH_TABLE_SIZE(table) * table->entrySize +
|
||||
ENTRY_STORE_EXTRA);
|
||||
if (sizeOfEntry) {
|
||||
SizeOfEntryEnumeratorArg arg = { 0, sizeOfEntry, mallocSizeOf };
|
||||
if (sizeOfEntryExcludingThis) {
|
||||
SizeOfEntryExcludingThisArg arg2 = { 0, sizeOfEntryExcludingThis, mallocSizeOf, arg };
|
||||
JS_DHashTableEnumerate(const_cast<JSDHashTable *>(table),
|
||||
SizeOfEntryEnumerator, &arg);
|
||||
n += arg.total;
|
||||
SizeOfEntryExcludingThisEnumerator, &arg2);
|
||||
n += arg2.total;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
JS_DHashTableSizeOfIncludingThis(const JSDHashTable *table,
|
||||
JSDHashSizeOfEntryFun sizeOfEntry,
|
||||
JSMallocSizeOfFun mallocSizeOf)
|
||||
JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
JSMallocSizeOfFun mallocSizeOf,
|
||||
void *arg /* = NULL */)
|
||||
{
|
||||
return mallocSizeOf(table, sizeof(JSDHashTable)) +
|
||||
JS_DHashTableSizeOfExcludingThis(table, sizeOfEntry, mallocSizeOf);
|
||||
JS_DHashTableSizeOfExcludingThis(table, sizeOfEntryExcludingThis,
|
||||
mallocSizeOf, arg);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -580,26 +580,30 @@ extern JS_PUBLIC_API(uint32_t)
|
|||
JS_DHashTableEnumerate(JSDHashTable *table, JSDHashEnumerator etor, void *arg);
|
||||
|
||||
typedef size_t
|
||||
(* JSDHashSizeOfEntryFun)(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf);
|
||||
(* JSDHashSizeOfEntryExcludingThisFun)(JSDHashEntryHdr *hdr,
|
||||
JSMallocSizeOfFun mallocSizeOf,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Measure the size of the table's entry storage, and if |sizeOfEntry| is
|
||||
* non-NULL, measure the size of things pointed to by entries. Doesn't measure
|
||||
* |ops| because it's often shared between tables, nor |data| because it's
|
||||
* opaque.
|
||||
* Measure the size of the table's entry storage, and if
|
||||
* |sizeOfEntryExcludingThis| is non-NULL, measure the size of things pointed
|
||||
* to by entries. Doesn't measure |ops| because it's often shared between
|
||||
* tables, nor |data| because it's opaque.
|
||||
*/
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
JS_DHashTableSizeOfExcludingThis(const JSDHashTable *table,
|
||||
JSDHashSizeOfEntryFun sizeOfEntry,
|
||||
JSMallocSizeOfFun mallocSizeOf);
|
||||
JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
JSMallocSizeOfFun mallocSizeOf,
|
||||
void *arg = NULL);
|
||||
|
||||
/**
|
||||
* Like JS_DHashTableSizeOfExcludingThis, but includes sizeof(*this).
|
||||
*/
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
JS_DHashTableSizeOfIncludingThis(const JSDHashTable *table,
|
||||
JSDHashSizeOfEntryFun sizeOfEntry,
|
||||
JSMallocSizeOfFun mallocSizeOf);
|
||||
JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
JSMallocSizeOfFun mallocSizeOf,
|
||||
void *arg = NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
|
|
|
@ -140,12 +140,13 @@ JSObject2WrappedJSMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
|
|||
{
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(this, sizeof(JSObject2WrappedJSMap));
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntry, mallocSizeOf) : 0;
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* static */ size_t
|
||||
JSObject2WrappedJSMap::SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf)
|
||||
JSObject2WrappedJSMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr,
|
||||
JSMallocSizeOfFun mallocSizeOf, void *)
|
||||
{
|
||||
return mallocSizeOf(((JSObject2WrappedJSMap::Entry*)hdr)->value,
|
||||
sizeof(nsXPCWrappedJS));
|
||||
|
@ -182,12 +183,13 @@ Native2WrappedNativeMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
|
|||
{
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(this, sizeof(Native2WrappedNativeMap));
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntry, mallocSizeOf) : 0;
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* static */ size_t
|
||||
Native2WrappedNativeMap::SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf)
|
||||
Native2WrappedNativeMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr,
|
||||
JSMallocSizeOfFun mallocSizeOf, void *)
|
||||
{
|
||||
return mallocSizeOf(((Native2WrappedNativeMap::Entry*)hdr)->value,
|
||||
sizeof(XPCWrappedNative));
|
||||
|
@ -271,12 +273,13 @@ IID2NativeInterfaceMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
|
|||
{
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(this, sizeof(IID2NativeInterfaceMap));
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntry, mallocSizeOf) : 0;
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* static */ size_t
|
||||
IID2NativeInterfaceMap::SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf)
|
||||
IID2NativeInterfaceMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr,
|
||||
JSMallocSizeOfFun mallocSizeOf, void *)
|
||||
{
|
||||
XPCNativeInterface *iface = ((IID2NativeInterfaceMap::Entry*)hdr)->value;
|
||||
return iface->SizeOfIncludingThis(mallocSizeOf);
|
||||
|
@ -349,12 +352,13 @@ ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSiz
|
|||
{
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(this, sizeof(ClassInfo2WrappedNativeProtoMap));
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntry, mallocSizeOf) : 0;
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* static */ size_t
|
||||
ClassInfo2WrappedNativeProtoMap::SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf)
|
||||
ClassInfo2WrappedNativeProtoMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr,
|
||||
JSMallocSizeOfFun mallocSizeOf, void *)
|
||||
{
|
||||
return mallocSizeOf(((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value,
|
||||
sizeof(XPCWrappedNativeProto));
|
||||
|
@ -473,12 +477,12 @@ NativeSetMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
|
|||
{
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(this, sizeof(NativeSetMap));
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntry, mallocSizeOf) : 0;
|
||||
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* static */ size_t
|
||||
NativeSetMap::SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf)
|
||||
NativeSetMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *)
|
||||
{
|
||||
XPCNativeSet *set = ((NativeSetMap::Entry*)hdr)->key_value;
|
||||
return set->SizeOfIncludingThis(mallocSizeOf);
|
||||
|
|
|
@ -109,7 +109,7 @@ private:
|
|||
JSObject2WrappedJSMap(); // no implementation
|
||||
JSObject2WrappedJSMap(int size);
|
||||
|
||||
static size_t SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf);
|
||||
static size_t SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *);
|
||||
|
||||
private:
|
||||
JSDHashTable *mTable;
|
||||
|
@ -177,7 +177,7 @@ private:
|
|||
Native2WrappedNativeMap(); // no implementation
|
||||
Native2WrappedNativeMap(int size);
|
||||
|
||||
static size_t SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf);
|
||||
static size_t SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *);
|
||||
|
||||
private:
|
||||
JSDHashTable *mTable;
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
IID2NativeInterfaceMap(); // no implementation
|
||||
IID2NativeInterfaceMap(int size);
|
||||
|
||||
static size_t SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf);
|
||||
static size_t SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *);
|
||||
|
||||
private:
|
||||
JSDHashTable *mTable;
|
||||
|
@ -415,7 +415,7 @@ private:
|
|||
ClassInfo2WrappedNativeProtoMap(); // no implementation
|
||||
ClassInfo2WrappedNativeProtoMap(int size);
|
||||
|
||||
static size_t SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf);
|
||||
static size_t SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *);
|
||||
|
||||
private:
|
||||
JSDHashTable *mTable;
|
||||
|
@ -488,7 +488,7 @@ private:
|
|||
NativeSetMap(); // no implementation
|
||||
NativeSetMap(int size);
|
||||
|
||||
static size_t SizeOfEntry(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf);
|
||||
static size_t SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *);
|
||||
|
||||
private:
|
||||
JSDHashTable *mTable;
|
||||
|
|
|
@ -103,8 +103,8 @@ size_t
|
|||
nsTransformedTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
{
|
||||
size_t total = gfxTextRun::SizeOfExcludingThis(aMallocSizeOf);
|
||||
total += mStyles.SizeOf();
|
||||
total += mCapitalize.SizeOf();
|
||||
total += mStyles.SizeOfExcludingThis(aMallocSizeOf);
|
||||
total += mCapitalize.SizeOfExcludingThis(aMallocSizeOf);
|
||||
if (mOwnsFactory) {
|
||||
// It's not worth the effort to get all the sub-class cases right for a
|
||||
// small size in the fallback case. So we use a |computedSize| of 0, which
|
||||
|
|
|
@ -754,10 +754,10 @@ void RuleHash::EnumerateAllRules(Element* aElement, RuleProcessorData* aData,
|
|||
}
|
||||
|
||||
static size_t
|
||||
SizeOfRuleHashTableEntry(PLDHashEntryHdr* aHdr, nsMallocSizeOfFun aMallocSizeOf)
|
||||
SizeOfRuleHashTableEntry(PLDHashEntryHdr* aHdr, nsMallocSizeOfFun aMallocSizeOf, void *)
|
||||
{
|
||||
RuleHashTableEntry* entry = static_cast<RuleHashTableEntry*>(aHdr);
|
||||
return entry->mRules.SizeOf();
|
||||
return entry->mRules.SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -789,7 +789,7 @@ RuleHash::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
|||
aMallocSizeOf);
|
||||
}
|
||||
|
||||
n += mUniversalRules.SizeOf();
|
||||
n += mUniversalRules.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
@ -951,10 +951,10 @@ struct RuleCascadeData {
|
|||
};
|
||||
|
||||
static size_t
|
||||
SizeOfSelectorsEntry(PLDHashEntryHdr* aHdr, nsMallocSizeOfFun aMallocSizeOf)
|
||||
SizeOfSelectorsEntry(PLDHashEntryHdr* aHdr, nsMallocSizeOfFun aMallocSizeOf, void *)
|
||||
{
|
||||
AtomSelectorEntry* entry = static_cast<AtomSelectorEntry*>(aHdr);
|
||||
return entry->mSelectors.SizeOf();
|
||||
return entry->mSelectors.SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -968,15 +968,15 @@ RuleCascadeData::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
|||
n += mPseudoElementRuleHashes[i]->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
n += mStateSelectors.SizeOf();
|
||||
n += mStateSelectors.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mIdSelectors,
|
||||
SizeOfSelectorsEntry, aMallocSizeOf);
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mClassSelectors,
|
||||
SizeOfSelectorsEntry, aMallocSizeOf);
|
||||
|
||||
n += mPossiblyNegatedClassSelectors.SizeOf();
|
||||
n += mPossiblyNegatedIDSelectors.SizeOf();
|
||||
n += mPossiblyNegatedClassSelectors.SizeOfExcludingThis(aMallocSizeOf);
|
||||
n += mPossiblyNegatedIDSelectors.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
n += PL_DHashTableSizeOfExcludingThis(&mAttributeSelectors,
|
||||
SizeOfSelectorsEntry, aMallocSizeOf);
|
||||
|
@ -987,8 +987,8 @@ RuleCascadeData::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
|||
SizeOfRuleHashTableEntry, aMallocSizeOf);
|
||||
#endif
|
||||
|
||||
n += mFontFaceRules.SizeOf();
|
||||
n += mKeyframesRules.SizeOf();
|
||||
n += mFontFaceRules.SizeOfExcludingThis(aMallocSizeOf);
|
||||
n += mKeyframesRules.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
@ -2576,7 +2576,7 @@ nsCSSRuleProcessor::MediumFeaturesChanged(nsPresContext* aPresContext)
|
|||
nsCSSRuleProcessor::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
|
||||
{
|
||||
size_t n = 0;
|
||||
n += mSheets.SizeOf();
|
||||
n += mSheets.SizeOfExcludingThis(aMallocSizeOf);
|
||||
for (RuleCascadeData* cascade = mRuleCascades; cascade;
|
||||
cascade = cascade->mNext) {
|
||||
n += cascade->SizeOfIncludingThis(aMallocSizeOf);
|
||||
|
|
|
@ -1587,26 +1587,17 @@ History::FetchPageInfo(VisitData& _place)
|
|||
return true;
|
||||
}
|
||||
|
||||
PLDHashOperator
|
||||
History::SizeOfEnumerator(KeyClass* aEntry, void* aArg)
|
||||
/* static */ size_t
|
||||
History::SizeOfEntryExcludingThis(KeyClass* aEntry, nsMallocSizeOfFun aMallocSizeOf, void *)
|
||||
{
|
||||
PRInt64 *size = reinterpret_cast<PRInt64*>(aArg);
|
||||
|
||||
// Don't add in sizeof(*aEntry); that's already accounted for in
|
||||
// mObservers.SizeOf().
|
||||
*size += aEntry->array.SizeOf();
|
||||
return PL_DHASH_NEXT;
|
||||
return aEntry->array.SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
PRInt64
|
||||
size_t
|
||||
History::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOfThis)
|
||||
{
|
||||
PRInt64 size = aMallocSizeOfThis(this, sizeof(History)) +
|
||||
mObservers.ShallowSizeOfExcludingThis(aMallocSizeOfThis);
|
||||
if (mObservers.IsInitialized()) {
|
||||
mObservers.EnumerateEntries(SizeOfEnumerator, &size);
|
||||
}
|
||||
return size;
|
||||
return aMallocSizeOfThis(this, sizeof(History)) +
|
||||
mObservers.SizeOfExcludingThis(SizeOfEntryExcludingThis, aMallocSizeOfThis);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
* Get the number of bytes of memory this History object is using,
|
||||
* including sizeof(*this))
|
||||
*/
|
||||
PRInt64 SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
|
||||
|
||||
/**
|
||||
* Obtains a pointer to this service.
|
||||
|
@ -194,9 +194,12 @@ private:
|
|||
};
|
||||
|
||||
/**
|
||||
* Helper function for nsTHashtable::EnumerateEntries call in SizeOf().
|
||||
* Helper function for nsTHashtable::SizeOfExcludingThis call in
|
||||
* SizeOfIncludingThis().
|
||||
*/
|
||||
static PLDHashOperator SizeOfEnumerator(KeyClass* aEntry, void* aArg);
|
||||
static size_t SizeOfEntryExcludingThis(KeyClass* aEntry,
|
||||
nsMallocSizeOfFun aMallocSizeOf,
|
||||
void*);
|
||||
|
||||
nsTHashtable<KeyClass> mObservers;
|
||||
};
|
||||
|
|
|
@ -335,14 +335,14 @@ nsUrlClassifierPrefixSet::Contains(PRUint32 aPrefix, bool * aFound)
|
|||
}
|
||||
|
||||
size_t
|
||||
nsUrlClassifierPrefixSet::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
|
||||
nsUrlClassifierPrefixSet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
||||
{
|
||||
MutexAutoLock lock(mPrefixSetLock);
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(this, sizeof(nsUrlClassifierPrefixSet));
|
||||
n += mDeltas.SizeOf();
|
||||
n += mIndexPrefixes.SizeOf();
|
||||
n += mIndexStarts.SizeOf();
|
||||
n += aMallocSizeOf(this, sizeof(nsUrlClassifierPrefixSet));
|
||||
n += mDeltas.SizeOfExcludingThis(aMallocSizeOf);
|
||||
n += mIndexPrefixes.SizeOfExcludingThis(aMallocSizeOf);
|
||||
n += mIndexStarts.SizeOfExcludingThis(aMallocSizeOf);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
@ -515,14 +515,21 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
// @return The amount of memory taken used by this nsTArray, not including
|
||||
// @return The amount of memory used by this nsTArray, excluding
|
||||
// sizeof(*this).
|
||||
size_t SizeOf() const {
|
||||
size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const {
|
||||
if (this->UsesAutoArrayBuffer() || Hdr() == EmptyHdr())
|
||||
return 0;
|
||||
size_t usable = moz_malloc_usable_size(this->Hdr());
|
||||
return usable ? usable :
|
||||
this->Capacity() * sizeof(elem_type) + sizeof(*this->Hdr());
|
||||
return mallocSizeOf(this->Hdr(),
|
||||
sizeof(nsTArrayHeader) +
|
||||
this->Capacity() * sizeof(elem_type));
|
||||
}
|
||||
|
||||
// @return The amount of memory used by this nsTArray, including
|
||||
// sizeof(*this).
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) const {
|
||||
return mallocSizeOf(this, sizeof(nsTArray)) +
|
||||
SizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -252,13 +252,35 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* The "Shallow" means that if the entries contain pointers to other objects,
|
||||
* their size isn't included in the measuring.
|
||||
* 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
|
||||
*/
|
||||
size_t ShallowSizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf)
|
||||
typedef size_t (* SizeOfEntryExcludingThisFun)(EntryType* aEntry,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Measure the size of the table's entry storage, and if
|
||||
* |sizeOfEntryExcludingThis| is non-NULL, 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
|
||||
*/
|
||||
size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
nsMallocSizeOfFun mallocSizeOf, void *userArg = NULL)
|
||||
{
|
||||
if (IsInitialized()) {
|
||||
return PL_DHashTableSizeOfExcludingThis(&mTable, nsnull, mallocSizeOf);
|
||||
s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg };
|
||||
return PL_DHashTableSizeOfExcludingThis(&mTable, s_SizeOfStub, mallocSizeOf, &args);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -304,6 +326,24 @@ protected:
|
|||
PLDHashEntryHdr *entry,
|
||||
PRUint32 number,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* passed internally during sizeOf counting. Allocated on the stack.
|
||||
*
|
||||
* @param userFunc the SizeOfEntryExcludingThisFun passed to
|
||||
* SizeOf{In,Ex}cludingThis by the client
|
||||
* @param userArg the userArg passed unaltered
|
||||
*/
|
||||
struct s_SizeOfArgs
|
||||
{
|
||||
SizeOfEntryExcludingThisFun userFunc;
|
||||
void* userArg;
|
||||
};
|
||||
|
||||
static size_t s_SizeOfStub(PLDHashEntryHdr *entry,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg);
|
||||
|
||||
private:
|
||||
// copy constructor, not implemented
|
||||
nsTHashtable(nsTHashtable<EntryType>& toCopy);
|
||||
|
@ -432,4 +472,17 @@ nsTHashtable<EntryType>::s_EnumStub(PLDHashTable *table,
|
|||
reinterpret_cast<s_EnumArgs*>(arg)->userArg);
|
||||
}
|
||||
|
||||
template<class EntryType>
|
||||
size_t
|
||||
nsTHashtable<EntryType>::s_SizeOfStub(PLDHashEntryHdr *entry,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg)
|
||||
{
|
||||
// dereferences the function-pointer to the user's enumeration function
|
||||
return (* reinterpret_cast<s_SizeOfArgs*>(arg)->userFunc)(
|
||||
reinterpret_cast<EntryType*>(entry),
|
||||
mallocSizeOf,
|
||||
reinterpret_cast<s_SizeOfArgs*>(arg)->userArg);
|
||||
}
|
||||
|
||||
#endif // nsTHashtable_h__
|
||||
|
|
|
@ -245,8 +245,8 @@ class nsAutoTObserverArray : protected nsTObserverArray_base {
|
|||
|
||||
// Returns the number of bytes on the heap taken up by this object, not
|
||||
// including sizeof(*this).
|
||||
PRUint64 SizeOf() {
|
||||
return mArray.SizeOf();
|
||||
size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) {
|
||||
return mArray.SizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -794,47 +794,51 @@ PL_DHashTableEnumerate(PLDHashTable *table, PLDHashEnumerator etor, void *arg)
|
|||
return i;
|
||||
}
|
||||
|
||||
struct SizeOfEntryEnumeratorArg
|
||||
struct SizeOfEntryExcludingThisArg
|
||||
{
|
||||
size_t total;
|
||||
PLDHashSizeOfEntryFun sizeOfEntry;
|
||||
PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis;
|
||||
nsMallocSizeOfFun mallocSizeOf;
|
||||
void *arg; // the arg passed by the user
|
||||
};
|
||||
|
||||
static PLDHashOperator
|
||||
SizeOfEntryEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
PRUint32 number, void *arg)
|
||||
SizeOfEntryExcludingThisEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
PRUint32 number, void *arg)
|
||||
{
|
||||
SizeOfEntryEnumeratorArg *e = (SizeOfEntryEnumeratorArg *)arg;
|
||||
e->total += e->sizeOfEntry(hdr, e->mallocSizeOf);
|
||||
SizeOfEntryExcludingThisArg *e = (SizeOfEntryExcludingThisArg *)arg;
|
||||
e->total += e->sizeOfEntryExcludingThis(hdr, e->mallocSizeOf, e->arg);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
size_t
|
||||
PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table,
|
||||
PLDHashSizeOfEntryFun sizeOfEntry,
|
||||
nsMallocSizeOfFun mallocSizeOf)
|
||||
PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg /* = NULL */)
|
||||
{
|
||||
size_t n = 0;
|
||||
n += mallocSizeOf(table->entryStore,
|
||||
PL_DHASH_TABLE_SIZE(table) * table->entrySize +
|
||||
ENTRY_STORE_EXTRA);
|
||||
if (sizeOfEntry) {
|
||||
SizeOfEntryEnumeratorArg arg = { 0, sizeOfEntry, mallocSizeOf };
|
||||
if (sizeOfEntryExcludingThis) {
|
||||
SizeOfEntryExcludingThisArg arg2 = { 0, sizeOfEntryExcludingThis, mallocSizeOf, arg };
|
||||
PL_DHashTableEnumerate(const_cast<PLDHashTable *>(table),
|
||||
SizeOfEntryEnumerator, &arg);
|
||||
n += arg.total;
|
||||
SizeOfEntryExcludingThisEnumerator, &arg2);
|
||||
n += arg2.total;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t
|
||||
PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table,
|
||||
PLDHashSizeOfEntryFun sizeOfEntry,
|
||||
nsMallocSizeOfFun mallocSizeOf)
|
||||
PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg /* = NULL */)
|
||||
{
|
||||
return mallocSizeOf(table, sizeof(PLDHashTable)) +
|
||||
PL_DHashTableSizeOfExcludingThis(table, sizeOfEntry, mallocSizeOf);
|
||||
PL_DHashTableSizeOfExcludingThis(table, sizeOfEntryExcludingThis,
|
||||
mallocSizeOf, arg);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -579,26 +579,30 @@ NS_COM_GLUE PRUint32
|
|||
PL_DHashTableEnumerate(PLDHashTable *table, PLDHashEnumerator etor, void *arg);
|
||||
|
||||
typedef size_t
|
||||
(* PLDHashSizeOfEntryFun)(PLDHashEntryHdr *hdr, nsMallocSizeOfFun mallocSizeOf);
|
||||
(* PLDHashSizeOfEntryExcludingThisFun)(PLDHashEntryHdr *hdr,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Measure the size of the table's entry storage, and if |sizeOfEntry| is
|
||||
* non-NULL, measure the size of things pointed to by entries. Doesn't measure
|
||||
* |ops| because it's often shared between tables, nor |data| because it's
|
||||
* opaque.
|
||||
* Measure the size of the table's entry storage, and if
|
||||
* |sizeOfEntryExcludingThis| is non-NULL, measure the size of things pointed
|
||||
* to by entries. Doesn't measure |ops| because it's often shared between
|
||||
* tables, nor |data| because it's opaque.
|
||||
*/
|
||||
NS_COM_GLUE size_t
|
||||
PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table,
|
||||
PLDHashSizeOfEntryFun sizeOfEntry,
|
||||
nsMallocSizeOfFun mallocSizeOf);
|
||||
PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg = NULL);
|
||||
|
||||
/**
|
||||
* Like PL_DHashTableSizeOfExcludingThis, but includes sizeof(*this).
|
||||
*/
|
||||
NS_COM_GLUE size_t
|
||||
PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table,
|
||||
PLDHashSizeOfEntryFun sizeOfEntry,
|
||||
nsMallocSizeOfFun mallocSizeOf);
|
||||
PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
|
||||
nsMallocSizeOfFun mallocSizeOf,
|
||||
void *arg = NULL);
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче