Native functions called from the trampoline may alter the registers used
for parameter passing, so save them no matter which get altered in the
trampoline itself.

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

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index ce09a45..5612ce6 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -2082,9 +2082,14 @@ void emit_trampoline(struct compilation_unit *cu,
         * to pass parameters, so save them if they get modified.
         */
        __emit64_push_reg(buf, REG_RDI);
+       __emit64_push_reg(buf, REG_RSI);
+       __emit64_push_reg(buf, REG_RDX);
+       __emit64_push_reg(buf, REG_RCX);
+       __emit64_push_reg(buf, REG_R8);
+       __emit64_push_reg(buf, REG_R9);
+
        __emit64_mov_imm_reg(buf, (unsigned long) cu, REG_RDI);
        __emit_call(buf, call_target);
-       __emit64_pop_reg(buf, REG_RDI);
 
        /*
         * Test for exception occurance.
@@ -2094,27 +2099,26 @@ void emit_trampoline(struct compilation_unit *cu,
         * mov fs:(0xXXX), %rcx
         * test (%rcx), %rcx
         */
-       __emit64_push_reg(buf, REG_RCX);
        emit(buf, 0x64);
        __emit_memdisp_reg(buf, 1, 0x8b,
                           get_thread_local_offset(&trampoline_exception_guard),
                           REG_RCX);
        __emit64_test_membase_reg(buf, REG_RCX, 0, REG_RCX);
-       __emit64_pop_reg(buf, REG_RCX);
 
        if (method_is_virtual(cu->method)) {
-               __emit64_push_reg(buf, REG_RDI);
-               __emit64_push_reg(buf, REG_RSI);
-
                __emit64_mov_reg_reg(buf, REG_RAX, REG_RDI);
                __emit64_mov_membase_reg(buf, REG_RBP, 0x08, REG_RSI);
                __emit64_mov_imm_reg(buf, (unsigned long) cu, REG_RDX);
                __emit_call(buf, fixup_vtable);
-
-               __emit64_pop_reg(buf, REG_RSI);
-               __emit64_pop_reg(buf, REG_RDI);
        }
 
+       __emit64_pop_reg(buf, REG_R9);
+       __emit64_pop_reg(buf, REG_R8);
+       __emit64_pop_reg(buf, REG_RCX);
+       __emit64_pop_reg(buf, REG_RDX);
+       __emit64_pop_reg(buf, REG_RSI);
+       __emit64_pop_reg(buf, REG_RDI);
+
        __emit64_pop_reg(buf, REG_RBP);
        emit_indirect_jump_reg(buf, REG_RAX);
 
-- 
1.6.0.6


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to