mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-27 02:49:42 +00:00
fix stack alignment (theoritically but it was OK in practise) in generated
functions, move m68k_compile_execute() to compiler/ dir since it's JIT generic and it now depends on USE_PUSH_POP (as it should)
This commit is contained in:
parent
bde3eb7972
commit
1b99c9501f
@ -81,6 +81,9 @@
|
||||
#define MUL_NREG1 EAX_INDEX /* %eax will hold the low 32 bits after a 32x32 mul */
|
||||
#define MUL_NREG2 EDX_INDEX /* %edx will hold the high 32 bits */
|
||||
|
||||
#define STACK_ALIGN 16
|
||||
#define STACK_OFFSET sizeof(void *)
|
||||
|
||||
uae_s8 always_used[]={4,-1};
|
||||
#if defined(__x86_64__)
|
||||
uae_s8 can_byte[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1};
|
||||
@ -3322,9 +3325,14 @@ static __inline__ void raw_load_flagx(uae_u32 target, uae_u32 r)
|
||||
raw_mov_l_rm(target,(uintptr)live.state[r].mem);
|
||||
}
|
||||
|
||||
static __inline__ void raw_dec_sp(int off)
|
||||
{
|
||||
if (off) raw_sub_l_ri(ESP_INDEX,off);
|
||||
}
|
||||
|
||||
static __inline__ void raw_inc_sp(int off)
|
||||
{
|
||||
raw_add_l_ri(ESP_INDEX,off);
|
||||
if (off) raw_add_l_ri(ESP_INDEX,off);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -132,6 +132,10 @@ static int untranslated_compfn(const void *e1, const void *e2)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ! USE_PUSH_POP
|
||||
static void (*m68k_do_compile_execute)(void) = NULL;
|
||||
#endif
|
||||
|
||||
static compop_func *compfunctbl[65536];
|
||||
static compop_func *nfcompfunctbl[65536];
|
||||
static cpuop_func *nfcpufunctbl[65536];
|
||||
@ -5996,6 +6000,15 @@ static __inline__ void create_popalls(void)
|
||||
}
|
||||
vm_protect(popallspace, POPALLSPACE_SIZE, VM_PAGE_READ | VM_PAGE_WRITE);
|
||||
|
||||
int stack_space = STACK_OFFSET;
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
stack_space += sizeof(void *);
|
||||
}
|
||||
stack_space %= STACK_ALIGN;
|
||||
if (stack_space)
|
||||
stack_space = STACK_ALIGN - stack_space;
|
||||
|
||||
current_compile_p=popallspace;
|
||||
set_target(current_compile_p);
|
||||
#if USE_PUSH_POP
|
||||
@ -6005,6 +6018,7 @@ static __inline__ void create_popalls(void)
|
||||
*/
|
||||
align_target(align_jumps);
|
||||
popall_do_nothing=get_target();
|
||||
raw_inc_sp(stack_space);
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
raw_pop_l_r(i);
|
||||
@ -6013,6 +6027,7 @@ static __inline__ void create_popalls(void)
|
||||
|
||||
align_target(align_jumps);
|
||||
popall_execute_normal=get_target();
|
||||
raw_inc_sp(stack_space);
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
raw_pop_l_r(i);
|
||||
@ -6021,6 +6036,7 @@ static __inline__ void create_popalls(void)
|
||||
|
||||
align_target(align_jumps);
|
||||
popall_cache_miss=get_target();
|
||||
raw_inc_sp(stack_space);
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
raw_pop_l_r(i);
|
||||
@ -6029,6 +6045,7 @@ static __inline__ void create_popalls(void)
|
||||
|
||||
align_target(align_jumps);
|
||||
popall_recompile_block=get_target();
|
||||
raw_inc_sp(stack_space);
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
raw_pop_l_r(i);
|
||||
@ -6037,6 +6054,7 @@ static __inline__ void create_popalls(void)
|
||||
|
||||
align_target(align_jumps);
|
||||
popall_exec_nostats=get_target();
|
||||
raw_inc_sp(stack_space);
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
raw_pop_l_r(i);
|
||||
@ -6045,6 +6063,7 @@ static __inline__ void create_popalls(void)
|
||||
|
||||
align_target(align_jumps);
|
||||
popall_check_checksum=get_target();
|
||||
raw_inc_sp(stack_space);
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
raw_pop_l_r(i);
|
||||
@ -6071,18 +6090,20 @@ static __inline__ void create_popalls(void)
|
||||
raw_push_l_r(i);
|
||||
}
|
||||
#endif
|
||||
raw_dec_sp(stack_space);
|
||||
r=REG_PC_TMP;
|
||||
raw_mov_l_rm(r,(uintptr)®s.pc_p);
|
||||
raw_and_l_ri(r,TAGMASK);
|
||||
raw_jmp_m_indexed((uintptr)cache_tags,r,SIZEOF_VOID_P);
|
||||
|
||||
#if defined(X86_ASSEMBLY) || defined(X86_64_ASSEMBLY)
|
||||
#if ! USE_PUSH_POP
|
||||
align_target(align_jumps);
|
||||
m68k_compile_execute = (void (*)(void))get_target();
|
||||
m68k_do_compile_execute = (void (*)(void))get_target();
|
||||
for (i=N_REGS;i--;) {
|
||||
if (need_to_preserve[i])
|
||||
raw_push_l_r(i);
|
||||
}
|
||||
raw_dec_sp(stack_space);
|
||||
align_target(align_loops);
|
||||
uae_u32 dispatch_loop = (uintptr)get_target();
|
||||
r=REG_PC_TMP;
|
||||
@ -6099,6 +6120,7 @@ static __inline__ void create_popalls(void)
|
||||
raw_cmp_b_mi((uintptr)&quit_program,0);
|
||||
raw_jcc_b_oponly(NATIVE_CC_EQ);
|
||||
emit_byte(dispatch_loop-((uintptr)get_target()+1));
|
||||
raw_inc_sp(stack_space);
|
||||
for (i=0;i<N_REGS;i++) {
|
||||
if (need_to_preserve[i])
|
||||
raw_pop_l_r(i);
|
||||
@ -7103,9 +7125,7 @@ void execute_normal(void)
|
||||
|
||||
typedef void (*compiled_handler)(void);
|
||||
|
||||
#if defined(X86_ASSEMBLY) || defined(X86_64_ASSEMBLY)
|
||||
void (*m68k_compile_execute)(void) = NULL;
|
||||
#else
|
||||
#if USE_PUSH_POP
|
||||
void m68k_do_compile_execute(void)
|
||||
{
|
||||
for (;;) {
|
||||
@ -7118,3 +7138,12 @@ void m68k_do_compile_execute(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void m68k_compile_execute (void)
|
||||
{
|
||||
for (;;) {
|
||||
if (quit_program)
|
||||
break;
|
||||
m68k_do_compile_execute();
|
||||
}
|
||||
}
|
||||
|
@ -1357,17 +1357,6 @@ void m68k_do_execute (void)
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_JIT && !(defined(X86_ASSEMBLY) || defined(X86_64_ASSEMBLY))
|
||||
void m68k_compile_execute (void)
|
||||
{
|
||||
for (;;) {
|
||||
if (quit_program)
|
||||
break;
|
||||
m68k_do_compile_execute();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void m68k_execute (void)
|
||||
{
|
||||
#if USE_JIT
|
||||
|
@ -287,14 +287,8 @@ extern void m68k_record_step(uaecptr) REGPARAM;
|
||||
extern void m68k_do_execute(void);
|
||||
extern void m68k_execute(void);
|
||||
#if USE_JIT
|
||||
#if defined(X86_ASSEMBLY) || defined(X86_64_ASSEMBLY)
|
||||
/* This is generated code */
|
||||
extern void (*m68k_compile_execute)(void);
|
||||
#else
|
||||
extern void m68k_do_compile_execute(void);
|
||||
extern void m68k_compile_execute(void);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_CPU_EMUL_SERVICES
|
||||
extern int32 emulated_ticks;
|
||||
extern void cpu_do_check_ticks(void);
|
||||
|
Loading…
Reference in New Issue
Block a user