OSDN Git Service

Jit: Startup/Shutdown cleanup
authorBill Buzbee <buzbee@google.com>
Tue, 9 Feb 2010 01:08:15 +0000 (17:08 -0800)
committerBill Buzbee <buzbee@google.com>
Tue, 9 Feb 2010 01:08:15 +0000 (17:08 -0800)
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.

vm/Init.c
vm/compiler/Compiler.c
vm/interp/Jit.c
vm/interp/Jit.h
vm/native/dalvik_system_VMRuntime.c

index 003e7c1..61afa7c 100644 (file)
--- a/vm/Init.c
+++ b/vm/Init.c
@@ -1378,7 +1378,7 @@ bool dvmInitAfterZygote(void)
 
 #ifdef WITH_JIT
     if (gDvm.executionMode == kExecutionModeJit) {
-        if (!dvmJitStartup())
+        if (!dvmCompilerStartup())
             return false;
     }
 #endif
@@ -1571,7 +1571,7 @@ void dvmShutdown(void)
 #ifdef WITH_JIT
     if (gDvm.executionMode == kExecutionModeJit) {
         /* shut down the compiler thread */
-        dvmJitShutdown();
+        dvmCompilerShutdown();
     }
 #endif
 
index 1d52198..705333b 100644 (file)
@@ -503,8 +503,25 @@ void dvmCompilerShutdown(void)
         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()
 {
index b3fe1bf..4949b9c 100644 (file)
@@ -343,18 +343,6 @@ static bool selfVerificationDebugInterp(const u2* pc, Thread* self)
 }
 #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 @@ void dvmJitStats()
 }
 
 
-/*
- * 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)
 {
 
index 03a8b64..eb4c95d 100644 (file)
@@ -108,8 +108,6 @@ typedef struct JitEntry {
     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);
index 5617e2e..5a22120 100644 (file)
@@ -188,9 +188,11 @@ static void Dalvik_dalvik_system_VMRuntime_startJitCompilation(const u4* args,
     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();
 }