Bug 720219 (part 4) - Clean up JS script measurement. r=bhackett.

--HG--
extra : rebase_source : 5c237412c6f3409f81ef23b1ab38b982540e14c3
This commit is contained in:
Nicholas Nethercote 2012-01-23 15:39:39 -08:00
parent ca4887ca0c
commit 8d17f2415b
8 changed files with 48 additions and 84 deletions

View File

@ -168,9 +168,9 @@ CellCallback(JSContext *cx, void *vdata, void *thing, JSGCTraceKind traceKind,
{
JSScript *script = static_cast<JSScript *>(thing);
curr->gcHeapScripts += thingSize;
curr->scriptData += script->dataSize(data->mallocSizeOf);
curr->scriptData += script->sizeOfData(data->mallocSizeOf);
#ifdef JS_METHODJIT
curr->mjitData += script->jitDataSize(data->mallocSizeOf);
curr->mjitData += script->sizeOfJitScripts(data->mallocSizeOf);
#endif
break;
}

View File

@ -1,2 +0,0 @@
if (typeof mjitdatastats == "function")
mjitdatastats();

View File

@ -1267,7 +1267,7 @@ JSScript::NewScriptFromEmitter(JSContext *cx, BytecodeEmitter *bce)
}
size_t
JSScript::dataSize()
JSScript::computedSizeOfData()
{
#if JS_SCRIPT_INLINE_DATA_LIMIT
if (data == inlineData)
@ -1280,14 +1280,14 @@ JSScript::dataSize()
}
size_t
JSScript::dataSize(JSMallocSizeOfFun mallocSizeOf)
JSScript::sizeOfData(JSMallocSizeOfFun mallocSizeOf)
{
#if JS_SCRIPT_INLINE_DATA_LIMIT
if (data == inlineData)
return 0;
#endif
return mallocSizeOf(data, dataSize());
return mallocSizeOf(data, computedSizeOfData());
}
/*
@ -1370,7 +1370,7 @@ JSScript::finalize(JSContext *cx, bool background)
if (data != inlineData)
#endif
{
JS_POISON(data, 0xdb, dataSize());
JS_POISON(data, 0xdb, computedSizeOfData());
cx->free_(data);
}
}

View File

@ -638,7 +638,7 @@ struct JSScript : public js::gc::Cell {
void resetUseCount() { useCount = 0; }
/* Size of the JITScript and all sections. (This method is implemented in MethodJIT.cpp.) */
size_t jitDataSize(JSMallocSizeOfFun mallocSizeOf);
size_t sizeOfJitScripts(JSMallocSizeOfFun mallocSizeOf);
#endif
@ -656,12 +656,13 @@ struct JSScript : public js::gc::Cell {
}
/*
* The first dataSize() is the in-use size of all the data sections, the
* second is the size of the block allocated to hold all the data sections
* computedSizeOfData() is the in-use size of all the data sections.
* sizeOfData() is the size of the block allocated to hold all the data sections
* (which can be larger than the in-use size).
*/
JS_FRIEND_API(size_t) dataSize(); /* Size of all data sections */
JS_FRIEND_API(size_t) dataSize(JSMallocSizeOfFun mallocSizeOf); /* Size of all data sections */
size_t computedSizeOfData();
size_t sizeOfData(JSMallocSizeOfFun mallocSizeOf);
uint32_t numNotes(); /* Number of srcnote slots in the srcnotes section */
/* Script notes are allocated right after the code. */

View File

@ -1334,7 +1334,7 @@ mjit::Compiler::finishThisUp()
nNmapLive++;
}
/* Please keep in sync with JITChunk::scriptDataSize! */
/* Please keep in sync with JITChunk::sizeOfIncludingThis! */
size_t dataSize = sizeof(JITChunk) +
sizeof(NativeMapEntry) * nNmapLive +
sizeof(InlineFrame) * inlineFrames.length() +
@ -1726,8 +1726,8 @@ mjit::Compiler::finishThisUp()
#endif
JS_ASSERT(size_t(cursor - (uint8_t*)chunk) == dataSize);
/* Pass in NULL here -- we don't want slop bytes to be counted. */
JS_ASSERT(chunk->scriptDataSize(NULL) == dataSize);
/* Use the computed size here -- we don't want slop bytes to be counted. */
JS_ASSERT(chunk->computedSizeOfIncludingThis() == dataSize);
/* Link fast and slow paths together. */
stubcc.fixCrossJumps(result, masm.size(), masm.size() + stubcc.size());

View File

