VM: the copying_collector only contained one method, so it can easily be

merged with its base class
db4
Björn Lindqvist 2015-05-04 03:50:02 +02:00 committed by John Benediktsson
parent 685a795aa0
commit e4bb3058e0
7 changed files with 17 additions and 30 deletions

View File

@ -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 \

View File

@ -36,9 +36,9 @@ void factor_vm::collect_aging() {
std::swap(data->aging, data->aging_semispace);
data->reset_aging();
copying_collector<aging_space, aging_policy> collector(this,
this->data->aging,
aging_policy(this));
collector<aging_space, aging_policy> collector(this,
this->data->aging,
aging_policy(this));
collector.visitor.visit_all_roots();
collector.cheneys_algorithm();

View 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);
}
}
};
}

View File

@ -1,20 +0,0 @@
namespace factor {
template <typename TargetGeneration, typename Policy>
struct copying_collector : collector<TargetGeneration, Policy> {
cell scan;
copying_collector(factor_vm* parent, TargetGeneration* target,
Policy policy)
: collector<TargetGeneration, Policy>(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);
}
}
};
}

View File

@ -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"

View File

@ -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<aging_space, nursery_policy> collector(this,
this->data->aging,
nursery_policy(this));
collector<aging_space, nursery_policy> collector(this,
this->data->aging,
nursery_policy(this));
collector.visitor.visit_all_roots();
gc_event* event = current_gc->event;

View File

@ -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<code_block*>* remembered_set);
void collect_nursery();
void collect_aging();
void collect_to_tenured();