From b1bf15e2c9f43f51dc1bd13f34920ecc1c5fb078 Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Mon, 28 Aug 2006 19:52:48 +0000 Subject: [PATCH] dump jump tables --- ChangeLog | 8 ++++++++ include/jit/jit-opcode.h | 1 + jit/jit-dump.c | 27 +++++++++++++++++++++++++++ jit/jit-opcode.c | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1ed6549..b444d69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-08-29 Aleksey Demakov + + * include/jit/jit-opcode.h: + * jit/jit-opcode.c: add JIT_OPCODE_IS_JUMP_TABLE flag to mark the + JIT_OP_JUMP_TABLE opcode. + + * jit/jit-dump.c (jit_dump_insn, dump_interp_code): add jump table + dumping. 2006-08-28 Klaus Treichel diff --git a/include/jit/jit-opcode.h b/include/jit/jit-opcode.h index 7006ead..3bc2226 100644 --- a/include/jit/jit-opcode.h +++ b/include/jit/jit-opcode.h @@ -568,6 +568,7 @@ struct jit_opcode_info #define JIT_OPCODE_IS_CALL_EXTERNAL 0x00004000 #define JIT_OPCODE_IS_REG 0x00008000 #define JIT_OPCODE_IS_ADDROF_LABEL 0x00010000 +#define JIT_OPCODE_IS_JUMP_TABLE 0x00020000 #define JIT_OPCODE_OPER_MASK 0x01F00000 #define JIT_OPCODE_OPER_NONE 0x00000000 #define JIT_OPCODE_OPER_ADD 0x00100000 diff --git a/jit/jit-dump.c b/jit/jit-dump.c index 439e60f..5c3d7b5 100644 --- a/jit/jit-dump.c +++ b/jit/jit-dump.c @@ -419,6 +419,22 @@ void jit_dump_insn(FILE *stream, jit_function_t func, jit_insn_t insn) (long)(jit_insn_get_label(insn))); return; } + else if((flags & JIT_OPCODE_IS_JUMP_TABLE) != 0) + { + jit_label_t *labels; + jit_nint num_labels, label; + labels = (jit_label_t *)jit_value_get_nint_constant(jit_insn_get_value1(insn)); + num_labels = jit_value_get_nint_constant(jit_insn_get_value2(insn)); + fprintf(stream, "jump_table "); + dump_value(stream, func, jit_insn_get_dest(insn), flags & JIT_OPCODE_DEST_MASK); + printf(" : {"); + for(label = 0; label < num_labels; label++) + { + printf(" .L%ld", (long) labels[label]); + } + printf(" }"); + return; + } /* Output the destination information */ if((flags & JIT_OPCODE_DEST_MASK) != JIT_OPCODE_DEST_EMPTY && @@ -629,6 +645,17 @@ static void dump_interp_code(FILE *stream, void **pc, void **end) (long)(jit_nint)(pc[1]), (long)(jit_nint)(pc[2])); pc += 3; } + else if((info->flags & JIT_OPCODE_IS_JUMP_TABLE) != 0) + { + jit_nint label, num_labels; + num_labels = (jit_nint)pc[0]; + for(label = 1; label <= num_labels; label++) + { + fprintf(stream, " %lX", + (long)(jit_nint)pc[label]); + } + pc += 1 + num_labels; + } } break; } diff --git a/jit/jit-opcode.c b/jit/jit-opcode.c index adacfaa..a80c5cc 100644 --- a/jit/jit-opcode.c +++ b/jit/jit-opcode.c @@ -539,7 +539,7 @@ jit_opcode_info_t const jit_opcodes[JIT_OP_NUM_OPCODES] = { /* * Switch statement support. */ - {"jump_table", F_(PTR, PTR, INT)}, + {"jump_table", F_(ANY, PTR, INT)|JIT_OPCODE_IS_JUMP_TABLE}, }; #if defined(JIT_BACKEND_INTERP) -- 2.47.3