]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/data_heap.hpp
xmode.marker: caching match group regexps for performance
[factor.git] / vm / data_heap.hpp
old mode 100755 (executable)
new mode 100644 (file)
index 8b8ca59..4e3e85c
@@ -1,72 +1,58 @@
-namespace factor
-{
-
-/* generational copying GC divides memory into zones */
-struct zone {
-       /* allocation pointer is 'here'; its offset is hardcoded in the
-       compiler backends */
-       cell start;
-       cell here;
-       cell size;
-       cell end;
-       
-       cell init_zone(cell size_, cell start_)
-       {
-               size = size_;
-               start = here = start_;
-               end = start_ + size_;
-               return end;
-       }
-};
+namespace factor {
 
 struct data_heap {
-       segment *seg;
-
-       cell young_size;
-       cell aging_size;
-       cell tenured_size;
-
-       cell gen_count;
-
-       zone *generations;
-       zone *semispaces;
-
-       char *allot_markers;
-       char *allot_markers_end;
-
-       char *cards;
-       char *cards_end;
-
-       char *decks;
-       char *decks_end;
-       
-       /* the 0th generation is where new objects are allocated. */
-       cell nursery() { return 0; }
-       
-       /* where objects hang around */
-       cell aging() { return gen_count - 2; }
-       
-       /* the oldest generation */
-       cell tenured() { return gen_count - 1; }
-       
-       bool have_aging_p() { return gen_count > 2; }
-
-       data_heap(factor_vm *myvm, cell gen_count, cell young_size, cell aging_size, cell tenured_size);
-       ~data_heap();
+  cell start;
+
+  cell young_size;
+  cell aging_size;
+  cell tenured_size;
+
+  segment* seg;
+
+  // Borrowed reference to a factor_vm::nursery
+  bump_allocator* nursery;
+  aging_space* aging;
+  aging_space* aging_semispace;
+  tenured_space* tenured;
+
+  card* cards;
+  card* cards_end;
+
+  card_deck* decks;
+  card_deck* decks_end;
+
+  data_heap(bump_allocator* vm_nursery,
+            cell young_size,
+            cell aging_size,
+            cell tenured_size);
+  ~data_heap();
+  data_heap* grow(bump_allocator* vm_nursery, cell requested_size);
+  template <typename Generation> void clear_cards(Generation* gen);
+  template <typename Generation> void clear_decks(Generation* gen);
+  void reset_nursery();
+  void reset_aging();
+  void reset_tenured();
+  bool high_fragmentation_p();
+  bool low_memory_p();
+  void mark_all_cards();
+  cell high_water_mark() { return nursery->size + aging->size; }
 };
 
-static const cell max_gen_count = 3;
-
-inline static bool in_zone(zone *z, object *pointer)
-{
-       return (cell)pointer >= z->start && (cell)pointer < z->end;
-}
-
-PRIMITIVE(data_room);
-PRIMITIVE(size);
-
-PRIMITIVE(begin_scan);
-PRIMITIVE(next_object);
-PRIMITIVE(end_scan);
+struct data_heap_room {
+  cell nursery_size;
+  cell nursery_occupied;
+  cell nursery_free;
+  cell aging_size;
+  cell aging_occupied;
+  cell aging_free;
+  cell tenured_size;
+  cell tenured_occupied;
+  cell tenured_total_free;
+  cell tenured_contiguous_free;
+  cell tenured_free_block_count;
+  cell cards;
+  cell decks;
+  cell mark_stack;
+};
 
 }