36 return;
37 }
38 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);
39 _counts->clear_range(mr);
40 }
41
42 size_t G1CardCounts::compute_size(size_t mem_region_size_in_words) {
43 // We keep card counts for every card, so the size of the card counts table must
44 // be the same as the card table.
45 return G1SATBCardTableLoggingModRefBS::compute_size(mem_region_size_in_words);
46 }
47
48 size_t G1CardCounts::heap_map_factor() {
49 // See G1CardCounts::compute_size() why we reuse the card table value.
50 return G1SATBCardTableLoggingModRefBS::heap_map_factor();
51 }
52
53 void G1CardCounts::clear_range(size_t from_card_num, size_t to_card_num) {
54 if (has_count_table()) {
55 assert(from_card_num < to_card_num,
56 err_msg("Wrong order? from: " SIZE_FORMAT ", to: " SIZE_FORMAT,
57 from_card_num, to_card_num));
58 Copy::fill_to_bytes(&_card_counts[from_card_num], (to_card_num - from_card_num));
59 }
60 }
61
62 G1CardCounts::G1CardCounts(G1CollectedHeap *g1h):
63 _listener(), _g1h(g1h), _card_counts(NULL), _reserved_max_card_num(0) {
64 _listener.set_cardcounts(this);
65 }
66
67 void G1CardCounts::initialize(G1RegionToSpaceMapper* mapper) {
68 assert(_g1h->max_capacity() > 0, "initialization order");
69 assert(_g1h->capacity() == 0, "initialization order");
70
71 if (G1ConcRSHotCardLimit > 0) {
72 // The max value we can store in the counts table is
73 // max_jubyte. Guarantee the value of the hot
74 // threshold limit is no more than this.
75 guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity");
76
77 _ct_bs = _g1h->g1_barrier_set();
79
80 _card_counts = (jubyte*) mapper->reserved().start();
81 _reserved_max_card_num = mapper->reserved().byte_size();
82 mapper->set_mapping_changed_listener(&_listener);
83 }
84 }
85
86 uint G1CardCounts::add_card_count(jbyte* card_ptr) {
87 // Returns the number of times the card has been refined.
88 // If we failed to reserve/commit the counts table, return 0.
89 // If card_ptr is beyond the committed end of the counts table,
90 // return 0.
91 // Otherwise return the actual count.
92 // Unless G1ConcRSHotCardLimit has been set appropriately,
93 // returning 0 will result in the card being considered
94 // cold and will be refined immediately.
95 uint count = 0;
96 if (has_count_table()) {
97 size_t card_num = ptr_2_card_num(card_ptr);
98 assert(card_num < _reserved_max_card_num,
99 err_msg("Card " SIZE_FORMAT " outside of card counts table (max size " SIZE_FORMAT ")",
100 card_num, _reserved_max_card_num));
101 count = (uint) _card_counts[card_num];
102 if (count < G1ConcRSHotCardLimit) {
103 _card_counts[card_num] =
104 (jubyte)(MIN2((uintx)(_card_counts[card_num] + 1), G1ConcRSHotCardLimit));
105 }
106 }
107 return count;
108 }
109
110 bool G1CardCounts::is_hot(uint count) {
111 return (count >= G1ConcRSHotCardLimit);
112 }
113
114 void G1CardCounts::clear_region(HeapRegion* hr) {
115 MemRegion mr(hr->bottom(), hr->end());
116 clear_range(mr);
117 }
118
119 void G1CardCounts::clear_range(MemRegion mr) {
120 if (has_count_table()) {
|
36 return;
37 }
38 MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);
39 _counts->clear_range(mr);
40 }
41
42 size_t G1CardCounts::compute_size(size_t mem_region_size_in_words) {
43 // We keep card counts for every card, so the size of the card counts table must
44 // be the same as the card table.
45 return G1SATBCardTableLoggingModRefBS::compute_size(mem_region_size_in_words);
46 }
47
48 size_t G1CardCounts::heap_map_factor() {
49 // See G1CardCounts::compute_size() why we reuse the card table value.
50 return G1SATBCardTableLoggingModRefBS::heap_map_factor();
51 }
52
53 void G1CardCounts::clear_range(size_t from_card_num, size_t to_card_num) {
54 if (has_count_table()) {
55 assert(from_card_num < to_card_num,
56 "Wrong order? from: " SIZE_FORMAT ", to: " SIZE_FORMAT,
57 from_card_num, to_card_num);
58 Copy::fill_to_bytes(&_card_counts[from_card_num], (to_card_num - from_card_num));
59 }
60 }
61
62 G1CardCounts::G1CardCounts(G1CollectedHeap *g1h):
63 _listener(), _g1h(g1h), _card_counts(NULL), _reserved_max_card_num(0) {
64 _listener.set_cardcounts(this);
65 }
66
67 void G1CardCounts::initialize(G1RegionToSpaceMapper* mapper) {
68 assert(_g1h->max_capacity() > 0, "initialization order");
69 assert(_g1h->capacity() == 0, "initialization order");
70
71 if (G1ConcRSHotCardLimit > 0) {
72 // The max value we can store in the counts table is
73 // max_jubyte. Guarantee the value of the hot
74 // threshold limit is no more than this.
75 guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity");
76
77 _ct_bs = _g1h->g1_barrier_set();
79
80 _card_counts = (jubyte*) mapper->reserved().start();
81 _reserved_max_card_num = mapper->reserved().byte_size();
82 mapper->set_mapping_changed_listener(&_listener);
83 }
84 }
85
86 uint G1CardCounts::add_card_count(jbyte* card_ptr) {
87 // Returns the number of times the card has been refined.
88 // If we failed to reserve/commit the counts table, return 0.
89 // If card_ptr is beyond the committed end of the counts table,
90 // return 0.
91 // Otherwise return the actual count.
92 // Unless G1ConcRSHotCardLimit has been set appropriately,
93 // returning 0 will result in the card being considered
94 // cold and will be refined immediately.
95 uint count = 0;
96 if (has_count_table()) {
97 size_t card_num = ptr_2_card_num(card_ptr);
98 assert(card_num < _reserved_max_card_num,
99 "Card " SIZE_FORMAT " outside of card counts table (max size " SIZE_FORMAT ")",
100 card_num, _reserved_max_card_num);
101 count = (uint) _card_counts[card_num];
102 if (count < G1ConcRSHotCardLimit) {
103 _card_counts[card_num] =
104 (jubyte)(MIN2((uintx)(_card_counts[card_num] + 1), G1ConcRSHotCardLimit));
105 }
106 }
107 return count;
108 }
109
110 bool G1CardCounts::is_hot(uint count) {
111 return (count >= G1ConcRSHotCardLimit);
112 }
113
114 void G1CardCounts::clear_region(HeapRegion* hr) {
115 MemRegion mr(hr->bottom(), hr->end());
116 clear_range(mr);
117 }
118
119 void G1CardCounts::clear_range(MemRegion mr) {
120 if (has_count_table()) {
|