Bug 715453 - Remove computedSize from nsMallocSizeOfFun. r=jlebar,bhackett.

--HG--
extra : rebase_source : a65039a407daab45360a5b375b53cbf1bc05b7f6
This commit is contained in:
Nicholas Nethercote 2012-01-25 00:52:51 -08:00
parent 40b8155c12
commit a7ad4ef70e
46 changed files with 94 additions and 152 deletions

View File

@ -102,12 +102,10 @@ NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(HunspellMallocSizeOfForCounterInc, "hunspel
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN_UN(HunspellMallocSizeOfForCounterDec)
void HunspellReportMemoryAllocation(void* ptr) {
// |computedSize| is zero because we don't know what it is.
gHunspellAllocatedSize += HunspellMallocSizeOfForCounterInc(ptr, 0);
gHunspellAllocatedSize += HunspellMallocSizeOfForCounterInc(ptr);
}
void HunspellReportMemoryDeallocation(void* ptr) {
// |computedSize| is zero because we don't know what it is.
gHunspellAllocatedSize -= HunspellMallocSizeOfForCounterDec(ptr, 0);
gHunspellAllocatedSize -= HunspellMallocSizeOfForCounterDec(ptr);
}
static PRInt64 HunspellGetCurrentAllocatedSize() {
return gHunspellAllocatedSize;

View File

@ -5279,10 +5279,7 @@ gfxTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
size_t
gfxTextRun::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
{
// The second arg is how much gfxTextRun::AllocateStorageForTextRun would
// have allocated, given the character count of this run.
return aMallocSizeOf(this, sizeof(gfxTextRun) + sizeof(CompressedGlyph) * GetLength()) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}

View File

@ -2105,7 +2105,7 @@ private:
}
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) {
return aMallocSizeOf(this, sizeof(DetailedGlyphStore)) +
return aMallocSizeOf(this) +
mDetails.SizeOfExcludingThis(aMallocSizeOf) +
mOffsetToIndex.SizeOfExcludingThis(aMallocSizeOf);
}

View File

@ -658,11 +658,11 @@ class HashTable : private AllocPolicy
}
size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const {
return mallocSizeOf(table, capacity() * sizeof(Entry));
return mallocSizeOf(table);
}
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const {
return mallocSizeOf(this, sizeof(HashTable)) + sizeOfExcludingThis(mallocSizeOf);
return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf);
}
Ptr lookup(const Lookup &l) const {
@ -1072,7 +1072,7 @@ class HashMap
* Don't just call |impl.sizeOfExcludingThis()| because there's no
* guarantee that |impl| is the first field in HashMap.
*/
return mallocSizeOf(this, sizeof(*this)) + impl.sizeOfExcludingThis(mallocSizeOf);
return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf);
}
/*
@ -1282,7 +1282,7 @@ class HashSet
* Don't just call |impl.sizeOfExcludingThis()| because there's no
* guarantee that |impl| is the first field in HashSet.
*/
return mallocSizeOf(this, sizeof(*this)) + impl.sizeOfExcludingThis(mallocSizeOf);
return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf);
}
/*

View File

@ -866,7 +866,7 @@ RoundUpPow2(size_t x)
/*
* This is SpiderMonkey's equivalent to |nsMallocSizeOfFun|.
*/
typedef size_t(*JSMallocSizeOfFun)(const void *p, size_t computedSize);
typedef size_t(*JSMallocSizeOfFun)(const void *p);
/* sixgill annotation defines */
#ifndef HAVE_STATIC_ANNOTATIONS

View File

@ -220,7 +220,7 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data)
ArenaCallback, CellCallback);
IterateChunks(cx, data, ChunkCallback);
data->runtimeObject = data->mallocSizeOf(rt, sizeof(JSRuntime));
data->runtimeObject = data->mallocSizeOf(rt);
size_t normal, temporary, regexpCode, stackCommitted;
rt->sizeOfExcludingThis(data->mallocSizeOf,

View File

@ -114,7 +114,7 @@ class BumpChunk
size_t used() const { return bump - bumpBase(); }
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) {
return mallocSizeOf(this, limit - headerBase());
return mallocSizeOf(this);
}
void resetBump() {
@ -305,8 +305,7 @@ class LifoAlloc
/* Like sizeOfExcludingThis(), but includes the size of the LifoAlloc itself. */
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const {
return mallocSizeOf(this, sizeof(LifoAlloc)) +
sizeOfExcludingThis(mallocSizeOf);
return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf);
}
/* Doesn't perform construction; useful for lazily-initialized POD types. */

