]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/gc.hpp
webapps: better style
[factor.git] / vm / gc.hpp
old mode 100755 (executable)
new mode 100644 (file)
index 02f5441..b28038e
--- a/vm/gc.hpp
+++ b/vm/gc.hpp
@@ -1,67 +1,55 @@
-namespace factor
-{
+namespace factor {
 
-/* statistics */
-struct generation_statistics {
-       cell collections;
-       u64 gc_time;
-       u64 max_gc_time;
-       cell object_count;
-       u64 bytes_copied;
+struct must_start_gc_again {
 };
 
-struct gc_statistics {
-       generation_statistics generations[gen_count];
-       u64 cards_scanned;
-       u64 decks_scanned;
-       u64 card_scan_time;
-       u64 code_blocks_scanned;
+enum gc_op {
+  COLLECT_NURSERY_OP,
+  COLLECT_AGING_OP,
+  COLLECT_TO_TENURED_OP,
+  COLLECT_FULL_OP,
+  COLLECT_COMPACT_OP,
+  COLLECT_GROWING_DATA_HEAP_OP
 };
 
-struct gc_state {
-       /* The data heap we're collecting */
-       data_heap *data;
-
-       /* sometimes we grow the heap */
-       bool growing_data_heap;
-
-       /* Which generation is being collected */
-       cell collecting_gen;
-
-       /* If true, we are collecting aging space for the second time, so if it is still
-          full, we go on to collect tenured */
-       bool collecting_aging_again;
-
-       /* GC start time, for benchmarking */
-       u64 start_time;
-
-        jmp_buf gc_unwind;
-
-       explicit gc_state(data_heap *data_, bool growing_data_heap_, cell collecting_gen_);
-       ~gc_state();
-
-       inline bool collecting_nursery_p()
-       {
-               return collecting_gen == nursery_gen;
-       }
+// These are the phases of the gc cycles we record the times of.
+enum gc_phase {
+  PHASE_CARD_SCAN,
+  PHASE_CODE_SCAN,
+  PHASE_DATA_SWEEP,
+  PHASE_CODE_SWEEP,
+  PHASE_DATA_COMPACTION,
+  PHASE_MARKING
+};
 
-       inline bool collecting_aging_p()
-       {
-               return collecting_gen == aging_gen;
-       }
+struct gc_event {
+  gc_op op;
+  data_heap_room data_heap_before;
+  allocator_room code_heap_before;
+  data_heap_room data_heap_after;
+  allocator_room code_heap_after;
+  cell cards_scanned;
+  cell decks_scanned;
+  cell code_blocks_scanned;
+  uint64_t start_time;
+  cell total_time;
+  cell times[6];
+  uint64_t temp_time;
+
+  gc_event(gc_op op, factor_vm* parent);
+  void reset_timer();
+  void ended_phase(gc_phase phase);
+  void ended_gc(factor_vm* parent);
+};
 
-       inline bool collecting_tenured_p()
-       {
-               return collecting_gen == tenured_gen;
-       }
+struct gc_state {
+  gc_op op;
+  uint64_t start_time;
+  gc_event* event;
 
-       inline bool collecting_accumulation_gen_p()
-       {
-               return ((collecting_aging_p() && !collecting_aging_again)
-                       || collecting_tenured_p());
-       }
+  gc_state(gc_op op, factor_vm* parent);
+  ~gc_state();
+  void start_again(gc_op op_, factor_vm* parent);
 };
 
-VM_C_API void inline_gc(cell *gc_roots_base, cell gc_roots_size, factor_vm *myvm);
-
 }