@ -1362,54 +1362,58 @@ JITScript::destroyChunk(JSContext *cx, unsigned chunkIndex, bool resetUses)
}
size_t
JSScript::jitDataSize(JSMallocSizeOfFun mallocSizeOf)
JSScript::sizeOfJitScripts(JSMallocSizeOfFun mallocSizeOf)
{
size_t n = 0;
if (jitNormal)
n += jitNormal->scriptDataSize(mallocSizeOf);
n += jitNormal->sizeOfIncludingThis(mallocSizeOf);
if (jitCtor)
n += jitCtor->scriptDataSize(mallocSizeOf);
n += jitCtor->sizeOfIncludingThis(mallocSizeOf);
return n;
}
size_t
mjit::JITScript::scriptDataSize(JSMallocSizeOfFun mallocSizeOf)
mjit::JITScript::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf)
{
size_t usable = mallocSizeOf(this,
sizeof(JITScript)
+ (nchunks * sizeof(ChunkDescriptor))
+ (nedges * sizeof(CrossChunkEdge)));
size_t computedSize = sizeof(JITScript) +
(nchunks * sizeof(ChunkDescriptor)) +
(nedges * sizeof(CrossChunkEdge));
size_t n = mallocSizeOf(this, computedSize);
for (unsigned i = 0; i < nchunks; i++) {
const ChunkDescriptor &desc = chunkDescriptor(i);
if (desc.chunk)
usable += desc.chunk->scriptDataSize(mallocSizeOf);
n += desc.chunk->sizeOfIncludingThis(mallocSizeOf);
}
return usable;
return n;
}
/* Please keep in sync with Compiler::finishThisUp! */
size_t
mjit::JITChunk::scriptDataSize(JSMallocSizeOfFun mallocSizeOf)
mjit::JITChunk::computedSizeOfIncludingThis()
{
size_t computedSize =
sizeof(JITChunk) +
sizeof(NativeMapEntry) * nNmapPairs +
sizeof(InlineFrame) * nInlineFrames +
sizeof(CallSite) * nCallSites +
return sizeof(JITChunk) +
sizeof(NativeMapEntry) * nNmapPairs +
sizeof(InlineFrame) * nInlineFrames +
sizeof(CallSite) * nCallSites +
#if defined JS_MONOIC
sizeof(ic::GetGlobalNameIC) * nGetGlobalNames +
sizeof(ic::SetGlobalNameIC) * nSetGlobalNames +
sizeof(ic::CallICInfo) * nCallICs +
sizeof(ic::EqualityICInfo) * nEqualityICs +
sizeof(ic::GetGlobalNameIC) * nGetGlobalNames +
sizeof(ic::SetGlobalNameIC) * nSetGlobalNames +
sizeof(ic::CallICInfo) * nCallICs +
sizeof(ic::EqualityICInfo) * nEqualityICs +
#endif
#if defined JS_POLYIC
sizeof(ic::PICInfo) * nPICs +
sizeof(ic::GetElementIC) * nGetElems +
sizeof(ic::SetElementIC) * nSetElems +
sizeof(ic::PICInfo) * nPICs +
sizeof(ic::GetElementIC) * nGetElems +
sizeof(ic::SetElementIC) * nSetElems +
#endif
0;
/* |mallocSizeOf| can be null here. */
return mallocSizeOf ? mallocSizeOf(this, computedSize) : computedSize;
0;
}
/* Please keep in sync with Compiler::finishThisUp! */
size_t
mjit::JITChunk::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf)
{
return mallocSizeOf(this, computedSizeOfIncludingThis());
}
void

View File

@ -719,8 +719,8 @@ struct JITChunk
void nukeScriptDependentICs();
/* |mallocSizeOf| can be NULL here, in which case the fallback size computation will be used. */
size_t scriptDataSize(JSMallocSizeOfFun mallocSizeOf);
size_t computedSizeOfIncludingThis();
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf);
~JITChunk();
@ -842,7 +842,7 @@ struct JITScript
jsbytecode *nativeToPC(void *returnAddress, CallSite **pinline);
size_t scriptDataSize(JSMallocSizeOfFun mallocSizeOf);
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf);
void destroy(JSContext *cx);
void destroyChunk(JSContext *cx, unsigned chunkIndex, bool resetUses = true);

View File

@ -3813,43 +3813,6 @@ MJitCodeStats(JSContext *cx, uintN argc, jsval *vp)
return true;
}
#ifdef JS_METHODJIT
static size_t
computedSize(const void *p, size_t size)
{
return size;
}
static void
SumJitDataSizeCallback(JSContext *cx, void *data, void *thing,
JSGCTraceKind traceKind, size_t thingSize)
{
size_t *sump = static_cast<size_t *>(data);
JS_ASSERT(traceKind == JSTRACE_SCRIPT);
JSScript *script = static_cast<JSScript *>(thing);
/*
* Passing in |computedSize| causes jitDataSize to fall back to its
* secondary size computation.
*/
*sump += script->jitDataSize(computedSize);
}
#endif
JSBool
MJitDataStats(JSContext *cx, uintN argc, jsval *vp)
{
#ifdef JS_METHODJIT
size_t n = 0;
IterateCells(cx, NULL, gc::FINALIZE_SCRIPT, &n, SumJitDataSizeCallback);
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(n));
#else
JS_SET_RVAL(cx, vp, JSVAL_VOID);
#endif
return true;
}
JSBool
MJitChunkLimit(JSContext *cx, uintN argc, jsval *vp)
{
@ -4041,7 +4004,6 @@ static JSFunctionSpec shell_functions[] = {
JS_FN("deserialize", Deserialize, 1,0),
#ifdef JS_METHODJIT
JS_FN("mjitcodestats", MJitCodeStats, 0,0),
JS_FN("mjitdatastats", MJitDataStats, 0,0),
#endif
JS_FN("mjitChunkLimit", MJitChunkLimit, 1,0),
JS_FN("stringstats", StringStats, 0,0),
@ -4189,7 +4151,6 @@ static const char *const shell_help_messages[] = {
"deserialize(a) Deserialize data generated by serialize.",
#ifdef JS_METHODJIT
"mjitcodestats() Return stats on mjit code memory usage.",
"mjitdatastats() Return stats on mjit data memory usage.",
#endif
"mjitChunkLimit(N) Specify limit on compiled chunk size during mjit compilation.",
"stringstats() Return stats on string memory usage.",