Index: vm/include/open/rt_helpers.h =================================================================== --- vm/include/open/rt_helpers.h (revision 645798) +++ vm/include/open/rt_helpers.h (working copy) @@ -214,19 +214,10 @@ * @return None. * * Acquire the monitor associated with the object. - * Throw java/lang/NullPointerException, if the argument is null. + * Doesn't throw java/lang/NullPointerException, if the argument + * is null, it assumes that the argument is non-null. Passing a null argument + * will result in undefined behavior.. */ - VM_RT_MONITOR_ENTER_NON_NULL=304, - /** - * @param Object - * - * @return None. - * - * Acquire the monitor associated with the object. - * This function is identical to VM_RT_MONITOR_ENTER except that it - * assumes that the argument is non-null. Passing a null argument - * will result in undefined behavior. - */ VM_RT_MONITOR_EXIT=301, /** * @param Object @@ -234,42 +225,22 @@ * @return None. * * Release the monitor associated with the object. - * Throw java/lang/NullPointerException, if the argument is null. + * Doesn't throw java/lang/NullPointerException, if the argument + * is null, it assumes that the argument is non-null. Passing a null argument + * will result in undefined behavior. * Throw java/lang/IllegalMonitorStateException, if the current * thread is not the owner of the lock. */ - VM_RT_MONITOR_EXIT_NON_NULL=305, - -/** - * @param Object - * - * @return None. - * - * Release the monitor associated with the object. - * This function is identical to VM_RT_MONITOR_EXIT except that it - * assumes that the argument is non-null. Passing a null argument - * will result in undefined behavior. - * Throw java/lang/IllegalMonitorStateException, if the current thread - * is not the owner of the lock. - */ - VM_RT_MONITOR_ENTER_STATIC=302, + + + VM_RT_CLASS_2_JLC=310, /** * @param Class handle * - * @return None. + * @return pointer to java/lang/Class object. * - * Acquire the monitor associated with the class passed as the argument. + * Converts Class handle to java/lang/Class object. */ - VM_RT_MONITOR_EXIT_STATIC=303, -/** - * @param Class handle - * - * @return None. - * - * Release the monitor associated with the class passed as the argument. - * Throw java/lang/IllegalMonitorStateException, if the current thread - * is not the owner of the lock. - */ //// // Type access routines Index: vm/vmcore/src/jit/rt_helper_info.cpp =================================================================== --- vm/vmcore/src/jit/rt_helper_info.cpp (revision 645798) +++ vm/vmcore/src/jit/rt_helper_info.cpp (working copy) @@ -86,31 +86,15 @@ "org/apache/harmony/drlvm/thread/ThreadHelper", "monitorEnterUseReservation", "(Ljava/lang/Object;)V", NULL}, - {VM_RT_MONITOR_ENTER_NON_NULL, "VM_RT_MONITOR_ENTER_NON_NULL", - INTERRUPTIBLE_SOMETIMES, CALLING_CONVENTION_STDCALL, 1, - "org/apache/harmony/drlvm/thread/ThreadHelper", "monitorEnterUseReservation", - "(Ljava/lang/Object;)V", NULL}, - {VM_RT_MONITOR_EXIT, "VM_RT_MONITOR_EXIT", INTERRUPTIBLE_SOMETIMES, CALLING_CONVENTION_STDCALL, 1, "org/apache/harmony/drlvm/thread/ThreadHelper", "monitorExit", "(Ljava/lang/Object;)V", NULL}, - {VM_RT_MONITOR_EXIT_NON_NULL, "VM_RT_MONITOR_EXIT_NON_NULL", - INTERRUPTIBLE_SOMETIMES, CALLING_CONVENTION_STDCALL, 1, - "org/apache/harmony/drlvm/thread/ThreadHelper", "monitorExit", - "(Ljava/lang/Object;)V", NULL}, + {VM_RT_CLASS_2_JLC, "VM_RT_CLASS_2_JLC", + INTERRUPTIBLE_NEVER, CALLING_CONVENTION_STDCALL, 1, + NULL, NULL, NULL, NULL}, - {VM_RT_MONITOR_ENTER_STATIC, "VM_RT_MONITOR_ENTER_STATIC", - INTERRUPTIBLE_SOMETIMES, CALLING_CONVENTION_STDCALL, 1, - "org/apache/harmony/drlvm/thread/ThreadHelper", "monitorEnterUseReservation", - "(Ljava/lang/Object;)V", NULL}, - - {VM_RT_MONITOR_EXIT_STATIC, "VM_RT_MONITOR_EXIT_STATIC", - INTERRUPTIBLE_SOMETIMES, CALLING_CONVENTION_STDCALL, 1, - "org/apache/harmony/drlvm/thread/ThreadHelper", "monitorExit", - "(Ljava/lang/Object;)V", NULL}, - {VM_RT_CHECKCAST, "VM_RT_CHECKCAST", INTERRUPTIBLE_ALWAYS, CALLING_CONVENTION_STDCALL, 2, "org/apache/harmony/drlvm/VMHelperFastPath", "checkCast", Index: vm/vmcore/src/jit/jit_runtime_support.cpp =================================================================== --- vm/vmcore/src/jit/jit_runtime_support.cpp (revision 645798) +++ vm/vmcore/src/jit/jit_runtime_support.cpp (working copy) @@ -1652,10 +1652,18 @@ //end of lazy resolution helpers ////////////////////////////////////////////////////////////////////////// +#if (defined PLATFORM_POSIX) && (defined _IA32_) +ManagedObject* __attribute__ ((__stdcall__)) rth_struct_Class_to_java_lang_Class(Class *clss) { +#elif defined _IA32_ +ManagedObject* __stdcall rth_struct_Class_to_java_lang_Class(Class *clss) { +#else +ManagedObject* rth_struct_Class_to_java_lang_Class(Class *clss) { +#endif + return struct_Class_to_java_lang_Class(clss); +} - NativeCodePtr rth_get_lil_helper(VM_RT_SUPPORT f) { int* dyn_count = NULL; @@ -1684,6 +1692,10 @@ return rth_wrap_exn_throw(dyn_count, "rth_throw_array_store", exn_get_rth_throw_array_store()); case VM_RT_THROW_LINKING_EXCEPTION: return rth_get_lil_throw_linking_exception(dyn_count); + + case VM_RT_CLASS_2_JLC: + return (NativeCodePtr)rth_struct_Class_to_java_lang_Class; + // Type tests case VM_RT_CHECKCAST: return rth_get_lil_checkcast(dyn_count); Index: vm/vmcore/src/jit/compile.cpp =================================================================== --- vm/vmcore/src/jit/compile.cpp (revision 645798) +++ vm/vmcore/src/jit/compile.cpp (working copy) @@ -288,11 +288,15 @@ if (is_synchronised) { if (is_static) { cs = lil_parse_onto_end(cs, + "out stdcall:pint:pint;" + "o0=%0i;" + "call %1i;" "out stdcall:pint:void;" - "o0=%0i;" - "call %1i;", + "o0=r;" + "call %2i;", clss, - lil_npc_to_fp(vm_helper_get_addr(VM_RT_MONITOR_ENTER_STATIC))); + lil_npc_to_fp(vm_helper_get_addr(VM_RT_CLASS_2_JLC)), + lil_npc_to_fp(vm_helper_get_addr(VM_RT_MONITOR_ENTER))); assert(cs); } else { cs = lil_parse_onto_end(cs, @@ -454,11 +458,15 @@ if (is_synchronised) { if (is_static) { cs = lil_parse_onto_end(cs, + "out stdcall:pint:pint;" + "o0=%0i;" + "call %1i;" "out stdcall:pint:void;" - "o0=%0i;" - "call %1i;", + "o0=r;" + "call %2i;", clss, - lil_npc_to_fp(vm_helper_get_addr(VM_RT_MONITOR_EXIT_STATIC))); + lil_npc_to_fp(vm_helper_get_addr(VM_RT_CLASS_2_JLC)), + lil_npc_to_fp(vm_helper_get_addr(VM_RT_MONITOR_EXIT))); } else { cs = lil_parse_onto_end(cs, "ld l0,[l0+%0i:ref];" Index: vm/vmcore/src/util/em64t/base/jit_lock_rt_support_em64t.cpp =================================================================== --- vm/vmcore/src/util/em64t/base/jit_lock_rt_support_em64t.cpp (revision 645798) +++ vm/vmcore/src/util/em64t/base/jit_lock_rt_support_em64t.cpp (working copy) @@ -58,23 +58,6 @@ const R_Opnd & input_param1); #define INPUT_ARG_OFFSET 8 - -// patch_addr_null_arg_ptr is the address of a variable holding the -// address of a branch instruction byte to patch with the destination -// to be taken if the struct Class* argument is NULL. -static char * gen_convert_struct_class_to_object(char *ss, char **patch_addr_null_arg_ptr) -{ - // First make sure the struct Class* argument is non-NULL. - ss = test(ss, rdi_opnd, rdi_opnd); - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0)); - *patch_addr_null_arg_ptr = ((char *)ss) - 1; - - // Convert the struct Class* argument to the corresponding java_lang_Class reference. - ss = call(ss, (char *)struct_Class_to_java_lang_Class); - ss = mov(ss, rdi_opnd, rax_opnd); // overwrite the struct Class* with the raw java_lang_Class reference - return ss; -} //gen_convert_struct_class_to_object - // Helper for monenter intstruction static char * gen_restore_monitor_enter(char *ss, char *patch_addr_null_arg) { @@ -87,9 +70,12 @@ // ss = inc(ss, M_Opnd((int64)incr)); #endif +#ifdef _DEBUG_CHECK_NULL_//_DEBUG + // check on the null ss = test(ss, rdi_opnd, rdi_opnd); ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0)); char *backpatch_address__null_pointer = ((char *)ss) - 1; +#endif // skip fast path if can_generate_monitor_events capability // was requested, so all TI events will be generated @@ -117,6 +103,7 @@ ss = ret(ss); +#ifdef _DEBUG_CHECK_NULL_//_DEBUG // Handle NPE here int64 npe_offset = (int64)ss - (int64)backpatch_address__null_pointer - 1; *backpatch_address__null_pointer = (char)npe_offset; @@ -127,7 +114,7 @@ // Object is null so throw a null pointer exception ss = jump(ss, (char*)exn_get_rth_throw_null_pointer()); - +#endif return ss; } //gen_restore_monitor_enter @@ -164,44 +151,7 @@ return addr; } -void * getaddress__vm_monitor_enter_static_naked() -{ - static void *addr = NULL; - if (addr != NULL) { - return addr; - } - const int stub_size = 208; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0xcc /*int 3*/, stub_size); -#endif - char *ss = stub; - -#ifdef VM_STATS - int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_ENTER_STATIC, 0, NULL); - ss = mov(ss, rax_opnd, Imm_Opnd(size_64, (int64)value)); - ss = inc(ss, M_Base_Opnd(rax_reg, 0)); -#endif - - char *patch_addr_null_arg; - ss = gen_convert_struct_class_to_object(ss, &patch_addr_null_arg); - ss = gen_restore_monitor_enter(ss, patch_addr_null_arg); - - addr = stub; - assert((ss - stub) < stub_size); - - compile_add_dynamic_generated_code_chunk("vm_monitor_enter_static_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_monitor_enter_static_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_monitor_enter_static_naked", ss - stub); - - return addr; -} //getaddress__vm_monitor_enter_static_naked - static char * gen_restore_monitor_exit(char *ss, char *patch_addr_null_arg) { @@ -211,9 +161,12 @@ // ss = inc(ss, M_Opnd((int64)incr)); #endif +#ifdef _DEBUG_CHECK_NULL_//_DEBUG + // check on teh null ss = test(ss, rdi_opnd, rdi_opnd); ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0)); char *backpatch_address__null_pointer = ((char *)ss) - 1; +#endif // skip fast path if can_generate_monitor_events capability // was requested, so all TI events will be generated @@ -242,6 +195,8 @@ // Monitor illegal state happend ss = jump(ss, (char*)exn_get_rth_throw_illegal_state_exception()); +#ifdef _DEBUG_CHECK_NULL_//_DEBUG + //NPE offset = (POINTER_SIZE_SINT)ss - (POINTER_SIZE_SINT)backpatch_address__null_pointer - 1; *backpatch_address__null_pointer = (char)offset; if (patch_addr_null_arg != NULL) { @@ -251,7 +206,7 @@ // Object is null so throw a null pointer exception ss = jump(ss, (char*)exn_get_rth_throw_null_pointer()); - +#endif return ss; } //gen_restore_monitor_exit @@ -289,41 +244,6 @@ return addr; } //getaddress__vm_monitor_exit_naked -void * getaddress__vm_monitor_exit_static_naked() -{ - static void *addr = NULL; - if (addr != NULL) { - return addr; - } - - const int stub_size = 144; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate); - char *ss = stub; - -#ifdef VM_STATS - int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_EXIT_STATIC, 0, NULL); - ss = mov(ss, rax_opnd, Imm_Opnd(size_64, (int64)value)); - ss = inc(ss, M_Base_Opnd(rax_reg, 0)); -#endif - - char *patch_addr_null_arg; - ss = gen_convert_struct_class_to_object(ss, &patch_addr_null_arg); - ss = gen_restore_monitor_exit(ss, patch_addr_null_arg); - - addr = stub; - assert((ss - stub) < stub_size); - - compile_add_dynamic_generated_code_chunk("vm_monitor_exit_static_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_monitor_exit_static_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_monitor_exit_static_naked", ss - stub); - - return addr; -} //getaddress__vm_monitor_exit_static_naked - // Windows x86-64 helpers static LilCodeStub * rth_get_lil_monitor_enter_generic(LilCodeStub * cs) { if(VM_Global_State::loader_env->TI->isEnabled() && @@ -357,41 +277,6 @@ } } -NativeCodePtr rth_get_lil_monitor_enter_static() { - static NativeCodePtr addr = NULL; - - if (addr != NULL) { - return addr; - } - - LilCodeStub * cs = lil_parse_code_stub("entry 0:stdcall:pint:void;"); -#ifdef VM_STATS -// int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_ENTER_STATIC, 0, NULL); -// cs = lil_parse_onto_end(cs, "inc [%0i:pint];", value); -// assert(cs); -#endif - // convert struct Class into java_lang_Class - cs = lil_parse_onto_end(cs, - "in2out platform:ref;" - "call %0i;" - "locals 1;" - "l0 = r;", - struct_Class_to_java_lang_Class - ); - assert(cs); - - // append generic monitor enter code - cs = rth_get_lil_monitor_enter_generic(cs); - assert(cs && lil_is_valid(cs)); - - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "monitor_enter_static", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - return addr; -} - NativeCodePtr rth_get_lil_monitor_enter() { static NativeCodePtr addr = NULL; @@ -406,19 +291,27 @@ // cs = lil_parse_onto_end(cs, "inc [%0i:pint];", value); // assert(cs); #endif + +#ifdef _DEBUG_CHECK_NULL_//_DEBUG // check if object is null cs = lil_parse_onto_end(cs, - "jc i0 = %0i:ref, throw_null_pointer;" - "locals 1;" - "l0 = i0;", + "jc i0 = %0i:ref, throw_null_pointer;", (ManagedObject *) VM_Global_State::loader_env->managed_null ); assert(cs); - +#endif + + cs = lil_parse_onto_end(cs, + "locals 1;" + "l0 = i0;" + ); + assert(cs); + // append generic monitor enter code cs = rth_get_lil_monitor_enter_generic(cs); assert(cs); - + +#ifdef _DEBUG_CHECK_NULL_//_DEBUG // throw NullPointerException cs = lil_parse_onto_end(cs, ":throw_null_pointer;" @@ -427,7 +320,8 @@ lil_npc_to_fp(exn_get_rth_throw_null_pointer()) ); assert(cs && lil_is_valid(cs)); - +#endif + addr = LilCodeGenerator::get_platform()->compile(cs); DUMP_STUB((char *)addr, "monitor_enter", lil_cs_get_code_size(cs)); @@ -436,39 +330,6 @@ return addr; } -// this function doesn't throw NullPointerException in case of null object -NativeCodePtr rth_get_lil_monitor_enter_non_null() { - static NativeCodePtr addr = NULL; - - if (addr != NULL) { - return addr; - } - - LilCodeStub * cs = lil_parse_code_stub( - "entry 0:stdcall:ref:void;" - "locals 1;" - "l0 = i0;" - ); - assert(cs); - -#ifdef VM_STATS -// int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_ENTER_NON_NULL, 0, NULL); -// cs = lil_parse_onto_end(cs, "inc [%0i:pint];", value); -// assert(cs); -#endif - // append generic monitor enter code - cs = rth_get_lil_monitor_enter_generic(cs); - assert(cs && lil_is_valid(cs)); - - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "monitor_enter_non_null", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - return addr; -} - - /* MONITOR EXIT RUNTIME SUPPORT */ static LilCodeStub * rth_get_lil_monitor_exit_generic(LilCodeStub * cs) { @@ -500,42 +361,7 @@ } } -NativeCodePtr rth_get_lil_monitor_exit_static() { - static NativeCodePtr addr = NULL; - - if (addr != NULL) { - return addr; - } - LilCodeStub * cs = lil_parse_code_stub("entry 0:stdcall:pint:void;"); -#ifdef VM_STATS -// int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_EXIT_STATIC, 0, NULL); -// cs = lil_parse_onto_end(cs, "inc [%0i:pint];", value); -// assert(cs); -#endif - // convert struct Class into java_lang_Class - cs = lil_parse_onto_end(cs, - "in2out platform:ref;" - "call %0i;" - "out platform:ref:g4;" - "o0 = r;", - struct_Class_to_java_lang_Class - ); - assert(cs); - - // append generic monitor enter code - cs = rth_get_lil_monitor_exit_generic(cs); - assert(cs && lil_is_valid(cs)); - - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "monitor_exit_static", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - return addr; -} - - NativeCodePtr rth_get_lil_monitor_exit() { static NativeCodePtr addr = NULL; @@ -550,19 +376,26 @@ // cs = lil_parse_onto_end(cs, "inc [%0i:pint];", value); // assert(cs); #endif + +#ifdef _DEBUG_CHECK_NULL_//_DEBUG // check if object is null cs = lil_parse_onto_end(cs, "jc i0 = %0i:ref, throw_null_pointer;" - "in2out platform:g4;", (ManagedObject *) VM_Global_State::loader_env->managed_null ); + assert(cs); +#endif + cs = lil_parse_onto_end(cs, + "in2out platform:g4;" + ); assert(cs); // append generic monitor enter code cs = rth_get_lil_monitor_exit_generic(cs); assert(cs); - + +#ifdef _DEBUG_CHECK_NULL_//_DEBUG // throw NullPointerException cs = lil_parse_onto_end(cs, ":throw_null_pointer;" @@ -571,7 +404,8 @@ lil_npc_to_fp(exn_get_rth_throw_null_pointer()) ); assert(cs && lil_is_valid(cs)); - +#endif + addr = LilCodeGenerator::get_platform()->compile(cs); DUMP_STUB(addr, "monitor_exit", lil_cs_get_code_size(cs)); @@ -580,38 +414,7 @@ return addr; } -// this function doesn't throw NullPointerException in case of null object -NativeCodePtr rth_get_lil_monitor_exit_non_null() { - static NativeCodePtr addr = NULL; - - if (addr != NULL) { - return addr; - } - LilCodeStub * cs = lil_parse_code_stub( - "entry 0:stdcall:ref:void;" - "in2out platform:g4;" - ); - assert(cs); - -#ifdef VM_STATS -// int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_EXIT_NON_NULL, 0, NULL); -// cs = lil_parse_onto_end(cs, "inc [%0i:pint];", value); -// assert(cs); -#endif - // append generic monitor enter code - cs = rth_get_lil_monitor_exit_generic(cs); - assert(cs && lil_is_valid(cs)); - - addr = LilCodeGenerator::get_platform()->compile(cs); - - DUMP_STUB(addr, "monitor_exit_non_null", lil_cs_get_code_size(cs)); - - lil_free_code_stub(cs); - return addr; -} - - Boolean jit_may_inline_object_synchronization(unsigned * UNREF thread_id_register, unsigned * UNREF sync_header_offset, unsigned * UNREF sync_header_width, Index: vm/vmcore/src/util/em64t/base/jit_runtime_support_em64t.cpp =================================================================== --- vm/vmcore/src/util/em64t/base/jit_runtime_support_em64t.cpp (revision 645798) +++ vm/vmcore/src/util/em64t/base/jit_runtime_support_em64t.cpp (working copy) @@ -311,37 +311,15 @@ switch(f) { #ifdef _WIN64 - // Monitor enter runtime helpers - case VM_RT_MONITOR_ENTER_STATIC: - return rth_get_lil_monitor_enter_static(); case VM_RT_MONITOR_ENTER: return rth_get_lil_monitor_enter(); - case VM_RT_MONITOR_ENTER_NON_NULL: - return rth_get_lil_monitor_enter_non_null(); - - // Monitor exit runtime helpers - case VM_RT_MONITOR_EXIT_STATIC: - return rth_get_lil_monitor_exit_static(); case VM_RT_MONITOR_EXIT: return rth_get_lil_monitor_exit(); - case VM_RT_MONITOR_EXIT_NON_NULL: - return rth_get_lil_monitor_exit_non_null(); #else - // Monitor enter runtime helpers - case VM_RT_MONITOR_ENTER_STATIC: - return getaddress__vm_monitor_enter_static_naked(); case VM_RT_MONITOR_ENTER: return getaddress__vm_monitor_enter_naked(); - case VM_RT_MONITOR_ENTER_NON_NULL: - return getaddress__vm_monitor_enter_naked(); - - // Monitor exit runtime helpers - case VM_RT_MONITOR_EXIT_STATIC: - return getaddress__vm_monitor_exit_static_naked(); case VM_RT_MONITOR_EXIT: return getaddress__vm_monitor_exit_naked(); - case VM_RT_MONITOR_EXIT_NON_NULL: - return getaddress__vm_monitor_exit_naked(); #endif // Object creation helper Index: vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp =================================================================== --- vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (revision 645798) +++ vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (working copy) @@ -1060,18 +1060,10 @@ return getaddress__vm_instanceof(); case VM_RT_MONITOR_ENTER: - case VM_RT_MONITOR_ENTER_NON_NULL: return getaddress__vm_monitor_enter_naked(); - - case VM_RT_MONITOR_ENTER_STATIC: - return getaddress__vm_monitor_enter_static_naked(); - case VM_RT_MONITOR_EXIT: - case VM_RT_MONITOR_EXIT_NON_NULL: return getaddress__vm_monitor_exit_naked(); - case VM_RT_MONITOR_EXIT_STATIC: - return getaddress__vm_monitor_exit_static_naked(); case VM_RT_GET_INTERFACE_VTABLE_VER0: return getaddress__vm_get_interface_vtable_old_naked(); //tryitx Index: vm/vmcore/src/util/ia32/base/jit_lock_rt_support_ia32.cpp =================================================================== --- vm/vmcore/src/util/ia32/base/jit_lock_rt_support_ia32.cpp (revision 645798) +++ vm/vmcore/src/util/ia32/base/jit_lock_rt_support_ia32.cpp (working copy) @@ -54,27 +54,6 @@ #define INPUT_ARG_OFFSET 4 - -// patch_addr_null_arg_ptr is the address of a variable holding the -// address of a branch instruction byte to patch with the destination -// to be taken if the struct Class* argument is NULL. -static char * gen_convert_struct_class_to_object(char *ss, char **patch_addr_null_arg_ptr) -{ - // First make sure the struct Class* argument is non-NULL. - ss = mov(ss, ecx_opnd, M_Base_Opnd(esp_reg, INPUT_ARG_OFFSET)); - ss = test(ss, ecx_opnd, ecx_opnd); - ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0)); - *patch_addr_null_arg_ptr = ((char *)ss) - 1; - - // Convert the struct Class* argument to the corresponding java_lang_Class reference. - ss = push(ss, M_Base_Opnd(esp_reg, INPUT_ARG_OFFSET)); - ss = call(ss, (char *)struct_Class_to_java_lang_Class); - ss = alu(ss, add_opc, esp_opnd, Imm_Opnd(4)); - ss = mov(ss, M_Base_Opnd(esp_reg, INPUT_ARG_OFFSET), eax_opnd); // overwrite the struct Class* with the raw java_lang_Class reference - return ss; -} //gen_convert_struct_class_to_object - - /* * Helper for monenter intstruction */ @@ -90,9 +69,12 @@ #endif ss = mov(ss, ecx_opnd, M_Base_Opnd(esp_reg, INPUT_ARG_OFFSET)); +#ifdef _DEBUG_CHECK_NULL_ //_DEBUG + //npe check ss = test(ss, ecx_opnd, ecx_opnd); ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0)); char *backpatch_address__null_pointer = ((char *)ss) - 1; +#endif // skip fast path if can_generate_monitor_events capability // was requested, so all TI events will be generated @@ -117,6 +99,7 @@ ss = ret(ss, Imm_Opnd(4)); +#ifdef _DEBUG_CHECK_NULL_//_DEBUG // Handle NPE here signed npe_offset = (signed)ss - (signed)backpatch_address__null_pointer - 1; *backpatch_address__null_pointer = (char)npe_offset; @@ -126,53 +109,10 @@ } // Object is null so throw a null pointer exception ss = jump(ss, (char*)exn_get_rth_throw_null_pointer()); - +#endif return ss; } //gen_restore_monitor_enter - -void * restore__vm_monitor_enter_naked(void * code_addr) -{ - char *stub = (char *)code_addr; - -#ifdef _DEBUG - const int stub_size = 86; - memset(stub, 0xcc, stub_size); -#endif - char *ss = stub; - - ss = gen_restore_monitor_enter(ss, /*patch_addr_null_arg*/ NULL); - - assert((ss - stub) < stub_size); - - DUMP_STUB(stub, "getaddress__vm_monitor_enter_naked_mt", ss - stub); - - return code_addr; -} //restore__vm_monitor_enter_naked - - -void * restore__vm_monitor_enter_static_naked(void * code_addr) -{ - char *stub = (char *)code_addr; - -#ifdef _DEBUG - const int stub_size = 107; - memset(stub, 0xcc, stub_size); -#endif - char *ss = stub; - - char *patch_addr_null_arg; - ss = gen_convert_struct_class_to_object(ss, &patch_addr_null_arg); - ss = gen_restore_monitor_enter(ss, patch_addr_null_arg); - - assert((ss - stub) < stub_size); - - DUMP_STUB(stub, "getaddress__vm_monitor_enter_static_naked_mt", ss - stub); - - return code_addr; -} //restore__vm_monitor_enter_static_naked - - static char * gen_restore_monitor_exit(char *ss, char *patch_addr_null_arg) { @@ -182,9 +122,14 @@ #endif ss = mov(ss, ecx_opnd, M_Base_Opnd(esp_reg, INPUT_ARG_OFFSET)); + +#ifdef _DEBUG_CHECK_NULL_//_DEBUG + //check npe ss = test(ss, ecx_opnd, ecx_opnd); ss = branch8(ss, Condition_Z, Imm_Opnd(size_8, 0)); char *backpatch_address__null_pointer = ((char *)ss) - 1; +#endif + // skip fast path if can_generate_monitor_events capability // was requested, so all TI events will be generated if (!VM_Global_State::loader_env->TI->get_global_capability( @@ -210,6 +155,8 @@ // illegal state happend ss = jump(ss, (char*)exn_get_rth_throw_illegal_state_exception()); +#ifdef _DEBUG_CHECK_NULL_//_DEBUG + //NPE offset = (signed)ss - (signed)backpatch_address__null_pointer - 1; *backpatch_address__null_pointer = (char)offset; if (patch_addr_null_arg != NULL) { @@ -218,54 +165,12 @@ } // Object is null so throw a null pointer exception ss = jump(ss, (char*)exn_get_rth_throw_null_pointer()); - +#endif return ss; } //gen_restore_monitor_exit -void * restore__vm_monitor_exit_naked(void * code_addr) -{ - char *stub = (char *)code_addr; - -#ifdef _DEBUG - const int stub_size = /*106*/210; - memset(stub, 0xcc, stub_size); -#endif - char *ss = stub; - - ss = gen_restore_monitor_exit(ss, /*patch_addr_null_arg*/ NULL); - - assert((ss - stub) < stub_size); - - DUMP_STUB(stub, "getaddress__vm_monitor_exit_naked_mt", ss - stub); - - return code_addr; -} //restore__vm_monitor_exit_naked - - -void * restore__vm_monitor_exit_static_naked(void * code_addr) -{ - char *stub = (char *)code_addr; - -#ifdef _DEBUG - const int stub_size = /*106*/210; - memset(stub, 0xcc, stub_size); -#endif - char *ss = stub; - - char *patch_addr_null_arg; - ss = gen_convert_struct_class_to_object(ss, &patch_addr_null_arg); - ss = gen_restore_monitor_exit(ss, patch_addr_null_arg); - - assert((ss - stub) < stub_size); - - DUMP_STUB(stub, "getaddress__vm_monitor_exit_static_naked_mt", ss - stub); - - return code_addr; -} //restore__vm_monitor_exit_static_naked - - void * getaddress__vm_monitor_enter_naked() { static void *addr = NULL; @@ -302,46 +207,6 @@ } -void * getaddress__vm_monitor_enter_static_naked() -{ - static void *addr = NULL; - if (addr != NULL) { - return addr; - } - - const int stub_size = 250; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate); -#ifdef _DEBUG - memset(stub, 0xcc /*int 3*/, stub_size); -#endif - char *ss = stub; - -#ifdef VM_STATS - int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_ENTER_STATIC, 0, NULL); - ss = inc(ss, M_Opnd((unsigned)value)); -#endif - - char *patch_addr_null_arg; - ss = gen_convert_struct_class_to_object(ss, &patch_addr_null_arg); - ss = gen_restore_monitor_enter(ss, patch_addr_null_arg); - - addr = stub; - assert((ss - stub) < stub_size); - - compile_add_dynamic_generated_code_chunk("vm_monitor_enter_static_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_monitor_enter_static_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_monitor_enter_static_naked", ss - stub); - - return addr; -} //getaddress__vm_monitor_enter_static_naked - - - - void * getaddress__vm_monitor_exit_naked() { static void *addr = NULL; @@ -376,40 +241,6 @@ } //getaddress__vm_monitor_exit_naked -void * getaddress__vm_monitor_exit_static_naked() -{ - static void *addr = NULL; - if (addr != NULL) { - return addr; - } - - const int stub_size = /*126*/210; - char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_MAX/2, CAA_Allocate); - char *ss = stub; - -#ifdef VM_STATS - int * value = VM_Statistics::get_vm_stats().rt_function_calls.lookup_or_add((void*)VM_RT_MONITOR_EXIT_STATIC, 0, NULL); - ss = inc(ss, M_Opnd((unsigned)value)); -#endif - - char *patch_addr_null_arg; - ss = gen_convert_struct_class_to_object(ss, &patch_addr_null_arg); - ss = gen_restore_monitor_exit(ss, patch_addr_null_arg); - - addr = stub; - assert((ss - stub) < stub_size); - - compile_add_dynamic_generated_code_chunk("vm_monitor_exit_static_naked", false, stub, stub_size); - - if (jvmti_should_report_event(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { - jvmti_send_dynamic_code_generated_event("vm_monitor_exit_static_naked", stub, stub_size); - } - - DUMP_STUB(stub, "getaddress__vm_monitor_exit_static_naked", ss - stub); - - return addr; -} //getaddress__vm_monitor_exit_static_naked - Boolean jit_may_inline_object_synchronization(unsigned * UNREF thread_id_register, unsigned * UNREF sync_header_offset, unsigned * UNREF sync_header_width, Index: vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp =================================================================== --- vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (revision 645798) +++ vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (working copy) @@ -1435,40 +1435,6 @@ } //get_vm_rt_monitor_exit_address - -static void *get_vm_rt_monitor_enter_static_address() -{ - static void *addr = 0; - if (addr) { - return addr; - } - // 20030220 The "static" monitor enter function is only called with a struct Class pointer, which can't be NULL. - void (*p_vm_monitor_enter)(ManagedObject *p_obj); - p_vm_monitor_enter = vm_monitor_enter; - addr = gen_vm_rt_monitor_wrapper((void **)p_vm_monitor_enter, gen_vm_rt_monitorenter_fast_path, - /*check_null*/ false, /*static_operation*/ true, - "rt_monitor_enter_static_slowpath", "rt_monitor_enter_static_fastpath"); - return addr; -} //get_vm_rt_monitor_enter_static_address - - - -static void *get_vm_rt_monitor_exit_static_address() -{ - static void *addr = 0; - if (addr) { - return addr; - } - // 20030220 The "static" monitor exit function is only called with a struct Class pointer, which can't be NULL. - void (*p_vm_monitor_exit)(ManagedObject *p_obj); - p_vm_monitor_exit = vm_monitor_exit; - addr = gen_vm_rt_monitor_wrapper((void **)p_vm_monitor_exit, gen_vm_rt_monitorexit_fast_path, - /*check_null*/ false, /*static_operation*/ true, - "rt_monitor_exit_static_slowpath", "rt_monitor_exit_static_fastpath"); - return addr; -} //get_vm_rt_monitor_exit_static_address - - #ifdef VM_STATS // exclude remark in release mode (defined but not used) // Return the log base 2 of the integer operand. If the argument is less than or equal to zero, return zero. static int get_log2(int value) @@ -1890,26 +1856,10 @@ dereference_fptr = false; break; case VM_RT_MONITOR_ENTER: - fptr = get_vm_rt_monitor_enter_address(true); - dereference_fptr = false; - break; - case VM_RT_MONITOR_ENTER_STATIC: - fptr = get_vm_rt_monitor_enter_static_address(); - dereference_fptr = false; - break; - case VM_RT_MONITOR_ENTER_NON_NULL: fptr = get_vm_rt_monitor_enter_address(false); dereference_fptr = false; break; case VM_RT_MONITOR_EXIT: - fptr = get_vm_rt_monitor_exit_address(true); - dereference_fptr = false; - break; - case VM_RT_MONITOR_EXIT_STATIC: - fptr = get_vm_rt_monitor_exit_static_address(); - dereference_fptr = false; - break; - case VM_RT_MONITOR_EXIT_NON_NULL: fptr = get_vm_rt_monitor_exit_address(false); dereference_fptr = false; break; Index: vm/jitrino/config/em64t/server_static.emconf =================================================================== --- vm/jitrino/config/em64t/server_static.emconf (revision 645798) +++ vm/jitrino/config/em64t/server_static.emconf (working copy) @@ -71,11 +71,11 @@ -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE=off -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE_hotnessPercent=1 --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL=on --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL_hotnessPercent=1 +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER=on +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_hotnessPercent=1 --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL=on --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL_hotnessPercent=1 +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT=on +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_hotnessPercent=1 -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=off -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0_hotnessPercent=1 Index: vm/jitrino/config/em64t/server.emconf =================================================================== --- vm/jitrino/config/em64t/server.emconf (revision 645798) +++ vm/jitrino/config/em64t/server.emconf (working copy) @@ -117,11 +117,11 @@ -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE=off -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE_hotnessPercent=1 --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL=on --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_hotnessPercent=1 --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL=on --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_hotnessPercent=1 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=off -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0_hotnessPercent=1 Index: vm/jitrino/config/ia32/server_static.emconf =================================================================== --- vm/jitrino/config/ia32/server_static.emconf (revision 645798) +++ vm/jitrino/config/ia32/server_static.emconf (working copy) @@ -71,11 +71,11 @@ -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE=on -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE_hotnessPercent=1 --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL=on --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL_hotnessPercent=1 +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER=on +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_hotnessPercent=1 --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL=on --XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL_hotnessPercent=1 +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT=on +-XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_hotnessPercent=1 -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=on -XX:jit.SS_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0_hotnessPercent=1 Index: vm/jitrino/config/ia32/server_aggressive.emconf =================================================================== --- vm/jitrino/config/ia32/server_aggressive.emconf (revision 645798) +++ vm/jitrino/config/ia32/server_aggressive.emconf (working copy) @@ -113,11 +113,11 @@ -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE=on -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE_hotnessPercent=1 --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL=on --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_hotnessPercent=1 --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL=on --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_hotnessPercent=1 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=on -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0_hotnessPercent=1 Index: vm/jitrino/config/ia32/server.emconf =================================================================== --- vm/jitrino/config/ia32/server.emconf (revision 645798) +++ vm/jitrino/config/ia32/server.emconf (working copy) @@ -119,11 +119,11 @@ -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE=on -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE_hotnessPercent=1 --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL=on --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_hotnessPercent=1 --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL=on --XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL_hotnessPercent=1 +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT=on +-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_hotnessPercent=1 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=on -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0_hotnessPercent=1 Index: vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp =================================================================== --- vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (revision 645798) +++ vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (working copy) @@ -2856,8 +2856,8 @@ //vmhelper slow paths case VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE: case VM_RT_NEW_VECTOR_USING_VTABLE: - case VM_RT_MONITOR_ENTER_NON_NULL: - case VM_RT_MONITOR_EXIT_NON_NULL: + case VM_RT_MONITOR_ENTER: + case VM_RT_MONITOR_EXIT: case VM_RT_GC_HEAP_WRITE_REF: case VM_RT_GET_INTERFACE_VTABLE_VER0: case VM_RT_CHECKCAST: @@ -2946,7 +2946,7 @@ void InstCodeSelector::tau_monitorEnter(CG_OpndHandle* obj, CG_OpndHandle* tauIsNonNull) { Opnd * helperOpnds[] = { (Opnd*)obj }; - CallInst * callInst=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_ENTER_NON_NULL, + CallInst * callInst=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_ENTER, 1, helperOpnds, NULL); appendInsts(callInst); } @@ -2958,7 +2958,7 @@ CG_OpndHandle* tauIsNonNull) { Opnd * helperOpnds[] = { (Opnd*)obj }; - CallInst * callInst=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_EXIT_NON_NULL, + CallInst * callInst=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_EXIT, 1, helperOpnds, NULL); appendInsts(callInst); } @@ -3023,10 +3023,16 @@ void InstCodeSelector::typeMonitorEnter(NamedType *type) { - Opnd * helperOpnds[]={irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, type)}; - CallInst * callInst=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_ENTER_STATIC, - 1, helperOpnds, NULL); - appendInsts(callInst); + Opnd * helperOpnds1[]={irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, type)}; + Opnd * retOpnd=irManager.newOpnd(type); + CallInst * callInst1=irManager.newRuntimeHelperCallInst(VM_RT_CLASS_2_JLC, + 1, helperOpnds1, retOpnd); + appendInsts(callInst1); + + Opnd * helperOpnds2[]={retOpnd}; + CallInst * callInst2=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_ENTER, + 1, helperOpnds2, NULL); + appendInsts(callInst2); } //_______________________________________________________________________________________________________________ @@ -3035,10 +3041,16 @@ void InstCodeSelector::typeMonitorExit(NamedType *type) { - Opnd * helperOpnds[]={irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, type)}; - CallInst * callInst=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_EXIT_STATIC, - 1, helperOpnds, NULL); - appendInsts(callInst); + Opnd * helperOpnds1[]={irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, type)}; + Opnd * retOpnd=irManager.newOpnd(type); + CallInst * callInst1=irManager.newRuntimeHelperCallInst(VM_RT_CLASS_2_JLC, + 1, helperOpnds1, retOpnd); + appendInsts(callInst1); + + Opnd * helperOpnds2[]={retOpnd}; + CallInst * callInst2=irManager.newRuntimeHelperCallInst(VM_RT_MONITOR_EXIT, + 1, helperOpnds2, NULL); + appendInsts(callInst2); } //_______________________________________________________________________________________________________________ Index: vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp =================================================================== --- vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp (revision 645798) +++ vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp (working copy) @@ -2025,7 +2025,7 @@ Opnd *helperArgs[] = { (Opnd *)obj }; - VM_RT_SUPPORT hId = VM_RT_MONITOR_ENTER_NON_NULL; + VM_RT_SUPPORT hId = VM_RT_MONITOR_ENTER; uint64 address = (uint64) compilationInterface.getRuntimeHelperAddress(hId); Opnd *helperAddress = opndManager->newImm(address); @@ -2042,7 +2042,7 @@ Opnd *helperArgs[] = { (Opnd *)obj }; - VM_RT_SUPPORT hId = VM_RT_MONITOR_EXIT_NON_NULL; + VM_RT_SUPPORT hId = VM_RT_MONITOR_EXIT; uint64 address = (uint64) compilationInterface.getRuntimeHelperAddress(hId); Opnd *helperAddress = opndManager->newImm(address); @@ -2057,13 +2057,24 @@ IPF_LOG << " typeMonitorEnter" << endl; uint64 typeRuntimeId = (uint64) type->getRuntimeIdentifier(); - Opnd *helperArgs[] = { opndManager->newImm(typeRuntimeId) }; + Opnd *helperArgs1[] = { opndManager->newImm(typeRuntimeId) }; - VM_RT_SUPPORT hId = VM_RT_MONITOR_ENTER_STATIC; - uint64 address = (uint64) compilationInterface.getRuntimeHelperAddress(hId); - Opnd *helperAddress = opndManager->newImm(address); + VM_RT_SUPPORT hId1 = VM_RT_CLASS_2_JLC; + uint64 address1 = (uint64) compilationInterface.getRuntimeHelperAddress(hId1); + Opnd* helperAddress1 = opndManager->newImm(address1); + OpndKind opndKind = toOpndKind(type->tag); + DataKind dataKind = toDataKind(type->tag); + RegOpnd* retOpnd = opndManager->newRegOpnd(opndKind, dataKind); - directCall(1, helperArgs, NULL, helperAddress, p0); + directCall(1, helperArgs1, retOpnd, helperAddress1, p0); + + Opnd *helperArgs2[] = { retOpnd }; + + VM_RT_SUPPORT hId2 = VM_RT_MONITOR_ENTER; + uint64 address2 = (uint64) compilationInterface.getRuntimeHelperAddress(hId2); + Opnd* helperAddress2 = opndManager->newImm(address2); + + directCall(1, helperArgs2, NULL, helperAddress2, p0); } //----------------------------------------------------------------------------// @@ -2074,13 +2085,24 @@ IPF_LOG << " typeMonitorExit" << endl; uint64 typeRuntimeId = (uint64) type->getRuntimeIdentifier(); - Opnd *helperArgs[] = { opndManager->newImm(typeRuntimeId) }; + Opnd *helperArgs1[] = { opndManager->newImm(typeRuntimeId) }; - VM_RT_SUPPORT hId = VM_RT_MONITOR_EXIT_STATIC; - uint64 address = (uint64) compilationInterface.getRuntimeHelperAddress(hId); - Opnd *helperAddress = opndManager->newImm(address); + VM_RT_SUPPORT hId1 = VM_RT_CLASS_2_JLC; + uint64 address1 = (uint64) compilationInterface.getRuntimeHelperAddress(hId1); + Opnd* helperAddress1 = opndManager->newImm(address1); + OpndKind opndKind = toOpndKind(type->tag); + DataKind dataKind = toDataKind(type->tag); + RegOpnd* retOpnd = opndManager->newRegOpnd(opndKind, dataKind); - directCall(1, helperArgs, NULL, helperAddress, p0); + directCall(1, helperArgs1, retOpnd, helperAddress1, p0); + + Opnd *helperArgs2[] = { retOpnd }; + + VM_RT_SUPPORT hId2 = VM_RT_MONITOR_EXIT; + uint64 address2 = (uint64) compilationInterface.getRuntimeHelperAddress(hId2); + Opnd* helperAddress2 = opndManager->newImm(address2); + + directCall(1, helperArgs2, NULL, helperAddress2, p0); } //----------------------------------------------------------------------------// Index: vm/jitrino/src/jet/sconsts.h =================================================================== --- vm/jitrino/src/jet/sconsts.h (revision 645798) +++ vm/jitrino/src/jet/sconsts.h (working copy) @@ -59,9 +59,9 @@ static char * rt_helper_monitor_enter; static char * rt_helper_monitor_exit; - static char * rt_helper_monitor_enter_static; - static char * rt_helper_monitor_exit_static; + static char * rt_helper_class_2_jlc; + static char * rt_helper_ldc_string; static char * rt_helper_init_class; static char * rt_helper_multinewarray; Index: vm/jitrino/src/jet/cg_meth.cpp =================================================================== --- vm/jitrino/src/jet/cg_meth.cpp (revision 645798) +++ vm/jitrino/src/jet/cg_meth.cpp (working copy) @@ -45,6 +45,10 @@ * CallSig for monitor_enter and monitor_exit helpers. */ static const CallSig cs_mon(CCONV_HELPERS, jvoid, jobj); +/** + * CallSig for Class* to java.lang.Class helpers. + */ +static const CallSig cs_jlc(CCONV_HELPERS, jobj, jobj); void Compiler::gen_prolog(void) { @@ -523,9 +527,13 @@ if (meth_is_sync()) { + unsigned stackFix = 0; if (is_set(DBG_TRACE_CG)) { dbg(";;>monitor_enter\n"); } if (method_is_static(m_method)) { - gen_call_vm(cs_mon, rt_helper_monitor_enter_static, 0, m_klass); + gen_call_vm(cs_jlc, rt_helper_class_2_jlc, 0, m_klass); + gen_save_ret(cs_jlc); + stackFix = gen_stack_to_args(true, cs_mon, 0); + //gen_call_vm(cs_mon, rt_helper_monitor_enter_static, 0, m_klass); } else { AR gr = gr0; @@ -542,8 +550,17 @@ ld(jobj, gr, m_base, voff(m_stack.thiz())); st(jobj, gr, sp, cs_mon.off(0)); } - gen_call_vm(cs_mon, rt_helper_monitor_enter, 1); + //gen_call_vm(cs_mon, rt_helper_monitor_enter, 1); } + gen_call_vm(cs_mon, rt_helper_monitor_enter, 1); + + if (method_is_static(m_method)) { + runlock(cs_mon); + if (stackFix != 0) { + alu(alu_sub, sp, stackFix); + } + } + if (is_set(DBG_TRACE_CG)) { dbg(";;>~monitor_enter\n"); } } @@ -572,38 +589,49 @@ } bool is_sync = meth_is_sync(); - if (is_sync && meth_is_static()) { + if (is_sync) { + unsigned stackFix = 0; + if (is_set(DBG_TRACE_CG)) { dbg(";;>monitor_exit\n"); } - gen_call_vm(cs_mon, rt_helper_monitor_exit_static, 0, m_klass); - if (is_set(DBG_TRACE_CG)) { - dbg(";;>~monitor_exit\n"); + + if (meth_is_static()) { + gen_call_vm(cs_jlc, rt_helper_class_2_jlc, 0, m_klass); + gen_save_ret(cs_jlc); + stackFix = gen_stack_to_args(true, cs_mon, 0); + //gen_call_vm(cs_mon, rt_helper_monitor_exit_static, 0, m_klass); + } else { + AR gr = valloc(jobj); + if (cs_mon.reg(0) != gr_x) { + if (cs_mon.size() != 0) { + assert(cs_mon.caller_pops()); + alu(alu_sub, sp, cs_mon.size()); + } + vpark(cs_mon.reg(0)); + ld(jobj, cs_mon.reg(0), m_base, voff(m_stack.thiz())); + } + else { + assert(cs_mon.size() != 0); + alu(alu_sub, sp, cs_mon.size()); + ld(jobj, gr, m_base, voff(m_stack.thiz())); + st(jobj, gr, sp, cs_mon.off(0)); + } + //gen_call_vm(cs_mon, rt_helper_monitor_exit, 1); } - } - else if (is_sync) { - if (is_set(DBG_TRACE_CG)) { - dbg(";;>monitor_exit\n"); + gen_call_vm(cs_mon, rt_helper_monitor_exit, 1); + + if (meth_is_static()) { + runlock(cs_mon); + if (stackFix != 0) { + alu(alu_sub, sp, stackFix); + } } - AR gr = valloc(jobj); - if (cs_mon.reg(0) != gr_x) { - if (cs_mon.size() != 0) { - assert(cs_mon.caller_pops()); - alu(alu_sub, sp, cs_mon.size()); - } - vpark(cs_mon.reg(0)); - ld(jobj, cs_mon.reg(0), m_base, voff(m_stack.thiz())); - } - else { - assert(cs_mon.size() != 0); - alu(alu_sub, sp, cs_mon.size()); - ld(jobj, gr, m_base, voff(m_stack.thiz())); - st(jobj, gr, sp, cs_mon.off(0)); - } - gen_call_vm(cs_mon, rt_helper_monitor_exit, 1); + if (is_set(DBG_TRACE_CG)) { dbg(";;>~monitor_exit\n"); } + } if (compilation_params.exe_notify_method_exit) { Index: vm/jitrino/src/jet/compiler.cpp =================================================================== --- vm/jitrino/src/jet/compiler.cpp (revision 645798) +++ vm/jitrino/src/jet/compiler.cpp (working copy) @@ -1484,10 +1484,9 @@ (char*)vm_helper_get_addr(VM_RT_MONITOR_ENTER); rt_helper_monitor_exit = (char*)vm_helper_get_addr(VM_RT_MONITOR_EXIT); - rt_helper_monitor_enter_static = - (char*)vm_helper_get_addr(VM_RT_MONITOR_ENTER_STATIC); - rt_helper_monitor_exit_static = - (char*)vm_helper_get_addr(VM_RT_MONITOR_EXIT_STATIC); + + rt_helper_class_2_jlc = + (char*)vm_helper_get_addr(VM_RT_CLASS_2_JLC); rt_helper_new_array = (char*)vm_helper_get_addr(VM_RT_NEW_VECTOR_USING_VTABLE); Index: vm/jitrino/src/jet/sconsts.cpp =================================================================== --- vm/jitrino/src/jet/sconsts.cpp (revision 645798) +++ vm/jitrino/src/jet/sconsts.cpp (working copy) @@ -39,9 +39,9 @@ char * StaticConsts::rt_helper_monitor_enter = NULL; char * StaticConsts::rt_helper_monitor_exit = NULL; -char * StaticConsts::rt_helper_monitor_enter_static = NULL; -char * StaticConsts::rt_helper_monitor_exit_static = NULL; +char * StaticConsts::rt_helper_class_2_jlc = NULL; + char * StaticConsts::rt_helper_ldc_string = NULL; char * StaticConsts::rt_helper_new = NULL; char * StaticConsts::rt_helper_new_array = NULL; Index: vm/jitrino/src/optimizer/helper_inliner.cpp =================================================================== --- vm/jitrino/src/optimizer/helper_inliner.cpp (revision 645798) +++ vm/jitrino/src/optimizer/helper_inliner.cpp (working copy) @@ -66,8 +66,8 @@ registerHelper(Op_NewObj, VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE); registerHelper(Op_NewArray, VM_RT_NEW_VECTOR_USING_VTABLE); - registerHelper(Op_TauMonitorEnter, VM_RT_MONITOR_ENTER_NON_NULL); - registerHelper(Op_TauMonitorExit, VM_RT_MONITOR_EXIT_NON_NULL); + registerHelper(Op_TauMonitorEnter, VM_RT_MONITOR_ENTER); + registerHelper(Op_TauMonitorExit, VM_RT_MONITOR_EXIT); registerHelper(Op_TauStRef, VM_RT_GC_HEAP_WRITE_REF); registerHelper(Op_TauLdIntfcVTableAddr, VM_RT_GET_INTERFACE_VTABLE_VER0); registerHelper(Op_TauCheckCast, VM_RT_CHECKCAST); Index: vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp =================================================================== --- vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (revision 645798) +++ vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (working copy) @@ -2996,13 +2996,13 @@ if (!strcmp(mname,"monitorEnter")) { assert(numArgs == 1); - irBuilder.genVMHelperCall(VM_RT_MONITOR_ENTER_NON_NULL, resType, numArgs, srcOpnds); + irBuilder.genVMHelperCall(VM_RT_MONITOR_ENTER, resType, numArgs, srcOpnds); return true; } if (!strcmp(mname,"monitorExit")) { assert(numArgs == 1); - irBuilder.genVMHelperCall(VM_RT_MONITOR_EXIT_NON_NULL, resType, numArgs, srcOpnds); + irBuilder.genVMHelperCall(VM_RT_MONITOR_EXIT, resType, numArgs, srcOpnds); return true; }