Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 include/vm/bytecodes.h |    4 +++-
 jit/trace-jit.c        |    3 ++-
 vm/bytecodes.c         |   28 +++++++++++++++++++++++++++-
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/include/vm/bytecodes.h b/include/vm/bytecodes.h
index 26da079..836c19c 100644
--- a/include/vm/bytecodes.h
+++ b/include/vm/bytecodes.h
@@ -4,6 +4,8 @@
 #include <stdint.h>
 #include <stdbool.h>
 
+struct vm_class;
+
 unsigned long bc_insn_size(const unsigned char *, unsigned long);
 bool bc_is_branch(unsigned char);
 bool bc_is_goto(unsigned char);
@@ -18,7 +20,7 @@ unsigned long bc_get_astore_index(const unsigned char *);
 unsigned long bc_get_ret_index(const unsigned char *);
 void bc_set_target_off(unsigned char *, long);
 
-void bytecode_disassemble(const unsigned char *, unsigned long);
+void bytecode_disassemble(struct vm_class *, const unsigned char *, unsigned 
long);
 
 static inline bool bc_branches_to_follower(unsigned char code)
 {
diff --git a/jit/trace-jit.c b/jit/trace-jit.c
index e1d698e..25a3d4b 100644
--- a/jit/trace-jit.c
+++ b/jit/trace-jit.c
@@ -663,7 +663,8 @@ void trace_exception_unwind_to_native(struct 
jit_stack_frame *frame)
 void trace_bytecode(struct vm_method *method)
 {
        trace_printf("Code:\n");
-       bytecode_disassemble(method->code_attribute.code,
+       bytecode_disassemble(method->class,
+                            method->code_attribute.code,
                             method->code_attribute.code_length);
        trace_printf("\nException table:\n");
        print_exception_table(method,
diff --git a/vm/bytecodes.c b/vm/bytecodes.c
index c374e82..4f20421 100644
--- a/vm/bytecodes.c
+++ b/vm/bytecodes.c
@@ -10,6 +10,7 @@
 #include "vm/vm.h"
 #include "vm/bytecode.h"
 #include "vm/bytecodes.h"
+#include "vm/class.h"
 #include "vm/die.h"
 #include "vm/opcodes.h"
 #include "vm/trace.h"
@@ -229,7 +230,8 @@ static char *bc_get_insn_name(const unsigned char *code)
        return strdup(buf);
 }
 
-void bytecode_disassemble(const unsigned char *code, unsigned long size)
+void bytecode_disassemble(struct vm_class *vmc, const unsigned char *code,
+                         unsigned long size)
 {
        unsigned long pc;
 
@@ -270,6 +272,30 @@ void bytecode_disassemble(const unsigned char *code, 
unsigned long size)
                for (int i = 1; i < size; i++)
                        trace_printf(" 0x%02x", (unsigned int)code[_pc + i]);
 
+               if (code[_pc] == OPC_INVOKESPECIAL ||
+                   code[_pc] == OPC_INVOKESTATIC ||
+                   code[_pc] == OPC_INVOKEINTERFACE ||
+                   code[_pc] == OPC_INVOKEVIRTUAL) {
+                       struct vm_class *r_vmc;
+                       char *r_name;
+                       char *r_type;
+                       uint16_t index;
+                       int err;
+
+                       index = read_u16(&code[_pc + 1]);
+
+                       if (code[_pc] == OPC_INVOKEINTERFACE)
+                               err = vm_class_resolve_interface_method(vmc,
+                                       index, &r_vmc, &r_name, &r_type);
+                       else
+                               err = vm_class_resolve_method(vmc, index, 
&r_vmc,
+                                                     &r_name, &r_type);
+
+                       if (!err)
+                               trace_printf(" // %s.%s%s", r_vmc->name, r_name,
+                                            r_type);
+               }
+
                trace_printf("\n");
        }
 }
-- 
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