Bug 729403 (part 2) - Add js/runtime/gc-marker memory reporter. r=wmccloskey.

--HG--
extra : rebase_source : 9f078515b971e3de4156bb3edd3f8aea74c9fa8f
This commit is contained in:
Nicholas Nethercote 2012-02-21 21:43:45 -08:00
Родитель 48b2c54482
Коммит 054154adb1
7 изменённых файлов: 33 добавлений и 6 удалений

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

@ -128,6 +128,7 @@ struct RuntimeStats
, runtimeTemporary(0)
, runtimeRegexpCode(0)
, runtimeStackCommitted(0)
, runtimeGCMarker(0)
, gcHeapChunkTotal(0)
, gcHeapChunkCleanUnused(0)
, gcHeapChunkDirtyUnused(0)
@ -159,6 +160,7 @@ struct RuntimeStats
size_t runtimeTemporary;
size_t runtimeRegexpCode;
size_t runtimeStackCommitted;
size_t runtimeGCMarker;
size_t gcHeapChunkTotal;
size_t gcHeapChunkCleanUnused;
size_t gcHeapChunkDirtyUnused;

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

@ -211,10 +211,9 @@ CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats)
&rtStats->runtimeNormal,
&rtStats->runtimeTemporary,
&rtStats->runtimeRegexpCode,
&rtStats->runtimeStackCommitted);
&rtStats->runtimeStackCommitted,
&rtStats->runtimeGCMarker);
// Nb: we use sizeOfExcludingThis() because atomState.atoms is within
// JSRuntime, and so counted when JSRuntime is counted.
rtStats->runtimeAtomsTable =
rt->atomState.atoms.sizeOfExcludingThis(rtStats->mallocSizeOf);
@ -335,7 +334,8 @@ GetExplicitNonHeapForRuntime(JSRuntime *rt, int64_t *amount,
NULL,
NULL,
&regexpCode,
&stackCommitted);
&stackCommitted,
NULL);
*amount += regexpCode;
*amount += stackCommitted;

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

@ -95,7 +95,7 @@ using namespace js::gc;
void
JSRuntime::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *normal, size_t *temporary,
size_t *regexpCode, size_t *stackCommitted)
size_t *regexpCode, size_t *stackCommitted, size_t *gcMarkerSize)
{
if (normal)
*normal = mallocSizeOf(dtoaState);
@ -113,6 +113,9 @@ JSRuntime::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *normal, s
if (stackCommitted)
*stackCommitted = stackSpace.sizeOfCommitted();
if (gcMarkerSize)
*gcMarkerSize = gcMarker.sizeOfExcludingThis(mallocSizeOf);
}
JS_FRIEND_API(void)

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

@ -689,7 +689,7 @@ struct JSRuntime : js::RuntimeFriendFields
}
void sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *normal, size_t *temporary,
size_t *regexpCode, size_t *stackCommitted);
size_t *regexpCode, size_t *stackCommitted, size_t *gcMarker);
void purge(JSContext *cx);
};

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

@ -2118,6 +2118,13 @@ GCMarker::GrayCallback(JSTracer *trc, void **thingp, JSGCTraceKind kind)
gcmarker->appendGrayRoot(*thingp, kind);
}
size_t
GCMarker::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const
{
return stack.sizeOfExcludingThis(mallocSizeOf) +
grayRoots.sizeOfExcludingThis(mallocSizeOf);
}
void
SetMarkStackLimit(JSRuntime *rt, size_t limit)
{

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

@ -1690,6 +1690,14 @@ struct MarkStack {
limit = newStack + newcap;
return true;
}
size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const {
size_t n = 0;
if (stack != ballast)
n += mallocSizeOf(stack);
n += mallocSizeOf(ballast);
return n;
}
};
/*
@ -1827,6 +1835,8 @@ struct GCMarker : public JSTracer {
static void GrayCallback(JSTracer *trc, void **thing, JSGCTraceKind kind);
size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const;
MarkStack<uintptr_t> stack;
private:

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

@ -1685,6 +1685,11 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, const nsACStri
"hardly costs anything.",
callback, closure);
ReportMemoryBytes(pathPrefix + NS_LITERAL_CSTRING("runtime/gc-marker"),
nsIMemoryReporter::KIND_NONHEAP, rtStats.runtimeGCMarker,
"Memory used for the GC mark stack and gray roots.",
callback, closure);
ReportGCHeapBytes(pathPrefix +
NS_LITERAL_CSTRING("gc-heap-chunk-dirty-unused"),
&gcTotal, rtStats.gcHeapChunkDirtyUnused,