View File

@ -96,12 +96,8 @@ void
JSRuntime::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *normal, size_t *temporary,
size_t *regexpCode, size_t *stackCommitted)
{
/*
* The computedSize is 0 because sizeof(DtoaState) isn't available here and
* it's not worth making it available.
*/
if (normal)
*normal = mallocSizeOf(dtoaState, /* sizeof(DtoaState) */0);
*normal = mallocSizeOf(dtoaState);
if (temporary)
*temporary = tempLifoAlloc.sizeOfExcludingThis(mallocSizeOf);
@ -1318,8 +1314,7 @@ JSContext::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const
* ones have been found by DMD to be worth measuring. More stuff may be
* added later.
*/
return mallocSizeOf(this, sizeof(JSContext)) +
busyArrays.sizeOfExcludingThis(mallocSizeOf);
return mallocSizeOf(this) + busyArrays.sizeOfExcludingThis(mallocSizeOf);
}
namespace JS {

View File

@ -808,9 +808,7 @@ JS_DHashTableSizeOfExcludingThis(const JSDHashTable *table,
void *arg /* = NULL */)
{
size_t n = 0;
n += mallocSizeOf(table->entryStore,
JS_DHASH_TABLE_SIZE(table) * table->entrySize +
ENTRY_STORE_EXTRA);
n += mallocSizeOf(table->entryStore);
if (sizeOfEntryExcludingThis) {
SizeOfEntryExcludingThisArg arg2 = { 0, sizeOfEntryExcludingThis, mallocSizeOf, arg };
JS_DHashTableEnumerate(const_cast<JSDHashTable *>(table),
@ -826,7 +824,7 @@ JS_DHashTableSizeOfIncludingThis(const JSDHashTable *table,
JSMallocSizeOfFun mallocSizeOf,
void *arg /* = NULL */)
{
return mallocSizeOf(table, sizeof(JSDHashTable)) +
return mallocSizeOf(table) +
JS_DHashTableSizeOfExcludingThis(table, sizeOfEntryExcludingThis,
mallocSizeOf, arg);
}

View File

@ -6304,18 +6304,18 @@ GetScriptMemoryStats(JSScript *script, TypeInferenceMemoryStats *stats, JSMalloc
/* If TI is disabled, a single TypeScript is still present. */
if (!script->compartment()->types.inferenceEnabled) {
stats->scripts += mallocSizeOf(typeScript, sizeof(TypeScript));
stats->scripts += mallocSizeOf(typeScript);
return;
}
stats->scripts += mallocSizeOf(typeScript->nesting, sizeof(TypeScriptNesting));
stats->scripts += mallocSizeOf(typeScript->nesting);
unsigned count = TypeScript::NumTypeSets(script);
stats->scripts += mallocSizeOf(typeScript, sizeof(TypeScript) + count * sizeof(TypeSet));
stats->scripts += mallocSizeOf(typeScript);
TypeResult *result = typeScript->dynamicList;
while (result) {
stats->scripts += mallocSizeOf(result, sizeof(TypeResult));
stats->scripts += mallocSizeOf(result);
result = result->next;
}
@ -6345,8 +6345,7 @@ JS::SizeOfCompartmentTypeInferenceData(JSContext *cx, JSCompartment *compartment
/* Pending arrays are cleared on GC along with the analysis pool. */
stats->temporary +=
mallocSizeOf(compartment->types.pendingArray,
sizeof(TypeCompartment::PendingWork) * compartment->types.pendingCapacity);
mallocSizeOf(compartment->types.pendingArray);
/* TypeCompartment::pendingRecompiles is non-NULL only while inference code is running. */
JS_ASSERT(!compartment->types.pendingRecompiles);
@ -6371,8 +6370,7 @@ JS::SizeOfCompartmentTypeInferenceData(JSContext *cx, JSCompartment *compartment
const ObjectTableEntry &value = e.front().value;
/* key.ids and values.types have the same length. */
stats->tables += mallocSizeOf(key.ids, key.nslots * sizeof(jsid)) +
mallocSizeOf(value.types, key.nslots * sizeof(Type));
stats->tables += mallocSizeOf(key.ids) + mallocSizeOf(value.types);
}
}
}
@ -6392,16 +6390,8 @@ JS::SizeOfTypeObjectExcludingThis(void *object_, TypeInferenceMemoryStats *stats
return;
}
if (object->newScript) {
/* The initializerList is tacked onto the end of the TypeNewScript. */
size_t computedSize = sizeof(TypeNewScript);
for (TypeNewScript::Initializer *init = object->newScript->initializerList; ; init++) {
computedSize += sizeof(TypeNewScript::Initializer);
if (init->kind == TypeNewScript::Initializer::DONE)
break;
}
stats->objects += mallocSizeOf(object->newScript, computedSize);
}
if (object->newScript)
stats->objects += mallocSizeOf(object->newScript);
/*
* This counts memory that is in the temp pool but gets attributed

View File

@ -1218,7 +1218,7 @@ JSObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
{
if (hasDynamicSlots()) {
size_t computedSize = numDynamicSlots() * sizeof(js::Value);
*slotsSize = mallocSizeOf ? mallocSizeOf(slots, computedSize) : computedSize;
*slotsSize = mallocSizeOf ? mallocSizeOf(slots) : computedSize;
} else {
*slotsSize = 0;
}
@ -1227,7 +1227,7 @@ JSObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
(js::ObjectElements::VALUES_PER_HEADER +
getElementsHeader()->capacity) * sizeof(js::Value);
*elementsSize =
mallocSizeOf ? mallocSizeOf(getElementsHeader(), computedSize) : computedSize;
mallocSizeOf ? mallocSizeOf(getElementsHeader()) : computedSize;
} else {
*elementsSize = 0;
}

View File

@ -177,8 +177,7 @@ struct PropertyTable {
* heap-allocated) and its |entries| array.
*/
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const {
return mallocSizeOf(this, sizeof(PropertyTable)) +
mallocSizeOf(entries, sizeOfEntries(capacity()));
return mallocSizeOf(this) + mallocSizeOf(entries);
}
/* Whether we need to grow. We want to do this if the load factor is >= 0.75 */

View File

@ -1287,7 +1287,7 @@ JSScript::sizeOfData(JSMallocSizeOfFun mallocSizeOf)
return 0;
#endif
return mallocSizeOf(data, computedSizeOfData());
return mallocSizeOf(data);
}
/*

View File

@ -637,7 +637,11 @@ struct JSScript : public js::gc::Cell {
size_t *addressOfUseCount() { return &useCount; }
void resetUseCount() { useCount = 0; }
/* Size of the JITScript and all sections. (This method is implemented in MethodJIT.cpp.) */
/*
* Size of the JITScript and all sections. If |mallocSizeOf| is NULL, the
* size is computed analytically. (This method is implemented in
* MethodJIT.cpp.)
*/
size_t sizeOfJitScripts(JSMallocSizeOfFun mallocSizeOf);
#endif

View File

@ -1375,10 +1375,7 @@ JSScript::sizeOfJitScripts(JSMallocSizeOfFun mallocSizeOf)
size_t
mjit::JITScript::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf)
{
size_t computedSize = sizeof(JITScript) +
(nchunks * sizeof(ChunkDescriptor)) +
(nedges * sizeof(CrossChunkEdge));
size_t n = mallocSizeOf(this, computedSize);
size_t n = mallocSizeOf(this);
for (unsigned i = 0; i < nchunks; i++) {
const ChunkDescriptor &desc = chunkDescriptor(i);
if (desc.chunk)
@ -1413,7 +1410,7 @@ mjit::JITChunk::computedSizeOfIncludingThis()
size_t
mjit::JITChunk::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf)
{
return mallocSizeOf(this, computedSizeOfIncludingThis());
return mallocSizeOf(this);
}
void

View File

@ -96,7 +96,7 @@ JSString::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf)
/* JSExtensibleString: count the full capacity, not just the used space. */
if (isExtensible()) {
JSExtensibleString &extensible = asExtensible();
return mallocSizeOf(extensible.chars(), asExtensible().capacity() * sizeof(jschar));
return mallocSizeOf(extensible.chars());
}
JS_ASSERT(isFixed());
@ -111,7 +111,7 @@ JSString::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf)
/* JSAtom, JSFixedString: count the chars. +1 for the null char. */
JSFixedString &fixed = asFixed();
return mallocSizeOf(fixed.chars(), (length() + 1) * sizeof(jschar));
return mallocSizeOf(fixed.chars());
}
static JS_ALWAYS_INLINE bool

View File

@ -973,7 +973,7 @@ size_t
XPCJSRuntime::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(XPCJSRuntime));
n += mallocSizeOf(this);
n += mWrappedJSMap->SizeOfIncludingThis(mallocSizeOf);
n += mIID2NativeInterfaceMap->SizeOfIncludingThis(mallocSizeOf);
n += mClassInfo2NativeSetMap->ShallowSizeOfIncludingThis(mallocSizeOf);

View File

@ -141,7 +141,7 @@ size_t
JSObject2WrappedJSMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(JSObject2WrappedJSMap));
n += mallocSizeOf(this);
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
return n;
}
@ -150,8 +150,7 @@ JSObject2WrappedJSMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
JSObject2WrappedJSMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr,
JSMallocSizeOfFun mallocSizeOf, void *)
{
return mallocSizeOf(((JSObject2WrappedJSMap::Entry*)hdr)->value,
sizeof(nsXPCWrappedJS));
return mallocSizeOf(((JSObject2WrappedJSMap::Entry*)hdr)->value);
}
/***************************************************************************/
@ -184,7 +183,7 @@ size_t
Native2WrappedNativeMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(Native2WrappedNativeMap));
n += mallocSizeOf(this);
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
return n;
}
@ -193,8 +192,7 @@ Native2WrappedNativeMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
Native2WrappedNativeMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr,
JSMallocSizeOfFun mallocSizeOf, void *)
{
return mallocSizeOf(((Native2WrappedNativeMap::Entry*)hdr)->value,
sizeof(XPCWrappedNative));
return mallocSizeOf(((Native2WrappedNativeMap::Entry*)hdr)->value);
}
/***************************************************************************/
@ -274,7 +272,7 @@ size_t
IID2NativeInterfaceMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(IID2NativeInterfaceMap));
n += mallocSizeOf(this);
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
return n;
}
@ -317,7 +315,7 @@ size_t
ClassInfo2NativeSetMap::ShallowSizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(ClassInfo2NativeSetMap));
n += mallocSizeOf(this);
// The second arg is NULL because this is a "shallow" measurement of the map.
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, NULL, mallocSizeOf) : 0;
return n;
@ -353,7 +351,7 @@ size_t
ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(ClassInfo2WrappedNativeProtoMap));
n += mallocSizeOf(this);
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
return n;
}
@ -362,8 +360,7 @@ ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSiz
ClassInfo2WrappedNativeProtoMap::SizeOfEntryExcludingThis(JSDHashEntryHdr *hdr,
JSMallocSizeOfFun mallocSizeOf, void *)
{
return mallocSizeOf(((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value,
sizeof(XPCWrappedNativeProto));
return mallocSizeOf(((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value);
}
/***************************************************************************/
@ -478,7 +475,7 @@ size_t
NativeSetMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(NativeSetMap));
n += mallocSizeOf(this);
n += mTable ? JS_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
return n;
}

View File

@ -419,11 +419,7 @@ XPCNativeInterface::DestroyInstance(XPCNativeInterface* inst)
size_t
XPCNativeInterface::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t computedSize = sizeof(XPCNativeInterface);
if (mMemberCount > 1)
computedSize += (mMemberCount - 1) * sizeof(XPCNativeMember);
return mallocSizeOf(this, computedSize);
return mallocSizeOf(this);
}
void
@ -785,11 +781,7 @@ XPCNativeSet::DestroyInstance(XPCNativeSet* inst)
size_t
XPCNativeSet::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t computedSize = sizeof(XPCNativeSet);
if (mInterfaceCount > 1)
computedSize += (mInterfaceCount - 1) * sizeof(XPCNativeInterface *);
return mallocSizeOf(this, computedSize);
return mallocSizeOf(this);
}
void

