mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 761723 - Add memory reporting for script sources. r=njn
--HG-- extra : rebase_source : 5f2cdb960f29829e9da19bbe137a810f456cc7fc
This commit is contained in:
parent
78a5439268
commit
dfea65352c
@ -56,6 +56,7 @@ struct RuntimeSizes
|
||||
, gcMarker(0)
|
||||
, mathCache(0)
|
||||
, scriptFilenames(0)
|
||||
, scriptSources(0)
|
||||
, compartmentObjects(0)
|
||||
{}
|
||||
|
||||
@ -71,6 +72,7 @@ struct RuntimeSizes
|
||||
size_t gcMarker;
|
||||
size_t mathCache;
|
||||
size_t scriptFilenames;
|
||||
size_t scriptSources;
|
||||
|
||||
// This is the exception to the "RuntimeSizes doesn't measure things within
|
||||
// compartments" rule. We combine the sizes of all the JSCompartment
|
||||
|
@ -105,6 +105,10 @@ JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *run
|
||||
for (ScriptFilenameTable::Range r = scriptFilenameTable.all(); !r.empty(); r.popFront())
|
||||
runtime->scriptFilenames += mallocSizeOf(r.front());
|
||||
|
||||
runtime->scriptSources = 0;
|
||||
for (ScriptSource *n = scriptSources; n; n = n->next)
|
||||
runtime->scriptSources += n->sizeOfIncludingThis(mallocSizeOf);
|
||||
|
||||
runtime->compartmentObjects = 0;
|
||||
CallbackData data(mallocSizeOf);
|
||||
JS_IterateCompartments(this, &data, CompartmentCallback);
|
||||
|
@ -1237,6 +1237,16 @@ ScriptSource::destroy(JSRuntime *rt)
|
||||
rt->free_(this);
|
||||
}
|
||||
|
||||
size_t
|
||||
ScriptSource::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
JS_ASSERT(onRuntime());
|
||||
JS_ASSERT(ready());
|
||||
// data is a union, but both members are pointers to allocated memory, so
|
||||
// just using compressed will work.
|
||||
return mallocSizeOf(this) + mallocSizeOf(data.compressed);
|
||||
}
|
||||
|
||||
void
|
||||
ScriptSource::sweep(JSRuntime *rt)
|
||||
{
|
||||
|
@ -989,6 +989,7 @@ struct ScriptSource
|
||||
bool ready() const { return ready_; }
|
||||
#endif
|
||||
JSFixedString *substring(JSContext *cx, uint32_t start, uint32_t stop);
|
||||
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf);
|
||||
|
||||
// For the GC.
|
||||
static void sweep(JSRuntime *rt);
|
||||
|
@ -1544,6 +1544,10 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||
nsIMemoryReporter::KIND_HEAP, rtStats.runtime.scriptFilenames,
|
||||
"Memory used for the table holding script filenames.");
|
||||
|
||||
RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/script-sources"),
|
||||
nsIMemoryReporter::KIND_HEAP, rtStats.runtime.scriptSources,
|
||||
"Memory use for storing JavaScript source code.");
|
||||
|
||||
RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/compartment-objects"),
|
||||
nsIMemoryReporter::KIND_HEAP, rtStats.runtime.compartmentObjects,
|
||||
"Memory used for JSCompartment objects. These are fairly "
|
||||
|
Loading…
x
Reference in New Issue
Block a user