New tracing option (-Xtrace:bytecode-offset) enables printing of bytecode offset mapping in LIR and assembly tracers.
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 | 14 +++++++++++++- vm/jato.c | 4 ++++ 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/include/jit/compiler.h b/include/jit/compiler.h index 9ee6069..65be96b 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_bytecode_offset; 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..0886b78 100644 --- a/jit/disass.c +++ b/jit/disass.c @@ -33,6 +33,10 @@ #include "disass.h" +#include <jit/compiler.h> +#include <jit/bc-offset-mapping.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_bytecode_offset) { + struct string *str = alloc_str(); + unsigned long bc_offset; + + bc_offset = native_ptr_to_bytecode_offset(cu, code); + print_bytecode_offset(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..71a6794 100644 --- a/jit/trace-jit.c +++ b/jit/trace-jit.c @@ -11,6 +11,7 @@ #include <jit/statement.h> #include <jit/tree-printer.h> #include <jit/vars.h> +#include <jit/bc-offset-mapping.h> #include <vm/buffer.h> #include <vm/string.h> @@ -31,6 +32,7 @@ bool opt_trace_liveness; bool opt_trace_regalloc; bool opt_trace_machine_code; bool opt_trace_magic_trampoline; +bool opt_trace_bytecode_offset; void trace_method(struct compilation_unit *cu) { @@ -111,6 +113,16 @@ void trace_lir(struct compilation_unit *cu) for_each_insn(insn, &bb->insn_list) { str = alloc_str(); lir_print(insn, str); + + if (opt_trace_bytecode_offset) { + unsigned long bc_offset = insn->bytecode_offset; + struct string *bc_str = alloc_str(); + + print_bytecode_offset(bc_offset, bc_str); + printf("[%-3s] ", bc_str->value); + free_str(bc_str); + } + printf("%-2lu \t%s\n", offset++, str->value); free_str(str); } @@ -209,7 +221,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 f52bb40..2122962 100644 --- a/vm/jato.c +++ b/vm/jato.c @@ -236,10 +236,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_bytecode_offset = true; } else if (strcmp(argv[i], "-Xtrace:trampoline") == 0) { opt_trace_magic_trampoline = true; + } else if (strcmp(argv[i], "-Xtrace:bytecode-offset") == 0) { + opt_trace_bytecode_offset = 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
