On x86 64-bit variables (eg. of type double) require 2 stack slots. We
must return the one which has lower memory address so that we can
correctly execute movsd instruction with that address.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 arch/x86/insn-selector.brg |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg
index 46e1e8d..39aaf6e 100644
--- a/arch/x86/insn-selector.brg
+++ b/arch/x86/insn-selector.brg
@@ -88,6 +88,30 @@ static void method_args_cleanup(struct basic_block *bb, 
struct tree_node *tree,
        select_insn(bb, tree, imm_reg_insn(INSN_ADD_IMM_REG, args_size, 
stack_ptr));
 }
 
+/**
+ * Returns the local slot for 64-bit value. On x86 such value requires
+ * 2 stack slots. We must return the one which has lower memory
+ * address.
+ */
+static struct stack_slot *
+get_local_slot_64(struct stack_frame *frame, unsigned long idx)
+{
+       struct stack_slot *s1, *s2;
+
+#ifdef CONFIG_X86_32
+       s1 = get_local_slot(frame, idx);
+       s2 = get_local_slot(frame, idx + 1);
+
+       if ((long) slot_offset(s1) < 0)
+               return s2; /* Local variable, decreasing addresses. */
+
+       /* This slot corresponds to call argument, increasing addresses. */
+       return s1;
+#else
+       return get_local_slot(frame, idx);
+#endif
+}
+
 struct _MBState;
 
 static void __binop_reg_local(struct _MBState *, struct basic_block *, struct 
tree_node *, enum insn_type, struct var_info *, long);
-- 
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