Other emitters need to save and restore parameter registers, so we split
this code from emit_trampoline() into separate functions.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munte...@linux360.ro>
---
 arch/x86/emit-code.c |   34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 96746b5..7b1f506 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -2906,6 +2906,26 @@ static void emit_restore_regs(struct buffer *buf)
        __emit_pop_reg(buf, MACH_REG_RBX);
 }
 
+static void emit_save_regparm(struct buffer *buf)
+{
+       __emit64_push_reg(buf, MACH_REG_RDI);
+       __emit64_push_reg(buf, MACH_REG_RSI);
+       __emit64_push_reg(buf, MACH_REG_RDX);
+       __emit64_push_reg(buf, MACH_REG_RCX);
+       __emit64_push_reg(buf, MACH_REG_R8);
+       __emit64_push_reg(buf, MACH_REG_R9);
+}
+
+static void emit_restore_regparm(struct buffer *buf)
+{
+       __emit64_pop_reg(buf, MACH_REG_R9);
+       __emit64_pop_reg(buf, MACH_REG_R8);
+       __emit64_pop_reg(buf, MACH_REG_RCX);
+       __emit64_pop_reg(buf, MACH_REG_RDX);
+       __emit64_pop_reg(buf, MACH_REG_RSI);
+       __emit64_pop_reg(buf, MACH_REG_RDI);
+}
+
 void emit_trampoline(struct compilation_unit *cu,
                     void *call_target,
                     struct jit_trampoline *trampoline)
@@ -2925,12 +2945,7 @@ void emit_trampoline(struct compilation_unit *cu,
         * %rdi, %rsi, %rdx, %rcx, %r8 and %r9 are used
         * to pass parameters, so save them if they get modified.
         */
-       __emit64_push_reg(buf, MACH_REG_RDI);
-       __emit64_push_reg(buf, MACH_REG_RSI);
-       __emit64_push_reg(buf, MACH_REG_RDX);
-       __emit64_push_reg(buf, MACH_REG_RCX);
-       __emit64_push_reg(buf, MACH_REG_R8);
-       __emit64_push_reg(buf, MACH_REG_R9);
+       emit_save_regparm(buf);
 
        __emit64_mov_imm_reg(buf, (unsigned long) cu, MACH_REG_RDI);
        __emit_call(buf, call_target);
@@ -2964,12 +2979,7 @@ void emit_trampoline(struct compilation_unit *cu,
                __emit64_pop_reg(buf, MACH_REG_RAX);
        }
 
-       __emit64_pop_reg(buf, MACH_REG_R9);
-       __emit64_pop_reg(buf, MACH_REG_R8);
-       __emit64_pop_reg(buf, MACH_REG_RCX);
-       __emit64_pop_reg(buf, MACH_REG_RDX);
-       __emit64_pop_reg(buf, MACH_REG_RSI);
-       __emit64_pop_reg(buf, MACH_REG_RDI);
+       emit_restore_regparm(buf);
 
        __emit64_pop_reg(buf, MACH_REG_RBP);
        emit_indirect_jump_reg(buf, MACH_REG_RAX);
-- 
1.6.0.6


------------------------------------------------------------------------------
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

Reply via email to