]> gitweb.factorcode.org Git - factor.git/blob - vm/full_collector.hpp
GC maps for more compact inline GC checks
[factor.git] / vm / full_collector.hpp
1 namespace factor
2 {
3
4 struct full_policy {
5         factor_vm *parent;
6         tenured_space *tenured;
7
8         explicit full_policy(factor_vm *parent_) : parent(parent_), tenured(parent->data->tenured) {}
9
10         bool should_copy_p(object *untagged)
11         {
12                 return !tenured->contains_p(untagged);
13         }
14
15         void promoted_object(object *obj)
16         {
17                 tenured->set_marked_p(obj);
18                 parent->mark_stack.push_back((cell)obj);
19         }
20
21         void visited_object(object *obj)
22         {
23                 if(!tenured->marked_p(obj))
24                         promoted_object(obj);
25         }
26 };
27
28 struct full_collector : collector<tenured_space,full_policy> {
29         code_block_visitor<gc_workhorse<tenured_space,full_policy> > code_visitor;
30
31         explicit full_collector(factor_vm *parent_);
32         void trace_code_block(code_block *compiled);
33         void trace_context_code_blocks();
34         void trace_uninitialized_code_blocks();
35         void trace_object_code_block(object *obj);
36 };
37
38 }