From nobody Mon Sep 17 00:00:00 2001 From: Pavel Afremov Date: Mon, 11 Sep 2006 19:58:22 +0400 Subject: [PATCH] [DRLVM] Fix bug: missed exception from compilation stage. When native code throwing exception during compilation (example, VerifyError), VM missing catch handler in java frame. Call of exn_rethrow was added to compilation stub to fix it. EM64T support update. Moved ASSERT_RAISE_AREA from monenter to monexit function. This jira depends on HARMONY-1363 --- vm/vmcore/src/jni/jni.cpp | 2 ++ vm/vmcore/src/thread/mon_enter_exit.cpp | 2 ++ vm/vmcore/src/util/em64t/base/compile_em64t.cpp | 10 +++++++++- vm/vmcore/src/util/ia32/base/compile_IA32.cpp | 10 ++++++---- 4 files changed, 19 insertions(+), 5 deletions(-) 2e6a0d54d8450161f45cf25fc0a8f56645b894f0 diff --git a/vm/vmcore/src/jni/jni.cpp b/vm/vmcore/src/jni/jni.cpp index 9488261..c8f7d28 100644 --- a/vm/vmcore/src/jni/jni.cpp +++ b/vm/vmcore/src/jni/jni.cpp @@ -1016,6 +1016,8 @@ jint JNICALL MonitorEnter(JNIEnv * UNREF jint JNICALL MonitorExit(JNIEnv * UNREF env, jobject obj) { + ASSERT_RAISE_AREA; + TRACE2("jni", "MonitorExit called"); assert(hythread_is_suspend_enabled()); jthread_monitor_exit(obj); diff --git a/vm/vmcore/src/thread/mon_enter_exit.cpp b/vm/vmcore/src/thread/mon_enter_exit.cpp index 39acf4e..ede2b05 100644 --- a/vm/vmcore/src/thread/mon_enter_exit.cpp +++ b/vm/vmcore/src/thread/mon_enter_exit.cpp @@ -86,6 +86,8 @@ static void vm_monitor_enter_default(Man static void vm_monitor_exit_default(ManagedObject *p_obj) { + ASSERT_RAISE_AREA; + assert(managed_object_is_valid(p_obj)); // assert(!hythread_is_suspend_enabled()); diff --git a/vm/vmcore/src/util/em64t/base/compile_em64t.cpp b/vm/vmcore/src/util/em64t/base/compile_em64t.cpp index 6467e53..d81a735 100644 --- a/vm/vmcore/src/util/em64t/base/compile_em64t.cpp +++ b/vm/vmcore/src/util/em64t/base/compile_em64t.cpp @@ -29,6 +29,8 @@ #include "compile.h" #include "nogc.h" #include "m2n.h" #include "../m2n_em64t_internal.h" +#include "exceptions.h" +#include "exceptions_jit.h" #define LOG_DOMAIN "vm.helpers" #include "cxxlog.h" @@ -146,7 +148,7 @@ static NativeCodePtr compile_get_compile return addr; } - const int STUB_SIZE = 350; + const int STUB_SIZE = 357; char * stub = (char *) malloc_fixed_code_for_jit(STUB_SIZE, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate); addr = stub; @@ -183,6 +185,12 @@ #endif stub = mov(stub, rdi_opnd, M_Base_Opnd(rsp_reg, 0)); // compile the method stub = call(stub, (char *)&compile_jit_a_method); + + // rethrow exception if it panding + stub = push(stub, rax_opnd); + stub = call(stub, (char *)&exn_rethrow_if_pending); + stub = pop(stub, rax_opnd); + // restore gp inputs from the stack // NOTE: m2n_gen_pop_m2n must not destroy inputs stub = pop(stub, rdi_opnd); diff --git a/vm/vmcore/src/util/ia32/base/compile_IA32.cpp b/vm/vmcore/src/util/ia32/base/compile_IA32.cpp index c47b3dd..56fac46 100644 --- a/vm/vmcore/src/util/ia32/base/compile_IA32.cpp +++ b/vm/vmcore/src/util/ia32/base/compile_IA32.cpp @@ -174,14 +174,16 @@ #endif stub = push(stub, ecx_opnd); // compile the method stub = call(stub, (char *)&compile_jit_a_method); + + // rethrow exception if it panding + stub = push(stub, eax_opnd); + stub = call(stub, (char *)&exn_rethrow_if_pending); + stub = pop(stub, eax_opnd); + // remove ecx from the stack stub = pop(stub, ecx_opnd); // pop m2n from the stack stub = m2n_gen_pop_m2n(stub, false, 0, 0, 1); - stub = push(stub, eax_opnd); - // rethrow exception if - stub = call(stub, (char *)&exn_rethrow_if_pending); - stub = pop(stub, eax_opnd); // transfer control to the compiled code stub = jump(stub, eax_opnd); -- 1.3.3