Signed-off-by: Vegard Nossum <[email protected]>
---
arch/x86/include/arch/instruction.h | 2 +
include/jit/compilation-unit.h | 5 ++++
jit/gc-map.c | 37 +++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/arch/instruction.h
b/arch/x86/include/arch/instruction.h
index 2ee8787..df9dab2 100644
--- a/arch/x86/include/arch/instruction.h
+++ b/arch/x86/include/arch/instruction.h
@@ -194,6 +194,8 @@ struct insn {
/* Position of this instruction in LIR. */
unsigned long lir_pos;
bool escaped;
+ /* True if this instruction is a GC safepoint */
+ bool safepoint;
unsigned long bytecode_offset;
};
diff --git a/include/jit/compilation-unit.h b/include/jit/compilation-unit.h
index 16700b3..5c9b978 100644
--- a/include/jit/compilation-unit.h
+++ b/include/jit/compilation-unit.h
@@ -78,6 +78,11 @@ struct compilation_unit {
* This maps LIR offset to instruction.
*/
struct radix_tree *lir_insn_map;
+
+ /*
+ * This maps machine-code offset (of gc safepoint) to gc map
+ */
+ struct radix_tree *safepoint_map;
};
struct compilation_unit *compilation_unit_alloc(struct vm_method *);
diff --git a/jit/gc-map.c b/jit/gc-map.c
index 277afb7..997c7e6 100644
--- a/jit/gc-map.c
+++ b/jit/gc-map.c
@@ -1,7 +1,44 @@
+#include <errno.h>
+
+#include "arch/instruction.h"
#include "jit/compilation-unit.h"
#include "jit/gc-map.h"
+#include "lib/bitset.h"
int gc_map_init(struct compilation_unit *cu)
{
+ cu->safepoint_map = alloc_radix_tree(8, 8 * sizeof(unsigned long));
+ if (!cu->safepoint_map)
+ return -ENOMEM;
+
+ struct basic_block *bb;
+ for_each_basic_block(bb, &cu->bb_list) {
+ struct insn *insn;
+ for_each_insn(insn, &bb->insn_list) {
+ if (!insn->safepoint)
+ continue;
+
+ /* XXX: Only allocate a map for vregs of type
+ * J_REFERENCE. */
+ struct bitset *live_vars = alloc_bitset(cu->nr_vregs);
+ if (!live_vars)
+ return -ENOMEM;
+
+ struct var_info *var;
+ for_each_variable(var, cu->var_infos) {
+ if (!in_range(&var->interval->range,
+ insn->mach_offset))
+ {
+ continue;
+ }
+
+ set_bit(live_vars->bits, var->vreg);
+ }
+
+ radix_tree_insert(cu->safepoint_map,
+ insn->mach_offset, live_vars);
+ }
+ }
+
return 0;
}
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel