Loading configure.in +19 −2 Original line number Diff line number Diff line Loading @@ -2114,10 +2114,24 @@ if test -n "$MOZ_VALGRIND"; then AC_MSG_ERROR( [--enable-valgrind specified but Valgrind is not installed])) AC_DEFINE(MOZ_VALGRIND) MOZ_VALGRIND=1 fi AC_SUBST(MOZ_VALGRIND) dnl ======================================================== dnl = Use DMD dnl ======================================================== MOZ_ARG_ENABLE_BOOL(dmd, [ --enable-dmd Enable DMD; also disables jemalloc (default=no)], MOZ_DMD=1, MOZ_DMD= ) if test -n "$MOZ_DMD"; then MOZ_CHECK_HEADER([valgrind/valgrind.h], [], AC_MSG_ERROR( [--enable-dmd specified but Valgrind is not installed])) AC_DEFINE(MOZ_DMD) fi AC_SUBST(MOZ_DMD) dnl ======================================================== dnl jprof dnl ======================================================== Loading Loading @@ -7095,7 +7109,7 @@ dnl = Enable trace malloc dnl ======================================================== NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC} MOZ_ARG_ENABLE_BOOL(trace-malloc, [ --enable-trace-malloc Enable malloc tracing], [ --enable-trace-malloc Enable malloc tracing; also disables jemalloc], NS_TRACE_MALLOC=1, NS_TRACE_MALLOC= ) if test "$NS_TRACE_MALLOC"; then Loading @@ -7117,6 +7131,9 @@ MOZ_ARG_ENABLE_BOOL(jemalloc, if test "$NS_TRACE_MALLOC"; then MOZ_MEMORY= fi if test "$MOZ_DMD"; then MOZ_MEMORY= fi if test "${OS_TARGET}" = "Android"; then dnl On Android, we use WRAP_LDFLAGS to link everything to mozutils Loading dom/base/nsJSEnvironment.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -2944,6 +2944,25 @@ static JSFunctionSpec JProfFunctions[] = { #endif /* defined(MOZ_JPROF) */ #ifdef MOZ_DMD // See https://wiki.mozilla.org/Performance/MemShrink/DMD for instructions on // how to use DMD. static JSBool DMDCheckJS(JSContext *cx, uintN argc, jsval *vp) { mozilla::DMDCheckAndDump(); return JS_TRUE; } static JSFunctionSpec DMDFunctions[] = { {"DMD", DMDCheckJS, 0, 0}, {nsnull, nsnull, 0, 0} }; #endif /* defined(MOZ_DMD) */ nsresult nsJSContext::InitClasses(JSObject* aGlobalObj) { Loading @@ -2967,6 +2986,11 @@ nsJSContext::InitClasses(JSObject* aGlobalObj) ::JS_DefineFunctions(mContext, aGlobalObj, JProfFunctions); #endif #ifdef MOZ_DMD // Attempt to initialize DMD functions ::JS_DefineFunctions(mContext, aGlobalObj, DMDFunctions); #endif JSOptionChangedCallback(js_options_dot_str, this); return rv; Loading extensions/spellcheck/hunspell/src/mozHunspell.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -98,15 +98,16 @@ NS_IMPL_CYCLE_COLLECTION_3(mozHunspell, // Memory reporting stuff. static PRInt64 gHunspellAllocatedSize = 0; NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(HunspellMallocSizeOfForCounterInc, "hunspell") NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN_UN(HunspellMallocSizeOfForCounterDec) void HunspellReportMemoryAllocation(void* ptr) { // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize += mozilla::MemoryReporterMallocSizeOfForCounterInc(ptr, 0); gHunspellAllocatedSize += HunspellMallocSizeOfForCounterInc(ptr, 0); } void HunspellReportMemoryDeallocation(void* ptr) { // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize -= mozilla::MemoryReporterMallocSizeOfForCounterDec(ptr, 0); gHunspellAllocatedSize -= HunspellMallocSizeOfForCounterDec(ptr, 0); } static PRInt64 HunspellGetCurrentAllocatedSize() { return gHunspellAllocatedSize; Loading js/xpconnect/src/XPCJSRuntime.cpp +18 −16 Original line number Diff line number Diff line Loading @@ -1235,6 +1235,8 @@ XPCJSRuntime::~XPCJSRuntime() namespace { NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(JsMallocSizeOf, "js") void CompartmentCallback(JSContext *cx, void *vdata, JSCompartment *compartment) { Loading @@ -1253,9 +1255,9 @@ CompartmentCallback(JSContext *cx, void *vdata, JSCompartment *compartment) curr->mjitCode = method + unused; #endif JS_GetTypeInferenceMemoryStats(cx, compartment, &curr->typeInferenceMemory, MemoryReporterMallocSizeOf); JsMallocSizeOf); curr->shapesCompartmentTables = js::GetCompartmentShapeTableSize(compartment, MemoryReporterMallocSizeOf); js::GetCompartmentShapeTableSize(compartment, JsMallocSizeOf); } void Loading Loading @@ -1300,14 +1302,14 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, } else { curr->gcHeapObjectsNonFunction += thingSize; } curr->objectSlots += js::GetObjectDynamicSlotSize(obj, MemoryReporterMallocSizeOf); curr->objectSlots += js::GetObjectDynamicSlotSize(obj, JsMallocSizeOf); break; } case JSTRACE_STRING: { JSString *str = static_cast<JSString *>(thing); curr->gcHeapStrings += thingSize; curr->stringChars += str->charsHeapSize(MemoryReporterMallocSizeOf); curr->stringChars += str->charsHeapSize(JsMallocSizeOf); break; } case JSTRACE_SHAPE: Loading @@ -1316,13 +1318,13 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, if (shape->inDictionary()) { curr->gcHeapShapesDict += thingSize; curr->shapesExtraDictTables += shape->sizeOfPropertyTable(MemoryReporterMallocSizeOf); shape->sizeOfPropertyTable(JsMallocSizeOf); } else { curr->gcHeapShapesTree += thingSize; curr->shapesExtraTreeTables += shape->sizeOfPropertyTable(MemoryReporterMallocSizeOf); shape->sizeOfPropertyTable(JsMallocSizeOf); curr->shapesExtraTreeShapeKids += shape->sizeOfKids(MemoryReporterMallocSizeOf); shape->sizeOfKids(JsMallocSizeOf); } break; } Loading @@ -1335,9 +1337,9 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, { JSScript *script = static_cast<JSScript *>(thing); curr->gcHeapScripts += thingSize; curr->scriptData += script->dataSize(MemoryReporterMallocSizeOf); curr->scriptData += script->dataSize(JsMallocSizeOf); #ifdef JS_METHODJIT curr->mjitData += script->jitDataSize(MemoryReporterMallocSizeOf); curr->mjitData += script->jitDataSize(JsMallocSizeOf); #endif break; } Loading @@ -1346,7 +1348,7 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, js::types::TypeObject *obj = static_cast<js::types::TypeObject *>(thing); curr->gcHeapTypeObjects += thingSize; JS_GetTypeInferenceObjectStats(obj, &curr->typeInferenceMemory, MemoryReporterMallocSizeOf); JsMallocSizeOf); break; } case JSTRACE_XML: Loading Loading @@ -1558,12 +1560,12 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) ArenaCallback, CellCallback); js::IterateChunks(cx, data, ChunkCallback); data->runtimeObject = MemoryReporterMallocSizeOf(rt, sizeof(JSRuntime)); data->runtimeObject = JsMallocSizeOf(rt, sizeof(JSRuntime)); // Nb: we use sizeOfExcludingThis() because atomState.atoms is within // JSRuntime, and so counted when JSRuntime is counted. data->runtimeAtomsTable = rt->atomState.atoms.sizeOfExcludingThis(MemoryReporterMallocSizeOf); rt->atomState.atoms.sizeOfExcludingThis(JsMallocSizeOf); { #ifndef JS_THREADSAFE Loading @@ -1577,13 +1579,13 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) JSContext *acx, *iter = NULL; while ((acx = JS_ContextIteratorUnlocked(rt, &iter)) != NULL) { data->runtimeContexts += acx->sizeOfIncludingThis(MemoryReporterMallocSizeOf); acx->sizeOfIncludingThis(JsMallocSizeOf); } for (JSThread::Map::Range r = rt->threads.all(); !r.empty(); r.popFront()) { JSThread *thread = r.front().value; size_t normal, temporary, regexpCode, stackCommitted; thread->sizeOfIncludingThis(MemoryReporterMallocSizeOf, thread->sizeOfIncludingThis(JsMallocSizeOf, &normal, &temporary, ®expCode, Loading @@ -1598,9 +1600,9 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) XPCJSRuntime *xpcrt = nsXPConnect::GetRuntimeInstance(); data->xpconnect += xpcrt->SizeOfIncludingThis(MemoryReporterMallocSizeOf); xpcrt->SizeOfIncludingThis(JsMallocSizeOf); data->xpconnect += XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(MemoryReporterMallocSizeOf); XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(JsMallocSizeOf); } JS_DestroyContextNoGC(cx); Loading layout/base/nsPresShell.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -622,6 +622,8 @@ struct MemoryReporterData } // anonymous namespace NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(LayoutMallocSizeOf, "layout") /* static */ PLDHashOperator PresShell::MemoryReporter::SizeEnumerator(PresShellPtrKey *aEntry, void *userArg) Loading Loading @@ -666,7 +668,7 @@ PresShell::MemoryReporter::SizeEnumerator(PresShellPtrKey *aEntry, PRUint32 styleSize; styleSize = aShell->StyleSet()->SizeOf(); PRInt64 textRunsSize = aShell->SizeOfTextRuns(MemoryReporterMallocSizeOf); PRInt64 textRunsSize = aShell->SizeOfTextRuns(LayoutMallocSizeOf); data->callback-> Callback(EmptyCString(), arenaPath, nsIMemoryReporter::KIND_HEAP, Loading @@ -688,6 +690,8 @@ PresShell::MemoryReporter::SizeEnumerator(PresShellPtrKey *aEntry, return PL_DHASH_NEXT; } NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(GfxTextrunWordCacheMallocSizeOf, "gfx/textrun-word-cache") NS_IMETHODIMP PresShell::MemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb, nsISupports* aClosure) Loading @@ -709,7 +713,7 @@ PresShell::MemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb, // now total up cached runs that aren't otherwise accounted for PRInt64 textRunWordCacheSize = gfxTextRunWordCache::MaybeSizeOfExcludingThis(MemoryReporterMallocSizeOf); gfxTextRunWordCache::MaybeSizeOfExcludingThis(GfxTextrunWordCacheMallocSizeOf); aCb->Callback(EmptyCString(), kTextRunWordCachePath, nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, Loading Loading
configure.in +19 −2 Original line number Diff line number Diff line Loading @@ -2114,10 +2114,24 @@ if test -n "$MOZ_VALGRIND"; then AC_MSG_ERROR( [--enable-valgrind specified but Valgrind is not installed])) AC_DEFINE(MOZ_VALGRIND) MOZ_VALGRIND=1 fi AC_SUBST(MOZ_VALGRIND) dnl ======================================================== dnl = Use DMD dnl ======================================================== MOZ_ARG_ENABLE_BOOL(dmd, [ --enable-dmd Enable DMD; also disables jemalloc (default=no)], MOZ_DMD=1, MOZ_DMD= ) if test -n "$MOZ_DMD"; then MOZ_CHECK_HEADER([valgrind/valgrind.h], [], AC_MSG_ERROR( [--enable-dmd specified but Valgrind is not installed])) AC_DEFINE(MOZ_DMD) fi AC_SUBST(MOZ_DMD) dnl ======================================================== dnl jprof dnl ======================================================== Loading Loading @@ -7095,7 +7109,7 @@ dnl = Enable trace malloc dnl ======================================================== NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC} MOZ_ARG_ENABLE_BOOL(trace-malloc, [ --enable-trace-malloc Enable malloc tracing], [ --enable-trace-malloc Enable malloc tracing; also disables jemalloc], NS_TRACE_MALLOC=1, NS_TRACE_MALLOC= ) if test "$NS_TRACE_MALLOC"; then Loading @@ -7117,6 +7131,9 @@ MOZ_ARG_ENABLE_BOOL(jemalloc, if test "$NS_TRACE_MALLOC"; then MOZ_MEMORY= fi if test "$MOZ_DMD"; then MOZ_MEMORY= fi if test "${OS_TARGET}" = "Android"; then dnl On Android, we use WRAP_LDFLAGS to link everything to mozutils Loading
dom/base/nsJSEnvironment.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -2944,6 +2944,25 @@ static JSFunctionSpec JProfFunctions[] = { #endif /* defined(MOZ_JPROF) */ #ifdef MOZ_DMD // See https://wiki.mozilla.org/Performance/MemShrink/DMD for instructions on // how to use DMD. static JSBool DMDCheckJS(JSContext *cx, uintN argc, jsval *vp) { mozilla::DMDCheckAndDump(); return JS_TRUE; } static JSFunctionSpec DMDFunctions[] = { {"DMD", DMDCheckJS, 0, 0}, {nsnull, nsnull, 0, 0} }; #endif /* defined(MOZ_DMD) */ nsresult nsJSContext::InitClasses(JSObject* aGlobalObj) { Loading @@ -2967,6 +2986,11 @@ nsJSContext::InitClasses(JSObject* aGlobalObj) ::JS_DefineFunctions(mContext, aGlobalObj, JProfFunctions); #endif #ifdef MOZ_DMD // Attempt to initialize DMD functions ::JS_DefineFunctions(mContext, aGlobalObj, DMDFunctions); #endif JSOptionChangedCallback(js_options_dot_str, this); return rv; Loading
extensions/spellcheck/hunspell/src/mozHunspell.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -98,15 +98,16 @@ NS_IMPL_CYCLE_COLLECTION_3(mozHunspell, // Memory reporting stuff. static PRInt64 gHunspellAllocatedSize = 0; NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(HunspellMallocSizeOfForCounterInc, "hunspell") NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN_UN(HunspellMallocSizeOfForCounterDec) void HunspellReportMemoryAllocation(void* ptr) { // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize += mozilla::MemoryReporterMallocSizeOfForCounterInc(ptr, 0); gHunspellAllocatedSize += HunspellMallocSizeOfForCounterInc(ptr, 0); } void HunspellReportMemoryDeallocation(void* ptr) { // |computedSize| is zero because we don't know what it is. gHunspellAllocatedSize -= mozilla::MemoryReporterMallocSizeOfForCounterDec(ptr, 0); gHunspellAllocatedSize -= HunspellMallocSizeOfForCounterDec(ptr, 0); } static PRInt64 HunspellGetCurrentAllocatedSize() { return gHunspellAllocatedSize; Loading
js/xpconnect/src/XPCJSRuntime.cpp +18 −16 Original line number Diff line number Diff line Loading @@ -1235,6 +1235,8 @@ XPCJSRuntime::~XPCJSRuntime() namespace { NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(JsMallocSizeOf, "js") void CompartmentCallback(JSContext *cx, void *vdata, JSCompartment *compartment) { Loading @@ -1253,9 +1255,9 @@ CompartmentCallback(JSContext *cx, void *vdata, JSCompartment *compartment) curr->mjitCode = method + unused; #endif JS_GetTypeInferenceMemoryStats(cx, compartment, &curr->typeInferenceMemory, MemoryReporterMallocSizeOf); JsMallocSizeOf); curr->shapesCompartmentTables = js::GetCompartmentShapeTableSize(compartment, MemoryReporterMallocSizeOf); js::GetCompartmentShapeTableSize(compartment, JsMallocSizeOf); } void Loading Loading @@ -1300,14 +1302,14 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, } else { curr->gcHeapObjectsNonFunction += thingSize; } curr->objectSlots += js::GetObjectDynamicSlotSize(obj, MemoryReporterMallocSizeOf); curr->objectSlots += js::GetObjectDynamicSlotSize(obj, JsMallocSizeOf); break; } case JSTRACE_STRING: { JSString *str = static_cast<JSString *>(thing); curr->gcHeapStrings += thingSize; curr->stringChars += str->charsHeapSize(MemoryReporterMallocSizeOf); curr->stringChars += str->charsHeapSize(JsMallocSizeOf); break; } case JSTRACE_SHAPE: Loading @@ -1316,13 +1318,13 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, if (shape->inDictionary()) { curr->gcHeapShapesDict += thingSize; curr->shapesExtraDictTables += shape->sizeOfPropertyTable(MemoryReporterMallocSizeOf); shape->sizeOfPropertyTable(JsMallocSizeOf); } else { curr->gcHeapShapesTree += thingSize; curr->shapesExtraTreeTables += shape->sizeOfPropertyTable(MemoryReporterMallocSizeOf); shape->sizeOfPropertyTable(JsMallocSizeOf); curr->shapesExtraTreeShapeKids += shape->sizeOfKids(MemoryReporterMallocSizeOf); shape->sizeOfKids(JsMallocSizeOf); } break; } Loading @@ -1335,9 +1337,9 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, { JSScript *script = static_cast<JSScript *>(thing); curr->gcHeapScripts += thingSize; curr->scriptData += script->dataSize(MemoryReporterMallocSizeOf); curr->scriptData += script->dataSize(JsMallocSizeOf); #ifdef JS_METHODJIT curr->mjitData += script->jitDataSize(MemoryReporterMallocSizeOf); curr->mjitData += script->jitDataSize(JsMallocSizeOf); #endif break; } Loading @@ -1346,7 +1348,7 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind, js::types::TypeObject *obj = static_cast<js::types::TypeObject *>(thing); curr->gcHeapTypeObjects += thingSize; JS_GetTypeInferenceObjectStats(obj, &curr->typeInferenceMemory, MemoryReporterMallocSizeOf); JsMallocSizeOf); break; } case JSTRACE_XML: Loading Loading @@ -1558,12 +1560,12 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) ArenaCallback, CellCallback); js::IterateChunks(cx, data, ChunkCallback); data->runtimeObject = MemoryReporterMallocSizeOf(rt, sizeof(JSRuntime)); data->runtimeObject = JsMallocSizeOf(rt, sizeof(JSRuntime)); // Nb: we use sizeOfExcludingThis() because atomState.atoms is within // JSRuntime, and so counted when JSRuntime is counted. data->runtimeAtomsTable = rt->atomState.atoms.sizeOfExcludingThis(MemoryReporterMallocSizeOf); rt->atomState.atoms.sizeOfExcludingThis(JsMallocSizeOf); { #ifndef JS_THREADSAFE Loading @@ -1577,13 +1579,13 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) JSContext *acx, *iter = NULL; while ((acx = JS_ContextIteratorUnlocked(rt, &iter)) != NULL) { data->runtimeContexts += acx->sizeOfIncludingThis(MemoryReporterMallocSizeOf); acx->sizeOfIncludingThis(JsMallocSizeOf); } for (JSThread::Map::Range r = rt->threads.all(); !r.empty(); r.popFront()) { JSThread *thread = r.front().value; size_t normal, temporary, regexpCode, stackCommitted; thread->sizeOfIncludingThis(MemoryReporterMallocSizeOf, thread->sizeOfIncludingThis(JsMallocSizeOf, &normal, &temporary, ®expCode, Loading @@ -1598,9 +1600,9 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) XPCJSRuntime *xpcrt = nsXPConnect::GetRuntimeInstance(); data->xpconnect += xpcrt->SizeOfIncludingThis(MemoryReporterMallocSizeOf); xpcrt->SizeOfIncludingThis(JsMallocSizeOf); data->xpconnect += XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(MemoryReporterMallocSizeOf); XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(JsMallocSizeOf); } JS_DestroyContextNoGC(cx); Loading
layout/base/nsPresShell.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -622,6 +622,8 @@ struct MemoryReporterData } // anonymous namespace NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(LayoutMallocSizeOf, "layout") /* static */ PLDHashOperator PresShell::MemoryReporter::SizeEnumerator(PresShellPtrKey *aEntry, void *userArg) Loading Loading @@ -666,7 +668,7 @@ PresShell::MemoryReporter::SizeEnumerator(PresShellPtrKey *aEntry, PRUint32 styleSize; styleSize = aShell->StyleSet()->SizeOf(); PRInt64 textRunsSize = aShell->SizeOfTextRuns(MemoryReporterMallocSizeOf); PRInt64 textRunsSize = aShell->SizeOfTextRuns(LayoutMallocSizeOf); data->callback-> Callback(EmptyCString(), arenaPath, nsIMemoryReporter::KIND_HEAP, Loading @@ -688,6 +690,8 @@ PresShell::MemoryReporter::SizeEnumerator(PresShellPtrKey *aEntry, return PL_DHASH_NEXT; } NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(GfxTextrunWordCacheMallocSizeOf, "gfx/textrun-word-cache") NS_IMETHODIMP PresShell::MemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb, nsISupports* aClosure) Loading @@ -709,7 +713,7 @@ PresShell::MemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb, // now total up cached runs that aren't otherwise accounted for PRInt64 textRunWordCacheSize = gfxTextRunWordCache::MaybeSizeOfExcludingThis(MemoryReporterMallocSizeOf); gfxTextRunWordCache::MaybeSizeOfExcludingThis(GfxTextrunWordCacheMallocSizeOf); aCb->Callback(EmptyCString(), kTextRunWordCachePath, nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, Loading