Signed-off-by: Tomek Grabiec <[email protected]>
---
include/vm/method.h | 2 ++
jit/bc-offset-mapping.c | 18 +++++++++---------
vm/method.c | 11 ++++++++++-
3 files changed, 21 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/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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel