decks_scanned(0),
code_blocks_scanned(0),
start_time(nano_count()),
- card_scan_time(0),
- code_scan_time(0),
- data_sweep_time(0),
- code_sweep_time(0),
- compaction_time(0) {
+ times{0} {
data_heap_before = parent->data_room();
code_heap_before = parent->code->allocator->as_allocator_room();
start_time = nano_count();
void gc_event::reset_timer() { temp_time = nano_count(); }
-void gc_event::ended_card_scan(cell cards_scanned_, cell decks_scanned_) {
- cards_scanned += cards_scanned_;
- decks_scanned += decks_scanned_;
- card_scan_time = (cell)(nano_count() - temp_time);
-}
-
-void gc_event::ended_code_scan(cell code_blocks_scanned_) {
- code_blocks_scanned += code_blocks_scanned_;
- code_scan_time = (cell)(nano_count() - temp_time);
-}
-
-void gc_event::ended_data_sweep() {
- data_sweep_time = (cell)(nano_count() - temp_time);
-}
-
-void gc_event::ended_code_sweep() {
- code_sweep_time = (cell)(nano_count() - temp_time);
-}
-
-void gc_event::ended_compaction() {
- compaction_time = (cell)(nano_count() - temp_time);
+void gc_event::ended_phase(gc_phase phase) {
+ times[phase] = (cell)(nano_count() - temp_time);
}
void gc_event::ended_gc(factor_vm* parent) {
}
}
-void factor_vm::end_gc() {
- if (gc_events) {
- current_gc->event->ended_gc(this);
- gc_events->push_back(*current_gc->event);
- }
-}
-
void factor_vm::start_gc_again() {
- switch (current_gc->op) {
- case collect_nursery_op:
- // Nursery collection can fail if aging does not have enough
- // free space to fit all live objects from nursery.
- current_gc->op = collect_aging_op;
- break;
- case collect_aging_op:
- // Aging collection can fail if the aging semispace cannot fit
- // all the live objects from the other aging semispace and the
- // nursery.
- current_gc->op = collect_to_tenured_op;
- break;
- default:
- // Nothing else should fail mid-collection due to insufficient
- // space in the target generation.
- critical_error("in start_gc_again, bad GC op", current_gc->op);
- break;
+ if (current_gc->op == COLLECT_NURSERY_OP) {
+ // Nursery collection can fail if aging does not have enough
+ // free space to fit all live objects from nursery.
+ current_gc->op = COLLECT_AGING_OP;
+ } else if (current_gc->op == COLLECT_AGING_OP) {
+ // Aging collection can fail if the aging semispace cannot fit
+ // all the live objects from the other aging semispace and the
+ // nursery.
+ current_gc->op = COLLECT_TO_TENURED_OP;
+ } else {
+ // Nothing else should fail mid-collection due to insufficient
+ // space in the target generation.
+ critical_error("in start_gc_again, bad GC op", current_gc->op);
}
}
current_gc->event->op = current_gc->op;
switch (current_gc->op) {
- case collect_nursery_op:
+ case COLLECT_NURSERY_OP:
collect_nursery();
break;
- case collect_aging_op:
+ case COLLECT_AGING_OP:
// We end up here if the above fails.
collect_aging();
if (data->high_fragmentation_p()) {
// Change GC op so that if we fail again, we crash.
- set_current_gc_op(collect_full_op);
+ set_current_gc_op(COLLECT_FULL_OP);
collect_full();
}
break;
- case collect_to_tenured_op:
+ case COLLECT_TO_TENURED_OP:
// We end up here if the above fails.
collect_to_tenured();
if (data->high_fragmentation_p()) {
// Change GC op so that if we fail again, we crash.
- set_current_gc_op(collect_full_op);
+ set_current_gc_op(COLLECT_FULL_OP);
collect_full();
}
break;
- case collect_full_op:
+ case COLLECT_FULL_OP:
collect_full();
break;
- case collect_compact_op:
+ case COLLECT_COMPACT_OP:
collect_compact();
break;
- case collect_growing_heap_op:
- collect_growing_heap(requested_size);
+ case COLLECT_GROWING_DATA_HEAP_OP:
+ collect_growing_data_heap(requested_size);
break;
default:
critical_error("in gc, bad GC op", current_gc->op);
catch (const must_start_gc_again&) {
// We come back here if the target generation is full.
start_gc_again();
- continue;
}
}
- end_gc();
+ if (gc_events) {
+ current_gc->event->ended_gc(this);
+ gc_events->push_back(*current_gc->event);
+ }
atomic::store(¤t_gc_p, false);
if (ctx)
}
void factor_vm::primitive_minor_gc() {
- gc(collect_nursery_op, 0);
+ gc(COLLECT_NURSERY_OP, 0);
}
void factor_vm::primitive_full_gc() {
- gc(collect_full_op, 0);
+ gc(COLLECT_FULL_OP, 0);
}
void factor_vm::primitive_compact_gc() {
- gc(collect_compact_op, 0);
+ gc(COLLECT_COMPACT_OP, 0);
}
void factor_vm::primitive_enable_gc_events() {