VM: use the check_d and check_r to trace the overinitialized stack locations
parent
5e1a0e212a
commit
8fb8313251
|
@ -39,13 +39,31 @@ struct gc_info {
|
||||||
return (uint8_t*)base_pointer_map() - total_bitmap_bytes();
|
return (uint8_t*)base_pointer_map() - total_bitmap_bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
cell callsite_scrub_d(cell index) { return index * scrub_d_count; }
|
cell callsite_scrub_d(cell index) {
|
||||||
|
cell base = 0;
|
||||||
|
return base + index * scrub_d_count;
|
||||||
|
}
|
||||||
|
|
||||||
cell callsite_scrub_r(cell index) {
|
cell callsite_scrub_r(cell index) {
|
||||||
cell base = return_address_count * scrub_d_count;
|
cell base = return_address_count * scrub_d_count;
|
||||||
return base + index * scrub_r_count;
|
return base + index * scrub_r_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cell callsite_check_d(cell index) {
|
||||||
|
cell base =
|
||||||
|
return_address_count * scrub_d_count +
|
||||||
|
return_address_count * scrub_r_count;
|
||||||
|
return base + index * check_d_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell callsite_check_r(cell index) {
|
||||||
|
cell base =
|
||||||
|
return_address_count * scrub_d_count +
|
||||||
|
return_address_count * scrub_r_count +
|
||||||
|
return_address_count * check_d_count;
|
||||||
|
return base + index + check_r_count;
|
||||||
|
}
|
||||||
|
|
||||||
cell callsite_gc_roots(cell index) {
|
cell callsite_gc_roots(cell index) {
|
||||||
cell base =
|
cell base =
|
||||||
return_address_count * scrub_d_count +
|
return_address_count * scrub_d_count +
|
||||||
|
|
|
@ -264,10 +264,12 @@ template <typename Fixup> void slot_visitor<Fixup>::visit_roots() {
|
||||||
template <typename Fixup> struct call_frame_slot_visitor {
|
template <typename Fixup> struct call_frame_slot_visitor {
|
||||||
factor_vm* parent;
|
factor_vm* parent;
|
||||||
slot_visitor<Fixup>* visitor;
|
slot_visitor<Fixup>* visitor;
|
||||||
|
context* ctx;
|
||||||
|
|
||||||
call_frame_slot_visitor(factor_vm* parent,
|
call_frame_slot_visitor(factor_vm* parent,
|
||||||
slot_visitor<Fixup>* visitor)
|
slot_visitor<Fixup>* visitor,
|
||||||
: parent(parent), visitor(visitor) {}
|
context* ctx)
|
||||||
|
: parent(parent), visitor(visitor), ctx(ctx) {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
frame top -> [return address]
|
frame top -> [return address]
|
||||||
|
@ -310,6 +312,29 @@ template <typename Fixup> struct call_frame_slot_visitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Trace all overinitialized stack locations. */
|
||||||
|
cell callsite_check_d = info->callsite_check_d(callsite);
|
||||||
|
for (uint32_t loc = 0; loc < info->check_d_count; loc++) {
|
||||||
|
if (bitmap_p(bitmap, callsite_check_d + loc)) {
|
||||||
|
#ifdef DEBUG_GC_MAPS
|
||||||
|
std::cout << "checking datastack location " << loc << std::endl;
|
||||||
|
#endif
|
||||||
|
cell* value_ptr = ((cell*)ctx->datastack + loc + 1);
|
||||||
|
visitor->visit_handle(value_ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cell callsite_check_r = info->callsite_check_r(callsite);
|
||||||
|
for (uint32_t loc = 0; loc < info->check_r_count; loc++) {
|
||||||
|
if (bitmap_p(bitmap, callsite_check_r + loc)) {
|
||||||
|
#ifdef DEBUG_GC_MAPS
|
||||||
|
std::cout << "checking retainstack location " << loc << std::endl;
|
||||||
|
#endif
|
||||||
|
cell* value_ptr = ((cell*)ctx->retainstack + loc + 1);
|
||||||
|
visitor->visit_handle(value_ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Update all GC roots, including base pointers. */
|
/* Update all GC roots, including base pointers. */
|
||||||
cell callsite_gc_roots = info->callsite_gc_roots(callsite);
|
cell callsite_gc_roots = info->callsite_gc_roots(callsite);
|
||||||
|
|
||||||
|
@ -334,13 +359,14 @@ template <typename Fixup> struct call_frame_slot_visitor {
|
||||||
|
|
||||||
template <typename Fixup>
|
template <typename Fixup>
|
||||||
void slot_visitor<Fixup>::visit_callstack_object(callstack* stack) {
|
void slot_visitor<Fixup>::visit_callstack_object(callstack* stack) {
|
||||||
call_frame_slot_visitor<Fixup> call_frame_visitor(parent, this);
|
/* TODO: is parent->ctx right? */
|
||||||
|
call_frame_slot_visitor<Fixup> call_frame_visitor(parent, this, parent->ctx);
|
||||||
parent->iterate_callstack_object(stack, call_frame_visitor, fixup);
|
parent->iterate_callstack_object(stack, call_frame_visitor, fixup);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Fixup>
|
template <typename Fixup>
|
||||||
void slot_visitor<Fixup>::visit_callstack(context* ctx) {
|
void slot_visitor<Fixup>::visit_callstack(context* ctx) {
|
||||||
call_frame_slot_visitor<Fixup> call_frame_visitor(parent, this);
|
call_frame_slot_visitor<Fixup> call_frame_visitor(parent, this, ctx);
|
||||||
parent->iterate_callstack(ctx, call_frame_visitor, fixup);
|
parent->iterate_callstack(ctx, call_frame_visitor, fixup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue