From 6bad6a2d77bcfeebf1f5a24406f49bda88503353 Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Thu, 28 Jan 2010 13:56:52 -0800 Subject: [PATCH] Add a callback for the framework to explicitly enable the JIT compiler. Dalvik_dalvik_system_VMRuntime_startJITCompilation ()V it is. --- .../src/main/java/dalvik/system/VMRuntime.java | 9 +++++++++ vm/native/dalvik_system_VMRuntime.c | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java b/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java index 7ac0849e9..96e43d8a7 100644 --- a/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java +++ b/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java @@ -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(); + } diff --git a/vm/native/dalvik_system_VMRuntime.c b/vm/native/dalvik_system_VMRuntime.c index 0ec3ced24..be276f4d7 100644 --- a/vm/native/dalvik_system_VMRuntime.c +++ b/vm/native/dalvik_system_VMRuntime.c @@ -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 }, }; - -- 2.11.0