]> gitweb.factorcode.org Git - factor.git/blob - vm/aging_collector.cpp
Merge branch 'ebnf' of git://double.co.nz/git/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_->gc_stats.aging_stats,
10                 parent_->data->aging,
11                 aging_policy(parent_)) {}
12
13 void factor_vm::collect_aging()
14 {
15         /* Promote objects referenced from tenured space to tenured space, copy
16         everything else to the aging semi-space, and reset the nursery pointer. */
17         {
18                 /* Change the op so that if we fail here, we proceed to a full
19                 tenured collection. We are collecting to tenured space, and
20                 cards were unmarked, so we can't proceed with a to_tenured
21                 collection. */
22                 current_gc->op = collect_to_tenured_op;
23
24                 to_tenured_collector collector(this);
25                 collector.trace_cards(data->tenured,
26                         card_points_to_aging,
27                         simple_unmarker(card_mark_mask));
28                 collector.cheneys_algorithm();
29         }
30         {
31                 /* If collection fails here, do a to_tenured collection. */
32                 current_gc->op = collect_aging_op;
33
34                 std::swap(data->aging,data->aging_semispace);
35                 reset_generation(data->aging);
36
37                 aging_collector collector(this);
38
39                 collector.trace_roots();
40                 collector.trace_contexts();
41                 collector.trace_code_heap_roots(&code->points_to_aging);
42                 collector.cheneys_algorithm();
43                 update_code_heap_for_minor_gc(&code->points_to_aging);
44
45                 nursery.here = nursery.start;
46                 code->points_to_nursery.clear();
47         }
48 }
49
50 }