>From 606b809d5b91b7a8af4f8bb4de2f9f89794054d0 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Tue, 24 Aug 2010 17:30:00 -0300 Subject: [PATCH 1/4] Change JIT_REXTMP to not clobber 6th argument. To not clobber JIT_R2, JIT_REXTMP is defined to the callee save register %r12, instead of the scratch register %r11. To have JIT_V_NUM at 3, it now also uses %r14, but does not add %r15, that could be JIT_V(4) to simplify logic of keeping stack 16 bytes aligned. --- lightning/i386/core-64.h | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lightning/i386/core-64.h b/lightning/i386/core-64.h index 4c0c5dc..927165a 100644 --- a/lightning/i386/core-64.h +++ b/lightning/i386/core-64.h @@ -36,12 +36,12 @@ /* Used to implement ldc, stc, ... */ #define JIT_CAN_16 0 -#define JIT_REXTMP _R9D +#define JIT_REXTMP _R12D #define JIT_R_NUM 3 #define JIT_R(i) ((i) == 0 ? _EAX : _R9D + (i)) #define JIT_V_NUM 3 -#define JIT_V(i) ((i) == 0 ? _EBX : _R11D + (i)) +#define JIT_V(i) ((i) == 0 ? _EBX : _R12D + (i)) struct jit_local_state { int long_jumps; @@ -123,10 +123,9 @@ struct jit_local_state { #define jit_pushr_i(rs) PUSHQr(rs) #define jit_popr_i(rs) POPQr(rs) -/* A return address is 8 bytes, plus 4 registers = 32 byte, total = 40 bytes. - The final push of EBX keeps the stack aligned to 16 bytes. */ +/* A return address is 8 bytes, plus 5 registers = 40 byte, total = 48 bytes. */ #define jit_prolog(n) (_jitl.nextarg_getfp = _jitl.nextarg_geti = 0, _jitl.alloca_offset = 0, \ - PUSHQr(_EBX), PUSHQr(_R12), PUSHQr(_R13), PUSHQr(_EBP), MOVQrr(_ESP, _EBP), PUSHQr(_EBX)) + PUSHQr(_EBX), PUSHQr(_R12), PUSHQr(_R13), PUSHQr(_R14), PUSHQr(_EBP), MOVQrr(_ESP, _EBP)) #define jit_calli(sub) (MOVQir((long) (sub), JIT_REXTMP), CALLsr(JIT_REXTMP)) #define jit_callr(reg) CALLsr((reg)) @@ -178,7 +177,7 @@ static int jit_arg_reg_order[] = { _EDI, _ESI, _EDX, _ECX, _R8D, _R9D }; #define jit_patch_long_at(jump_pc,v) (*_PSL((jump_pc) - sizeof(long)) = _jit_SL((jit_insn *)(v))) #define jit_patch_short_at(jump_pc,v) (*_PSI((jump_pc) - sizeof(int)) = _jit_SI((jit_insn *)(v) - (jump_pc))) #define jit_patch_at(jump_pc,v) (_jitl.long_jumps ? jit_patch_long_at((jump_pc)-3, v) : jit_patch_short_at(jump_pc, v)) -#define jit_ret() (LEAVE_(), POPQr(_R13), POPQr(_R12), POPQr(_EBX), RET_()) +#define jit_ret() (LEAVE_(), POPQr(_R14), POPQr(_R13), POPQr(_R12), POPQr(_EBX), RET_()) /* Memory */ -- 1.7.2.1