Jit: Startup/Shutdown cleanup
A legacy of early parallel Jit development was separate Startup & Shutdown
code for the interpreter half of the jit (dvmJitStartup/dvmJitShutdown)
and the compiler half (dvmCompilerStartup/dvmCompilerShutdown). This cl
eliminates the dvmJit pair. Additionally, guard coded added to the
framework callback to return immediately if the Jit isn't active.
diff --git a/vm/Init.c b/vm/Init.c
index 003e7c1..61afa7c 100644
--- a/vm/Init.c
+++ b/vm/Init.c
@@ -1378,7 +1378,7 @@
#ifdef WITH_JIT
if (gDvm.executionMode == kExecutionModeJit) {
- if (!dvmJitStartup())
+ if (!dvmCompilerStartup())
return false;
}
#endif
@@ -1571,7 +1571,7 @@
#ifdef WITH_JIT
if (gDvm.executionMode == kExecutionModeJit) {
/* shut down the compiler thread */
- dvmJitShutdown();
+ dvmCompilerShutdown();
}
#endif
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index 2fafd4e..d23a52f 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -503,8 +503,25 @@
else if (gDvm.verboseShutdown)
LOGD("Compiler thread has shut down\n");
}
-}
+ if (gDvm.verboseShutdown)
+ dvmCompilerDumpStats();
+
+ dvmDestroyMutex(&gDvmJit.tableLock);
+ dvmDestroyMutex(&gDvmJit.compilerLock);
+ dvmDestroyMutex(&gDvmJit.compilerICPatchLock);
+
+ if (gDvmJit.pJitEntryTable) {
+ free(gDvmJit.pJitEntryTable);
+ gDvmJit.pJitEntryTable = NULL;
+ }
+
+ if (gDvmJit.pProfTable) {
+ free(gDvmJit.pProfTable);
+ gDvmJit.pProfTable = NULL;
+ }
+
+}
void dvmCompilerStateRefresh()
{
diff --git a/vm/interp/Jit.c b/vm/interp/Jit.c
index b3fe1bf..4949b9c 100644
--- a/vm/interp/Jit.c
+++ b/vm/interp/Jit.c
@@ -343,18 +343,6 @@
}
#endif
-int dvmJitStartup(void)
-{
- unsigned int i;
- bool res = true; /* Assume success */
-
- // Create the compiler thread, which will complete initialization
- if (gDvm.executionMode == kExecutionModeJit) {
- res = dvmCompilerStartup();
- }
- return res;
-}
-
/*
* If one of our fixed tables or the translation buffer fills up,
* call this routine to avoid wasting cycles on future translation requests.
@@ -447,32 +435,6 @@
}
-/*
- * Final JIT shutdown. Only do this once, and do not attempt to restart
- * the JIT later.
- */
-void dvmJitShutdown(void)
-{
- /* Shutdown the compiler thread */
-
- dvmCompilerShutdown();
-
- if (gDvm.verboseShutdown)
- dvmCompilerDumpStats();
-
- dvmDestroyMutex(&gDvmJit.tableLock);
-
- if (gDvmJit.pJitEntryTable) {
- free(gDvmJit.pJitEntryTable);
- gDvmJit.pJitEntryTable = NULL;
- }
-
- if (gDvmJit.pProfTable) {
- free(gDvmJit.pProfTable);
- gDvmJit.pProfTable = NULL;
- }
-}
-
void setTraceConstruction(JitEntry *slot, bool value)
{
diff --git a/vm/interp/Jit.h b/vm/interp/Jit.h
index 3afaa6a..273b35f 100644
--- a/vm/interp/Jit.h
+++ b/vm/interp/Jit.h
@@ -109,8 +109,6 @@
void* codeAddress; /* Code address of native translation */
} JitEntry;
-int dvmJitStartup(void);
-void dvmJitShutdown(void);
int dvmCheckJit(const u2* pc, Thread* self, InterpState* interpState);
void* dvmJitGetCodeAddr(const u2* dPC);
bool dvmJitCheckTraceRequest(Thread* self, InterpState* interpState);
diff --git a/vm/native/dalvik_system_VMRuntime.c b/vm/native/dalvik_system_VMRuntime.c
index 5617e2e..5a22120 100644
--- a/vm/native/dalvik_system_VMRuntime.c
+++ b/vm/native/dalvik_system_VMRuntime.c
@@ -188,9 +188,11 @@
JValue* pResult)
{
#if defined(WITH_JIT)
- dvmLockMutex(&gDvmJit.compilerLock);
- pthread_cond_signal(&gDvmJit.compilerQueueActivity);
- dvmUnlockMutex(&gDvmJit.compilerLock);
+ if (gDvm.executionMode == kExecutionModeJit) {
+ dvmLockMutex(&gDvmJit.compilerLock);
+ pthread_cond_signal(&gDvmJit.compilerQueueActivity);
+ dvmUnlockMutex(&gDvmJit.compilerLock);
+ }
#endif
RETURN_VOID();
}