Fix the JIT blocking mode to unblock itself.
Change-Id: Iaf1da9ee3ce337f2c5ad4985a6c776bc68472f8c
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index 0380e02..bd12e56 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -118,7 +118,13 @@
int oldStatus = dvmChangeStatus(NULL, THREAD_VMWAIT);
dvmLockMutex(&gDvmJit.compilerLock);
while (workQueueLength() != 0 && !gDvmJit.haltCompilerThread) {
- pthread_cond_wait(&gDvmJit.compilerQueueEmpty, &gDvmJit.compilerLock);
+ /*
+ * Use timed wait here - more than one mutator threads may be blocked
+ * but the compiler thread will only signal once when the queue is
+ * emptied. Furthermore, the compiler thread may have been shutdown
+ * so the blocked thread may never get the wakeup signal.
+ */
+ dvmRelativeCondWait(&gDvmJit.compilerQueueEmpty, &gDvmJit.compilerLock, 1000, 0);
}
dvmUnlockMutex(&gDvmJit.compilerLock);
dvmChangeStatus(NULL, oldStatus);