vm: make the code nice and pretty

db4
Slava Pestov 2009-10-16 02:55:02 -05:00
parent 98a2f5152c
commit 0a3d08bc52
8 changed files with 23 additions and 22 deletions

View File

@ -12,6 +12,8 @@ aging_collector::aging_collector(factor_vm *myvm_) :
void factor_vm::collect_aging() void factor_vm::collect_aging()
{ {
/* Promote objects referenced from tenured space to tenured space, copy
everything else to the aging semi-space, and reset the nursery pointer. */
{ {
/* Change the op so that if we fail here, we proceed to a full /* Change the op so that if we fail here, we proceed to a full
tenured collection. We are collecting to tenured space, and tenured collection. We are collecting to tenured space, and

View File

@ -11,6 +11,12 @@ void code_heap::write_barrier(code_block *compiled)
points_to_aging.insert(compiled); points_to_aging.insert(compiled);
} }
void code_heap::clear_remembered_set()
{
points_to_nursery.clear();
points_to_aging.clear();
}
bool code_heap::needs_fixup_p(code_block *compiled) bool code_heap::needs_fixup_p(code_block *compiled)
{ {
return needs_fixup.count(compiled) > 0; return needs_fixup.count(compiled) > 0;
@ -224,7 +230,7 @@ void factor_vm::fixup_object_xts()
/* Move all free space to the end of the code heap. This is not very efficient, /* Move all free space to the end of the code heap. This is not very efficient,
since it makes several passes over the code and data heaps, but we only ever since it makes several passes over the code and data heaps, but we only ever
do this before saving a deployed image and exiting, so performaance is not do this before saving a deployed image and exiting, so performance is not
critical here */ critical here */
void factor_vm::compact_code_heap() void factor_vm::compact_code_heap()
{ {

View File

@ -13,6 +13,7 @@ struct code_heap : heap {
explicit code_heap(bool secure_gc, cell size); explicit code_heap(bool secure_gc, cell size);
void write_barrier(code_block *compiled); void write_barrier(code_block *compiled);
void clear_remembered_set();
bool needs_fixup_p(code_block *compiled); bool needs_fixup_p(code_block *compiled);
void code_heap_free(code_block *compiled); void code_heap_free(code_block *compiled);
}; };

View File

@ -123,23 +123,6 @@ struct after_full_updater {
} }
}; };
void factor_vm::update_code_heap_for_full_gc(bool growing_data_heap)
{
if(growing_data_heap)
{
after_growing_heap_updater updater(this);
code->free_unmarked(updater);
}
else
{
after_full_updater updater(this);
code->free_unmarked(updater);
}
code->points_to_nursery.clear();
code->points_to_aging.clear();
}
void factor_vm::collect_full_impl(bool trace_contexts_p) void factor_vm::collect_full_impl(bool trace_contexts_p)
{ {
full_collector collector(this); full_collector collector(this);
@ -159,19 +142,27 @@ void factor_vm::collect_full_impl(bool trace_contexts_p)
void factor_vm::collect_growing_heap(cell requested_bytes, bool trace_contexts_p) void factor_vm::collect_growing_heap(cell requested_bytes, bool trace_contexts_p)
{ {
/* Grow the data heap and copy all live objects to the new heap. */
data_heap *old = data; data_heap *old = data;
set_data_heap(data->grow(requested_bytes)); set_data_heap(data->grow(requested_bytes));
collect_full_impl(trace_contexts_p); collect_full_impl(trace_contexts_p);
update_code_heap_for_full_gc(true);
delete old; delete old;
after_growing_heap_updater updater(this);
code->free_unmarked(updater);
code->clear_remembered_set();
} }
void factor_vm::collect_full(bool trace_contexts_p) void factor_vm::collect_full(bool trace_contexts_p)
{ {
/* Copy all live objects to the tenured semispace. */
std::swap(data->tenured,data->tenured_semispace); std::swap(data->tenured,data->tenured_semispace);
reset_generation(data->tenured); reset_generation(data->tenured);
collect_full_impl(trace_contexts_p); collect_full_impl(trace_contexts_p);
update_code_heap_for_full_gc(false);
after_full_updater updater(this);
code->free_unmarked(updater);
code->clear_remembered_set();
} }
} }

View File

@ -12,6 +12,8 @@ nursery_collector::nursery_collector(factor_vm *myvm_) :
void factor_vm::collect_nursery() void factor_vm::collect_nursery()
{ {
/* Copy live objects from the nursery (as determined by the root set and
marked cards in aging and tenured) to aging space. */
nursery_collector collector(this); nursery_collector collector(this);
collector.trace_roots(); collector.trace_roots();

View File

@ -12,6 +12,7 @@ to_tenured_collector::to_tenured_collector(factor_vm *myvm_) :
void factor_vm::collect_to_tenured() void factor_vm::collect_to_tenured()
{ {
/* Copy live objects from aging space to tenured space. */
to_tenured_collector collector(this); to_tenured_collector collector(this);
collector.trace_roots(); collector.trace_roots();

View File

@ -15,7 +15,6 @@ struct to_tenured_policy {
struct to_tenured_collector : copying_collector<tenured_space,to_tenured_policy> { struct to_tenured_collector : copying_collector<tenured_space,to_tenured_policy> {
to_tenured_collector(factor_vm *myvm_); to_tenured_collector(factor_vm *myvm_);
void go();
}; };
} }

View File

@ -238,7 +238,6 @@ struct factor_vm
void collect_nursery(); void collect_nursery();
void collect_aging(); void collect_aging();
void collect_to_tenured(); void collect_to_tenured();
void update_code_heap_for_full_gc(bool growing_data_heap);
void collect_full_impl(bool trace_contexts_p); void collect_full_impl(bool trace_contexts_p);
void collect_growing_heap(cell requested_bytes, bool trace_contexts_p); void collect_growing_heap(cell requested_bytes, bool trace_contexts_p);
void collect_full(bool trace_contexts_p); void collect_full(bool trace_contexts_p);