]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/gc.cpp
audio.engine.test: cleanup using
[factor.git] / vm / gc.cpp
index a5e82a79aee852e79730e657ffe0d896c31718fe..58e39d8d6274adc992164b1abae7902e25651436 100644 (file)
--- a/vm/gc.cpp
+++ b/vm/gc.cpp
@@ -8,11 +8,7 @@ gc_event::gc_event(gc_op op, factor_vm* parent)
       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();
@@ -20,27 +16,8 @@ gc_event::gc_event(gc_op op, factor_vm* parent)
 
 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) {
@@ -65,15 +42,15 @@ gc_state::~gc_state() {
 }
 
 void factor_vm::start_gc_again() {
-  if (current_gc->op == collect_nursery_op) {
+  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) {
+    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;
+    current_gc->op = COLLECT_TO_TENURED_OP;
   } else {
     // Nothing else should fail mid-collection due to insufficient
     // space in the target generation.
@@ -110,34 +87,34 @@ void factor_vm::gc(gc_op op, cell requested_size) {
         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_data_heap_op:
+        case COLLECT_GROWING_DATA_HEAP_OP:
           collect_growing_data_heap(requested_size);
           break;
         default:
@@ -169,15 +146,15 @@ void factor_vm::gc(gc_op op, cell requested_size) {
 }
 
 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() {