5 struct to_aging_copier
: no_fixup
{
7 tenured_space
* tenured
;
9 to_aging_copier(aging_space
* aging
, tenured_space
* tenured
)
10 : aging(aging
), tenured(tenured
) { }
12 object
* fixup_data(object
* obj
) {
13 if (aging
->contains_p(obj
) || tenured
->contains_p(obj
)) {
17 // Is there another forwarding pointer?
18 while (obj
->forwarding_pointer_p()) {
19 object
* dest
= obj
->forwarding_pointer();
23 if (aging
->contains_p(obj
) || tenured
->contains_p(obj
)) {
27 cell size
= obj
->size();
28 object
* newpointer
= aging
->allot(size
);
30 throw must_start_gc_again();
32 memcpy(newpointer
, obj
, size
);
33 obj
->forward_to(newpointer
);
39 void factor_vm::collect_aging() {
40 // Promote objects referenced from tenured space to tenured space, copy
41 // everything else to the aging semi-space, and reset the nursery pointer.
43 // Change the op so that if we fail here, an assertion will be raised.
44 current_gc
->op
= COLLECT_TO_TENURED_OP
;
46 slot_visitor
<from_tenured_refs_copier
>
47 visitor(this, from_tenured_refs_copier(data
->tenured
, &mark_stack
));
49 gc_event
* event
= current_gc
->event
;
53 visitor
.visit_cards(data
->tenured
, card_points_to_aging
, 0xff);
55 event
->ended_phase(PHASE_CARD_SCAN
);
56 event
->cards_scanned
+= visitor
.cards_scanned
;
57 event
->decks_scanned
+= visitor
.decks_scanned
;
62 visitor
.visit_code_heap_roots(&code
->points_to_aging
);
64 event
->ended_phase(PHASE_CODE_SCAN
);
65 event
->code_blocks_scanned
+= code
->points_to_aging
.size();
67 visitor
.visit_mark_stack(&mark_stack
);
70 // If collection fails here, do a to_tenured collection.
71 current_gc
->op
= COLLECT_AGING_OP
;
73 std::swap(data
->aging
, data
->aging_semispace
);
76 aging_space
*aging
= data
->aging
;
77 slot_visitor
<to_aging_copier
>
78 visitor(this, to_aging_copier(aging
, data
->tenured
));
80 cell scan
= aging
->start
+ aging
->occupied_space();
82 visitor
.visit_all_roots();
83 visitor
.cheneys_algorithm(aging
, scan
);
85 data
->reset_nursery();
86 code
->clear_remembered_set();