]> gitweb.factorcode.org Git - factor.git/blob - vm/aging_collector.cpp
VM: the unmarker classes are not needed, easier to just send the unmask pattern to...
[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, 0xff);
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.visitor.visit_mark_stack(&mark_stack);
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
42     collector.visitor.visit_all_roots();
43     collector.cheneys_algorithm();
44
45     data->reset_nursery();
46     code->clear_remembered_set();
47   }
48 }
49
50 }