From 3475f9cdb47a6d6f8ad2ce49bbc3af46bca92f09 Mon Sep 17 00:00:00 2001 From: Carl Shapiro Date: Mon, 21 Mar 2011 13:35:24 -0700 Subject: Move finalization out of the VM. This change introduces a new reference class whose referent points to instances requiring finalization. This makes the finalization of objects possible using a reference queue and a dedicated thread which removes objects from the queue. Change-Id: I0ff6dd272f00ca08c6ed3aa667bf766a039a944e --- vm/native/dalvik_system_VMRuntime.c | 19 ------------------- vm/native/dalvik_system_Zygote.c | 12 ++++++------ vm/native/java_lang_Runtime.c | 27 --------------------------- 3 files changed, 6 insertions(+), 52 deletions(-) (limited to 'vm/native') diff --git a/vm/native/dalvik_system_VMRuntime.c b/vm/native/dalvik_system_VMRuntime.c index af0df7a9e..3642f9098 100644 --- a/vm/native/dalvik_system_VMRuntime.c +++ b/vm/native/dalvik_system_VMRuntime.c @@ -54,23 +54,6 @@ static void Dalvik_dalvik_system_VMRuntime_nativeSetTargetHeapUtilization( RETURN_VOID(); } -/* - * public native void runFinalizationSync() - * - * Does not return until any pending finalizers have been called. - * This may or may not happen in the context of the calling thread. - * No exceptions will escape. - * - * Used by zygote, which doesn't have a HeapWorker thread. - */ -static void Dalvik_dalvik_system_VMRuntime_runFinalizationSync(const u4* args, - JValue* pResult) -{ - dvmRunFinalizationSync(); - - RETURN_VOID(); -} - /* * public native void startJitCompilation() * @@ -216,8 +199,6 @@ const DalvikNativeMethod dvm_dalvik_system_VMRuntime[] = { Dalvik_dalvik_system_VMRuntime_newNonMovableArray }, { "properties", "()[Ljava/lang/String;", Dalvik_dalvik_system_VMRuntime_properties }, - { "runFinalizationSync", "()V", - Dalvik_dalvik_system_VMRuntime_runFinalizationSync }, { "startJitCompilation", "()V", Dalvik_dalvik_system_VMRuntime_startJitCompilation }, { "vmVersion", "()Ljava/lang/String;", diff --git a/vm/native/dalvik_system_Zygote.c b/vm/native/dalvik_system_Zygote.c index 905eb9a51..6f7e6fa69 100644 --- a/vm/native/dalvik_system_Zygote.c +++ b/vm/native/dalvik_system_Zygote.c @@ -513,11 +513,11 @@ static void Dalvik_dalvik_system_Zygote_forkSystemServer( } const DalvikNativeMethod dvm_dalvik_system_Zygote[] = { - { "fork", "()I", - Dalvik_dalvik_system_Zygote_fork }, - { "forkAndSpecialize", "(II[II[[I)I", - Dalvik_dalvik_system_Zygote_forkAndSpecialize }, - { "forkSystemServer", "(II[II[[IJJ)I", - Dalvik_dalvik_system_Zygote_forkSystemServer }, + { "nativeFork", "()I", + Dalvik_dalvik_system_Zygote_fork }, + { "nativeForkAndSpecialize", "(II[II[[I)I", + Dalvik_dalvik_system_Zygote_forkAndSpecialize }, + { "nativeForkSystemServer", "(II[II[[IJJ)I", + Dalvik_dalvik_system_Zygote_forkSystemServer }, { NULL, NULL, NULL }, }; diff --git a/vm/native/java_lang_Runtime.c b/vm/native/java_lang_Runtime.c index b5c6a3362..112448c78 100644 --- a/vm/native/java_lang_Runtime.c +++ b/vm/native/java_lang_Runtime.c @@ -92,31 +92,6 @@ static void Dalvik_java_lang_Runtime_nativeLoad(const u4* args, RETURN_PTR(result); } -/* - * public void runFinalization(boolean forced) - * - * Requests that the VM runs finalizers for objects on the heap. If the - * parameter forced is true, then the VM needs to ensure finalization. - * Otherwise this only inspires the VM to make a best-effort attempt to - * run finalizers before returning, but it's not guaranteed to actually - * do anything. - */ -static void Dalvik_java_lang_Runtime_runFinalization(const u4* args, - JValue* pResult) -{ - bool forced = (args[0] != 0); - - dvmWaitForHeapWorkerIdle(); - if (forced) { - // TODO(Google) Need to explicitly implement this, - // although dvmWaitForHeapWorkerIdle() - // should usually provide the "forced" - // behavior already. - } - - RETURN_VOID(); -} - /* * public long maxMemory() * @@ -166,8 +141,6 @@ const DalvikNativeMethod dvm_java_lang_Runtime[] = { Dalvik_java_lang_Runtime_nativeExit }, { "nativeLoad", "(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/String;", Dalvik_java_lang_Runtime_nativeLoad }, - { "runFinalization", "(Z)V", - Dalvik_java_lang_Runtime_runFinalization }, { "totalMemory", "()J", Dalvik_java_lang_Runtime_totalMemory }, { NULL, NULL, NULL }, -- cgit v1.2.3