Monitor emitters and locking code can't get *this otherwise because the
corresponding instructions aren't insn-selected. Therefore we save *this
in a known place on the stack.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munte...@linux360.ro>
---
 arch/x86/emit-code.c                |    6 ++++++
 arch/x86/include/arch/stack-frame.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index e84e725..ff22482 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -2855,6 +2855,9 @@ void emit_prolog(struct buffer *buf, unsigned long 
nr_locals)
        __emit_push_reg(buf, MACH_REG_R14);
        __emit_push_reg(buf, MACH_REG_R15);
 
+       /* Save *this. */
+       __emit_push_reg(buf, MACH_REG_RDI);
+
        /*
         * The ABI requires us to clear DF, but we
         * don't need to. Though keep this in mind:
@@ -2872,6 +2875,9 @@ void emit_prolog(struct buffer *buf, unsigned long 
nr_locals)
 
 static void emit_restore_regs(struct buffer *buf)
 {
+       /* Clear *this from stack. */
+       __emit64_add_imm_reg(buf, 0x08, MACH_REG_RSP);
+
        __emit_pop_reg(buf, MACH_REG_R15);
        __emit_pop_reg(buf, MACH_REG_R14);
        __emit_pop_reg(buf, MACH_REG_R13);
diff --git a/arch/x86/include/arch/stack-frame.h 
b/arch/x86/include/arch/stack-frame.h
index 4b3a5e6..1188ac2 100644
--- a/arch/x86/include/arch/stack-frame.h
+++ b/arch/x86/include/arch/stack-frame.h
@@ -34,6 +34,7 @@ struct jit_stack_frame {
        unsigned long old_r13;
        unsigned long old_r12;
        unsigned long old_rbx;
+       unsigned long this;
        unsigned long return_address;
        unsigned long args[0];
 } __attribute__((packed));
-- 
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