25 # include "incls/_precompiled.incl" |
25 # include "incls/_precompiled.incl" |
26 # include "incls/_cardTableRS.cpp.incl" |
26 # include "incls/_cardTableRS.cpp.incl" |
27 |
27 |
28 CardTableRS::CardTableRS(MemRegion whole_heap, |
28 CardTableRS::CardTableRS(MemRegion whole_heap, |
29 int max_covered_regions) : |
29 int max_covered_regions) : |
30 GenRemSet(&_ct_bs), |
30 GenRemSet(), |
31 _ct_bs(whole_heap, max_covered_regions), |
31 _cur_youngergen_card_val(youngergenP1_card), |
32 _cur_youngergen_card_val(youngergenP1_card) |
32 _regions_to_iterate(max_covered_regions - 1) |
33 { |
33 { |
|
34 #ifndef SERIALGC |
|
35 if (UseG1GC) { |
|
36 if (G1RSBarrierUseQueue) { |
|
37 _ct_bs = new G1SATBCardTableLoggingModRefBS(whole_heap, |
|
38 max_covered_regions); |
|
39 } else { |
|
40 _ct_bs = new G1SATBCardTableModRefBS(whole_heap, max_covered_regions); |
|
41 } |
|
42 } else { |
|
43 _ct_bs = new CardTableModRefBSForCTRS(whole_heap, max_covered_regions); |
|
44 } |
|
45 #else |
|
46 _ct_bs = new CardTableModRefBSForCTRS(whole_heap, max_covered_regions); |
|
47 #endif |
|
48 set_bs(_ct_bs); |
34 _last_cur_val_in_gen = new jbyte[GenCollectedHeap::max_gens + 1]; |
49 _last_cur_val_in_gen = new jbyte[GenCollectedHeap::max_gens + 1]; |
35 if (_last_cur_val_in_gen == NULL) { |
50 if (_last_cur_val_in_gen == NULL) { |
36 vm_exit_during_initialization("Could not last_cur_val_in_gen array."); |
51 vm_exit_during_initialization("Could not last_cur_val_in_gen array."); |
37 } |
52 } |
38 for (int i = 0; i < GenCollectedHeap::max_gens + 1; i++) { |
53 for (int i = 0; i < GenCollectedHeap::max_gens + 1; i++) { |
39 _last_cur_val_in_gen[i] = clean_card_val(); |
54 _last_cur_val_in_gen[i] = clean_card_val(); |
40 } |
55 } |
41 _ct_bs.set_CTRS(this); |
56 _ct_bs->set_CTRS(this); |
42 } |
57 } |
43 |
58 |
44 void CardTableRS::resize_covered_region(MemRegion new_region) { |
59 void CardTableRS::resize_covered_region(MemRegion new_region) { |
45 _ct_bs.resize_covered_region(new_region); |
60 _ct_bs->resize_covered_region(new_region); |
46 } |
61 } |
47 |
62 |
48 jbyte CardTableRS::find_unused_youngergenP_card_value() { |
63 jbyte CardTableRS::find_unused_youngergenP_card_value() { |
49 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
|
50 for (jbyte v = youngergenP1_card; |
64 for (jbyte v = youngergenP1_card; |
51 v < cur_youngergen_and_prev_nonclean_card; |
65 v < cur_youngergen_and_prev_nonclean_card; |
52 v++) { |
66 v++) { |
53 bool seen = false; |
67 bool seen = false; |
54 for (int g = 0; g < gch->n_gens()+1; g++) { |
68 for (int g = 0; g < _regions_to_iterate; g++) { |
55 if (_last_cur_val_in_gen[g] == v) { |
69 if (_last_cur_val_in_gen[g] == v) { |
56 seen = true; |
70 seen = true; |
57 break; |
71 break; |
58 } |
72 } |
59 } |
73 } |
219 } while (true); |
233 } while (true); |
220 } |
234 } |
221 |
235 |
222 void CardTableRS::younger_refs_in_space_iterate(Space* sp, |
236 void CardTableRS::younger_refs_in_space_iterate(Space* sp, |
223 OopsInGenClosure* cl) { |
237 OopsInGenClosure* cl) { |
224 DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, _ct_bs.precision(), |
238 DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, _ct_bs->precision(), |
225 cl->gen_boundary()); |
239 cl->gen_boundary()); |
226 ClearNoncleanCardWrapper clear_cl(dcto_cl, this); |
240 ClearNoncleanCardWrapper clear_cl(dcto_cl, this); |
227 |
241 |
228 _ct_bs.non_clean_card_iterate(sp, sp->used_region_at_save_marks(), |
242 _ct_bs->non_clean_card_iterate(sp, sp->used_region_at_save_marks(), |
229 dcto_cl, &clear_cl, false); |
243 dcto_cl, &clear_cl, false); |
230 } |
244 } |
231 |
245 |
232 void CardTableRS::clear_into_younger(Generation* gen, bool clear_perm) { |
246 void CardTableRS::clear_into_younger(Generation* gen, bool clear_perm) { |
233 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
247 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
547 Generation* pg = SharedHeap::heap()->perm_gen(); |
561 Generation* pg = SharedHeap::heap()->perm_gen(); |
548 HeapWord* pg_boundary = pg->reserved().start(); |
562 HeapWord* pg_boundary = pg->reserved().start(); |
549 |
563 |
550 if (ch->kind() == CollectedHeap::GenCollectedHeap) { |
564 if (ch->kind() == CollectedHeap::GenCollectedHeap) { |
551 GenCollectedHeap::heap()->generation_iterate(&blk, false); |
565 GenCollectedHeap::heap()->generation_iterate(&blk, false); |
552 _ct_bs.verify(); |
566 _ct_bs->verify(); |
553 |
567 |
554 // If the old gen collections also collect perm, then we are only |
568 // If the old gen collections also collect perm, then we are only |
555 // interested in perm-to-young pointers, not perm-to-old pointers. |
569 // interested in perm-to-young pointers, not perm-to-old pointers. |
556 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
570 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
557 CollectorPolicy* cp = gch->collector_policy(); |
571 CollectorPolicy* cp = gch->collector_policy(); |