5 struct nursery_copier
: no_fixup
{
6 bump_allocator
* nursery
;
9 nursery_copier(bump_allocator
* nursery
, aging_space
* aging
)
10 : nursery(nursery
), aging(aging
) { }
12 object
* fixup_data(object
* obj
) {
13 if (!nursery
->contains_p(obj
)) {
17 // The while-loop is a needed micro-optimization.
18 while (obj
->forwarding_pointer_p()) {
19 obj
= obj
->forwarding_pointer();
22 if (!nursery
->contains_p(obj
)) {
26 cell size
= obj
->size();
27 object
* newpointer
= aging
->allot(size
);
29 throw must_start_gc_again();
31 memcpy(newpointer
, obj
, size
);
32 obj
->forward_to(newpointer
);
37 void factor_vm::collect_nursery() {
38 // Copy live objects from the nursery (as determined by the root set and
39 // marked cards in aging and tenured) to aging space.
40 slot_visitor
<nursery_copier
>
41 visitor(this, nursery_copier(data
->nursery
, data
->aging
));
43 cell scan
= data
->aging
->start
+ data
->aging
->occupied_space();
45 visitor
.visit_all_roots();
46 gc_event
* event
= current_gc
->event
;
50 visitor
.visit_cards(data
->tenured
, card_points_to_nursery
,
51 card_points_to_nursery
);
52 visitor
.visit_cards(data
->aging
, card_points_to_nursery
, 0xff);
54 event
->ended_phase(PHASE_CARD_SCAN
);
55 event
->cards_scanned
+= visitor
.cards_scanned
;
56 event
->decks_scanned
+= visitor
.decks_scanned
;
61 visitor
.visit_code_heap_roots(&code
->points_to_nursery
);
63 event
->ended_phase(PHASE_CODE_SCAN
);
64 event
->code_blocks_scanned
+= code
->points_to_nursery
.size();
67 visitor
.cheneys_algorithm(data
->aging
, scan
);
69 data
->reset_nursery();
70 code
->points_to_nursery
.clear();