Bug 961883 (part 1) - Measure and report the SourceDataCache. r=benjamin.

--HG--
extra : rebase_source : b599e19fb681e972b1f6e184c44f5a726a61009f
This commit is contained in:
Nicholas Nethercote 2014-01-20 19:52:57 -08:00
parent b60b20f34b
commit 5de1ab52da
5 changed files with 24 additions and 0 deletions

View File

@ -296,6 +296,7 @@ struct RuntimeSizes
macro(_, _, interpreterStack) \
macro(_, _, gcMarker) \
macro(_, _, mathCache) \
macro(_, _, sourceDataCache) \
macro(_, _, scriptData) \
macro(_, _, scriptSources)

View File

@ -1207,6 +1207,20 @@ SourceDataCache::purge()
map_ = nullptr;
}
size_t
SourceDataCache::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
{
size_t n = 0;
if (map_ && !map_->empty()) {
n += map_->sizeOfIncludingThis(mallocSizeOf);
for (Map::Range r = map_->all(); !r.empty(); r.popFront()) {
const jschar *v = r.front().value();
n += mallocSizeOf(v);
}
}
return n;
}
const jschar *
ScriptSource::chars(JSContext *cx, const SourceDataCache::AutoSuppressPurge &asp)
{

View File

@ -353,6 +353,8 @@ class SourceDataCache
bool put(ScriptSource *ss, const jschar *chars, const AutoSuppressPurge &asp);
void purge();
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
};
class ScriptSource

View File

@ -619,6 +619,8 @@ JSRuntime::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::Runtim
rtSizes->mathCache += mathCache_ ? mathCache_->sizeOfIncludingThis(mallocSizeOf) : 0;
rtSizes->sourceDataCache += sourceDataCache.sizeOfExcludingThis(mallocSizeOf);
rtSizes->scriptData += scriptDataTable().sizeOfExcludingThis(mallocSizeOf);
for (ScriptDataTable::Range r = scriptDataTable().all(); !r.empty(); r.popFront())
rtSizes->scriptData += mallocSizeOf(r.front());

View File

@ -2272,6 +2272,11 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
KIND_HEAP, rtStats.runtime.mathCache,
"Memory used for the math cache.");
RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/source-data-cache"),
KIND_HEAP, rtStats.runtime.sourceDataCache,
"Memory used for the source data cache, which holds "
"decompressed script source code.");
RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/script-data"),
KIND_HEAP, rtStats.runtime.scriptData,
"Memory used for the table holding script data shared in "