Index: vm/port/src/lil/em64t/pim/m2n_em64t.cpp =================================================================== --- vm/port/src/lil/em64t/pim/m2n_em64t.cpp (revision 598210) +++ vm/port/src/lil/em64t/pim/m2n_em64t.cpp (working copy) @@ -273,7 +273,7 @@ unsigned m2n_push_m2n_size(unsigned num_callee_saves, unsigned num_std_need_to_save) { - return 82 - (5 * num_callee_saves) + + return 91 - (5 * num_callee_saves) + m2n_ts_to_register_size(num_std_need_to_save, 0); } @@ -296,6 +296,10 @@ LcgEM64TContext::get_reg_from_map(LcgEM64TContext::GR_LOCALS_OFFSET + i), size_64); } + // init pop_regs to null + bytes_to_m2n_top -= LcgEM64TContext::GR_SIZE; + buf = mov(buf, M_Base_Opnd(rsp_reg, bytes_to_m2n_top), + Imm_Opnd(size_32, 0), size_64); // store current_frame_type bytes_to_m2n_top -= LcgEM64TContext::GR_SIZE; assert(fit32(current_frame_type)); @@ -406,8 +410,8 @@ buf = mov(buf, r11_opnd, M_Base_Opnd(rsp_reg, bytes_to_m2n_bottom), size_64); bytes_to_m2n_bottom += LcgEM64TContext::GR_SIZE; buf = mov(buf, M_Base_Opnd(r11_reg, 0), r10_opnd, size_64); - // skip local_object_handles, method, current_frame_type - bytes_to_m2n_bottom += 3 * LcgEM64TContext::GR_SIZE; + // skip local_object_handles, method, current_frame_type, pop_regs + bytes_to_m2n_bottom += 4 * LcgEM64TContext::GR_SIZE; // restore part of callee-saves registers for (int i = LcgEM64TContext::MAX_GR_LOCALS - 1; i >= (int)num_callee_saves; i--) { @@ -423,12 +427,11 @@ // returns pointer to the registers used for jvmti PopFrame Registers* get_pop_frame_registers(M2nFrame* m2nf) { - // Empty implementation - return NULL; + return m2nf->pop_regs; } // sets pointer to the registers used for jvmti PopFrame void set_pop_frame_registers(M2nFrame* m2nf, Registers* regs) { - // Empty implementation + m2nf->pop_regs = regs; } Index: vm/port/src/lil/em64t/pim/m2n_em64t_internal.h =================================================================== --- vm/port/src/lil/em64t/pim/m2n_em64t_internal.h (revision 598210) +++ vm/port/src/lil/em64t/pim/m2n_em64t_internal.h (working copy) @@ -33,9 +33,9 @@ #include "encoder.h" #ifdef _WIN64 -const unsigned m2n_sizeof_m2n_frame = 112; +const unsigned m2n_sizeof_m2n_frame = 120; #else -const unsigned m2n_sizeof_m2n_frame = 96; +const unsigned m2n_sizeof_m2n_frame = 104; #endif typedef struct M2nFrame M2nFrame; @@ -59,6 +59,7 @@ ObjectHandles * local_object_handles; Method_Handle method; frame_type current_frame_type; + Registers* pop_regs; // This is only for M2nFrames for suspended managed code (as against ones that call stubs and prepare jvmtiPopFrame) uint64 rbx; uint64 rbp; #ifdef _WIN64 Index: vm/vmcore/src/jvmti/jvmti_pop_frame.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_pop_frame.cpp (revision 598210) +++ vm/vmcore/src/jvmti/jvmti_pop_frame.cpp (working copy) @@ -138,22 +138,8 @@ assert(0); } -#elif defined _EM64T_ +#else // _IA32_ & _EM64T_ -void jvmti_jit_prepare_pop_frame(){ - assert(0); -} - -void jvmti_jit_complete_pop_frame(){ - assert(0); -} - -void jvmti_jit_do_pop_frame(){ - assert(0); -} - -#else // _IA32_ - // requires stack iterator and buffer to save intermediate information static void jvmti_jit_prepare_pop_frame(StackIterator* si, uint32* buf) { TRACE(("Prepare PopFrame for JIT")); @@ -191,57 +177,27 @@ // find correct ip and restore required registers context NativeCodePtr current_method_addr = NULL; + cci = si_get_code_chunk_info(si); + method = cci->get_method(); NativeCodePtr ip = si_get_ip(si); + JIT *jit = cci->get_jit(); + TRACE(("PopFrame method %s.%s%s, set IP begin: %p", class_get_name(method_get_class(si_get_code_chunk_info(si)->get_method())), method_get_name(si_get_code_chunk_info(si)->get_method()), method_get_descriptor(si_get_code_chunk_info(si)->get_method()), ip )); - size_t ip_reduce; - // invoke static - if (is_method_static) { - ip_reduce = 6; + uint16 bcOffset; + NativeCodePtr bcip; + jit->fix_handler_context(method, si_get_jit_context(si)); + jit->get_bc_location_for_native(method, (NativeCodePtr)((POINTER_SIZE_INT)ip - 1), &bcOffset); + jit->get_native_location_for_bc(method, bcOffset, &bcip); + si_set_ip(si, bcip, false); - // invoke interface - } else if (0xd0ff == (*((unsigned short*)(((char*)ip)-2)))) { - ip_reduce = 2; - current_method_addr = cci->get_code_block_addr(); - *buf = (uint32)current_method_addr; - jitContext->p_eax = buf; - - // invoke virtual and special - } else { - VTable_Handle vtable = class_get_vtable( method_class); - *buf = (uint32) vtable; - unsigned short code = (*((unsigned short*)(((char*)ip)-3))); - - // invoke virtual - if (0x50ff == code) { - jitContext->p_eax = buf; - ip_reduce = 3; - } else if (0x51ff == code) { - jitContext->p_ecx = buf; - ip_reduce = 3; - } else if (0x52ff == code) { - jitContext->p_edx = buf; - ip_reduce = 3; - } else if (0x53ff == code) { - jitContext->p_ebx = buf; - ip_reduce = 3; - - // invoke special - } else{ - ip_reduce = 6; - } - } - - // set correct ip - ip = (NativeCodePtr)(((char*)ip) - ip_reduce); TRACE(("PopFrame method %s.%s%s, set IP end: %p", class_get_name(method_get_class(si_get_code_chunk_info(si)->get_method())), method_get_name(si_get_code_chunk_info(si)->get_method()), method_get_descriptor(si_get_code_chunk_info(si)->get_method()), ip )); - si_set_ip(si, ip, false); } void jvmti_jit_prepare_pop_frame() { @@ -263,39 +219,9 @@ jvmti_jit_prepare_pop_frame(si, &buf); // save regs value from jit context to m2n - JitFrameContext* jitContext = si_get_jit_context(si); Registers* regs = get_pop_frame_registers(top_frame); + si_copy_to_registers(si, regs); - regs->esp = jitContext->esp; - regs->eip = *(jitContext->p_eip); - regs->esi = *(jitContext->p_esi); - regs->edi = *(jitContext->p_edi); - regs->ebp = *(jitContext->p_ebp); - - if (0 == jitContext->p_eax) { - regs->eax = 0; - } else { - regs->eax = *(jitContext->p_eax); - } - - if (0 == jitContext->p_ebx) { - regs->ebx = 0; - } else { - regs->ebx = *(jitContext->p_ebx); - } - - if (0 == jitContext->p_ecx) { - regs->ecx = 0; - } else { - regs->ecx = *(jitContext->p_ecx); - } - - if (0 == jitContext->p_edx) { - regs->edx = 0; - } else { - regs->edx = *(jitContext->p_edx); - } - // set pop done frame state m2n_set_frame_type(top_frame, frame_type(FRAME_POP_DONE | FRAME_MODIFIED_STACK)); return; Index: vm/vmcore/src/jvmti/jvmti_capability.cpp =================================================================== --- vm/vmcore/src/jvmti/jvmti_capability.cpp (revision 598210) +++ vm/vmcore/src/jvmti/jvmti_capability.cpp (working copy) @@ -159,7 +159,7 @@ 1, // can_get_owned_monitor_info 1, // can_get_current_contended_monitor 1, // can_get_monitor_info - 0, // can_pop_frame + 1, // can_pop_frame 0, // can_redefine_classes 1, // can_signal_thread 1, // can_get_source_file_name Index: vm/vmcore/src/util/em64t/base/compile_em64t.cpp =================================================================== --- vm/vmcore/src/util/em64t/base/compile_em64t.cpp (revision 598210) +++ vm/vmcore/src/util/em64t/base/compile_em64t.cpp (working copy) @@ -56,10 +56,10 @@ uint64 * const m2n_base_addr = (uint64 *)m2n_get_frame_base(m2n_get_last_frame()); // 6(scratched registers on the stack) assert(m2n_get_size() % 8 == 0); - // 15 = 1(alignment) + n(fp) + n(gp) registers were preserved on the stack + // 14 = 0(alignment) + n(fp) + n(gp) registers were preserved on the stack uint64 * const inputs_addr = m2n_base_addr - (m2n_get_size() / 8) + 2 - - 1 - MAX_GR - MAX_FR; + - MAX_GR - MAX_FR; // 1(return ip); #ifdef _WIN64 // WIN64, reserve 4 words of shadow space @@ -172,7 +172,7 @@ // method handle // Stack size should be (% 8 == 0) but shouldn't be (% 16 == 0) -const int ALIGNMENT = 8; +const int ALIGNMENT = 0; const int32 gr_stack_size = (1 + MAX_GR)*GR_STACK_SIZE + SHADOW; Index: vm/jitrino/src/jet/mib.cpp =================================================================== --- vm/jitrino/src/jet/mib.cpp (revision 598210) +++ vm/jitrino/src/jet/mib.cpp (working copy) @@ -98,6 +98,10 @@ int r = max_idx; int m = 0; const char * val = NULL; + + assert(rt_header->code_start <= ip); + assert(ip <= rt_header->code_start + rt_header->m_code_len); + // // Step 1. // Find first element which is above or equal to the given IP. Index: vm/jitrino/src/jet/compiler.cpp =================================================================== --- vm/jitrino/src/jet/compiler.cpp (revision 598210) +++ vm/jitrino/src/jet/compiler.cpp (working copy) @@ -483,6 +483,7 @@ CodeBlockHeatDefault, 0, CAA_Allocate); m_infoBlock.set_code_start(m_vmCode); + m_infoBlock.set_code_len(total_code_size); } // // Copy and reposition code from m_codeStream into the allocated buf. Index: vm/jitrino/src/jet/rt.cpp =================================================================== --- vm/jitrino/src/jet/rt.cpp (revision 598210) +++ vm/jitrino/src/jet/rt.cpp (working copy) @@ -398,6 +398,10 @@ void *** pip = (void***)((char*)context + ip_off); char * where = (char*)**pip; char * meth_start = infoBlock.get_code_start(); + unsigned meth_len = infoBlock.get_code_len(); + assert(meth_start <= where); + assert(where <= meth_start + meth_len); + unsigned whereLen = (unsigned)(where - meth_start); if (whereLencode_start; } + /** + * @brief Sets size of native code, in bytes. + */ + void set_code_len(unsigned len) + { + rt_header->m_code_len = len; + } + + /** + * @brief Returns size of native code, in bytes. + */ + unsigned get_code_len(void) + { + return rt_header->m_code_len; + } + void set_compile_params(const OpenMethodExecutionParams& compileParams) { rt_header->compileParams = compileParams;