The bytecode offset mapping is displayed in the LIR trace. If jato is run with -Xtrace:jit or -Xtrace:mapping then the mapping is displayed in disassembly trace.
Signed-off-by: Tomek Grabiec <[email protected]> --- include/jit/compiler.h | 1 + jit/disass-common.c | 4 ++-- jit/disass.c | 16 +++++++++++++++- jit/disass.h | 5 +++-- jit/trace-jit.c | 15 +++++++++++++-- vm/jato.c | 4 ++++ 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/jit/compiler.h b/include/jit/compiler.h index 9ee6069..0d87f6f 100644 --- a/include/jit/compiler.h +++ b/include/jit/compiler.h @@ -77,6 +77,7 @@ extern bool opt_trace_liveness; extern bool opt_trace_regalloc; extern bool opt_trace_machine_code; extern bool opt_trace_magic_trampoline; +extern bool opt_trace_bcoffset_mapping; void trace_magic_trampoline(struct compilation_unit *); void trace_method(struct compilation_unit *); diff --git a/jit/disass-common.c b/jit/disass-common.c index 8eab869..a9c1ba7 100644 --- a/jit/disass-common.c +++ b/jit/disass-common.c @@ -60,10 +60,10 @@ unsigned long disass_len; *******************************************************************************/ -void disassemble(void *start, void *end) +void disassemble(struct compilation_unit *cu, void *start, void *end) { for (; start < end; ) - start = disassinstr(start); + start = disassinstr(cu, start); } diff --git a/jit/disass.c b/jit/disass.c index 7ac77a8..fa42c11 100644 --- a/jit/disass.c +++ b/jit/disass.c @@ -33,6 +33,10 @@ #include "disass.h" +#include <jit/bcoffset-mapping.h> +#include <jit/compiler.h> +#include <vm/string.h> + #include <assert.h> #include <dis-asm.h> #include <stdarg.h> @@ -64,7 +68,7 @@ unsigned char *disassinstr(unsigned char *code) return NULL; } #else -unsigned char *disassinstr(unsigned char *code) +unsigned char *disassinstr(struct compilation_unit *cu, unsigned char *code) { unsigned long seqlen; unsigned long i; @@ -81,6 +85,16 @@ unsigned char *disassinstr(unsigned char *code) disass_initialized = 1; } + if (opt_trace_bcoffset_mapping) { + struct string *str = alloc_str(); + unsigned long bc_offset; + + bc_offset = mapping_get_native_bcoffset(cu, code); + bcoffset_print(bc_offset, str); + printf("[%-3s]", str->value); + free_str(str); + } + printf(" 0x%08lx: ", (unsigned long) code); disass_len = 0; diff --git a/jit/disass.h b/jit/disass.h index 356d08c..f34ebc6 100644 --- a/jit/disass.h +++ b/jit/disass.h @@ -34,6 +34,7 @@ #ifndef _DISASS_H #define _DISASS_H +#include <jit/compilation-unit.h> #include <dis-asm.h> #include <stdbool.h> @@ -59,7 +60,7 @@ extern unsigned long disass_len; /* function prototypes *******************************************************/ -void disassemble(void *start, void *end); +void disassemble(struct compilation_unit *cu, void *start, void *end); void disass_printf(PTR p, const char *fmt, ...); @@ -67,6 +68,6 @@ int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int le /* machine dependent functions */ -unsigned char *disassinstr(unsigned char *code); +unsigned char *disassinstr(struct compilation_unit *cu, unsigned char *code); #endif /* _DISASS_H */ diff --git a/jit/trace-jit.c b/jit/trace-jit.c index 8eaee81..26785c6 100644 --- a/jit/trace-jit.c +++ b/jit/trace-jit.c @@ -31,6 +31,7 @@ bool opt_trace_liveness; bool opt_trace_regalloc; bool opt_trace_machine_code; bool opt_trace_magic_trampoline; +bool opt_trace_bcoffset_mapping; void trace_method(struct compilation_unit *cu) { @@ -101,18 +102,28 @@ void trace_tree_ir(struct compilation_unit *cu) void trace_lir(struct compilation_unit *cu) { unsigned long offset = 0; + unsigned long bc_offset; struct basic_block *bb; struct string *str; + struct string *bc_str; struct insn *insn; printf("LIR:\n\n"); + printf("offset source\n"); for_each_basic_block(bb, &cu->bb_list) { for_each_insn(insn, &bb->insn_list) { str = alloc_str(); + bc_str = alloc_str(); + + bc_offset = mapping_get_insn_bcoffset(cu, insn); + + bcoffset_print(bc_offset, bc_str); lir_print(insn, str); - printf("%-2lu \t%s\n", offset++, str->value); + + printf("%-8lu %-8s\t%s\n", offset++, bc_str->value, str->value); free_str(str); + free_str(bc_str); } } @@ -209,7 +220,7 @@ void trace_machine_code(struct compilation_unit *cu) start = buffer_ptr(cu->objcode); end = buffer_current(cu->objcode); - disassemble(start, end); + disassemble(cu, start, end); printf("\n"); } diff --git a/vm/jato.c b/vm/jato.c index caa1385..710052a 100644 --- a/vm/jato.c +++ b/vm/jato.c @@ -235,10 +235,14 @@ int parseCommandLine(int argc, char *argv[], InitArgs *args) { opt_trace_regalloc = true; opt_trace_machine_code = true; opt_trace_magic_trampoline = true; + opt_trace_bcoffset_mapping = true; } else if (strcmp(argv[i], "-Xtrace:trampoline") == 0) { opt_trace_magic_trampoline = true; + } else if (strcmp(argv[i], "-Xtrace:mapping") == 0) { + opt_trace_bcoffset_mapping = true; + } else if(strcmp(argv[i], "-Xtrace:asm") == 0) { opt_trace_method = true; opt_trace_machine_code = true; -- 1.6.0.6 ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf _______________________________________________ Jatovm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jatovm-devel
