зеркало из https://github.com/mozilla/pjs.git
Bug 671280 - Rename KIND_MAPPED to KIND_NONHEAP in nsIMemoryReporter. r=njn
This commit is contained in:
Родитель
308a19625c
Коммит
b8fa6f6a6a
|
@ -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,7 +1291,7 @@ 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 "
|
||||
|
@ -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"),
|
||||
|
|
|
@ -48,7 +48,7 @@ var gVerbose = (location.href.split(/[\?,]/).indexOf("verbose") !== -1);
|
|||
|
||||
var gAddedObserver = false;
|
||||
|
||||
const KIND_MAPPED = Ci.nsIMemoryReporter.KIND_MAPPED;
|
||||
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;
|
||||
|
@ -649,7 +649,7 @@ function genMrValueText(aValue)
|
|||
function kindToString(aKind)
|
||||
{
|
||||
switch (aKind) {
|
||||
case KIND_MAPPED: return "(Mapped) ";
|
||||
case KIND_NONHEAP: return "(Non-heap) ";
|
||||
case KIND_HEAP: return "(Heap) ";
|
||||
case KIND_OTHER: return "";
|
||||
default: return "(???) ";
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
const KB = 1024;
|
||||
const MB = KB * KB;
|
||||
const kUnknown = -1;
|
||||
const MAPPED = Ci.nsIMemoryReporter.KIND_MAPPED;
|
||||
const NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP;
|
||||
const HEAP = Ci.nsIMemoryReporter.KIND_HEAP;
|
||||
const OTHER = Ci.nsIMemoryReporter.KIND_OTHER;
|
||||
|
||||
|
@ -77,8 +77,8 @@
|
|||
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/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),
|
||||
|
@ -89,11 +89,11 @@
|
|||
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/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);
|
||||
}
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -144,7 +144,7 @@
|
|||
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", "explicit/b", NONHEAP, kUnknown),
|
||||
f("3rd", "other1", OTHER, kUnknown)
|
||||
];
|
||||
for (var i = 0; i < fakeReporters2.length; i++) {
|
||||
|
|
|
@ -99,23 +99,32 @@ 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_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.
|
||||
*/
|
||||
|
|
|
@ -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<MemoryReportsWrapper *>(aWrappedMRs);
|
||||
MemoryReport mr(aPath, aAmount);
|
||||
|
@ -603,10 +603,10 @@ isParent(const nsACString &path1, const nsACString &path2)
|
|||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit)
|
||||
{
|
||||
InfallibleTArray<MemoryReport> mapped;
|
||||
InfallibleTArray<MemoryReport> 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<nsISimpleEnumerator> 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<nsISimpleEnumerator> e2;
|
||||
EnumerateMultiReporters(getter_AddRefs(e2));
|
||||
nsRefPtr<MemoryReportsWrapper> wrappedMRs =
|
||||
new MemoryReportsWrapper(&mapped);
|
||||
new MemoryReportsWrapper(&nonheap);
|
||||
nsRefPtr<MemoryReportCallback> 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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче