OSDN Git Service

Add a callback for the framework to explicitly enable the JIT compiler.
authorBen Cheng <bccheng@google.com>
Thu, 28 Jan 2010 21:56:52 +0000 (13:56 -0800)
committerBen Cheng <bccheng@google.com>
Thu, 28 Jan 2010 22:36:01 +0000 (14:36 -0800)
Dalvik_dalvik_system_VMRuntime_startJITCompilation ()V it is.

libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java
vm/native/dalvik_system_VMRuntime.c

index 7ac0849..96e43d8 100644 (file)
@@ -186,4 +186,13 @@ public final class VMRuntime {
      * @return the number of bytes
      */
     public native long getExternalBytesAllocated();
+
+    /**
+     * Tells the VM to enable the JIT compiler. If the VM does not have a JIT
+     * implementation, calling this method should have no effect.
+     *
+     * {@hide}
+     */
+    public native void startJITCompilation();
+
 }
index 0ec3ced..be276f4 100644 (file)
@@ -178,6 +178,25 @@ static void Dalvik_dalvik_system_VMRuntime_getExternalBytesAllocated(
     RETURN_LONG((s8)dvmGetExternalBytesAllocated());
 }
 
+/*
+ * public native void startJITCompilation()
+ *
+ * Callback function from the framework to indicate that an app has gone
+ * through the startup phase and it is time to enable the JIT compiler.
+ */
+static void Dalvik_dalvik_system_VMRuntime_startJITCompilation(const u4* args,
+    JValue* pResult)
+{
+#if defined(WITH_JIT)
+    /*
+     * TODO - experiment the timing and put code here to start JIT'ing
+     * The tentative plan is onResume() will invoke the callback.
+     */
+#endif
+
+    RETURN_VOID();
+}
+
 const DalvikNativeMethod dvm_dalvik_system_VMRuntime[] = {
     { "getTargetHeapUtilization", "()F",
         Dalvik_dalvik_system_VMRuntime_getTargetHeapUtilization },
@@ -195,6 +214,7 @@ const DalvikNativeMethod dvm_dalvik_system_VMRuntime[] = {
         Dalvik_dalvik_system_VMRuntime_trackExternalFree },
     { "getExternalBytesAllocated", "()J",
         Dalvik_dalvik_system_VMRuntime_getExternalBytesAllocated },
+    { "startJITCompilation", "()V",
+        Dalvik_dalvik_system_VMRuntime_startJITCompilation },
     { NULL, NULL, NULL },
 };
-