]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/collector.hpp
VM: the copying_collector only contained one method, so it can easily be
[factor.git] / vm / collector.hpp
index ce8b6445b8d5ab0ae92524ffd9d2067c67cd3688..791446e9fee1f77c66a41e2eed892b4526ee8000 100644 (file)
@@ -69,6 +69,7 @@ template <typename TargetGeneration, typename Policy> struct collector {
   cell cards_scanned;
   cell decks_scanned;
   cell code_blocks_scanned;
+  cell scan;
 
   collector(factor_vm* parent, TargetGeneration* target, Policy policy)
       : parent(parent),
@@ -79,7 +80,9 @@ template <typename TargetGeneration, typename Policy> struct collector {
         visitor(parent, workhorse),
         cards_scanned(0),
         decks_scanned(0),
-        code_blocks_scanned(0) {}
+        code_blocks_scanned(0) {
+    scan = target->start + target->occupied_space();
+  }
 
   void trace_code_heap_roots(std::set<code_block*>* remembered_set) {
     std::set<code_block*>::const_iterator iter = remembered_set->begin();
@@ -173,6 +176,13 @@ template <typename TargetGeneration, typename Policy> struct collector {
       }
     }
   }
+
+  void cheneys_algorithm() {
+    while (scan && scan < this->target->here) {
+      this->visitor.visit_object((object*)scan);
+      scan = this->target->next_object_after(scan);
+    }
+  }
 };
 
 }