diff --git a/js/src/xpconnect/src/xpcjsruntime.cpp b/js/src/xpconnect/src/xpcjsruntime.cpp index 6bf0acb344a..c0fc40f1a0c 100644 --- a/js/src/xpconnect/src/xpcjsruntime.cpp +++ b/js/src/xpconnect/src/xpcjsruntime.cpp @@ -1266,7 +1266,7 @@ static XPConnectGCChunkAllocator gXPCJSChunkAllocator; #ifdef MOZ_MEMORY #define JS_GC_HEAP_KIND nsIMemoryReporter::KIND_HEAP #else -#define JS_GC_HEAP_KIND nsIMemoryReporter::KIND_MAPPED +#define JS_GC_HEAP_KIND nsIMemoryReporter::KIND_NONHEAP #endif // We have per-compartment GC heap totals, so we can't put the total GC heap @@ -1291,11 +1291,11 @@ GetJSStack() NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSStack, "explicit/js/stack", - KIND_MAPPED, + KIND_NONHEAP, nsIMemoryReporter::UNITS_BYTES, GetJSStack, "Memory used for the JavaScript stack. This is the committed portion " - "of the stack; any uncommitted portion is not measured because it " + "of the stack; any uncommitted portion is not measured because it " "hardly costs anything.") class XPConnectJSCompartmentsMultiReporter : public nsIMemoryMultiReporter @@ -1622,7 +1622,7 @@ public: #ifdef JS_METHODJIT DO(mkPath(name, "mjit-code"), - nsIMemoryReporter::KIND_MAPPED, stats->mjitCode, + nsIMemoryReporter::KIND_NONHEAP, stats->mjitCode, "Memory used by the method JIT to hold generated code."); DO(mkPath(name, "mjit-data"), @@ -1632,7 +1632,7 @@ public: #endif #ifdef JS_TRACER DO(mkPath(name, "tjit-code"), - nsIMemoryReporter::KIND_MAPPED, stats->tjitCode, + nsIMemoryReporter::KIND_NONHEAP, stats->tjitCode, "Memory used by the trace JIT to hold generated code."); DO(mkPath(name, "tjit-data/allocators-main"), diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index 7a9ff6027c3..d21d8e50f68 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -48,11 +48,11 @@ var gVerbose = (location.href.split(/[\?,]/).indexOf("verbose") !== -1); var gAddedObserver = false; -const KIND_MAPPED = Ci.nsIMemoryReporter.KIND_MAPPED; -const KIND_HEAP = Ci.nsIMemoryReporter.KIND_HEAP; -const KIND_OTHER = Ci.nsIMemoryReporter.KIND_OTHER; -const UNITS_BYTES = Ci.nsIMemoryReporter.UNITS_BYTES; -const UNITS_COUNT = Ci.nsIMemoryReporter.UNITS_COUNT; +const KIND_NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP; +const KIND_HEAP = Ci.nsIMemoryReporter.KIND_HEAP; +const KIND_OTHER = Ci.nsIMemoryReporter.KIND_OTHER; +const UNITS_BYTES = Ci.nsIMemoryReporter.UNITS_BYTES; +const UNITS_COUNT = Ci.nsIMemoryReporter.UNITS_COUNT; const kUnknown = -1; // used for _amount if a memory reporter failed @@ -649,10 +649,10 @@ function genMrValueText(aValue) function kindToString(aKind) { switch (aKind) { - case KIND_MAPPED: return "(Mapped) "; - case KIND_HEAP: return "(Heap) "; - case KIND_OTHER: return ""; - default: return "(???) "; + case KIND_NONHEAP: return "(Non-heap) "; + case KIND_HEAP: return "(Heap) "; + case KIND_OTHER: return ""; + default: return "(???) "; } } diff --git a/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul b/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul index 5ef3daf1993..c55c3fdf6a6 100644 --- a/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul +++ b/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul @@ -47,9 +47,9 @@ const KB = 1024; const MB = KB * KB; const kUnknown = -1; - const MAPPED = Ci.nsIMemoryReporter.KIND_MAPPED; - const HEAP = Ci.nsIMemoryReporter.KIND_HEAP; - const OTHER = Ci.nsIMemoryReporter.KIND_OTHER; + const NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP; + const HEAP = Ci.nsIMemoryReporter.KIND_HEAP; + const OTHER = Ci.nsIMemoryReporter.KIND_OTHER; const BYTES = Ci.nsIMemoryReporter.UNITS_BYTES; const COUNT = Ci.nsIMemoryReporter.UNITS_COUNT; @@ -70,38 +70,38 @@ } var fakeReporters = [ - f("", "heap-allocated", OTHER, 500 * MB), - f("", "heap-unallocated", OTHER, 100 * MB), - f("", "explicit/a", HEAP, 222 * MB), - f("", "explicit/b/a", HEAP, 85 * MB), - f("", "explicit/b/b", HEAP, 75 * MB), - f("", "explicit/b/c/a", HEAP, 70 * MB), - f("", "explicit/b/c/b", HEAP, 2 * MB), // omitted - f("", "explicit/c", MAPPED, 100 * MB), - f("", "explicit/c/d", MAPPED, 13 * MB), // subsumed by parent - f("", "explicit/g", HEAP, 1 * MB), // internal, dup: merge - f("", "explicit/g/a", HEAP, 6 * MB), - f("", "explicit/g/b", HEAP, 5 * MB), - f("", "other1", OTHER, 111 * MB), - f2("", "other4", OTHER, COUNT, 888), - f2("", "unknown-unit", OTHER, /*bogus unit*/999, 999) + f("", "heap-allocated", OTHER, 500 * MB), + f("", "heap-unallocated", OTHER, 100 * MB), + f("", "explicit/a", HEAP, 222 * MB), + f("", "explicit/b/a", HEAP, 85 * MB), + f("", "explicit/b/b", HEAP, 75 * MB), + f("", "explicit/b/c/a", HEAP, 70 * MB), + f("", "explicit/b/c/b", HEAP, 2 * MB), // omitted + f("", "explicit/c", NONHEAP, 100 * MB), + f("", "explicit/c/d", NONHEAP, 13 * MB), // subsumed by parent + f("", "explicit/g", HEAP, 1 * MB), // internal, dup: merge + f("", "explicit/g/a", HEAP, 6 * MB), + f("", "explicit/g/b", HEAP, 5 * MB), + f("", "other1", OTHER, 111 * MB), + f2("", "other4", OTHER, COUNT, 888), + f2("", "unknown-unit", OTHER, /*bogus unit*/999, 999) ]; var fakeMultiReporters = [ { collectReports: function(cbObj, closure) { function f(p, k, u, a) { cbObj.callback("", p, k, u, a, "(desc)", closure); } - f("explicit/c/d", MAPPED, BYTES, 10 * MB), // dup, subsumed by parent - f("explicit/cc", MAPPED, BYTES, 13 * MB); - f("explicit/cc", MAPPED, BYTES, 10 * MB); // dup - f("explicit/d", MAPPED, BYTES, 499 * KB); // omitted - f("explicit/e", MAPPED, BYTES, 100 * KB); // omitted - f("explicit/f/g/h/i", HEAP, BYTES, 20 * MB); + f("explicit/c/d", NONHEAP, BYTES, 10 * MB), // dup, subsumed by parent + f("explicit/cc", NONHEAP, BYTES, 13 * MB); + f("explicit/cc", NONHEAP, BYTES, 10 * MB); // dup + f("explicit/d", NONHEAP, BYTES, 499 * KB); // omitted + f("explicit/e", NONHEAP, BYTES, 100 * KB); // omitted + f("explicit/f/g/h/i", HEAP, BYTES, 20 * MB); } }, { collectReports: function(cbObj, closure) { function f(p, k, u, a) { cbObj.callback("", p, k, u, a, "(desc)", closure); } - f("explicit/g", HEAP, BYTES, 14 * MB); // internal - f("other2", OTHER, BYTES, 222 * MB); - f("other3", OTHER, COUNT, 777); + f("explicit/g", HEAP, BYTES, 14 * MB); // internal + f("other2", OTHER, BYTES, 222 * MB); + f("other3", OTHER, COUNT, 777); } } ]; @@ -112,7 +112,7 @@ mgr.registerMultiReporter(fakeMultiReporters[i]); } - // mgr.explicit sums "heap-allocated" and all the appropriate MAPPED ones: + // mgr.explicit sums "heap-allocated" and all the appropriate NONHEAP ones: // - "explicit/c", "explicit/cc" x 2, "explicit/d", "explicit/e" // - but *not* "explicit/c/d" x 2 // Check explicit now before we add the fake reporters for the fake 2nd @@ -124,28 +124,28 @@ dummy = mgr.resident; var fakeReporters2 = [ - f("2nd", "heap-allocated", OTHER, 1000 * MB), - f("2nd", "heap-unallocated", OTHER, 100 * MB), - f("2nd", "explicit/a/b/c", HEAP, 498 * MB), - f("2nd", "explicit/a/b/c", HEAP, 1 * MB), // dup: merge + f("2nd", "heap-allocated", OTHER, 1000 * MB), + f("2nd", "heap-unallocated",OTHER, 100 * MB), + f("2nd", "explicit/a/b/c", HEAP, 498 * MB), + f("2nd", "explicit/a/b/c", HEAP, 1 * MB), // dup: merge f("2nd", "explicit/flip\\the\\backslashes", - HEAP, 200 * MB), + HEAP, 200 * MB), f("2nd", "explicit/compartment(this-will-be-truncated-in-non-verbose-mode-abcdefghijklmnopqrstuvwxyz)", - HEAP, 200 * MB), + HEAP, 200 * MB), // The escaping of compartment names must prevent this script from running. f("2nd", "danger", - OTHER, 666 * MB), - f("2nd", "other1", OTHER, 111 * MB), + OTHER, 666 * MB), + f("2nd", "other1", OTHER, 111 * MB), // kUnknown should be handled gracefully for "heap-allocated", non-leaf // reporters, leaf-reporters, and "other" reporters. - f("3rd", "heap-allocated", OTHER, kUnknown), - f("3rd", "explicit/a", HEAP, kUnknown), - f("3rd", "explicit/a/b", HEAP, 333 * MB), - f("3rd", "explicit/a/c", HEAP, 444 * MB), - f("3rd", "explicit/a/d", HEAP, kUnknown), - f("3rd", "explicit/b", MAPPED,kUnknown), - f("3rd", "other1", OTHER, kUnknown) + f("3rd", "heap-allocated", OTHER, kUnknown), + f("3rd", "explicit/a", HEAP, kUnknown), + f("3rd", "explicit/a/b", HEAP, 333 * MB), + f("3rd", "explicit/a/c", HEAP, 444 * MB), + f("3rd", "explicit/a/d", HEAP, kUnknown), + f("3rd", "explicit/b", NONHEAP, kUnknown), + f("3rd", "other1", OTHER, kUnknown) ]; for (var i = 0; i < fakeReporters2.length; i++) { mgr.registerReporter(fakeReporters2[i]); diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index b2770c9e00d..02ee8c2e4d5 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -99,22 +99,31 @@ interface nsIMemoryReporter : nsISupports /* * There are three categories of memory reporters: * - * - MAPPED: memory allocated directly by the OS, e.g. by calling mmap, - * VirtualAlloc, or vm_allocate. Reporters in this category must have - * units UNITS_BYTES and must have a path starting with "explicit". - * * - HEAP: memory allocated by the heap allocator, e.g. by calling malloc, * calloc, realloc, memalign, operator new, or operator new[]. Reporters * in this category must have units UNITS_BYTES and must have a path * starting with "explicit". + + * - NONHEAP: memory which the program explicitly allocated, but does not + * live on the heap. Such memory is commonly allocated by calling one of + * the OS's memory-mapping functions (e.g. mmap, VirtualAlloc, or + * vm_allocate). Reporters in this category must have units UNITS_BYTES + * and must have a path starting with "explicit". * * - OTHER: reporters which don't fit into either of these categories. Such * reporters must have a path that does not start with "explicit" and may * have any units. */ - const PRInt32 KIND_MAPPED = 0; - const PRInt32 KIND_HEAP = 1; - const PRInt32 KIND_OTHER = 2; + const PRInt32 KIND_NONHEAP = 0; + const PRInt32 KIND_HEAP = 1; + const PRInt32 KIND_OTHER = 2; + + /* + * KIND_MAPPED is a deprecated synonym for KIND_NONHEAP. We keep it around + * to as not to break extensions which might use this interface, but we will + * remove it eventually. + */ + const PRInt32 KIND_MAPPED = 0; /* * The reporter kind. See KIND_* above. diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index c3caf12e510..f234c8520a9 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -574,7 +574,7 @@ public: const nsACString &aDescription, nsISupports *aWrappedMRs) { - if (aKind == nsIMemoryReporter::KIND_MAPPED && aAmount != PRInt64(-1)) { + if (aKind == nsIMemoryReporter::KIND_NONHEAP && aAmount != PRInt64(-1)) { MemoryReportsWrapper *wrappedMRs = static_cast(aWrappedMRs); MemoryReport mr(aPath, aAmount); @@ -603,10 +603,10 @@ isParent(const nsACString &path1, const nsACString &path2) NS_IMETHODIMP nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit) { - InfallibleTArray mapped; + InfallibleTArray nonheap; PRInt64 heapUsed = PRInt64(-1); - // Get "heap-allocated" and all the KIND_MAPPED measurements from vanilla + // Get "heap-allocated" and all the KIND_NONHEAP measurements from vanilla // reporters. nsCOMPtr e; EnumerateReporters(getter_AddRefs(e)); @@ -620,7 +620,7 @@ nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit) nsresult rv = r->GetKind(&kind); NS_ENSURE_SUCCESS(rv, rv); - if (kind == nsIMemoryReporter::KIND_MAPPED) { + if (kind == nsIMemoryReporter::KIND_NONHEAP) { nsCString path; rv = r->GetPath(path); NS_ENSURE_SUCCESS(rv, rv); @@ -629,11 +629,11 @@ nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit) rv = r->GetAmount(&amount); NS_ENSURE_SUCCESS(rv, rv); - // Just skip any MAPPED reporters that fail, because + // Just skip any NONHEAP reporters that fail, because // "heap-allocated" is the most important one. if (amount != PRInt64(-1)) { MemoryReport mr(path, amount); - mapped.AppendElement(mr); + nonheap.AppendElement(mr); } } else { nsCString path; @@ -653,11 +653,11 @@ nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit) } } - // Get KIND_MAPPED measurements from multi-reporters, too. + // Get KIND_NONHEAP measurements from multi-reporters, too. nsCOMPtr e2; EnumerateMultiReporters(getter_AddRefs(e2)); nsRefPtr wrappedMRs = - new MemoryReportsWrapper(&mapped); + new MemoryReportsWrapper(&nonheap); nsRefPtr cb = new MemoryReportCallback(); while (NS_SUCCEEDED(e2->HasMoreElements(&more)) && more) { @@ -668,24 +668,24 @@ nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit) // Ignore (by zeroing its amount) any reporter that is a child of another // reporter. Eg. if we have "explicit/a" and "explicit/a/b", zero the - // latter. This is quadratic in the number of MAPPED reporters, but there + // latter. This is quadratic in the number of NONHEAP reporters, but there // shouldn't be many. - for (PRUint32 i = 0; i < mapped.Length(); i++) { - const nsCString &iPath = mapped[i].path; - for (PRUint32 j = i + 1; j < mapped.Length(); j++) { - const nsCString &jPath = mapped[j].path; + for (PRUint32 i = 0; i < nonheap.Length(); i++) { + const nsCString &iPath = nonheap[i].path; + for (PRUint32 j = i + 1; j < nonheap.Length(); j++) { + const nsCString &jPath = nonheap[j].path; if (isParent(iPath, jPath)) { - mapped[j].amount = 0; + nonheap[j].amount = 0; } else if (isParent(jPath, iPath)) { - mapped[i].amount = 0; + nonheap[i].amount = 0; } } } - // Sum all the mapped reporters and heapUsed. + // Sum all the nonheap reporters and heapUsed. *aExplicit = heapUsed; - for (PRUint32 i = 0; i < mapped.Length(); i++) { - *aExplicit += mapped[i].amount; + for (PRUint32 i = 0; i < nonheap.Length(); i++) { + *aExplicit += nonheap[i].amount; } return NS_OK;