summaryrefslogtreecommitdiffstats
path: root/vm/compiler/Compiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm/compiler/Compiler.c')
-rw-r--r--vm/compiler/Compiler.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index 886b1f11a..a1e3d0e8d 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -99,6 +99,7 @@ bool dvmCompilerWorkEnqueue(const u2 *pc, WorkOrderKind kind, void* info)
newOrder->result.codeAddress = NULL;
newOrder->result.discardResult =
(kind == kWorkOrderTraceDebug) ? true : false;
+ newOrder->result.cacheVersion = gDvmJit.cacheVersion;
newOrder->result.requestingThread = dvmThreadSelf();
gDvmJit.compilerWorkEnqueueIndex++;
@@ -264,6 +265,9 @@ static void resetCodeCache(void)
/* Lock the mutex to clean up the work queue */
dvmLockMutex(&gDvmJit.compilerLock);
+ /* Update the translation cache version */
+ gDvmJit.cacheVersion++;
+
/* Drain the work queue to free the work orders */
while (workQueueLength()) {
CompilerWorkOrder work = workDequeue();
@@ -749,6 +753,33 @@ void dvmCompilerStateRefresh()
return;
}
+ /*
+ * On the first enabling of method tracing, switch the compiler
+ * into a mode that includes trace support for invokes and returns.
+ * If there are any existing translations, flush them. NOTE: we
+ * can't blindly flush the translation cache because this code
+ * may be executed before the compiler thread has finished
+ * initialization.
+ */
+ if ((gDvm.interpBreak & kSubModeMethodTrace) &&
+ !gDvmJit.methodTraceSupport) {
+ bool resetRequired;
+ /*
+ * compilerLock will prevent new compilations from being
+ * installed while we are working.
+ */
+ dvmLockMutex(&gDvmJit.compilerLock);
+ gDvmJit.cacheVersion++; // invalidate compilations in flight
+ gDvmJit.methodTraceSupport = true;
+ resetRequired = (gDvmJit.numCompilations != 0);
+ dvmUnlockMutex(&gDvmJit.compilerLock);
+ if (resetRequired) {
+ dvmSuspendAllThreads(SUSPEND_FOR_CC_RESET);
+ resetCodeCache();
+ dvmResumeAllThreads(SUSPEND_FOR_CC_RESET);
+ }
+ }
+
dvmLockMutex(&gDvmJit.tableLock);
jitActive = gDvmJit.pProfTable != NULL;
jitActivate = !dvmDebuggerOrProfilerActive();