]> gitweb.factorcode.org Git - factor.git/blob - vm/aging_collector.cpp
Merge branch 'master' of git://github.com/killy971/factor
[factor.git] / vm / aging_collector.cpp
1 #include "master.hpp"
2
3 namespace factor
4 {
5
6 aging_collector::aging_collector(factor_vm *parent_) :
7         copying_collector<aging_space,aging_policy>(
8                 parent_,
9                 parent_->data->aging,
10                 aging_policy(parent_)) {}
11
12 void factor_vm::collect_aging()
13 {
14         /* Promote objects referenced from tenured space to tenured space, copy
15         everything else to the aging semi-space, and reset the nursery pointer. */
16         {
17                 /* Change the op so that if we fail here, we proceed to a full
18                 tenured collection. We are collecting to tenured space, and
19                 cards were unmarked, so we can't proceed with a to_tenured
20                 collection. */
21                 current_gc->op = collect_to_tenured_op;
22
23                 to_tenured_collector collector(this);
24
25                 current_gc->event->started_code_scan();
26                 collector.trace_cards(data->tenured,
27                         card_points_to_aging,
28                         full_unmarker());
29                 current_gc->event->ended_card_scan(collector.cards_scanned,collector.decks_scanned);
30
31                 current_gc->event->started_code_scan();
32                 collector.trace_code_heap_roots(&code->points_to_aging);
33                 current_gc->event->ended_code_scan(collector.code_blocks_scanned);
34
35                 collector.tenure_reachable_objects();
36
37                 current_gc->event->started_code_sweep();
38                 update_code_heap_for_minor_gc(&code->points_to_aging);
39                 current_gc->event->ended_code_sweep();
40         }
41         {
42                 /* If collection fails here, do a to_tenured collection. */
43                 current_gc->op = collect_aging_op;
44
45                 std::swap(data->aging,data->aging_semispace);
46                 data->reset_generation(data->aging);
47
48                 aging_collector collector(this);
49
50                 collector.trace_roots();
51                 collector.trace_contexts();
52
53                 collector.cheneys_algorithm();
54
55                 data->reset_generation(&nursery);
56                 code->points_to_nursery.clear();
57                 code->points_to_aging.clear();
58         }
59 }
60
61 }