From e4bb3058e0d54925cb92842d162255304e870916 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Lindqvist?= Date: Mon, 4 May 2015 03:50:02 +0200 Subject: [PATCH] VM: the copying_collector only contained one method, so it can easily be merged with its base class --- GNUmakefile | 1 - vm/aging_collector.cpp | 6 +++--- vm/collector.hpp | 12 +++++++++++- vm/copying_collector.hpp | 20 -------------------- vm/master.hpp | 1 - vm/nursery_collector.cpp | 6 +++--- vm/vm.hpp | 1 - 7 files changed, 17 insertions(+), 30 deletions(-) delete mode 100644 vm/copying_collector.hpp diff --git a/GNUmakefile b/GNUmakefile index 8bb924a995..2089b0787a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -115,7 +115,6 @@ ifdef CONFIG vm/callstack.hpp \ vm/slot_visitor.hpp \ vm/collector.hpp \ - vm/copying_collector.hpp \ vm/nursery_collector.hpp \ vm/aging_collector.hpp \ vm/to_tenured_collector.hpp \ diff --git a/vm/aging_collector.cpp b/vm/aging_collector.cpp index cd6b031383..0765409d90 100644 --- a/vm/aging_collector.cpp +++ b/vm/aging_collector.cpp @@ -36,9 +36,9 @@ void factor_vm::collect_aging() { std::swap(data->aging, data->aging_semispace); data->reset_aging(); - copying_collector collector(this, - this->data->aging, - aging_policy(this)); + collector collector(this, + this->data->aging, + aging_policy(this)); collector.visitor.visit_all_roots(); collector.cheneys_algorithm(); diff --git a/vm/collector.hpp b/vm/collector.hpp index ce8b6445b8..791446e9fe 100644 --- a/vm/collector.hpp +++ b/vm/collector.hpp @@ -69,6 +69,7 @@ template 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 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* remembered_set) { std::set::const_iterator iter = remembered_set->begin(); @@ -173,6 +176,13 @@ template struct collector { } } } + + void cheneys_algorithm() { + while (scan && scan < this->target->here) { + this->visitor.visit_object((object*)scan); + scan = this->target->next_object_after(scan); + } + } }; } diff --git a/vm/copying_collector.hpp b/vm/copying_collector.hpp deleted file mode 100644 index 911363f97f..0000000000 --- a/vm/copying_collector.hpp +++ /dev/null @@ -1,20 +0,0 @@ -namespace factor { - -template -struct copying_collector : collector { - cell scan; - - copying_collector(factor_vm* parent, TargetGeneration* target, - Policy policy) - : collector(parent, target, policy), - scan(target->here) {} - - void cheneys_algorithm() { - while (scan && scan < this->target->here) { - this->visitor.visit_object((object*)scan); - scan = this->target->next_object_after(scan); - } - } -}; - -} diff --git a/vm/master.hpp b/vm/master.hpp index 2110ddd230..27e823252f 100644 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -135,7 +135,6 @@ namespace factor { struct factor_vm; } #include "callstack.hpp" #include "slot_visitor.hpp" #include "collector.hpp" -#include "copying_collector.hpp" #include "nursery_collector.hpp" #include "aging_collector.hpp" #include "to_tenured_collector.hpp" diff --git a/vm/nursery_collector.cpp b/vm/nursery_collector.cpp index 72c7df0eab..2ba4937c8e 100644 --- a/vm/nursery_collector.cpp +++ b/vm/nursery_collector.cpp @@ -5,9 +5,9 @@ namespace factor { void factor_vm::collect_nursery() { /* Copy live objects from the nursery (as determined by the root set and marked cards in aging and tenured) to aging space. */ - copying_collector collector(this, - this->data->aging, - nursery_policy(this)); + collector collector(this, + this->data->aging, + nursery_policy(this)); collector.visitor.visit_all_roots(); gc_event* event = current_gc->event; diff --git a/vm/vm.hpp b/vm/vm.hpp index a6988c2de5..efc3ea06e6 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -355,7 +355,6 @@ struct factor_vm { void end_gc(); void set_current_gc_op(gc_op op); void start_gc_again(); - void update_code_heap_for_minor_gc(std::set* remembered_set); void collect_nursery(); void collect_aging(); void collect_to_tenured(); -- 2.34.1