EAX and EDX registers can be scratched by objectUnlock() function so
they should be saved before the call.

Signed-off-by: Tomek Grabiec <[email protected]>
---
 arch/x86/emit-code_32.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/x86/emit-code_32.c b/arch/x86/emit-code_32.c
index fc374e4..139856b 100644
--- a/arch/x86/emit-code_32.c
+++ b/arch/x86/emit-code_32.c
@@ -843,9 +843,17 @@ void emit_lock(struct buffer *buf, struct object *obj)
 
 void emit_unlock(struct buffer *buf, struct object *obj)
 {
+       /* Save caller-saved registers which contain method's return value */
+       __emit_push_reg(buf, REG_EAX);
+       __emit_push_reg(buf, REG_EDX);
+
        __emit_push_imm(buf, (unsigned long)obj);
        __emit_call(buf, objectUnlock);
        __emit_add_imm_reg(buf, 0x04, REG_ESP);
+
+
+       __emit_pop_reg(buf, REG_EDX);
+       __emit_pop_reg(buf, REG_EAX);
 }
 
 void emit_lock_this(struct buffer *buf)
@@ -865,9 +873,16 @@ void emit_unlock_this(struct buffer *buf)
 
        this_arg_offset = offsetof(struct jit_stack_frame, args);
 
+       /* Save caller-saved registers which contain method's return value */
+       __emit_push_reg(buf, REG_EAX);
+       __emit_push_reg(buf, REG_EDX);
+
        __emit_push_membase(buf, REG_EBP, this_arg_offset);
        __emit_call(buf, objectUnlock);
        __emit_add_imm_reg(buf, 0x04, REG_ESP);
+
+       __emit_pop_reg(buf, REG_EDX);
+       __emit_pop_reg(buf, REG_EAX);
 }
 
 enum emitter_type {
-- 
1.6.0.6


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to