PageRenderTime 22ms CodeModel.GetById 13ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/vm/aging_collector.cpp

http://github.com/abeaumont/factor
C++ | 56 lines | 37 code | 14 blank | 5 comment | 4 complexity | eacdec5916eeea82c591e7f88b04082f MD5 | raw file
 1#include "master.hpp"
 2
 3namespace factor
 4{
 5
 6aging_collector::aging_collector(factor_vm *parent_) :
 7	copying_collector<aging_space,aging_policy>(
 8		parent_,
 9		parent_->data->aging,
10		aging_policy(parent_)) {}
11
12void 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}