View File

@ -974,7 +974,7 @@ size_t
XPCWrappedNativeScope::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
n += mallocSizeOf(this, sizeof(XPCWrappedNativeScope));
n += mallocSizeOf(this);
n += mWrappedNativeMap->SizeOfIncludingThis(mallocSizeOf);
n += mWrappedNativeProtoMap->SizeOfIncludingThis(mallocSizeOf);
n += mMainThreadWrappedNativeProtoMap->SizeOfIncludingThis(mallocSizeOf);

View File

@ -209,7 +209,7 @@ bool StringToJsval(JSContext *cx, nsString &str, JS::Value *rval);
void *GetCompartmentName(JSContext *cx, JSCompartment *c);
void DestroyCompartmentName(void *string);
size_t JsMallocSizeOf(const void *ptr, size_t computedSize);
size_t JsMallocSizeOf(const void *ptr);
} // namespace xpc

View File

@ -389,14 +389,14 @@ struct nsPresArena::State {
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this, sizeof(*this));
size_t n = aMallocSizeOf(this);
// The first PLArena is within the PLArenaPool, i.e. within |this|, so we
// don't measure it. Subsequent PLArenas are by themselves and must be
// measured.
const PLArena *arena = mPool.first.next;
while (arena) {
n += aMallocSizeOf(arena, arena->limit - arena->base);
n += aMallocSizeOf(arena);
arena = arena->next;
}
return n;

