7 tenured_space* tenured;
9 explicit full_policy(factor_vm* parent)
10 : parent(parent), tenured(parent->data->tenured) {}
12 bool should_copy_p(object* untagged) {
13 return !tenured->contains_p(untagged);
16 void promoted_object(object* obj) {
17 tenured->state.set_marked_p((cell)obj, obj->size());
18 parent->mark_stack.push_back((cell)obj);
21 void visited_object(object* obj) {
22 if (!tenured->state.marked_p((cell)obj))
27 /* After a sweep, invalidate any code heap roots which are not marked,
28 so that if a block makes a tail call to a generic word, and the PIC
29 compiler triggers a GC, and the caller block gets GCd as a result,
30 the PIC code won't try to overwrite the call site */
31 void factor_vm::update_code_roots_for_sweep() {
32 mark_bits* state = &code->allocator->state;
34 FACTOR_FOR_EACH(code_roots) {
35 code_root* root = *iter;
36 cell block = root->value & (~data_alignment - 1);
37 if (root->valid && !state->marked_p(block))
42 void factor_vm::collect_mark_impl() {
43 gc_workhorse<tenured_space, full_policy>
44 workhorse(this, this->data->tenured, full_policy(this));
46 slot_visitor<gc_workhorse<tenured_space, full_policy> >
47 visitor(this, workhorse);
51 code->allocator->state.clear_mark_bits();
52 data->tenured->state.clear_mark_bits();
54 visitor.visit_all_roots();
55 visitor.visit_context_code_blocks();
56 visitor.visit_uninitialized_code_blocks();
58 visitor.visit_mark_stack(&mark_stack);
60 data->reset_tenured();
62 data->reset_nursery();
63 code->clear_remembered_set();
66 void factor_vm::collect_sweep_impl() {
67 gc_event* event = current_gc->event;
70 event->started_data_sweep();
71 data->tenured->sweep();
73 event->ended_data_sweep();
75 update_code_roots_for_sweep();
78 event->started_code_sweep();
81 event->ended_code_sweep();
84 void factor_vm::collect_full() {
88 if (data->low_memory_p()) {
89 /* Full GC did not free up enough memory. Grow the heap. */
90 set_current_gc_op(collect_growing_heap_op);
91 collect_growing_heap(0);
92 } else if (data->high_fragmentation_p()) {
93 /* Enough free memory, but it is not contiguous. Perform a
95 set_current_gc_op(collect_compact_op);
96 collect_compact_impl();