This fixes the follwing bug: http://jato.lighthouseapp.com/projects/29055/tickets/7-ebcdx-are-unavailable-for-allocation-after-some-call-instructions
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- arch/mmix/include/arch/instruction.h | 5 +++++ arch/mmix/include/arch/registers.h | 3 +++ arch/mmix/register.c | 2 ++ arch/x86/include/arch/instruction.h | 11 +++++++++++ arch/x86/include/arch/registers_32.h | 3 +++ arch/x86/registers_32.c | 16 ++++++++++++++++ arch/x86/use-def.c | 22 ++-------------------- jit/liveness.c | 15 ++++++++++++--- 8 files changed, 54 insertions(+), 23 deletions(-) diff --git a/arch/mmix/include/arch/instruction.h b/arch/mmix/include/arch/instruction.h index 27dc801..2fe1686 100644 --- a/arch/mmix/include/arch/instruction.h +++ b/arch/mmix/include/arch/instruction.h @@ -118,4 +118,9 @@ static inline const char *reg_name(enum machine_reg reg) return "<unknown>"; } +static inline bool insn_is_call(struct insn *insn) +{ + return false; +} + #endif /* __ARCH_INSTRUCTION_H */ diff --git a/arch/mmix/include/arch/registers.h b/arch/mmix/include/arch/registers.h index 8faa73f..05d71bd 100644 --- a/arch/mmix/include/arch/registers.h +++ b/arch/mmix/include/arch/registers.h @@ -20,6 +20,9 @@ enum machine_reg { MACH_REG_UNASSIGNED = INT_MAX, }; +#define NR_CALLER_SAVE_REGS 0 +extern enum machine_reg caller_save_regs[NR_CALLER_SAVE_REGS]; + static inline bool reg_supports_type(enum machine_reg reg, enum vm_type type) { return true; diff --git a/arch/mmix/register.c b/arch/mmix/register.c index 1cde43d..8aa587b 100644 --- a/arch/mmix/register.c +++ b/arch/mmix/register.c @@ -1,2 +1,4 @@ #include "arch/registers.h" #include "jit/vars.h" + +enum machine_reg caller_save_regs[NR_CALLER_SAVE_REGS] = {}; diff --git a/arch/x86/include/arch/instruction.h b/arch/x86/include/arch/instruction.h index be321de..c33bafa 100644 --- a/arch/x86/include/arch/instruction.h +++ b/arch/x86/include/arch/instruction.h @@ -323,4 +323,15 @@ static inline bool insn_is_branch(struct insn *insn) } } +static inline bool insn_is_call(struct insn *insn) +{ + switch (insn->type) { + case INSN_CALL_REG: + case INSN_CALL_REL: + return true; + default: + return false; + } +} + #endif diff --git a/arch/x86/include/arch/registers_32.h b/arch/x86/include/arch/registers_32.h index ac6e308..30fa29d 100644 --- a/arch/x86/include/arch/registers_32.h +++ b/arch/x86/include/arch/registers_32.h @@ -48,6 +48,9 @@ enum machine_reg { #define GPR_VM_TYPE J_INT +#define NR_CALLER_SAVE_REGS 11 +extern enum machine_reg caller_save_regs[NR_CALLER_SAVE_REGS]; + const char *reg_name(enum machine_reg reg); bool reg_supports_type(enum machine_reg reg, enum vm_type type); diff --git a/arch/x86/registers_32.c b/arch/x86/registers_32.c index 5d88f1c..ce3c476 100644 --- a/arch/x86/registers_32.c +++ b/arch/x86/registers_32.c @@ -26,10 +26,26 @@ #include "arch/registers.h" #include "jit/vars.h" +#include "vm/system.h" #include <assert.h> #include <stdbool.h> +enum machine_reg caller_save_regs[NR_CALLER_SAVE_REGS] = { + MACH_REG_EAX, + MACH_REG_ECX, + MACH_REG_EDX, + + MACH_REG_XMM0, + MACH_REG_XMM1, + MACH_REG_XMM2, + MACH_REG_XMM3, + MACH_REG_XMM4, + MACH_REG_XMM5, + MACH_REG_XMM6, + MACH_REG_XMM7 +}; + static const char *register_names[] = { [MACH_REG_EAX] = "EAX", [MACH_REG_ECX] = "ECX", diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c index 0730a07..1653195 100644 --- a/arch/x86/use-def.c +++ b/arch/x86/use-def.c @@ -22,7 +22,6 @@ enum { USE_NONE = 512, USE_SRC = 1024, USE_FP = 2048, /* frame pointer */ - DEF_CALLER_SAVED = 4096, #ifdef CONFIG_X86_32 DEF_EAX = DEF_xAX, @@ -50,8 +49,8 @@ static struct insn_info insn_infos[] = { DECLARE_INFO(INSN_ADD_REG_REG, USE_SRC | USE_DST | DEF_DST), DECLARE_INFO(INSN_AND_MEMBASE_REG, USE_SRC | USE_DST | DEF_DST), DECLARE_INFO(INSN_AND_REG_REG, USE_SRC | USE_DST | DEF_DST), - DECLARE_INFO(INSN_CALL_REG, USE_SRC | DEF_CALLER_SAVED), - DECLARE_INFO(INSN_CALL_REL, USE_NONE | DEF_CALLER_SAVED), + DECLARE_INFO(INSN_CALL_REG, USE_SRC | DEF_NONE), + DECLARE_INFO(INSN_CALL_REL, USE_NONE | DEF_NONE), DECLARE_INFO(INSN_CLTD_REG_REG, USE_SRC | DEF_SRC | DEF_DST), DECLARE_INFO(INSN_CMP_IMM_REG, USE_DST), DECLARE_INFO(INSN_CMP_MEMBASE_REG, USE_SRC | USE_DST), @@ -188,25 +187,8 @@ static struct mach_reg_def checkregs[] = { { MACH_REG_xAX, DEF_xAX }, { MACH_REG_xCX, DEF_xCX }, { MACH_REG_xDX, DEF_xDX }, - -#ifdef CONFIG_X86_32 - { MACH_REG_EAX, DEF_CALLER_SAVED }, - { MACH_REG_ECX, DEF_CALLER_SAVED }, - { MACH_REG_EDX, DEF_CALLER_SAVED }, -#else - { MACH_REG_RAX, DEF_CALLER_SAVED }, - { MACH_REG_RDI, DEF_CALLER_SAVED }, - { MACH_REG_RSI, DEF_CALLER_SAVED }, - { MACH_REG_RDX, DEF_CALLER_SAVED }, - { MACH_REG_RCX, DEF_CALLER_SAVED }, - { MACH_REG_R8, DEF_CALLER_SAVED }, - { MACH_REG_R9, DEF_CALLER_SAVED }, - { MACH_REG_R10, DEF_CALLER_SAVED }, - { MACH_REG_R11, DEF_CALLER_SAVED }, -#endif }; - int insn_defs(struct compilation_unit *cu, struct insn *insn, struct var_info **defs) { struct insn_info *info; diff --git a/jit/liveness.c b/jit/liveness.c index 4089298..0d6b97c 100644 --- a/jit/liveness.c +++ b/jit/liveness.c @@ -41,9 +41,9 @@ static void __update_live_ranges(struct compilation_unit *cu, struct basic_block struct var_info *uses[MAX_REG_OPERANDS]; struct var_info *defs[MAX_REG_OPERANDS]; struct insn *insn; - int nr_uses; - int nr_defs; - int i; + unsigned int nr_uses; + unsigned int nr_defs; + unsigned int i; for_each_insn_reverse(insn, &bb->insn_list) { nr_defs = insn_defs(bb->b_parent, insn, defs); @@ -62,6 +62,15 @@ static void __update_live_ranges(struct compilation_unit *cu, struct basic_block nr_uses = insn_uses(insn, uses); for (i = 0; i < nr_uses; i++) interval_add_range(uses[i]->interval, bb->start_insn, insn->lir_pos + 1); + + if (insn_is_call(insn)) { + for (i = 0; i < NR_CALLER_SAVE_REGS; i++) { + struct live_interval *reg; + + reg = cu->fixed_var_infos[caller_save_regs[i]]->interval; + interval_add_range(reg, insn->lir_pos + 1, insn->lir_pos + 2); + } + } } } -- 1.6.3.3 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel