Bug 474500 - TM: Need an API to flush and (optionally?) deallocate the code cache per thread.

This commit is contained in:
Andreas Gal 2009-12-28 09:46:50 -08:00
parent 0fe5da21fb
commit 2943a7a949
5 changed files with 29 additions and 6 deletions

View File

@ -2604,6 +2604,12 @@ JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key)
#endif
}
JS_PUBLIC_API(void)
JS_FlushCaches(JSContext *cx)
{
js_FlushJITCache(cx);
}
JS_PUBLIC_API(intN)
JS_AddExternalStringFinalizer(JSStringFinalizeOp finalizer)
{

View File

@ -1324,6 +1324,15 @@ JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32 value);
extern JS_PUBLIC_API(uint32)
JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key);
/*
* Flush the code cache for the current thread. The operation might be
* delayed if the cache cannot be flushed currently because native
* code is currently executing.
*/
extern JS_PUBLIC_API(void)
JS_FlushCaches(JSContext *cx);
/*
* Add a finalizer for external strings created by JS_NewExternalString (see
* below) using a type-code returned from this function, and that understands

View File

@ -3265,7 +3265,7 @@ class RegExpNativeCompiler {
js_FragProfiling_FragFinalizer(frag, tm);
}
)
js_ResetJIT(cx);
js_FlushJITCache(cx);
} else {
if (!guard) insertGuard(loopLabel, re_chars, re_length);
re->flags |= JSREG_NOCOMPILE;

View File

@ -2279,11 +2279,11 @@ SpecializeTreesToMissingGlobals(JSContext* cx, JSObject* globalObj, TreeFragment
SpecializeTreesToLateGlobals(cx, root, root->globalTypeMap(), root->nGlobalTypes());
}
static JS_REQUIRES_STACK void
static void
ResetJITImpl(JSContext* cx);
#ifdef MOZ_TRACEVIS
static JS_INLINE JS_REQUIRES_STACK void
static JS_INLINE void
ResetJIT(JSContext* cx, TraceVisFlushReason r)
{
js_LogTraceVisEvent(cx, S_RESET, r);
@ -2293,6 +2293,12 @@ ResetJIT(JSContext* cx, TraceVisFlushReason r)
#define ResetJIT(cx, r) ResetJITImpl(cx)
#endif
void
js_FlushJITCache(JSContext *cx)
{
ResetJIT(cx, FR_OOM);
}
static void
TrashTree(JSContext* cx, TreeFragment* f);
@ -4308,15 +4314,17 @@ ProhibitFlush(JSContext* cx)
return false;
}
static JS_REQUIRES_STACK void
static void
ResetJITImpl(JSContext* cx)
{
if (!TRACING_ENABLED(cx))
return;
JSTraceMonitor* tm = &JS_TRACE_MONITOR(cx);
debug_only_print0(LC_TMTracer, "Flushing cache.\n");
if (tm->recorder)
if (tm->recorder) {
JS_ASSERT_NOT_ON_TRACE(cx);
js_AbortRecording(cx, "flush cache");
}
if (ProhibitFlush(cx)) {
debug_only_print0(LC_TMTracer, "Deferring JIT flush due to deep bail.\n");
tm->needFlush = JS_TRUE;

View File

@ -1480,7 +1480,7 @@ extern bool
js_OverfullJITCache(JSTraceMonitor* tm);
extern void
js_ResetJIT(JSContext* cx);
js_FlushJITCache(JSContext* cx);
extern void
js_PurgeJITOracle();