Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 include/vm/method.h     |    2 ++
 jit/bc-offset-mapping.c |   18 +++++++++---------
 test/arch-x86/Makefile  |    1 +
 vm/method.c             |   11 ++++++++++-
 4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/include/vm/method.h b/include/vm/method.h
index 9d5c255..49b3040 100644
--- a/include/vm/method.h
+++ b/include/vm/method.h
@@ -9,6 +9,7 @@
 
 #include <cafebabe/code_attribute.h>
 #include <cafebabe/class.h>
+#include <cafebabe/line_number_table_attribute.h>
 #include <cafebabe/method_info.h>
 
 #include <jit/compilation-unit.h>
@@ -30,6 +31,7 @@ struct vm_method {
        int args_count;
 
        struct cafebabe_code_attribute code_attribute;
+       struct cafebabe_line_number_table_attribute line_number_table_attribute;
 
        struct compilation_unit *compilation_unit;
        struct jit_trampoline *trampoline;
diff --git a/jit/bc-offset-mapping.c b/jit/bc-offset-mapping.c
index 0699812..ff5f93a 100644
--- a/jit/bc-offset-mapping.c
+++ b/jit/bc-offset-mapping.c
@@ -121,19 +121,19 @@ bool all_insn_have_bytecode_offset(struct 
compilation_unit *cu)
 
 int bytecode_offset_to_line_no(struct vm_method *mb, unsigned long bc_offset)
 {
-       NOT_IMPLEMENTED;
-       return 0;
-
-#if 0
+       struct cafebabe_line_number_table_entry *table;
+       int length;
        int i;
 
-       if(mb->line_no_table_size == 0 || bc_offset == BC_OFFSET_UNKNOWN)
+       table = mb->line_number_table_attribute.line_number_table;
+       length = mb->line_number_table_attribute.line_number_table_length;
+
+       if(bc_offset == BC_OFFSET_UNKNOWN || length == 0)
                return -1;
 
-       i = mb->line_no_table_size - 1;
-       while (i && bc_offset < mb->line_no_table[i].start_pc)
+       i = length - 1;
+       while (i && bc_offset < table[i].start_pc)
                i--;
 
-       return mb->line_no_table[i].line_no;
-#endif
+       return table[i].line_number;
 }
diff --git a/test/arch-x86/Makefile b/test/arch-x86/Makefile
index 8a5a3e9..c2b4d6d 100644
--- a/test/arch-x86/Makefile
+++ b/test/arch-x86/Makefile
@@ -38,6 +38,7 @@ OBJS = \
        ../../cafebabe/src/cafebabe/constant_value_attribute.o \
        ../../cafebabe/src/cafebabe/error.o \
        ../../cafebabe/src/cafebabe/field_info.o \
+       ../../cafebabe/src/cafebabe/line_number_table_attribute.o \
        ../../cafebabe/src/cafebabe/method_info.o \
        ../../cafebabe/src/cafebabe/source_file_attribute.o \
        ../../cafebabe/src/cafebabe/stream.o \
diff --git a/vm/method.c b/vm/method.c
index e599446..c905764 100644
--- a/vm/method.c
+++ b/vm/method.c
@@ -3,6 +3,7 @@
 
 #include <cafebabe/attribute_array.h>
 #include <cafebabe/attribute_info.h>
+#include <cafebabe/line_number_table_attribute.h>
 #include <cafebabe/class.h>
 #include <cafebabe/code_attribute.h>
 #include <cafebabe/constant_pool.h>
@@ -67,7 +68,7 @@ int vm_method_init(struct vm_method *vmm,
 
        /*
         * Note: We can return here because the rest of the function deals
-        * with loading the Code attribute (which native methods don't have).
+        * with loading attributes which native and abstract methods don't have.
         */
        if (vm_method_is_native(vmm) || vm_method_is_abstract(vmm)) {
                /* Hm, we're now modifying a cafebabe structure. */
@@ -109,6 +110,14 @@ int vm_method_init(struct vm_method *vmm,
 
        cafebabe_stream_close_buffer(&stream);
 
+       if (cafebabe_read_line_number_table_attribute(class,
+               &vmm->code_attribute.attributes,
+               &vmm->line_number_table_attribute))
+       {
+               NOT_IMPLEMENTED;
+               return -1;
+       }
+
        return 0;
 }
 
-- 
1.6.0.6


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to