Also print out the stack slot (if known). This code probably still needs
some fixing.

Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 jit/gc-map.c    |   22 ++++++++++++++++------
 jit/trace-jit.c |   13 +++++++++----
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/jit/gc-map.c b/jit/gc-map.c
index 292f2fc..ec95ed5 100644
--- a/jit/gc-map.c
+++ b/jit/gc-map.c
@@ -15,21 +15,31 @@ int gc_map_init(struct compilation_unit *cu)
        for_each_basic_block(bb, &cu->bb_list) {
                struct insn *insn;
                for_each_insn(insn, &bb->insn_list) {
+                       struct var_info *var;
+
                        if (!insn->safepoint)
                                continue;
 
-                       /* XXX: Only allocate a map for vregs of type
-                        * J_REFERENCE. */
-                       struct bitset *live_vars = alloc_bitset(cu->nr_vregs);
+                       /* Count the number of reference-type variables */
+                       unsigned int nr_ref_vars = 0;
+                       for_each_variable(var, cu->var_infos) {
+                               if (var->vm_type == J_REFERENCE)
+                                       ++nr_ref_vars;
+                       }
+
+                       /* XXX: XMM registers can never hold references, so
+                        * we should not allocate bits for them. */
+                       struct bitset *live_vars
+                               = alloc_bitset(NR_REGISTERS + nr_ref_vars);
                        if (!live_vars)
                                return -ENOMEM;
 
-                       struct var_info *var;
+                       unsigned int i = NR_REGISTERS;
                        for_each_variable(var, cu->var_infos) {
-                               if  (var->vm_type != J_REFERENCE)
+                               if (var->vm_type != J_REFERENCE)
                                        continue;
 
-                               set_bit(live_vars->bits, var->vreg);
+                               set_bit(live_vars->bits, i++);
                        }
 
                        radix_tree_insert(cu->safepoint_map,
diff --git a/jit/trace-jit.c b/jit/trace-jit.c
index 19f5523..9438f3a 100644
--- a/jit/trace-jit.c
+++ b/jit/trace-jit.c
@@ -356,15 +356,20 @@ static void print_gc_map(struct compilation_unit *cu, 
struct insn *insn)
        trace_printf(" * %p: ", buffer_ptr(cu->objcode) + insn->mach_offset);
 
        struct var_info *var;
+       unsigned int i = NR_REGISTERS;
        for_each_variable(var, cu->var_infos) {
-               if (!test_bit(live_vars->bits, var->vreg))
+               if (var->vm_type != J_REFERENCE)
                        continue;
 
-               if (in_range(&var->interval->range, insn->mach_offset)) {
+               if (!test_bit(live_vars->bits, i++))
+                       continue;
+
+               if (in_range(&var->interval->range, insn->lir_pos)) {
                        trace_printf("%d (%s), ",
                                var->vreg, reg_name(var->interval->reg));
-               } else {
-                       trace_printf("%d (stack), ", var->vreg);
+               } else if (var->interval->need_spill) {
+                       trace_printf("%d (%d), ",
+                               var->vreg, var->interval->spill_slot->index);
                }
        }
 
-- 
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