Bug 846733 - Add baseline compiler memory reporters. r=djvj

This commit is contained in:
Jan de Mooij 2013-03-05 10:53:54 +01:00
parent 5faa964d74
commit 5b01371df1
7 changed files with 52 additions and 3 deletions

View File

@ -169,6 +169,8 @@ struct CompartmentStats
, shapesCompartmentTables(0)
, scriptData(0)
, jaegerData(0)
, baselineData(0)
, baselineStubs(0)
, ionData(0)
, compartmentObject(0)
, crossCompartmentWrappersTable(0)
@ -205,6 +207,8 @@ struct CompartmentStats
, shapesCompartmentTables(other.shapesCompartmentTables)
, scriptData(other.scriptData)
, jaegerData(other.jaegerData)
, baselineData(other.baselineData)
, baselineStubs(other.baselineStubs)
, ionData(other.ionData)
, compartmentObject(other.compartmentObject)
, crossCompartmentWrappersTable(other.crossCompartmentWrappersTable)
@ -247,6 +251,8 @@ struct CompartmentStats
size_t shapesCompartmentTables;
size_t scriptData;
size_t jaegerData;
size_t baselineData;
size_t baselineStubs;
size_t ionData;
size_t compartmentObject;
size_t crossCompartmentWrappersTable;
@ -287,6 +293,8 @@ struct CompartmentStats
ADD(shapesCompartmentTables);
ADD(scriptData);
ADD(jaegerData);
ADD(baselineData);
ADD(baselineStubs);
ADD(ionData);
ADD(compartmentObject);
ADD(crossCompartmentWrappersTable);

View File

@ -713,3 +713,14 @@ ion::IonCompartment::toggleBaselineStubBarriers(bool enabled)
code->togglePreBarriers(enabled);
}
}
void
ion::SizeOfBaselineData(JSScript *script, JSMallocSizeOfFun mallocSizeOf, size_t *data,
size_t *stubs)
{
*data = 0;
*stubs = 0;
if (script->hasBaselineScript())
script->baseline->sizeOfIncludingThis(mallocSizeOf, data, stubs);
}

View File

@ -48,6 +48,9 @@ struct ICStubSpace
void free() {
allocator_.freeAll();
}
size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const {
return allocator_.sizeOfExcludingThis(mallocSizeOf);
}
};
class PCMappingSlotInfo
@ -178,6 +181,15 @@ struct BaselineScript
return offsetof(BaselineScript, method_);
}
void sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *data, size_t *stubs) const {
*data = mallocSizeOf(this);
// data already includes the ICStubSpace itself, so use
// sizeOfExcludingThis.
*stubs = fallbackStubSpace_.sizeOfExcludingThis(mallocSizeOf) +
optimizedStubSpace_.sizeOfExcludingThis(mallocSizeOf);
}
bool active() const {
return flags_ & ACTIVE;
}
@ -281,6 +293,9 @@ EnterBaselineAtBranch(JSContext *cx, StackFrame *fp, jsbytecode *pc);
void
FinishDiscardBaselineScript(FreeOp *fop, UnrootedScript script);
void
SizeOfBaselineData(JSScript *script, JSMallocSizeOfFun mallocSizeOf, size_t *data, size_t *stubs);
struct BaselineBailoutInfo
{
// Pointer into the current C stack, where overwriting will start.

View File

@ -2440,7 +2440,8 @@ ion::PurgeCaches(UnrootedScript script, JSCompartment *c) {
}
size_t
ion::MemoryUsed(UnrootedScript script, JSMallocSizeOfFun mallocSizeOf) {
ion::SizeOfIonData(UnrootedScript script, JSMallocSizeOfFun mallocSizeOf)
{
size_t result = 0;
if (script->hasIonScript())

View File

@ -336,7 +336,7 @@ void ForbidCompilation(JSContext *cx, UnrootedScript script, ExecutionMode mode)
uint32_t UsesBeforeIonRecompile(UnrootedScript script, jsbytecode *pc);
void PurgeCaches(UnrootedScript script, JSCompartment *c);
size_t MemoryUsed(UnrootedScript script, JSMallocSizeOfFun mallocSizeOf);
size_t SizeOfIonData(UnrootedScript script, JSMallocSizeOfFun mallocSizeOf);
void DestroyIonScripts(FreeOp *fop, UnrootedScript script);
void TraceIonScripts(JSTracer* trc, UnrootedScript script);

View File

@ -16,6 +16,7 @@
#include "jsobj.h"
#include "jsscript.h"
#include "ion/BaselineJIT.h"
#include "ion/Ion.h"
#include "ion/IonCode.h"
#include "vm/Shape.h"
@ -217,7 +218,11 @@ StatsCellCallback(JSRuntime *rt, void *data, void *thing, JSGCTraceKind traceKin
#ifdef JS_METHODJIT
cStats->jaegerData += script->sizeOfJitScripts(rtStats->mallocSizeOf_);
# ifdef JS_ION
cStats->ionData += ion::MemoryUsed(script, rtStats->mallocSizeOf_);
size_t baselineData = 0, baselineStubs = 0;
ion::SizeOfBaselineData(script, rtStats->mallocSizeOf_, &baselineData, &baselineStubs);
cStats->baselineData += baselineData;
cStats->baselineStubs += baselineStubs;
cStats->ionData += ion::SizeOfIonData(script, rtStats->mallocSizeOf_);
# endif
#endif

View File

@ -1711,6 +1711,15 @@ ReportCompartmentStats(const JS::CompartmentStats &cStats,
"Memory used by the JaegerMonkey JIT for compilation data: "
"JITScripts, native maps, and inline cache structs.");
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("baseline-data"),
cStats.baselineData,
"Memory used by the Baseline JIT for compilation data: "
"BaselineScripts.");
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("baseline-stubs"),
cStats.baselineStubs,
"Memory used by Baseline IC stubs (excluding code).");
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("ion-data"),
cStats.ionData,
"Memory used by the IonMonkey JIT for compilation data: "