]> gitweb.factorcode.org Git - factor.git/blob - vm/aging_collector.cpp
Clean up some GC logic and fix a bug where large object allocation could grow the...
[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, an assertion will be
18                 raised. */
19                 current_gc->op = collect_to_tenured_op;
20
21                 to_tenured_collector collector(this);
22
23                 gc_event *event = current_gc->event;
24
25                 if(event) event->started_card_scan();
26                 collector.trace_cards(data->tenured,
27                         card_points_to_aging,
28                         full_unmarker());
29                 if(event) event->ended_card_scan(collector.cards_scanned,collector.decks_scanned);
30
31                 if(event) event->started_code_scan();
32                 collector.trace_code_heap_roots(&code->points_to_aging);
33                 if(event) event->ended_code_scan(collector.code_blocks_scanned);
34
35                 collector.tenure_reachable_objects();
36         }
37         {
38                 /* If collection fails here, do a to_tenured collection. */
39                 current_gc->op = collect_aging_op;
40
41                 std::swap(data->aging,data->aging_semispace);
42                 data->reset_generation(data->aging);
43
44                 aging_collector collector(this);
45
46                 collector.trace_roots();
47                 collector.trace_contexts();
48
49                 collector.cheneys_algorithm();
50
51                 data->reset_generation(&nursery);
52                 code->clear_remembered_set();
53         }
54 }
55
56 }