]> gitweb.factorcode.org Git - factor.git/blob - vm/aging_collector.cpp
VM: to_tenured_collector isn't needed, it's just a normal collector instance
[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     collector<tenured_space, to_tenured_policy> collector(this,
14                                                           this->data->tenured,
15                                                           to_tenured_policy(this));
16     gc_event* event = current_gc->event;
17
18     if (event)
19       event->started_card_scan();
20     collector.trace_cards(data->tenured, card_points_to_aging, 0xff);
21     if (event)
22       event->ended_card_scan(collector.cards_scanned, collector.decks_scanned);
23
24     if (event)
25       event->started_code_scan();
26     collector.trace_code_heap_roots(&code->points_to_aging);
27     if (event)
28       event->ended_code_scan(collector.code_blocks_scanned);
29
30     collector.visitor.visit_mark_stack(&mark_stack);
31   }
32   {
33     /* If collection fails here, do a to_tenured collection. */
34     current_gc->op = collect_aging_op;
35
36     std::swap(data->aging, data->aging_semispace);
37     data->reset_aging();
38
39     copying_collector<aging_space, aging_policy> collector(this,
40                                                            this->data->aging,
41                                                            aging_policy(this));
42
43     collector.visitor.visit_all_roots();
44     collector.cheneys_algorithm();
45
46     data->reset_nursery();
47     code->clear_remembered_set();
48   }
49 }
50
51 }