Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 include/jit/compiler.h |    2 ++
 jit/compiler.c         |    3 +++
 jit/trace-jit.c        |   41 +++++++++++++++++++++++++++++++++++++++++
 vm/jato.c              |    6 ++++++
 4 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/include/jit/compiler.h b/include/jit/compiler.h
index 776196f..1bae506 100644
--- a/include/jit/compiler.h
+++ b/include/jit/compiler.h
@@ -97,6 +97,7 @@ extern bool opt_trace_lir;
 extern bool opt_trace_liveness;
 extern bool opt_trace_regalloc;
 extern bool opt_trace_machine_code;
+extern bool opt_trace_gc_maps;
 extern bool opt_trace_magic_trampoline;
 extern bool opt_trace_bytecode_offset;
 extern bool opt_trace_invoke;
@@ -113,6 +114,7 @@ void trace_lir(struct compilation_unit *);
 void trace_liveness(struct compilation_unit *);
 void trace_regalloc(struct compilation_unit *);
 void trace_machine_code(struct compilation_unit *);
+void trace_gc_maps(struct compilation_unit *);
 void trace_invoke(struct compilation_unit *);
 void trace_exception(struct compilation_unit *, struct jit_stack_frame *, 
unsigned char *);
 void trace_exception_handler(struct compilation_unit *, unsigned char *);
diff --git a/jit/compiler.c b/jit/compiler.c
index cd095b3..f4e1c59 100644
--- a/jit/compiler.c
+++ b/jit/compiler.c
@@ -121,6 +121,9 @@ int compile(struct compilation_unit *cu)
        if (err)
                goto out;
 
+       if (opt_trace_gc_maps)
+               trace_gc_maps(cu);
+
        cu->native_ptr = buffer_ptr(cu->objcode);
        cu->is_compiled = true;
 
diff --git a/jit/trace-jit.c b/jit/trace-jit.c
index 25a3d4b..2923c89 100644
--- a/jit/trace-jit.c
+++ b/jit/trace-jit.c
@@ -44,6 +44,7 @@ bool opt_trace_lir;
 bool opt_trace_liveness;
 bool opt_trace_regalloc;
 bool opt_trace_machine_code;
+bool opt_trace_gc_maps;
 bool opt_trace_magic_trampoline;
 bool opt_trace_bytecode_offset;
 bool opt_trace_invoke;
@@ -346,6 +347,46 @@ void trace_machine_code(struct compilation_unit *cu)
        trace_printf("\n");
 }
 
+static void print_gc_map(struct compilation_unit *cu, struct insn *insn)
+{
+       struct bitset *live_vars
+               = radix_tree_lookup(cu->safepoint_map, insn->mach_offset);
+       assert(live_vars);
+
+       trace_printf(" * %p: ", buffer_ptr(cu->objcode) + insn->mach_offset);
+
+       struct var_info *var;
+       for_each_variable(var, cu->var_infos) {
+               if (!test_bit(live_vars->bits, var->vreg))
+                       continue;
+
+               trace_printf("%d (%s), ",
+                       var->vreg, "" /* reg_name(var->interval->reg) */);
+       }
+
+       trace_printf("\n");
+}
+
+void trace_gc_maps(struct compilation_unit *cu)
+{
+       trace_printf("GC Map:\n\n");
+
+       struct basic_block *bb;
+       for_each_basic_block(bb, &cu->bb_list) {
+               trace_printf("[bb %p]:\n", bb);
+
+               struct insn *insn;
+               for_each_insn(insn, &bb->insn_list) {
+                       if (!insn->safepoint)
+                               continue;
+
+                       print_gc_map(cu, insn);
+               }
+       }
+
+       trace_printf("\n");
+}
+
 void trace_magic_trampoline(struct compilation_unit *cu)
 {
        trace_printf("jit_magic_trampoline: ret0=%p, ret1=%p: %s.%s #%d\n",
diff --git a/vm/jato.c b/vm/jato.c
index 78973e5..5223478 100644
--- a/vm/jato.c
+++ b/vm/jato.c
@@ -898,6 +898,11 @@ static void handle_trace_exceptions(void)
        opt_trace_exceptions = true;
 }
 
+static void handle_trace_gc_maps(void)
+{
+       opt_trace_gc_maps = true;
+}
+
 static void handle_trace_invoke(void)
 {
        opt_trace_invoke = true;
@@ -1008,6 +1013,7 @@ const struct option options[] = {
        DEFINE_OPTION("Xtrace:bytecode-offset", handle_trace_bytecode_offset),
        DEFINE_OPTION("Xtrace:classloader",     handle_trace_classloader),
        DEFINE_OPTION("Xtrace:exceptions",      handle_trace_exceptions),
+       DEFINE_OPTION("Xtrace:gc-maps",         handle_trace_gc_maps),
        DEFINE_OPTION("Xtrace:invoke",          handle_trace_invoke),
        DEFINE_OPTION("Xtrace:invoke-verbose",  handle_trace_invoke_verbose),
        DEFINE_OPTION("Xtrace:itable",          handle_trace_itable),
-- 
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