vm: grow the heap if a full collection doesn't reclaim enough space

db4
Slava Pestov 2009-12-05 19:03:53 -05:00
parent 9e1c5adca7
commit 344c357ef1
4 changed files with 17 additions and 3 deletions

View File

@ -98,11 +98,16 @@ void data_heap::reset_generation(tenured_space *gen)
clear_decks(gen);
}
bool data_heap::low_memory_p()
bool data_heap::high_fragmentation_p()
{
return (tenured->largest_free_block() <= nursery->size + aging->size);
}
bool data_heap::low_memory_p()
{
return (tenured->free_space() <= nursery->size + aging->size);
}
void data_heap::mark_all_cards()
{
memset(cards,-1,cards_end - cards);

View File

@ -29,6 +29,7 @@ struct data_heap {
void reset_generation(nursery_space *gen);
void reset_generation(aging_space *gen);
void reset_generation(tenured_space *gen);
bool high_fragmentation_p();
bool low_memory_p();
void mark_all_cards();
};

View File

@ -143,12 +143,20 @@ void factor_vm::collect_full(bool trace_contexts_p)
{
collect_mark_impl(trace_contexts_p);
collect_sweep_impl();
if(data->low_memory_p())
{
current_gc->op = collect_growing_heap_op;
current_gc->event->op = collect_growing_heap_op;
collect_growing_heap(0,trace_contexts_p);
}
else if(data->high_fragmentation_p())
{
current_gc->op = collect_compact_op;
current_gc->event->op = collect_compact_op;
collect_compact_impl(trace_contexts_p);
}
code->flush_icache();
}

View File

@ -152,7 +152,7 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
break;
case collect_aging_op:
collect_aging();
if(data->low_memory_p())
if(data->high_fragmentation_p())
{
current_gc->op = collect_full_op;
current_gc->event->op = collect_full_op;
@ -161,7 +161,7 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
break;
case collect_to_tenured_op:
collect_to_tenured();
if(data->low_memory_p())
if(data->high_fragmentation_p())
{
current_gc->op = collect_full_op;
current_gc->event->op = collect_full_op;