Bug 672732 - Don't report per-compartment measurements that have zero bytes. r=gal.

This commit is contained in:
Nicholas Nethercote 2011-07-21 17:39:01 -07:00
parent 49346550bd
commit ca8a2e6e49
2 changed files with 24 additions and 17 deletions

View File

@ -2881,7 +2881,8 @@ NewCompartment(JSContext *cx, JSPrincipals *principals)
JSRuntime *rt = cx->runtime;
JSCompartment *compartment = cx->new_<JSCompartment>(rt);
if (compartment && compartment->init()) {
// The trusted compartment is a system compartment.
// Any compartment with the trusted principals -- and there can be
// multiple -- is a system compartment.
compartment->isSystemCompartment = principals && rt->trustedPrincipals() == principals;
if (principals) {
compartment->principals = principals;

View File

@ -1613,7 +1613,13 @@ public:
#define BYTES(path, kind, amount, desc) \
callback->Callback(p, path, kind, nsIMemoryReporter::UNITS_BYTES, \
amount, NS_LITERAL_CSTRING(desc), closure);
amount, NS_LITERAL_CSTRING(desc), closure)
#define BYTES0(path, kind, amount, desc) \
do { \
if (amount != 0) \
BYTES(path, kind, amount, desc); \
} while (0)
#define PERCENTAGE(path, kind, amount, desc) \
callback->Callback(p, path, kind, nsIMemoryReporter::UNITS_PERCENTAGE, \
@ -1634,28 +1640,28 @@ public:
gcHeapArenaUnused += stats->gcHeapArenaUnused;
BYTES(mkPath(name, "gc-heap/arena-headers"),
BYTES0(mkPath(name, "gc-heap/arena-headers"),
JS_GC_HEAP_KIND, stats->gcHeapArenaHeaders,
"Memory on the compartment's garbage-collected JavaScript heap, within "
"arenas, that is used to hold internal book-keeping information.");
BYTES(mkPath(name, "gc-heap/arena-padding"),
BYTES0(mkPath(name, "gc-heap/arena-padding"),
JS_GC_HEAP_KIND, stats->gcHeapArenaPadding,
"Memory on the compartment's garbage-collected JavaScript heap, within "
"arenas, that is unused and present only so that other data is aligned. "
"This constitutes internal fragmentation.");
BYTES(mkPath(name, "gc-heap/arena-unused"),
BYTES0(mkPath(name, "gc-heap/arena-unused"),
JS_GC_HEAP_KIND, stats->gcHeapArenaUnused,
"Memory on the compartment's garbage-collected JavaScript heap, within "
"arenas, that could be holding useful data but currently isn't.");
BYTES(mkPath(name, "gc-heap/objects"),
BYTES0(mkPath(name, "gc-heap/objects"),
JS_GC_HEAP_KIND, stats->gcHeapObjects,
"Memory on the compartment's garbage-collected JavaScript heap that holds "
"objects.");
BYTES(mkPath(name, "gc-heap/strings"),
BYTES0(mkPath(name, "gc-heap/strings"),
JS_GC_HEAP_KIND, stats->gcHeapStrings,
"Memory on the compartment's garbage-collected JavaScript heap that holds "
"string headers. String headers contain various pieces of information "
@ -1663,18 +1669,18 @@ public:
"strings) the string characters; characters in longer strings are counted "
"under 'gc-heap/string-chars' instead.");
BYTES(mkPath(name, "gc-heap/shapes"),
BYTES0(mkPath(name, "gc-heap/shapes"),
JS_GC_HEAP_KIND, stats->gcHeapShapes,
"Memory on the compartment's garbage-collected JavaScript heap that holds "
"shapes. A shape is an internal data structure that makes JavaScript "
"property accesses fast.");
BYTES(mkPath(name, "gc-heap/xml"),
BYTES0(mkPath(name, "gc-heap/xml"),
JS_GC_HEAP_KIND, stats->gcHeapXml,
"Memory on the compartment's garbage-collected JavaScript heap that holds "
"E4X XML objects.");
BYTES(mkPath(name, "object-slots"),
BYTES0(mkPath(name, "object-slots"),
nsIMemoryReporter::KIND_HEAP, stats->objectSlots,
"Memory allocated for the compartment's non-fixed object slot arrays, "
"which are used to represent object properties. Some objects also "
@ -1682,7 +1688,7 @@ public:
"JavaScript heap; those slots are not counted here, but in "
"'gc-heap/objects' instead.");
BYTES(mkPath(name, "string-chars"),
BYTES0(mkPath(name, "string-chars"),
nsIMemoryReporter::KIND_HEAP, stats->stringChars,
"Memory allocated to hold the compartment's string characters. Sometimes "
"more memory is allocated than necessary, to simplify string "
@ -1690,7 +1696,7 @@ public:
"compartment's JavaScript heap; that header is not counted here, but in "
"'gc-heap/strings' instead.");
BYTES(mkPath(name, "scripts"),
BYTES0(mkPath(name, "scripts"),
nsIMemoryReporter::KIND_HEAP, stats->scripts,
"Memory allocated for the compartment's JSScripts. A JSScript is created "
"for each user-defined function in a script. One is also created for "
@ -1698,26 +1704,26 @@ public:
"various other things.");
#ifdef JS_METHODJIT
BYTES(mkPath(name, "mjit-code"),
BYTES0(mkPath(name, "mjit-code"),
nsIMemoryReporter::KIND_NONHEAP, stats->mjitCode,
"Memory used by the method JIT to hold the compartment's generated code.");
BYTES(mkPath(name, "mjit-data"),
BYTES0(mkPath(name, "mjit-data"),
nsIMemoryReporter::KIND_HEAP, stats->mjitData,
"Memory used by the method JIT for the compartment's compilation data: "
"JITScripts, native maps, and inline cache structs.");
#endif
#ifdef JS_TRACER
BYTES(mkPath(name, "tjit-code"),
BYTES0(mkPath(name, "tjit-code"),
nsIMemoryReporter::KIND_NONHEAP, stats->tjitCode,
"Memory used by the trace JIT to hold the compartment's generated code.");
BYTES(mkPath(name, "tjit-data/allocators-main"),
BYTES0(mkPath(name, "tjit-data/allocators-main"),
nsIMemoryReporter::KIND_HEAP, stats->tjitDataAllocatorsMain,
"Memory used by the trace JIT to store the compartment's trace-related "
"data. This data is allocated via the compartment's VMAllocators.");
BYTES(mkPath(name, "tjit-data/allocators-reserve"),
BYTES0(mkPath(name, "tjit-data/allocators-reserve"),
nsIMemoryReporter::KIND_HEAP, stats->tjitDataAllocatorsReserve,
"Memory used by the trace JIT and held in reserve for the compartment's "
"VMAllocators in case of OOM.");