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));
45 slot_visitor<gc_workhorse<tenured_space, full_policy>>
46 visitor(this, workhorse);
50 code->allocator->state.clear_mark_bits();
51 data->tenured->state.clear_mark_bits();
53 visitor.visit_all_roots();
54 visitor.visit_context_code_blocks();
55 visitor.visit_uninitialized_code_blocks();
57 visitor.visit_mark_stack(&mark_stack);
59 data->reset_tenured();
61 data->reset_nursery();
62 code->clear_remembered_set();
65 void factor_vm::collect_sweep_impl() {
66 gc_event* event = current_gc->event;
70 data->tenured->sweep();
72 event->ended_data_sweep();
74 update_code_roots_for_sweep();
80 event->ended_code_sweep();
83 void factor_vm::collect_full() {
87 if (data->low_memory_p()) {
88 // Full GC did not free up enough memory. Grow the heap.
89 set_current_gc_op(collect_growing_heap_op);
90 collect_growing_heap(0);
91 } else if (data->high_fragmentation_p()) {
92 // Enough free memory, but it is not contiguous. Perform a
94 set_current_gc_op(collect_compact_op);
95 collect_compact_impl();