From 9b751356a74577baa8be2d1bdbb41cf1e7208573 Mon Sep 17 00:00:00 2001 From: Frode Solheim Date: Sun, 6 Sep 2015 22:13:27 +0200 Subject: [PATCH] JIT: use align_target(align_jumps) --- jit/codegen_x86.cpp | 3 +++ jit/compemu_support.cpp | 27 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/jit/codegen_x86.cpp b/jit/codegen_x86.cpp index bef0ebb2..5a38cc2e 100644 --- a/jit/codegen_x86.cpp +++ b/jit/codegen_x86.cpp @@ -3402,7 +3402,10 @@ raw_init_cpu(void) /* Alignments */ if (tune_alignment) { align_loops = x86_alignments[c->x86_processor].align_loop; +#ifdef UAE +#else align_jumps = x86_alignments[c->x86_processor].align_jump; +#endif } { TCHAR *s = au (c->x86_vendor_id); diff --git a/jit/compemu_support.cpp b/jit/compemu_support.cpp index ff618b60..8ef35a4b 100644 --- a/jit/compemu_support.cpp +++ b/jit/compemu_support.cpp @@ -3366,6 +3366,15 @@ static inline void create_popalls(void) current_compile_p=popallspace; set_target(current_compile_p); + /* We need to guarantee 16-byte stack alignment on x86 at any point + within the JIT generated code. We have multiple exit points + possible but a single entry. A "jmp" is used so that we don't + have to generate stack alignment in generated code that has to + call external functions (e.g. a generic instruction handler). + + In summary, JIT generated code is not leaf so we have to deal + with it here to maintain correct stack alignment. */ + align_target(align_jumps); current_compile_p=get_target(); pushall_call_handler=get_target(); for (i=N_REGS;i--;) { @@ -3378,47 +3387,47 @@ static inline void create_popalls(void) raw_jmp_m_indexed((uintptr)cache_tags,r,SIZEOF_VOID_P); /* now the exit points */ - align_target(32); + align_target(align_jumps); popall_do_nothing=get_target(); for (i=0;idirect_pen=(cpuop_func*)get_target(); raw_mov_l_rm(0,(uintptr)&(bi->pc_p)); raw_mov_l_mr((uintptr)®s.pc_p,0); raw_jmp((uintptr)popall_execute_normal); - align_target(32); + align_target(align_jumps); bi->direct_pcc=(cpuop_func*)get_target(); raw_mov_l_rm(0,(uintptr)&(bi->pc_p)); raw_mov_l_mr((uintptr)®s.pc_p,0); @@ -4288,7 +4297,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) #endif log_dump(); - align_target(32); + align_target(align_jumps); current_compile_p=get_target(); raise_in_cl_list(bi); -- 2.47.3