Bug 677466 - Add memory reporter for the atoms table. r=luke.

This commit is contained in:
Nicholas Nethercote 2011-08-09 22:33:27 -07:00
Родитель 7a25ed675d
Коммит 93ca5cf15c
3 изменённых файлов: 22 добавлений и 2 удалений

Просмотреть файл

@ -628,7 +628,7 @@ class HashTable : private AllocPolicy
return !entryCount;
}
uint32 count() const{
uint32 count() const {
return entryCount;
}
@ -636,6 +636,10 @@ class HashTable : private AllocPolicy
return gen;
}
size_t tableSize() const {
return tableCapacity * sizeof(Entry);
}
Ptr lookup(const Lookup &l) const {
ReentrancyGuard g(*this);
HashNumber keyHash = prepareHash(l);
@ -1064,6 +1068,7 @@ class HashMap
typedef typename Impl::Range Range;
Range all() const { return impl.all(); }
size_t count() const { return impl.count(); }
size_t tableSize() const { return impl.tableSize(); }
/*
* Typedef for the enumeration class. An Enum may be used to examine and
@ -1262,6 +1267,7 @@ class HashSet
typedef typename Impl::Range Range;
Range all() const { return impl.all(); }
size_t count() const { return impl.count(); }
size_t tableSize() const { return impl.tableSize(); }
/*
* Typedef for the enumeration class. An Enum may be used to examine and

Просмотреть файл

@ -1624,6 +1624,8 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data)
for(js::ThreadDataIter i(rt); !i.empty(); i.popFront())
data->stackSize += i.threadData()->stackSpace.committedSize();
data->atomsTableSize += rt->atomState.atoms.tableSize();
}
JS_DestroyContextNoGC(cx);
@ -1817,6 +1819,16 @@ ReportJSRuntimeStats(const IterateData &data, const nsACString &pathPrefix,
callback, closure);
}
ReportMemoryBytes(pathPrefix + NS_LITERAL_CSTRING("runtime/runtime-object"),
nsIMemoryReporter::KIND_NONHEAP, sizeof(JSRuntime),
"Memory used by the JSRuntime object.",
callback, closure);
ReportMemoryBytes(pathPrefix + NS_LITERAL_CSTRING("runtime/atoms-table"),
nsIMemoryReporter::KIND_NONHEAP, data.atomsTableSize,
"Memory used by the atoms table.",
callback, closure);
ReportMemoryBytes(pathPrefix + NS_LITERAL_CSTRING("stack"),
nsIMemoryReporter::KIND_NONHEAP, data.stackSize,
"Memory used for the JavaScript stack. This is the committed portion "

Просмотреть файл

@ -225,7 +225,8 @@ struct CompartmentStats
struct IterateData
{
IterateData()
: stackSize(0),
: atomsTableSize(0),
stackSize(0),
gcHeapChunkTotal(0),
gcHeapChunkCleanUnused(0),
gcHeapChunkDirtyUnused(0),
@ -235,6 +236,7 @@ struct IterateData
compartmentStatsVector(),
currCompartmentStats(NULL) { }
PRInt64 atomsTableSize;
PRInt64 stackSize;
PRInt64 gcHeapChunkTotal;
PRInt64 gcHeapChunkCleanUnused;