From: Erik Charlebois Date: Sun, 12 May 2013 01:39:48 +0000 (-0400) Subject: VM: Refactor aging_collector to Factor style X-Git-Tag: 0.97~1326 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=ee9fd64b69ad38768cc0b4b57ff9ac80ebb511e7 VM: Refactor aging_collector to Factor style --- diff --git a/vm/aging_collector.cpp b/vm/aging_collector.cpp index 4bd1b81ec7..fb28697325 100644 --- a/vm/aging_collector.cpp +++ b/vm/aging_collector.cpp @@ -1,56 +1,55 @@ #include "master.hpp" -namespace factor -{ +namespace factor { -aging_collector::aging_collector(factor_vm *parent_) : - copying_collector( - parent_, - parent_->data->aging, - aging_policy(parent_)) {} +aging_collector::aging_collector(factor_vm* parent_) + : copying_collector(parent_, + parent_->data->aging, + aging_policy(parent_)) {} -void factor_vm::collect_aging() -{ - /* Promote objects referenced from tenured space to tenured space, copy - everything else to the aging semi-space, and reset the nursery pointer. */ - { - /* Change the op so that if we fail here, an assertion will be - raised. */ - current_gc->op = collect_to_tenured_op; +void factor_vm::collect_aging() { + /* Promote objects referenced from tenured space to tenured space, copy + everything else to the aging semi-space, and reset the nursery pointer. */ + { + /* Change the op so that if we fail here, an assertion will be + raised. */ + current_gc->op = collect_to_tenured_op; - to_tenured_collector collector(this); + to_tenured_collector collector(this); - gc_event *event = current_gc->event; + gc_event* event = current_gc->event; - if(event) event->started_card_scan(); - collector.trace_cards(data->tenured, - card_points_to_aging, - full_unmarker()); - if(event) event->ended_card_scan(collector.cards_scanned,collector.decks_scanned); + if (event) + event->started_card_scan(); + collector.trace_cards(data->tenured, card_points_to_aging, full_unmarker()); + if (event) + event->ended_card_scan(collector.cards_scanned, collector.decks_scanned); - if(event) event->started_code_scan(); - collector.trace_code_heap_roots(&code->points_to_aging); - if(event) event->ended_code_scan(collector.code_blocks_scanned); + if (event) + event->started_code_scan(); + collector.trace_code_heap_roots(&code->points_to_aging); + if (event) + event->ended_code_scan(collector.code_blocks_scanned); - collector.tenure_reachable_objects(); - } - { - /* If collection fails here, do a to_tenured collection. */ - current_gc->op = collect_aging_op; + collector.tenure_reachable_objects(); + } + { + /* If collection fails here, do a to_tenured collection. */ + current_gc->op = collect_aging_op; - std::swap(data->aging,data->aging_semispace); - data->reset_generation(data->aging); + std::swap(data->aging, data->aging_semispace); + data->reset_generation(data->aging); - aging_collector collector(this); + aging_collector collector(this); - collector.trace_roots(); - collector.trace_contexts(); + collector.trace_roots(); + collector.trace_contexts(); - collector.cheneys_algorithm(); + collector.cheneys_algorithm(); - data->reset_generation(&nursery); - code->clear_remembered_set(); - } + data->reset_generation(&nursery); + code->clear_remembered_set(); + } } } diff --git a/vm/aging_collector.hpp b/vm/aging_collector.hpp index 56550b211a..bd215c20d5 100644 --- a/vm/aging_collector.hpp +++ b/vm/aging_collector.hpp @@ -1,28 +1,26 @@ -namespace factor -{ +namespace factor { struct aging_policy { - factor_vm *parent; - aging_space *aging; - tenured_space *tenured; + factor_vm* parent; + aging_space* aging; + tenured_space* tenured; - explicit aging_policy(factor_vm *parent_) : - parent(parent_), - aging(parent->data->aging), - tenured(parent->data->tenured) {} + explicit aging_policy(factor_vm* parent_) + : parent(parent_), + aging(parent->data->aging), + tenured(parent->data->tenured) {} - bool should_copy_p(object *untagged) - { - return !(aging->contains_p(untagged) || tenured->contains_p(untagged)); - } + bool should_copy_p(object* untagged) { + return !(aging->contains_p(untagged) || tenured->contains_p(untagged)); + } - void promoted_object(object *obj) {} + void promoted_object(object* obj) {} - void visited_object(object *obj) {} + void visited_object(object* obj) {} }; -struct aging_collector : copying_collector { - explicit aging_collector(factor_vm *parent_); +struct aging_collector : copying_collector { + explicit aging_collector(factor_vm* parent_); }; }