New field was added to struct basic_block for storing machine offset.
We cannot get that information from instruction list because there are
basic blocks (exit_bb) which have no instructions.

Signed-off-by: Tomek Grabiec <[email protected]>
---
 arch/x86/emit-code_32.c   |    3 ++-
 include/jit/basic-block.h |    2 ++
 jit/basic-block.c         |    7 +++++++
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/arch/x86/emit-code_32.c b/arch/x86/emit-code_32.c
index db998cd..97cc3fb 100644
--- a/arch/x86/emit-code_32.c
+++ b/arch/x86/emit-code_32.c
@@ -941,7 +941,8 @@ void emit_body(struct basic_block *bb, struct buffer *buf)
 {
        struct insn *insn;
 
-       backpatch_branches(buf, &bb->backpatch_insns, buffer_offset(buf));
+       bb->mach_offset = buffer_offset(buf);
+       backpatch_branches(buf, &bb->backpatch_insns, bb->mach_offset);
 
        for_each_insn(insn, &bb->insn_list) {
                emit_insn(buf, insn);
diff --git a/include/jit/basic-block.h b/include/jit/basic-block.h
index 0cb4784..550fcb4 100644
--- a/include/jit/basic-block.h
+++ b/include/jit/basic-block.h
@@ -23,6 +23,7 @@ struct basic_block {
        unsigned long br_target_off;    /* Branch target offset in bytecode 
insns. */
        unsigned long nr_successors;
        struct basic_block **successors;
+       unsigned long mach_offset;
 
        /* The mimic stack is used to simulate JVM operand stack at
           compile-time.  See Section 2.2 ("Lazy code selection") of the paper
@@ -65,6 +66,7 @@ struct basic_block *bb_split(struct basic_block *, unsigned 
long);
 void bb_add_stmt(struct basic_block *, struct statement *);
 void bb_add_insn(struct basic_block *, struct insn *);
 int bb_add_successor(struct basic_block *, struct basic_block *);
+unsigned char *bb_native_ptr(struct basic_block *bb);
 
 #define for_each_basic_block(bb, bb_list) list_for_each_entry(bb, bb_list, 
bb_list_node)
 #define for_each_basic_block_reverse(bb, bb_list) 
list_for_each_entry_reverse(bb, bb_list, bb_list_node)
diff --git a/jit/basic-block.c b/jit/basic-block.c
index 052169f..5a76da2 100644
--- a/jit/basic-block.c
+++ b/jit/basic-block.c
@@ -17,6 +17,8 @@
 #include <string.h>
 #include <errno.h>
 
+#include <vm/buffer.h>
+
 struct basic_block *alloc_basic_block(struct compilation_unit *b_parent, 
unsigned long start, unsigned long end)
 {
        struct basic_block *bb;
@@ -149,3 +151,8 @@ int bb_add_successor(struct basic_block *bb, struct 
basic_block *successor)
 
        return 0;
 }
+
+unsigned char *bb_native_ptr(struct basic_block *bb)
+{
+       return buffer_ptr(bb->b_parent->objcode) + bb->mach_offset;
+}
-- 
1.6.0.6


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to