]> gitweb.factorcode.org Git - factor.git/blob - vm/aging_collector.cpp
VM: replaced the reset_generation() generic method with one method for each generation
[factor.git] / vm / aging_collector.cpp
1 #include "master.hpp"
2
3 namespace factor {
4
5 void factor_vm::collect_aging() {
6   /* Promote objects referenced from tenured space to tenured space, copy
7      everything else to the aging semi-space, and reset the nursery pointer. */
8   {
9     /* Change the op so that if we fail here, an assertion will be
10        raised. */
11     current_gc->op = collect_to_tenured_op;
12
13     to_tenured_collector collector(this);
14
15     gc_event* event = current_gc->event;
16
17     if (event)
18       event->started_card_scan();
19     collector.trace_cards(data->tenured, card_points_to_aging, full_unmarker());
20     if (event)
21       event->ended_card_scan(collector.cards_scanned, collector.decks_scanned);
22
23     if (event)
24       event->started_code_scan();
25     collector.trace_code_heap_roots(&code->points_to_aging);
26     if (event)
27       event->ended_code_scan(collector.code_blocks_scanned);
28
29     collector.tenure_reachable_objects();
30   }
31   {
32     /* If collection fails here, do a to_tenured collection. */
33     current_gc->op = collect_aging_op;
34
35     std::swap(data->aging, data->aging_semispace);
36     data->reset_aging();
37
38     copying_collector<aging_space, aging_policy> collector(this,
39                                                            this->data->aging,
40                                                            aging_policy(this));
41     collector.data_visitor.visit_roots();
42     collector.data_visitor.visit_contexts();
43
44     collector.cheneys_algorithm();
45
46     data->reset_nursery();
47     code->clear_remembered_set();
48   }
49 }
50
51 }