1 /* |
1 /* |
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
38 } |
38 } |
39 |
39 |
40 size_t G1CardCounts::compute_size(size_t mem_region_size_in_words) { |
40 size_t G1CardCounts::compute_size(size_t mem_region_size_in_words) { |
41 // We keep card counts for every card, so the size of the card counts table must |
41 // We keep card counts for every card, so the size of the card counts table must |
42 // be the same as the card table. |
42 // be the same as the card table. |
43 return G1SATBCardTableLoggingModRefBS::compute_size(mem_region_size_in_words); |
43 return G1CardTable::compute_size(mem_region_size_in_words); |
44 } |
44 } |
45 |
45 |
46 size_t G1CardCounts::heap_map_factor() { |
46 size_t G1CardCounts::heap_map_factor() { |
47 // See G1CardCounts::compute_size() why we reuse the card table value. |
47 // See G1CardCounts::compute_size() why we reuse the card table value. |
48 return G1SATBCardTableLoggingModRefBS::heap_map_factor(); |
48 return G1CardTable::heap_map_factor(); |
49 } |
49 } |
50 |
50 |
51 void G1CardCounts::clear_range(size_t from_card_num, size_t to_card_num) { |
51 void G1CardCounts::clear_range(size_t from_card_num, size_t to_card_num) { |
52 if (has_count_table()) { |
52 if (has_count_table()) { |
53 assert(from_card_num < to_card_num, |
53 assert(from_card_num < to_card_num, |
70 // The max value we can store in the counts table is |
70 // The max value we can store in the counts table is |
71 // max_jubyte. Guarantee the value of the hot |
71 // max_jubyte. Guarantee the value of the hot |
72 // threshold limit is no more than this. |
72 // threshold limit is no more than this. |
73 guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity"); |
73 guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity"); |
74 |
74 |
75 _ct_bs = _g1h->g1_barrier_set(); |
75 _ct = _g1h->card_table(); |
76 _ct_bot = _ct_bs->byte_for_const(_g1h->reserved_region().start()); |
76 _ct_bot = _ct->byte_for_const(_g1h->reserved_region().start()); |
77 |
77 |
78 _card_counts = (jubyte*) mapper->reserved().start(); |
78 _card_counts = (jubyte*) mapper->reserved().start(); |
79 _reserved_max_card_num = mapper->reserved().byte_size(); |
79 _reserved_max_card_num = mapper->reserved().byte_size(); |
80 mapper->set_mapping_changed_listener(&_listener); |
80 mapper->set_mapping_changed_listener(&_listener); |
81 } |
81 } |
114 clear_range(mr); |
114 clear_range(mr); |
115 } |
115 } |
116 |
116 |
117 void G1CardCounts::clear_range(MemRegion mr) { |
117 void G1CardCounts::clear_range(MemRegion mr) { |
118 if (has_count_table()) { |
118 if (has_count_table()) { |
119 const jbyte* from_card_ptr = _ct_bs->byte_for_const(mr.start()); |
119 const jbyte* from_card_ptr = _ct->byte_for_const(mr.start()); |
120 // We use the last address in the range as the range could represent the |
120 // We use the last address in the range as the range could represent the |
121 // last region in the heap. In which case trying to find the card will be an |
121 // last region in the heap. In which case trying to find the card will be an |
122 // OOB access to the card table. |
122 // OOB access to the card table. |
123 const jbyte* last_card_ptr = _ct_bs->byte_for_const(mr.last()); |
123 const jbyte* last_card_ptr = _ct->byte_for_const(mr.last()); |
124 |
124 |
125 #ifdef ASSERT |
125 #ifdef ASSERT |
126 HeapWord* start_addr = _ct_bs->addr_for(from_card_ptr); |
126 HeapWord* start_addr = _ct->addr_for(from_card_ptr); |
127 assert(start_addr == mr.start(), "MemRegion start must be aligned to a card."); |
127 assert(start_addr == mr.start(), "MemRegion start must be aligned to a card."); |
128 HeapWord* last_addr = _ct_bs->addr_for(last_card_ptr); |
128 HeapWord* last_addr = _ct->addr_for(last_card_ptr); |
129 assert((last_addr + CardTableModRefBS::card_size_in_words) == mr.end(), "MemRegion end must be aligned to a card."); |
129 assert((last_addr + G1CardTable::card_size_in_words) == mr.end(), "MemRegion end must be aligned to a card."); |
130 #endif // ASSERT |
130 #endif // ASSERT |
131 |
131 |
132 // Clear the counts for the (exclusive) card range. |
132 // Clear the counts for the (exclusive) card range. |
133 size_t from_card_num = ptr_2_card_num(from_card_ptr); |
133 size_t from_card_num = ptr_2_card_num(from_card_ptr); |
134 size_t to_card_num = ptr_2_card_num(last_card_ptr) + 1; |
134 size_t to_card_num = ptr_2_card_num(last_card_ptr) + 1; |