View File

@ -971,8 +971,7 @@ public:
}
virtual NS_MUST_OVERRIDE size_t
SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
return aMallocSizeOf(this, sizeof(nsPresContext)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
bool IsRootContentDocument();
@ -1325,8 +1324,7 @@ public:
}
virtual NS_MUST_OVERRIDE size_t
SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE {
return aMallocSizeOf(this, sizeof(nsRootPresContext)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
protected:

View File

@ -138,10 +138,10 @@ public:
size_t n = 0;
StackBlock *block = mBlocks;
while (block) {
n += aMallocSizeOf(block, sizeof(StackBlock));
n += aMallocSizeOf(block);
block = block->mNext;
}
n += aMallocSizeOf(mMarks, mMarkLength * sizeof(StackMark));
n += aMallocSizeOf(mMarks);
return n;
}
@ -904,7 +904,7 @@ public:
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
size_t n = 0;
n += aMallocSizeOf(this, sizeof(PresShell));
n += aMallocSizeOf(this);
n += mStackArena.SizeOfExcludingThis(aMallocSizeOf);
n += mFrameArena.SizeOfExcludingThis(aMallocSizeOf);

View File

@ -103,10 +103,7 @@ nsTransformedTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
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
// disables any usable vs. computedSize checking done by aMallocSizeOf.
total += aMallocSizeOf(mFactory, 0);
total += aMallocSizeOf(mFactory);
}
return total;
}
@ -114,9 +111,7 @@ nsTransformedTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
size_t
nsTransformedTextRun::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
{
return aMallocSizeOf(this, sizeof(nsTransformedTextRun) +
GetLength() * sizeof(CompressedGlyph)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
nsTransformedTextRun*

View File

@ -136,8 +136,7 @@ CommonAnimationManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) con
/* virtual */ size_t
CommonAnimationManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this, sizeof(CommonAnimationManager)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
/* static */ bool

View File

@ -443,8 +443,7 @@ nsAnimationManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
/* virtual */ size_t
nsAnimationManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this, sizeof(nsAnimationManager)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
nsIStyleRule*

View File

@ -797,8 +797,7 @@ RuleHash::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
size_t
RuleHash::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this, sizeof(RuleHash)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
//--------------------------------
@ -960,7 +959,7 @@ SizeOfSelectorsEntry(PLDHashEntryHdr* aHdr, nsMallocSizeOfFun aMallocSizeOf, voi
size_t
RuleCascadeData::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this, sizeof(RuleCascadeData));
size_t n = aMallocSizeOf(this);
n += mRuleHash.SizeOfExcludingThis(aMallocSizeOf);
for (PRUint32 i = 0; i < ArrayLength(mPseudoElementRuleHashes); ++i) {
@ -2588,8 +2587,7 @@ nsCSSRuleProcessor::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
/* virtual */ size_t
nsCSSRuleProcessor::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this, sizeof(nsCSSRuleProcessor)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
// Append all the currently-active font face rules to aArray. Return

View File

@ -172,8 +172,7 @@ nsHTMLCSSStyleSheet::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
/* virtual */ size_t
nsHTMLCSSStyleSheet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this, sizeof(nsHTMLCSSStyleSheet)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
void

View File

@ -148,7 +148,7 @@ nsStyleSet::nsStyleSet()
size_t
nsStyleSet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this, sizeof(nsStyleSet));
size_t n = aMallocSizeOf(this);
for (int i = 0; i < eSheetTypeCount; i++) {
if (mRuleProcessors[i]) {

View File

@ -724,8 +724,7 @@ nsTransitionManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
/* virtual */ size_t
nsTransitionManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this, sizeof(nsTransitionManager)) +
SizeOfExcludingThis(aMallocSizeOf);
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
struct TransitionEventInfo {

View File

@ -271,10 +271,9 @@ moz_malloc_usable_size(void *ptr)
#endif
}
size_t moz_malloc_size_of(const void *ptr, size_t computedSize)
size_t moz_malloc_size_of(const void *ptr)
{
size_t usable = moz_malloc_usable_size((void *)ptr);
return usable ? usable : computedSize;
return moz_malloc_usable_size((void *)ptr);
}
namespace mozilla {

View File

@ -135,7 +135,7 @@ MOZALLOC_EXPORT char* moz_strdup(const char* str)
MOZALLOC_EXPORT size_t moz_malloc_usable_size(void *ptr);
MOZALLOC_EXPORT size_t moz_malloc_size_of(const void *ptr, size_t computedSize);
MOZALLOC_EXPORT size_t moz_malloc_size_of(const void *ptr);
#if defined(HAVE_STRNDUP)
MOZALLOC_EXPORT char* moz_xstrndup(const char* str, size_t strsize)

View File

@ -169,8 +169,7 @@ nsDiskCacheMap::Open(nsILocalFile * cacheDirectory)
{
// extra scope so the compiler doesn't barf on the above gotos jumping
// past this declaration down here
PRUint32 overhead =
moz_malloc_size_of(mRecordArray, mHeader.mRecordCount * sizeof(nsDiskCacheRecord));
PRUint32 overhead = moz_malloc_size_of(mRecordArray);
mozilla::Telemetry::Accumulate(mozilla::Telemetry::HTTP_DISK_CACHE_OVERHEAD,
overhead);
}

View File

@ -367,7 +367,7 @@ StartupCache::HeapSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
{
// This function could measure more members, but they haven't been found by
// DMD to be significant. They can be added later if necessary.
return aMallocSizeOf(this, sizeof(StartupCache)) +
return aMallocSizeOf(this) +
mTable.SizeOfExcludingThis(SizeOfEntryExcludingThis, aMallocSizeOf);
}

View File

@ -115,7 +115,7 @@ struct CacheEntry
}
size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) {
return mallocSizeOf(data, size);
return mallocSizeOf(data);
}
};

