mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 623281: about:memory reporting for method JIT space usage, r=dvander
--HG-- extra : rebase_source : 39276fb0279b528f5e17122a980e243ff92fde27
This commit is contained in:
parent
75cfb7dd76
commit
2efe7ec019
@ -1435,6 +1435,10 @@ struct JSRuntime {
|
||||
JSWrapObjectCallback wrapObjectCallback;
|
||||
JSPreWrapCallback preWrapObjectCallback;
|
||||
|
||||
#ifdef JS_METHODJIT
|
||||
uint32 mjitMemoryUsed;
|
||||
#endif
|
||||
|
||||
JSRuntime();
|
||||
~JSRuntime();
|
||||
|
||||
|
@ -417,6 +417,7 @@ mjit::Compiler::finishThisUp(JITScript **jitp)
|
||||
nNmapLive++;
|
||||
}
|
||||
|
||||
/* Please keep in sync with JITScript::scriptDataSize! */
|
||||
size_t totalBytes = sizeof(JITScript) +
|
||||
sizeof(NativeMapEntry) * nNmapLive +
|
||||
#if defined JS_MONOIC
|
||||
@ -818,6 +819,9 @@ mjit::Compiler::finishThisUp(JITScript **jitp)
|
||||
jit->nNmapPairs = nNmapLive;
|
||||
*jitp = jit;
|
||||
|
||||
/* We tolerate a race in the stats. */
|
||||
cx->runtime->mjitMemoryUsed += totalSize + totalBytes;
|
||||
|
||||
return Compile_Okay;
|
||||
}
|
||||
|
||||
|
@ -838,23 +838,48 @@ mjit::JITScript::~JITScript()
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Please keep in sync with Compiler::finishThisUp! */
|
||||
size_t
|
||||
mjit::JITScript::scriptDataSize()
|
||||
{
|
||||
return sizeof(JITScript) +
|
||||
sizeof(NativeMapEntry) * nNmapPairs +
|
||||
#if defined JS_MONOIC
|
||||
sizeof(ic::MICInfo) * nMICs +
|
||||
sizeof(ic::CallICInfo) * nCallICs +
|
||||
sizeof(ic::EqualityICInfo) * nEqualityICs +
|
||||
sizeof(ic::TraceICInfo) * nTraceICs +
|
||||
#endif
|
||||
#if defined JS_POLYIC
|
||||
sizeof(ic::PICInfo) * nPICs +
|
||||
sizeof(ic::GetElementIC) * nGetElems +
|
||||
sizeof(ic::SetElementIC) * nSetElems +
|
||||
#endif
|
||||
sizeof(CallSite) * nCallSites;
|
||||
}
|
||||
|
||||
void
|
||||
mjit::ReleaseScriptCode(JSContext *cx, JSScript *script)
|
||||
{
|
||||
// NB: The recompiler may call ReleaseScriptCode, in which case it
|
||||
// will get called again when the script is destroyed, so we
|
||||
// must protect against calling ReleaseScriptCode twice.
|
||||
JITScript *jscr;
|
||||
|
||||
if (script->jitNormal) {
|
||||
script->jitNormal->~JITScript();
|
||||
cx->free(script->jitNormal);
|
||||
if ((jscr = script->jitNormal)) {
|
||||
cx->runtime->mjitMemoryUsed -= jscr->scriptDataSize() + jscr->mainCodeSize();
|
||||
|
||||
jscr->~JITScript();
|
||||
cx->free(jscr);
|
||||
script->jitNormal = NULL;
|
||||
script->jitArityCheckNormal = NULL;
|
||||
}
|
||||
|
||||
if (script->jitCtor) {
|
||||
script->jitCtor->~JITScript();
|
||||
cx->free(script->jitCtor);
|
||||
if ((jscr = script->jitCtor)) {
|
||||
cx->runtime->mjitMemoryUsed -= jscr->scriptDataSize() + jscr->mainCodeSize();
|
||||
|
||||
jscr->~JITScript();
|
||||
cx->free(jscr);
|
||||
script->jitCtor = NULL;
|
||||
script->jitArityCheckCtor = NULL;
|
||||
}
|
||||
|
@ -354,6 +354,10 @@ struct JITScript {
|
||||
void sweepCallICs(bool purgeAll);
|
||||
void purgeMICs();
|
||||
void purgePICs();
|
||||
|
||||
size_t auxCodeSize();
|
||||
|
||||
size_t mainCodeSize() { return code.m_size; } /* doesn't account for fragmentation */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -4299,6 +4299,13 @@ DefGlobalPropIf(JSContext *cx, uintN argc, jsval *vp)
|
||||
return global && JS_DefineOwnProperty(cx, global, id, argv[2], &ignore);
|
||||
}
|
||||
|
||||
JSBool
|
||||
MJitStats(JSContext *cx, uintN argc, jsval *vp)
|
||||
{
|
||||
JS_SET_RVAL(cx, vp, INT_TO_JSVAL(cx->runtime->mjitMemoryUsed));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* We use a mix of JS_FS and JS_FN to test both kinds of natives. */
|
||||
static JSFunctionSpec shell_functions[] = {
|
||||
JS_FN("version", Version, 0,0),
|
||||
@ -4398,6 +4405,9 @@ static JSFunctionSpec shell_functions[] = {
|
||||
JS_FN("deserialize", Deserialize, 1,0),
|
||||
JS_FN("setGlobalPropIf",SetGlobalPropIf,3,0),
|
||||
JS_FN("defGlobalPropIf",DefGlobalPropIf,3,0),
|
||||
#ifdef JS_METHODJIT
|
||||
JS_FN("mjitstats", MJitStats, 0,0),
|
||||
#endif
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
@ -4530,6 +4540,9 @@ static const char *const shell_help_messages[] = {
|
||||
"setGlobalPropIf(b,id,v) If b, get the global object o and perform o[id] = v.\n",
|
||||
"defGlobalPropIf(b,id,dsc)If b, get the global object o and perform\n"
|
||||
" Object.defineProperty(o, id, dsc).\n"
|
||||
#ifdef JS_METHODJIT
|
||||
,"mjitstats() Return stats on mjit memory usage.\n"
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Help messages must match shell functions. */
|
||||
|
@ -1192,11 +1192,31 @@ protected:
|
||||
static XPConnectGCChunkAllocator gXPCJSChunkAllocator;
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSRuntimeGCChunks,
|
||||
"xpconnect/js/gcchunks",
|
||||
"Memory in use by main JS Runtime GC chunks",
|
||||
"js/gc-heap",
|
||||
"Main JS GC heap",
|
||||
XPConnectGCChunkAllocator::GetGCChunkBytesInUse,
|
||||
&gXPCJSChunkAllocator)
|
||||
|
||||
/* FIXME: use API provided by bug 623271 */
|
||||
#include "jscntxt.h"
|
||||
|
||||
static PRInt64
|
||||
GetJSMethodJitCodeMemoryInUse(void *data)
|
||||
{
|
||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
#ifdef JS_METHODJIT
|
||||
return rt->mjitMemoryUsed;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSMethodJitCode,
|
||||
"js/mjit-code",
|
||||
"Memory in use by method-JIT for compiled code",
|
||||
GetJSMethodJitCodeMemoryInUse,
|
||||
NULL)
|
||||
|
||||
XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
: mXPConnect(aXPConnect),
|
||||
mJSRuntime(nsnull),
|
||||
@ -1259,6 +1279,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
mJSRuntime->setCustomGCChunkAllocator(&gXPCJSChunkAllocator);
|
||||
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSRuntimeGCChunks));
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSMethodJitCode));
|
||||
}
|
||||
|
||||
if(!JS_DHashTableInit(&mJSHolders, JS_DHashGetStubOps(), nsnull,
|
||||
|
Loading…
Reference in New Issue
Block a user