Jit stress mode: translate everything we can and self verify.
This represents a general clean-up of some existing command-line
options: -Xjitthreshold:num and -Xjitblocking. The jit threshold
controls how quickly we treat a Dalvik address as a potential trace
head. Normally this is set around 200 (and the range is 0..255, where
0 is in effect 256 and 1 means begin trace selection on first visit).
-Xjitblocking forces the system to pause execution whenever a translation
request is made and resume when that translation is complete. Normally
the system make a request but continues execution (to avoid jitter).
Additionally, if WITH_SELF_VERIFICATION is defined, we force blocking
to be true, and set the threshold to 1. And finally, we treat
threshold==1 as a special case and disable the 2nd-level trace-building
filter - which causes the system to immediately start trace selection.
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index a44e1c3..b53ebf8 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -96,11 +96,13 @@
/* Block until queue length is 0 */
void dvmCompilerDrainQueue(void)
{
+ int oldStatus = dvmChangeStatus(NULL, THREAD_VMWAIT);
dvmLockMutex(&gDvmJit.compilerLock);
while (workQueueLength() != 0 && !gDvmJit.haltCompilerThread) {
pthread_cond_wait(&gDvmJit.compilerQueueEmpty, &gDvmJit.compilerLock);
}
dvmUnlockMutex(&gDvmJit.compilerLock);
+ dvmChangeStatus(NULL, oldStatus);
}
static void *compilerThreadStart(void *arg)
@@ -135,11 +137,12 @@
if (gDvmJit.haltCompilerThread) {
LOGD("Compiler shutdown in progress - discarding request");
} else {
- /* Compilation is successful */
- if (dvmCompilerDoWork(&work)) {
- dvmJitSetCodeAddr(work.pc, work.result.codeAddress,
- work.result.instructionSet);
+ /* If compilation failed, use interpret-template */
+ if (!dvmCompilerDoWork(&work)) {
+ work.result.codeAddress = gDvmJit.interpretTemplate;
}
+ dvmJitSetCodeAddr(work.pc, work.result.codeAddress,
+ work.result.instructionSet);
}
free(work.info);
dvmLockMutex(&gDvmJit.compilerLock);