View File

@ -1705,7 +1705,7 @@ History::SizeOfEntryExcludingThis(KeyClass* aEntry, nsMallocSizeOfFun aMallocSiz
size_t
History::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOfThis)
{
return aMallocSizeOfThis(this, sizeof(History)) +
return aMallocSizeOfThis(this) +
mObservers.SizeOfExcludingThis(SizeOfEntryExcludingThis, aMallocSizeOfThis);
}

View File

@ -350,7 +350,7 @@ nsUrlClassifierPrefixSet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
{
MutexAutoLock lock(mPrefixSetLock);
size_t n = 0;
n += aMallocSizeOf(this, sizeof(nsUrlClassifierPrefixSet));
n += aMallocSizeOf(this);
n += mDeltas.SizeOfExcludingThis(aMallocSizeOf);
n += mIndexPrefixes.SizeOfExcludingThis(aMallocSizeOf);
n += mIndexStarts.SizeOfExcludingThis(aMallocSizeOf);

View File

@ -345,11 +345,8 @@ namespace mozilla {
/*
* Functions generated via this macro should be used by all traversal-based
* memory reporters. Such functions return moz_malloc_usable_size(ptr),
* which will be 0 on obscure platforms that don't implement
* malloc_usable_size() or an equivalent.
*
* XXX: bug 715453 will remove the unused |computedSize| argument.
* memory reporters. Such functions return |moz_malloc_size_of(ptr)|; this
* will always be zero on some obscure platforms.
*
* You might be wondering why we have a macro that creates multiple functions
* distinguished only by |name|, instead of a single MemoryReporterMallocSizeOf
@ -359,9 +356,9 @@ namespace mozilla {
* the relevant memory reporter(s).
*/
#define NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(fn, name) \
size_t fn(const void *ptr, size_t computedSize) \
size_t fn(const void *ptr) \
{ \
size_t usable = moz_malloc_usable_size((void*)ptr); \
size_t usable = moz_malloc_size_of(ptr); \
VALGRIND_DMD_REPORT(ptr, usable, name); \
return usable; \
}
@ -371,9 +368,9 @@ namespace mozilla {
* "unreport" message to DMD.
*/
#define NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN_UN(fn) \
size_t fn(const void *ptr, size_t computedSize) \
size_t fn(const void *ptr) \
{ \
size_t usable = moz_malloc_usable_size((void*)ptr); \
size_t usable = moz_malloc_size_of(ptr); \
VALGRIND_DMD_UNREPORT(ptr); \
return usable; \
}

View File

@ -58,11 +58,10 @@
#include "prtypes.h"
/*
* This is for functions that are like malloc_usable_size but also take a
* computed size as a fallback. Such functions are used for measuring the size
* of data structures.
* This is for functions that are like malloc_usable_size. Such functions are
* used for measuring the size of data structures.
*/
typedef size_t(*nsMallocSizeOfFun)(const void *p, size_t computedSize);
typedef size_t(*nsMallocSizeOfFun)(const void *p);
/* Core XPCOM declarations. */

View File

@ -453,7 +453,7 @@ AtomImpl::IsStaticAtom()
size_t
AtomImpl::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return aMallocSizeOf(this, sizeof(AtomImpl)) +
return aMallocSizeOf(this) +
nsStringBuffer::FromData(mString)->
SizeOfIncludingThisIfUnshared(aMallocSizeOf);
}

View File

@ -522,16 +522,13 @@ public:
size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const {
if (this->UsesAutoArrayBuffer() || Hdr() == EmptyHdr())
return 0;
return mallocSizeOf(this->Hdr(),
sizeof(nsTArrayHeader) +
this->Capacity() * sizeof(elem_type));
return mallocSizeOf(this->Hdr());
}
// @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);
return mallocSizeOf(this) + SizeOfExcludingThis(mallocSizeOf);
}
//

View File

@ -818,9 +818,7 @@ PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table,
void *arg /* = NULL */)
{
size_t n = 0;
n += mallocSizeOf(table->entryStore,
PL_DHASH_TABLE_SIZE(table) * table->entrySize +
ENTRY_STORE_EXTRA);
n += mallocSizeOf(table->entryStore);
if (sizeOfEntryExcludingThis) {
SizeOfEntryExcludingThisArg arg2 = { 0, sizeOfEntryExcludingThis, mallocSizeOf, arg };
PL_DHashTableEnumerate(const_cast<PLDHashTable *>(table),
@ -836,7 +834,7 @@ PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table,
nsMallocSizeOfFun mallocSizeOf,
void *arg /* = NULL */)
{
return mallocSizeOf(table, sizeof(PLDHashTable)) +
return mallocSizeOf(table) +
PL_DHashTableSizeOfExcludingThis(table, sizeOfEntryExcludingThis,
mallocSizeOf, arg);
}

View File

@ -312,7 +312,7 @@ nsStringBuffer::SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) c
{
if (!IsReadonly())
{
return aMallocSizeOf(this, sizeof(nsStringBuffer) + mStorageSize);
return aMallocSizeOf(this);
}
return 0;
}

View File

@ -83,7 +83,7 @@ XPT_PUBLIC_API(void)
XPT_ArenaFree(XPTArena *arena, void* block);
/* A synonym of |nsMallocSizeOfFun|, because we don't #include nscore.h. */
typedef size_t(*xptMallocSizeOfFun)(const void *p, size_t computedSize);
typedef size_t(*xptMallocSizeOfFun)(const void *p);
XPT_PUBLIC_API(size_t)
XPT_SizeOfArena(XPTArena *arena, xptMallocSizeOfFun mallocSizeOf);

View File

@ -340,7 +340,7 @@ XPT_AssertFailed(const char *s, const char *file, PRUint32 lineno)
XPT_PUBLIC_API(size_t)
XPT_SizeOfArena(XPTArena *arena, xptMallocSizeOfFun mallocSizeOf)
{
size_t n = mallocSizeOf(arena, sizeof(XPTArena));
size_t n = mallocSizeOf(arena);
/*
* We don't measure arena->name separately because it's allocated out of
@ -353,7 +353,7 @@ XPT_SizeOfArena(XPTArena *arena, xptMallocSizeOfFun mallocSizeOf)
cur = arena->first;
while (cur) {
next = cur->next;
n += mallocSizeOf(cur, cur->size);
n += mallocSizeOf(cur);
cur = next;
}