vm: fix issue with unnecessary heap growth
parent
9ffb01a9bd
commit
e1c365e69a
|
@ -127,9 +127,8 @@ void *factor_vm::get_rel_symbol(array *literals, cell index)
|
|||
}
|
||||
case ARRAY_TYPE:
|
||||
{
|
||||
cell i;
|
||||
array *names = untag<array>(symbol);
|
||||
for(i = 0; i < array_capacity(names); i++)
|
||||
for(cell i = 0; i < array_capacity(names); i++)
|
||||
{
|
||||
symbol_char *name = alien_offset(array_nth(names,i));
|
||||
void *sym = ffi_dlsym(d,name);
|
||||
|
|
|
@ -98,6 +98,11 @@ void data_heap::reset_generation(tenured_space *gen)
|
|||
clear_decks(gen);
|
||||
}
|
||||
|
||||
bool data_heap::low_memory_p()
|
||||
{
|
||||
return (tenured->free_space() <= nursery->size + aging->size);
|
||||
}
|
||||
|
||||
void factor_vm::set_data_heap(data_heap *data_)
|
||||
{
|
||||
data = data_;
|
||||
|
|
|
@ -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 low_memory_p();
|
||||
};
|
||||
|
||||
struct data_heap_room {
|
||||
|
|
|
@ -118,6 +118,22 @@ void factor_vm::collect_sweep_impl()
|
|||
current_gc->event->ended_data_sweep();
|
||||
}
|
||||
|
||||
void factor_vm::collect_full(bool trace_contexts_p)
|
||||
{
|
||||
collect_mark_impl(trace_contexts_p);
|
||||
collect_sweep_impl();
|
||||
if(data->tenured->largest_free_block() <= data->nursery->size + data->aging->size)
|
||||
collect_compact_impl(trace_contexts_p);
|
||||
else
|
||||
update_code_heap_words_and_literals();
|
||||
}
|
||||
|
||||
void factor_vm::collect_compact(bool trace_contexts_p)
|
||||
{
|
||||
collect_mark_impl(trace_contexts_p);
|
||||
collect_compact_impl(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. */
|
||||
|
|
28
vm/gc.cpp
28
vm/gc.cpp
|
@ -152,12 +152,6 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
|
|||
start_gc_again();
|
||||
}
|
||||
|
||||
if(current_gc->op == collect_aging_op || current_gc->op == collect_to_tenured_op)
|
||||
{
|
||||
if(data->tenured->free_space() <= data->nursery->size + data->aging->size)
|
||||
current_gc->op = collect_full_op;
|
||||
}
|
||||
|
||||
current_gc->event->op = current_gc->op;
|
||||
|
||||
switch(current_gc->op)
|
||||
|
@ -167,21 +161,27 @@ 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())
|
||||
{
|
||||
current_gc->op = collect_full_op;
|
||||
current_gc->event->op = collect_full_op;
|
||||
collect_full(trace_contexts_p);
|
||||
}
|
||||
break;
|
||||
case collect_to_tenured_op:
|
||||
collect_to_tenured();
|
||||
if(data->low_memory_p())
|
||||
{
|
||||
current_gc->op = collect_full_op;
|
||||
current_gc->event->op = collect_full_op;
|
||||
collect_full(trace_contexts_p);
|
||||
}
|
||||
break;
|
||||
case collect_full_op:
|
||||
collect_mark_impl(trace_contexts_p);
|
||||
collect_sweep_impl();
|
||||
if(data->tenured->largest_free_block() <= data->nursery->size + data->aging->size)
|
||||
collect_compact_impl(trace_contexts_p);
|
||||
else
|
||||
update_code_heap_words_and_literals();
|
||||
collect_full(trace_contexts_p);
|
||||
break;
|
||||
case collect_compact_op:
|
||||
collect_mark_impl(trace_contexts_p);
|
||||
collect_compact_impl(trace_contexts_p);
|
||||
collect_compact(trace_contexts_p);
|
||||
break;
|
||||
case collect_growing_heap_op:
|
||||
collect_growing_heap(requested_bytes,trace_contexts_p);
|
||||
|
|
|
@ -262,8 +262,10 @@ struct factor_vm
|
|||
void update_code_roots_for_compaction();
|
||||
void collect_mark_impl(bool trace_contexts_p);
|
||||
void collect_sweep_impl();
|
||||
void collect_full(bool trace_contexts_p);
|
||||
void collect_compact_impl(bool trace_contexts_p);
|
||||
void collect_compact_code_impl(bool trace_contexts_p);
|
||||
void collect_compact(bool trace_contexts_p);
|
||||
void collect_growing_heap(cell requested_bytes, bool trace_contexts_p);
|
||||
void gc(gc_op op, cell requested_bytes, bool trace_contexts_p);
|
||||
void primitive_minor_gc();
|
||||
|
|
Loading…
Reference in New Issue