author | tschatzl |
Wed, 04 Apr 2018 14:51:26 +0200 | |
changeset 49672 | f1d2b6c0693b |
parent 49632 | 64f9ebc85e67 |
child 49806 | 2d62570a615c |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47789
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
1374 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5346
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5346
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5346
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/g1/g1BlockOffsetTable.inline.hpp" |
27 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
|
47789
a77a7d3bc4f6
8149127: Rename g1/concurrentMarkThread.* to g1/g1ConcurrentMarkThread.*
tschatzl
parents:
47634
diff
changeset
|
28 |
#include "gc/g1/g1ConcurrentRefine.hpp" |
30764 | 29 |
#include "gc/g1/heapRegionManager.inline.hpp" |
30 |
#include "gc/g1/heapRegionRemSet.hpp" |
|
31 |
#include "gc/shared/space.inline.hpp" |
|
7397 | 32 |
#include "memory/allocation.hpp" |
23452
d7dca4e6b95d
8035815: Cache-align and pad the from card cache
tschatzl
parents:
23451
diff
changeset
|
33 |
#include "memory/padded.inline.hpp" |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
34 |
#include "oops/oop.inline.hpp" |
40655
9f644073d3a0
8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents:
38271
diff
changeset
|
35 |
#include "runtime/atomic.hpp" |
7397 | 36 |
#include "utilities/bitMap.inline.hpp" |
46560
388aa8d67c80
8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
43666
diff
changeset
|
37 |
#include "utilities/debug.hpp" |
388aa8d67c80
8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
43666
diff
changeset
|
38 |
#include "utilities/formatBuffer.hpp" |
7397 | 39 |
#include "utilities/globalDefinitions.hpp" |
19339 | 40 |
#include "utilities/growableArray.hpp" |
1374 | 41 |
|
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
42 |
const char* HeapRegionRemSet::_state_strings[] = {"Untracked", "Updating", "Complete"}; |
49672
f1d2b6c0693b
8200305: Update gc,liveness output with remset state after rebuild remset concurrently changes
tschatzl
parents:
49632
diff
changeset
|
43 |
const char* HeapRegionRemSet::_short_state_strings[] = {"UNTRA", "UPDAT", "CMPLT"}; |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
44 |
|
13195 | 45 |
class PerRegionTable: public CHeapObj<mtGC> { |
1374 | 46 |
friend class OtherRegionsTable; |
47 |
friend class HeapRegionRemSetIterator; |
|
48 |
||
49 |
HeapRegion* _hr; |
|
38177 | 50 |
CHeapBitMap _bm; |
1374 | 51 |
jint _occupied; |
52 |
||
13335 | 53 |
// next pointer for free/allocated 'all' list |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
54 |
PerRegionTable* _next; |
1374 | 55 |
|
13335 | 56 |
// prev pointer for the allocated 'all' list |
57 |
PerRegionTable* _prev; |
|
1374 | 58 |
|
13335 | 59 |
// next pointer in collision list |
60 |
PerRegionTable * _collision_list_next; |
|
1374 | 61 |
|
13335 | 62 |
// Global free list of PRTs |
41283
2615c024f3eb
8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents:
40655
diff
changeset
|
63 |
static PerRegionTable* volatile _free_list; |
1374 | 64 |
|
65 |
protected: |
|
66 |
// We need access in order to union things into the base table. |
|
67 |
BitMap* bm() { return &_bm; } |
|
68 |
||
69 |
PerRegionTable(HeapRegion* hr) : |
|
70 |
_hr(hr), |
|
71 |
_occupied(0), |
|
46745
f7b9bb98bb72
8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents:
46560
diff
changeset
|
72 |
_bm(HeapRegion::CardsPerRegion, mtGC), |
13335 | 73 |
_collision_list_next(NULL), _next(NULL), _prev(NULL) |
1374 | 74 |
{} |
75 |
||
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
76 |
void add_card_work(CardIdx_t from_card, bool par) { |
1374 | 77 |
if (!_bm.at(from_card)) { |
78 |
if (par) { |
|
79 |
if (_bm.par_at_put(from_card, 1)) { |
|
80 |
Atomic::inc(&_occupied); |
|
81 |
} |
|
82 |
} else { |
|
83 |
_bm.at_put(from_card, 1); |
|
84 |
_occupied++; |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
89 |
void add_reference_work(OopOrNarrowOopStar from, bool par) { |
1374 | 90 |
// Must make this robust in case "from" is not in "_hr", because of |
91 |
// concurrency. |
|
92 |
||
93 |
HeapRegion* loc_hr = hr(); |
|
94 |
// If the test below fails, then this table was reused concurrently |
|
95 |
// with this operation. This is OK, since the old table was coarsened, |
|
96 |
// and adding a bit to the new table is never incorrect. |
|
33786
ac8da6513351
8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents:
33783
diff
changeset
|
97 |
if (loc_hr->is_in_reserved(from)) { |
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
98 |
CardIdx_t from_card = OtherRegionsTable::card_within_region(from, loc_hr); |
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
99 |
add_card_work(from_card, par); |
1374 | 100 |
} |
101 |
} |
|
102 |
||
103 |
public: |
|
104 |
||
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
105 |
HeapRegion* hr() const { return OrderAccess::load_acquire(&_hr); } |
1374 | 106 |
|
107 |
jint occupied() const { |
|
108 |
// Overkill, but if we ever need it... |
|
109 |
// guarantee(_occupied == _bm.count_one_bits(), "Check"); |
|
110 |
return _occupied; |
|
111 |
} |
|
112 |
||
13335 | 113 |
void init(HeapRegion* hr, bool clear_links_to_all_list) { |
114 |
if (clear_links_to_all_list) { |
|
115 |
set_next(NULL); |
|
116 |
set_prev(NULL); |
|
117 |
} |
|
118 |
_collision_list_next = NULL; |
|
1374 | 119 |
_occupied = 0; |
120 |
_bm.clear(); |
|
35875
8ea0b4b0bcc8
8147087: Race when reusing PerRegionTable bitmaps may result in dropped remembered set entries
tschatzl
parents:
35461
diff
changeset
|
121 |
// Make sure that the bitmap clearing above has been finished before publishing |
8ea0b4b0bcc8
8147087: Race when reusing PerRegionTable bitmaps may result in dropped remembered set entries
tschatzl
parents:
35461
diff
changeset
|
122 |
// this PRT to concurrent threads. |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
123 |
OrderAccess::release_store(&_hr, hr); |
1374 | 124 |
} |
125 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
126 |
void add_reference(OopOrNarrowOopStar from) { |
1374 | 127 |
add_reference_work(from, /*parallel*/ true); |
128 |
} |
|
129 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
130 |
void seq_add_reference(OopOrNarrowOopStar from) { |
1374 | 131 |
add_reference_work(from, /*parallel*/ false); |
132 |
} |
|
133 |
||
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
134 |
void add_card(CardIdx_t from_card_index) { |
1374 | 135 |
add_card_work(from_card_index, /*parallel*/ true); |
136 |
} |
|
137 |
||
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
138 |
void seq_add_card(CardIdx_t from_card_index) { |
1374 | 139 |
add_card_work(from_card_index, /*parallel*/ false); |
140 |
} |
|
141 |
||
142 |
// (Destructively) union the bitmap of the current table into the given |
|
143 |
// bitmap (which is assumed to be of the same size.) |
|
144 |
void union_bitmap_into(BitMap* bm) { |
|
145 |
bm->set_union(_bm); |
|
146 |
} |
|
147 |
||
148 |
// Mem size in bytes. |
|
149 |
size_t mem_size() const { |
|
24108
dfc2242fc6b0
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
24106
diff
changeset
|
150 |
return sizeof(PerRegionTable) + _bm.size_in_words() * HeapWordSize; |
1374 | 151 |
} |
152 |
||
153 |
// Requires "from" to be in "hr()". |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
154 |
bool contains_reference(OopOrNarrowOopStar from) const { |
1374 | 155 |
assert(hr()->is_in_reserved(from), "Precondition."); |
156 |
size_t card_ind = pointer_delta(from, hr()->bottom(), |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
47789
diff
changeset
|
157 |
G1CardTable::card_size); |
1374 | 158 |
return _bm.at(card_ind); |
159 |
} |
|
160 |
||
13335 | 161 |
// Bulk-free the PRTs from prt to last, assumes that they are |
162 |
// linked together using their _next field. |
|
163 |
static void bulk_free(PerRegionTable* prt, PerRegionTable* last) { |
|
1374 | 164 |
while (true) { |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
165 |
PerRegionTable* fl = _free_list; |
13335 | 166 |
last->set_next(fl); |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
167 |
PerRegionTable* res = Atomic::cmpxchg(prt, &_free_list, fl); |
13335 | 168 |
if (res == fl) { |
169 |
return; |
|
170 |
} |
|
1374 | 171 |
} |
172 |
ShouldNotReachHere(); |
|
173 |
} |
|
174 |
||
13335 | 175 |
static void free(PerRegionTable* prt) { |
176 |
bulk_free(prt, prt); |
|
177 |
} |
|
178 |
||
179 |
// Returns an initialized PerRegionTable instance. |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
180 |
static PerRegionTable* alloc(HeapRegion* hr) { |
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
181 |
PerRegionTable* fl = _free_list; |
1374 | 182 |
while (fl != NULL) { |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
183 |
PerRegionTable* nxt = fl->next(); |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
184 |
PerRegionTable* res = Atomic::cmpxchg(nxt, &_free_list, fl); |
1374 | 185 |
if (res == fl) { |
13335 | 186 |
fl->init(hr, true); |
1374 | 187 |
return fl; |
188 |
} else { |
|
189 |
fl = _free_list; |
|
190 |
} |
|
191 |
} |
|
192 |
assert(fl == NULL, "Loop condition."); |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
193 |
return new PerRegionTable(hr); |
1374 | 194 |
} |
195 |
||
13335 | 196 |
PerRegionTable* next() const { return _next; } |
197 |
void set_next(PerRegionTable* next) { _next = next; } |
|
198 |
PerRegionTable* prev() const { return _prev; } |
|
199 |
void set_prev(PerRegionTable* prev) { _prev = prev; } |
|
200 |
||
201 |
// Accessor and Modification routines for the pointer for the |
|
202 |
// singly linked collision list that links the PRTs within the |
|
203 |
// OtherRegionsTable::_fine_grain_regions hash table. |
|
204 |
// |
|
205 |
// It might be useful to also make the collision list doubly linked |
|
206 |
// to avoid iteration over the collisions list during scrubbing/deletion. |
|
207 |
// OTOH there might not be many collisions. |
|
208 |
||
209 |
PerRegionTable* collision_list_next() const { |
|
210 |
return _collision_list_next; |
|
211 |
} |
|
212 |
||
213 |
void set_collision_list_next(PerRegionTable* next) { |
|
214 |
_collision_list_next = next; |
|
215 |
} |
|
216 |
||
217 |
PerRegionTable** collision_list_next_addr() { |
|
218 |
return &_collision_list_next; |
|
219 |
} |
|
220 |
||
1374 | 221 |
static size_t fl_mem_size() { |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
222 |
PerRegionTable* cur = _free_list; |
1374 | 223 |
size_t res = 0; |
224 |
while (cur != NULL) { |
|
17631
17992863b0ab
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
17398
diff
changeset
|
225 |
res += cur->mem_size(); |
1374 | 226 |
cur = cur->next(); |
227 |
} |
|
228 |
return res; |
|
229 |
} |
|
17631
17992863b0ab
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
17398
diff
changeset
|
230 |
|
17992863b0ab
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
17398
diff
changeset
|
231 |
static void test_fl_mem_size(); |
1374 | 232 |
}; |
233 |
||
41283
2615c024f3eb
8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents:
40655
diff
changeset
|
234 |
PerRegionTable* volatile PerRegionTable::_free_list = NULL; |
1374 | 235 |
|
236 |
size_t OtherRegionsTable::_max_fine_entries = 0; |
|
237 |
size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0; |
|
238 |
size_t OtherRegionsTable::_fine_eviction_stride = 0; |
|
239 |
size_t OtherRegionsTable::_fine_eviction_sample_size = 0; |
|
240 |
||
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
241 |
OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) : |
1374 | 242 |
_g1h(G1CollectedHeap::heap()), |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
243 |
_hr(hr), _m(m), |
46745
f7b9bb98bb72
8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents:
46560
diff
changeset
|
244 |
_coarse_map(G1CollectedHeap::heap()->max_regions(), mtGC), |
1374 | 245 |
_fine_grain_regions(NULL), |
13335 | 246 |
_first_all_fine_prts(NULL), _last_all_fine_prts(NULL), |
1374 | 247 |
_n_fine_entries(0), _n_coarse_entries(0), |
248 |
_fine_eviction_start(0), |
|
38161
1c7dd1e39fcf
8155811: Remove HeapRegionRemSet::_coarse_dirty flag
tschatzl
parents:
38156
diff
changeset
|
249 |
_sparse_table(hr) |
1374 | 250 |
{ |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
251 |
typedef PerRegionTable* PerRegionTablePtr; |
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
252 |
|
1374 | 253 |
if (_max_fine_entries == 0) { |
254 |
assert(_mod_max_fine_entries_mask == 0, "Both or none."); |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
255 |
size_t max_entries_log = (size_t)log2_long((jlong)G1RSetRegionEntries); |
13752
92f03fcf979a
7197906: BlockOffsetArray::power_to_cards_back() needs to handle > 32 bit shifts
brutisso
parents:
13335
diff
changeset
|
256 |
_max_fine_entries = (size_t)1 << max_entries_log; |
1374 | 257 |
_mod_max_fine_entries_mask = _max_fine_entries - 1; |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
258 |
|
1374 | 259 |
assert(_fine_eviction_sample_size == 0 |
260 |
&& _fine_eviction_stride == 0, "All init at same time."); |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
261 |
_fine_eviction_sample_size = MAX2((size_t)4, max_entries_log); |
1374 | 262 |
_fine_eviction_stride = _max_fine_entries / _fine_eviction_sample_size; |
263 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
264 |
|
17376
4ee999c3c007
8012902: remove use of global operator new - take 2
minqi
parents:
17119
diff
changeset
|
265 |
_fine_grain_regions = NEW_C_HEAP_ARRAY3(PerRegionTablePtr, _max_fine_entries, |
25946 | 266 |
mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL); |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
267 |
|
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
268 |
if (_fine_grain_regions == NULL) { |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
17031
diff
changeset
|
269 |
vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, OOM_MALLOC_ERROR, |
1374 | 270 |
"Failed to allocate _fine_grain_entries."); |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
271 |
} |
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
272 |
|
1374 | 273 |
for (size_t i = 0; i < _max_fine_entries; i++) { |
274 |
_fine_grain_regions[i] = NULL; |
|
275 |
} |
|
276 |
} |
|
277 |
||
13335 | 278 |
void OtherRegionsTable::link_to_all(PerRegionTable* prt) { |
279 |
// We always append to the beginning of the list for convenience; |
|
280 |
// the order of entries in this list does not matter. |
|
281 |
if (_first_all_fine_prts != NULL) { |
|
282 |
assert(_first_all_fine_prts->prev() == NULL, "invariant"); |
|
283 |
_first_all_fine_prts->set_prev(prt); |
|
284 |
prt->set_next(_first_all_fine_prts); |
|
285 |
} else { |
|
286 |
// this is the first element we insert. Adjust the "last" pointer |
|
287 |
_last_all_fine_prts = prt; |
|
288 |
assert(prt->next() == NULL, "just checking"); |
|
289 |
} |
|
290 |
// the new element is always the first element without a predecessor |
|
291 |
prt->set_prev(NULL); |
|
292 |
_first_all_fine_prts = prt; |
|
293 |
||
294 |
assert(prt->prev() == NULL, "just checking"); |
|
295 |
assert(_first_all_fine_prts == prt, "just checking"); |
|
296 |
assert((_first_all_fine_prts == NULL && _last_all_fine_prts == NULL) || |
|
297 |
(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL), |
|
298 |
"just checking"); |
|
299 |
assert(_last_all_fine_prts == NULL || _last_all_fine_prts->next() == NULL, |
|
300 |
"just checking"); |
|
301 |
assert(_first_all_fine_prts == NULL || _first_all_fine_prts->prev() == NULL, |
|
302 |
"just checking"); |
|
303 |
} |
|
304 |
||
305 |
void OtherRegionsTable::unlink_from_all(PerRegionTable* prt) { |
|
306 |
if (prt->prev() != NULL) { |
|
307 |
assert(_first_all_fine_prts != prt, "just checking"); |
|
308 |
prt->prev()->set_next(prt->next()); |
|
309 |
// removing the last element in the list? |
|
310 |
if (_last_all_fine_prts == prt) { |
|
311 |
_last_all_fine_prts = prt->prev(); |
|
312 |
} |
|
313 |
} else { |
|
314 |
assert(_first_all_fine_prts == prt, "just checking"); |
|
315 |
_first_all_fine_prts = prt->next(); |
|
316 |
// list is empty now? |
|
317 |
if (_first_all_fine_prts == NULL) { |
|
318 |
_last_all_fine_prts = NULL; |
|
319 |
} |
|
320 |
} |
|
321 |
||
322 |
if (prt->next() != NULL) { |
|
323 |
prt->next()->set_prev(prt->prev()); |
|
324 |
} |
|
325 |
||
326 |
prt->set_next(NULL); |
|
327 |
prt->set_prev(NULL); |
|
328 |
||
329 |
assert((_first_all_fine_prts == NULL && _last_all_fine_prts == NULL) || |
|
330 |
(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL), |
|
331 |
"just checking"); |
|
332 |
assert(_last_all_fine_prts == NULL || _last_all_fine_prts->next() == NULL, |
|
333 |
"just checking"); |
|
334 |
assert(_first_all_fine_prts == NULL || _first_all_fine_prts->prev() == NULL, |
|
335 |
"just checking"); |
|
336 |
} |
|
337 |
||
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
338 |
CardIdx_t OtherRegionsTable::card_within_region(OopOrNarrowOopStar within_region, HeapRegion* hr) { |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
339 |
assert(hr->is_in_reserved(within_region), |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
340 |
"HeapWord " PTR_FORMAT " is outside of region %u [" PTR_FORMAT ", " PTR_FORMAT ")", |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
341 |
p2i(within_region), hr->hrm_index(), p2i(hr->bottom()), p2i(hr->end())); |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
342 |
CardIdx_t result = (CardIdx_t)(pointer_delta((HeapWord*)within_region, hr->bottom()) >> (CardTable::card_shift - LogHeapWordSize)); |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
343 |
return result; |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
344 |
} |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
345 |
|
26850
515ff48cf5f0
8036116: Fix thread-id types in G1 remembered set implementations
brutisso
parents:
26424
diff
changeset
|
346 |
void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, uint tid) { |
28030 | 347 |
uint cur_hrm_ind = _hr->hrm_index(); |
1374 | 348 |
|
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
349 |
uintptr_t from_card = uintptr_t(from) >> CardTable::card_shift; |
1374 | 350 |
|
35200
7802299b31e7
8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents:
35199
diff
changeset
|
351 |
if (G1FromCardCache::contains_or_replace(tid, cur_hrm_ind, from_card)) { |
35875
8ea0b4b0bcc8
8147087: Race when reusing PerRegionTable bitmaps may result in dropped remembered set entries
tschatzl
parents:
35461
diff
changeset
|
352 |
assert(contains_reference(from), "We just found " PTR_FORMAT " in the FromCardCache", p2i(from)); |
1374 | 353 |
return; |
354 |
} |
|
355 |
||
356 |
// Note that this may be a continued H region. |
|
33786
ac8da6513351
8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents:
33783
diff
changeset
|
357 |
HeapRegion* from_hr = _g1h->heap_region_containing(from); |
26424
639e661f19f3
8057143: Incomplete renaming of variables containing "hrs" to "hrm" related to HeapRegionSeq
tschatzl
parents:
26422
diff
changeset
|
358 |
RegionIdx_t from_hrm_ind = (RegionIdx_t) from_hr->hrm_index(); |
1374 | 359 |
|
360 |
// If the region is already coarsened, return. |
|
26424
639e661f19f3
8057143: Incomplete renaming of variables containing "hrs" to "hrm" related to HeapRegionSeq
tschatzl
parents:
26422
diff
changeset
|
361 |
if (_coarse_map.at(from_hrm_ind)) { |
35875
8ea0b4b0bcc8
8147087: Race when reusing PerRegionTable bitmaps may result in dropped remembered set entries
tschatzl
parents:
35461
diff
changeset
|
362 |
assert(contains_reference(from), "We just found " PTR_FORMAT " in the Coarse table", p2i(from)); |
1374 | 363 |
return; |
364 |
} |
|
365 |
||
366 |
// Otherwise find a per-region table to add it to. |
|
26424
639e661f19f3
8057143: Incomplete renaming of variables containing "hrs" to "hrm" related to HeapRegionSeq
tschatzl
parents:
26422
diff
changeset
|
367 |
size_t ind = from_hrm_ind & _mod_max_fine_entries_mask; |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
368 |
PerRegionTable* prt = find_region_table(ind, from_hr); |
1374 | 369 |
if (prt == NULL) { |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
370 |
MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); |
1374 | 371 |
// Confirm that it's really not there... |
372 |
prt = find_region_table(ind, from_hr); |
|
373 |
if (prt == NULL) { |
|
374 |
||
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
375 |
CardIdx_t card_index = card_within_region(from, from_hr); |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
376 |
|
1374 | 377 |
if (G1HRRSUseSparseTable && |
26424
639e661f19f3
8057143: Incomplete renaming of variables containing "hrs" to "hrm" related to HeapRegionSeq
tschatzl
parents:
26422
diff
changeset
|
378 |
_sparse_table.add_card(from_hrm_ind, card_index)) { |
35875
8ea0b4b0bcc8
8147087: Race when reusing PerRegionTable bitmaps may result in dropped remembered set entries
tschatzl
parents:
35461
diff
changeset
|
379 |
assert(contains_reference_locked(from), "We just added " PTR_FORMAT " to the Sparse table", p2i(from)); |
1374 | 380 |
return; |
381 |
} |
|
382 |
||
383 |
if (_n_fine_entries == _max_fine_entries) { |
|
384 |
prt = delete_region_table(); |
|
13335 | 385 |
// There is no need to clear the links to the 'all' list here: |
386 |
// prt will be reused immediately, i.e. remain in the 'all' list. |
|
387 |
prt->init(from_hr, false /* clear_links_to_all_list */); |
|
1374 | 388 |
} else { |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
389 |
prt = PerRegionTable::alloc(from_hr); |
13335 | 390 |
link_to_all(prt); |
1374 | 391 |
} |
392 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
393 |
PerRegionTable* first_prt = _fine_grain_regions[ind]; |
13335 | 394 |
prt->set_collision_list_next(first_prt); |
30765
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
395 |
// The assignment into _fine_grain_regions allows the prt to |
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
396 |
// start being used concurrently. In addition to |
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
397 |
// collision_list_next which must be visible (else concurrent |
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
398 |
// parsing of the list, if any, may fail to see other entries), |
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
399 |
// the content of the prt must be visible (else for instance |
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
400 |
// some mark bits may not yet seem cleared or a 'later' update |
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
401 |
// performed by a concurrent thread could be undone when the |
32398da8ba8f
8035496: G1 ARM: missing remset entry noticed by VerifyAfterGC for vm/gc/concurrent/lp50yp10rp70mr30st0
bdelsart
parents:
30764
diff
changeset
|
402 |
// zeroing becomes visible). This requires store ordering. |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
403 |
OrderAccess::release_store(&_fine_grain_regions[ind], prt); |
1374 | 404 |
_n_fine_entries++; |
405 |
||
406 |
if (G1HRRSUseSparseTable) { |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
407 |
// Transfer from sparse to fine-grain. |
26424
639e661f19f3
8057143: Incomplete renaming of variables containing "hrs" to "hrm" related to HeapRegionSeq
tschatzl
parents:
26422
diff
changeset
|
408 |
SparsePRTEntry *sprt_entry = _sparse_table.get_entry(from_hrm_ind); |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
409 |
assert(sprt_entry != NULL, "There should have been an entry"); |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38177
diff
changeset
|
410 |
for (int i = 0; i < sprt_entry->num_valid_cards(); i++) { |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
411 |
CardIdx_t c = sprt_entry->card(i); |
38271
4425ba8ed50f
8047328: Improve memory usage for cards in SparsePRTEntry
tschatzl
parents:
38177
diff
changeset
|
412 |
prt->add_card(c); |
1374 | 413 |
} |
414 |
// Now we can delete the sparse entry. |
|
26424
639e661f19f3
8057143: Incomplete renaming of variables containing "hrs" to "hrm" related to HeapRegionSeq
tschatzl
parents:
26422
diff
changeset
|
415 |
bool res = _sparse_table.delete_entry(from_hrm_ind); |
1374 | 416 |
assert(res, "It should have been there."); |
417 |
} |
|
418 |
} |
|
419 |
assert(prt != NULL && prt->hr() == from_hr, "consequence"); |
|
420 |
} |
|
421 |
// Note that we can't assert "prt->hr() == from_hr", because of the |
|
422 |
// possibility of concurrent reuse. But see head comment of |
|
423 |
// OtherRegionsTable for why this is OK. |
|
424 |
assert(prt != NULL, "Inv"); |
|
425 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
426 |
prt->add_reference(from); |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
427 |
assert(contains_reference(from), "We just added " PTR_FORMAT " to the PRT (%d)", p2i(from), prt->contains_reference(from)); |
1374 | 428 |
} |
429 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
430 |
PerRegionTable* |
1374 | 431 |
OtherRegionsTable::find_region_table(size_t ind, HeapRegion* hr) const { |
29580
a67a581cfe11
8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents:
28379
diff
changeset
|
432 |
assert(ind < _max_fine_entries, "Preconditions."); |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
433 |
PerRegionTable* prt = _fine_grain_regions[ind]; |
1374 | 434 |
while (prt != NULL && prt->hr() != hr) { |
13335 | 435 |
prt = prt->collision_list_next(); |
1374 | 436 |
} |
437 |
// Loop postcondition is the method postcondition. |
|
438 |
return prt; |
|
439 |
} |
|
440 |
||
441 |
jint OtherRegionsTable::_n_coarsenings = 0; |
|
442 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
443 |
PerRegionTable* OtherRegionsTable::delete_region_table() { |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
444 |
assert(_m->owned_by_self(), "Precondition"); |
1374 | 445 |
assert(_n_fine_entries == _max_fine_entries, "Precondition"); |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
446 |
PerRegionTable* max = NULL; |
1374 | 447 |
jint max_occ = 0; |
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
33105
diff
changeset
|
448 |
PerRegionTable** max_prev = NULL; |
1374 | 449 |
size_t max_ind; |
450 |
||
451 |
size_t i = _fine_eviction_start; |
|
452 |
for (size_t k = 0; k < _fine_eviction_sample_size; k++) { |
|
453 |
size_t ii = i; |
|
454 |
// Make sure we get a non-NULL sample. |
|
455 |
while (_fine_grain_regions[ii] == NULL) { |
|
456 |
ii++; |
|
457 |
if (ii == _max_fine_entries) ii = 0; |
|
458 |
guarantee(ii != i, "We must find one."); |
|
459 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
460 |
PerRegionTable** prev = &_fine_grain_regions[ii]; |
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
461 |
PerRegionTable* cur = *prev; |
1374 | 462 |
while (cur != NULL) { |
463 |
jint cur_occ = cur->occupied(); |
|
464 |
if (max == NULL || cur_occ > max_occ) { |
|
465 |
max = cur; |
|
466 |
max_prev = prev; |
|
467 |
max_ind = i; |
|
468 |
max_occ = cur_occ; |
|
469 |
} |
|
13335 | 470 |
prev = cur->collision_list_next_addr(); |
471 |
cur = cur->collision_list_next(); |
|
1374 | 472 |
} |
473 |
i = i + _fine_eviction_stride; |
|
474 |
if (i >= _n_fine_entries) i = i - _n_fine_entries; |
|
475 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
476 |
|
1374 | 477 |
_fine_eviction_start++; |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
478 |
|
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
479 |
if (_fine_eviction_start >= _n_fine_entries) { |
1374 | 480 |
_fine_eviction_start -= _n_fine_entries; |
481 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
482 |
|
1374 | 483 |
guarantee(max != NULL, "Since _n_fine_entries > 0"); |
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
33105
diff
changeset
|
484 |
guarantee(max_prev != NULL, "Since max != NULL."); |
1374 | 485 |
|
486 |
// Set the corresponding coarse bit. |
|
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
487 |
size_t max_hrm_index = (size_t) max->hr()->hrm_index(); |
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
488 |
if (!_coarse_map.at(max_hrm_index)) { |
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
489 |
_coarse_map.at_put(max_hrm_index, true); |
1374 | 490 |
_n_coarse_entries++; |
491 |
} |
|
492 |
||
493 |
// Unsplice. |
|
13335 | 494 |
*max_prev = max->collision_list_next(); |
1374 | 495 |
Atomic::inc(&_n_coarsenings); |
496 |
_n_fine_entries--; |
|
497 |
return max; |
|
498 |
} |
|
499 |
||
28379
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
500 |
bool OtherRegionsTable::occupancy_less_or_equal_than(size_t limit) const { |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
501 |
if (limit <= (size_t)G1RSetSparseRegionEntries) { |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
502 |
return occ_coarse() == 0 && _first_all_fine_prts == NULL && occ_sparse() <= limit; |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
503 |
} else { |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
504 |
// Current uses of this method may only use values less than G1RSetSparseRegionEntries |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
505 |
// for the limit. The solution, comparing against occupied() would be too slow |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
506 |
// at this time. |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
507 |
Unimplemented(); |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
508 |
return false; |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
509 |
} |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
510 |
} |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
511 |
|
25889
221296ac4359
8027959: Early reclamation of large objects in G1
tschatzl
parents:
25492
diff
changeset
|
512 |
bool OtherRegionsTable::is_empty() const { |
221296ac4359
8027959: Early reclamation of large objects in G1
tschatzl
parents:
25492
diff
changeset
|
513 |
return occ_sparse() == 0 && occ_coarse() == 0 && _first_all_fine_prts == NULL; |
221296ac4359
8027959: Early reclamation of large objects in G1
tschatzl
parents:
25492
diff
changeset
|
514 |
} |
1374 | 515 |
|
516 |
size_t OtherRegionsTable::occupied() const { |
|
517 |
size_t sum = occ_fine(); |
|
518 |
sum += occ_sparse(); |
|
519 |
sum += occ_coarse(); |
|
520 |
return sum; |
|
521 |
} |
|
522 |
||
523 |
size_t OtherRegionsTable::occ_fine() const { |
|
524 |
size_t sum = 0; |
|
13335 | 525 |
|
526 |
size_t num = 0; |
|
527 |
PerRegionTable * cur = _first_all_fine_prts; |
|
528 |
while (cur != NULL) { |
|
529 |
sum += cur->occupied(); |
|
530 |
cur = cur->next(); |
|
531 |
num++; |
|
1374 | 532 |
} |
13335 | 533 |
guarantee(num == _n_fine_entries, "just checking"); |
1374 | 534 |
return sum; |
535 |
} |
|
536 |
||
537 |
size_t OtherRegionsTable::occ_coarse() const { |
|
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3262
diff
changeset
|
538 |
return (_n_coarse_entries * HeapRegion::CardsPerRegion); |
1374 | 539 |
} |
540 |
||
541 |
size_t OtherRegionsTable::occ_sparse() const { |
|
542 |
return _sparse_table.occupied(); |
|
543 |
} |
|
544 |
||
545 |
size_t OtherRegionsTable::mem_size() const { |
|
546 |
size_t sum = 0; |
|
17395
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
547 |
// all PRTs are of the same size so it is sufficient to query only one of them. |
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
548 |
if (_first_all_fine_prts != NULL) { |
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
549 |
assert(_last_all_fine_prts != NULL && |
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
550 |
_first_all_fine_prts->mem_size() == _last_all_fine_prts->mem_size(), "check that mem_size() is constant"); |
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
551 |
sum += _first_all_fine_prts->mem_size() * _n_fine_entries; |
1374 | 552 |
} |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
553 |
sum += (sizeof(PerRegionTable*) * _max_fine_entries); |
1374 | 554 |
sum += (_coarse_map.size_in_words() * HeapWordSize); |
555 |
sum += (_sparse_table.mem_size()); |
|
24108
dfc2242fc6b0
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
24106
diff
changeset
|
556 |
sum += sizeof(OtherRegionsTable) - sizeof(_sparse_table); // Avoid double counting above. |
1374 | 557 |
return sum; |
558 |
} |
|
559 |
||
560 |
size_t OtherRegionsTable::static_mem_size() { |
|
35200
7802299b31e7
8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents:
35199
diff
changeset
|
561 |
return G1FromCardCache::static_mem_size(); |
1374 | 562 |
} |
563 |
||
564 |
size_t OtherRegionsTable::fl_mem_size() { |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
565 |
return PerRegionTable::fl_mem_size(); |
1374 | 566 |
} |
567 |
||
568 |
void OtherRegionsTable::clear_fcc() { |
|
35200
7802299b31e7
8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents:
35199
diff
changeset
|
569 |
G1FromCardCache::clear(_hr->hrm_index()); |
1374 | 570 |
} |
571 |
||
572 |
void OtherRegionsTable::clear() { |
|
13335 | 573 |
// if there are no entries, skip this step |
574 |
if (_first_all_fine_prts != NULL) { |
|
575 |
guarantee(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL, "just checking"); |
|
576 |
PerRegionTable::bulk_free(_first_all_fine_prts, _last_all_fine_prts); |
|
577 |
memset(_fine_grain_regions, 0, _max_fine_entries * sizeof(_fine_grain_regions[0])); |
|
578 |
} else { |
|
579 |
guarantee(_first_all_fine_prts == NULL && _last_all_fine_prts == NULL, "just checking"); |
|
1374 | 580 |
} |
13335 | 581 |
|
582 |
_first_all_fine_prts = _last_all_fine_prts = NULL; |
|
1374 | 583 |
_sparse_table.clear(); |
38161
1c7dd1e39fcf
8155811: Remove HeapRegionRemSet::_coarse_dirty flag
tschatzl
parents:
38156
diff
changeset
|
584 |
if (_n_coarse_entries > 0) { |
38156 | 585 |
_coarse_map.clear(); |
586 |
} |
|
1374 | 587 |
_n_fine_entries = 0; |
588 |
_n_coarse_entries = 0; |
|
589 |
||
590 |
clear_fcc(); |
|
591 |
} |
|
592 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
593 |
bool OtherRegionsTable::contains_reference(OopOrNarrowOopStar from) const { |
1374 | 594 |
// Cast away const in this case. |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
595 |
MutexLockerEx x((Mutex*)_m, Mutex::_no_safepoint_check_flag); |
1374 | 596 |
return contains_reference_locked(from); |
597 |
} |
|
598 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
599 |
bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const { |
33786
ac8da6513351
8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents:
33783
diff
changeset
|
600 |
HeapRegion* hr = _g1h->heap_region_containing(from); |
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
601 |
RegionIdx_t hr_ind = (RegionIdx_t) hr->hrm_index(); |
1374 | 602 |
// Is this region in the coarse map? |
603 |
if (_coarse_map.at(hr_ind)) return true; |
|
604 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
605 |
PerRegionTable* prt = find_region_table(hr_ind & _mod_max_fine_entries_mask, |
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
606 |
hr); |
1374 | 607 |
if (prt != NULL) { |
608 |
return prt->contains_reference(from); |
|
609 |
||
610 |
} else { |
|
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
611 |
CardIdx_t card_index = card_within_region(from, hr); |
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
612 |
return _sparse_table.contains_card(hr_ind, card_index); |
1374 | 613 |
} |
614 |
} |
|
615 |
||
8072 | 616 |
void |
617 |
OtherRegionsTable::do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task) { |
|
618 |
_sparse_table.do_cleanup_work(hrrs_cleanup_task); |
|
619 |
} |
|
620 |
||
35461 | 621 |
HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetTable* bot, |
1374 | 622 |
HeapRegion* hr) |
35461 | 623 |
: _bot(bot), |
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
26850
diff
changeset
|
624 |
_m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never), |
37988
bf4018edea5e
8153503: Move remset scan iteration claim to remset local data structure
tschatzl
parents:
37414
diff
changeset
|
625 |
_code_roots(), |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
626 |
_state(Untracked), |
37988
bf4018edea5e
8153503: Move remset scan iteration claim to remset local data structure
tschatzl
parents:
37414
diff
changeset
|
627 |
_other_regions(hr, &_m) { |
10000
5bbb58b0dbb9
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
9989
diff
changeset
|
628 |
} |
1374 | 629 |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
630 |
void HeapRegionRemSet::setup_remset_size() { |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
631 |
// Setup sparse and fine-grain tables sizes. |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
632 |
// table_size = base * (log(region_size / 1M) + 1) |
12779
06778de5193e
7171936: LOG_G incorrectly defined in globalDefinitions.hpp
brutisso
parents:
12381
diff
changeset
|
633 |
const int LOG_M = 20; |
06778de5193e
7171936: LOG_G incorrectly defined in globalDefinitions.hpp
brutisso
parents:
12381
diff
changeset
|
634 |
int region_size_log_mb = MAX2(HeapRegion::LogOfHRGrainBytes - LOG_M, 0); |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
635 |
if (FLAG_IS_DEFAULT(G1RSetSparseRegionEntries)) { |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
636 |
G1RSetSparseRegionEntries = G1RSetSparseRegionEntriesBase * (region_size_log_mb + 1); |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
637 |
} |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
638 |
if (FLAG_IS_DEFAULT(G1RSetRegionEntries)) { |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
639 |
G1RSetRegionEntries = G1RSetRegionEntriesBase * (region_size_log_mb + 1); |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
640 |
} |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
641 |
guarantee(G1RSetSparseRegionEntries > 0 && G1RSetRegionEntries > 0 , "Sanity"); |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
642 |
} |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
643 |
|
1374 | 644 |
void HeapRegionRemSet::cleanup() { |
645 |
SparsePRT::cleanup_all(); |
|
646 |
} |
|
647 |
||
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
648 |
void HeapRegionRemSet::clear(bool only_cardset) { |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
649 |
MutexLockerEx x(&_m, Mutex::_no_safepoint_check_flag); |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
650 |
clear_locked(only_cardset); |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
651 |
} |
19339 | 652 |
|
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
653 |
void HeapRegionRemSet::clear_locked(bool only_cardset) { |
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
654 |
if (!only_cardset) { |
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
655 |
_code_roots.clear(); |
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
656 |
} |
1374 | 657 |
_other_regions.clear(); |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
658 |
set_state_empty(); |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
659 |
assert(occupied_locked() == 0, "Should be clear."); |
1374 | 660 |
} |
661 |
||
19339 | 662 |
// Code roots support |
26422 | 663 |
// |
664 |
// The code root set is protected by two separate locking schemes |
|
665 |
// When at safepoint the per-hrrs lock must be held during modifications |
|
666 |
// except when doing a full gc. |
|
667 |
// When not at safepoint the CodeCache_lock must be held during modifications. |
|
668 |
// When concurrent readers access the contains() function |
|
669 |
// (during the evacuation phase) no removals are allowed. |
|
19339 | 670 |
|
671 |
void HeapRegionRemSet::add_strong_code_root(nmethod* nm) { |
|
672 |
assert(nm != NULL, "sanity"); |
|
35879 | 673 |
assert((!CodeCache_lock->owned_by_self() || SafepointSynchronize::is_at_safepoint()), |
674 |
"should call add_strong_code_root_locked instead. CodeCache_lock->owned_by_self(): %s, is_at_safepoint(): %s", |
|
675 |
BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint())); |
|
26422 | 676 |
// Optimistic unlocked contains-check |
677 |
if (!_code_roots.contains(nm)) { |
|
678 |
MutexLockerEx ml(&_m, Mutex::_no_safepoint_check_flag); |
|
679 |
add_strong_code_root_locked(nm); |
|
680 |
} |
|
681 |
} |
|
682 |
||
683 |
void HeapRegionRemSet::add_strong_code_root_locked(nmethod* nm) { |
|
684 |
assert(nm != NULL, "sanity"); |
|
35879 | 685 |
assert((CodeCache_lock->owned_by_self() || |
686 |
(SafepointSynchronize::is_at_safepoint() && |
|
687 |
(_m.owned_by_self() || Thread::current()->is_VM_thread()))), |
|
688 |
"not safely locked. CodeCache_lock->owned_by_self(): %s, is_at_safepoint(): %s, _m.owned_by_self(): %s, Thread::current()->is_VM_thread(): %s", |
|
689 |
BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()), |
|
690 |
BOOL_TO_STR(_m.owned_by_self()), BOOL_TO_STR(Thread::current()->is_VM_thread())); |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
691 |
_code_roots.add(nm); |
19339 | 692 |
} |
693 |
||
694 |
void HeapRegionRemSet::remove_strong_code_root(nmethod* nm) { |
|
695 |
assert(nm != NULL, "sanity"); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
696 |
assert_locked_or_safepoint(CodeCache_lock); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
697 |
|
26422 | 698 |
MutexLockerEx ml(CodeCache_lock->owned_by_self() ? NULL : &_m, Mutex::_no_safepoint_check_flag); |
699 |
_code_roots.remove(nm); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
700 |
|
19339 | 701 |
// Check that there were no duplicates |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
702 |
guarantee(!_code_roots.contains(nm), "duplicate entry found"); |
19339 | 703 |
} |
704 |
||
26422 | 705 |
void HeapRegionRemSet::strong_code_roots_do(CodeBlobClosure* blk) const { |
706 |
_code_roots.nmethods_do(blk); |
|
19339 | 707 |
} |
708 |
||
26422 | 709 |
void HeapRegionRemSet::clean_strong_code_roots(HeapRegion* hr) { |
710 |
_code_roots.clean(hr); |
|
19339 | 711 |
} |
712 |
||
713 |
size_t HeapRegionRemSet::strong_code_roots_mem_size() { |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
714 |
return _code_roots.mem_size(); |
19339 | 715 |
} |
716 |
||
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
717 |
HeapRegionRemSetIterator:: HeapRegionRemSetIterator(HeapRegionRemSet* hrrs) : |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
718 |
_hrrs(hrrs), |
1374 | 719 |
_g1h(G1CollectedHeap::heap()), |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
720 |
_coarse_map(&hrrs->_other_regions._coarse_map), |
35461 | 721 |
_bot(hrrs->_bot), |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
722 |
_is(Sparse), |
1374 | 723 |
// Set these values so that we increment to the first region. |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
724 |
_coarse_cur_region_index(-1), |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
725 |
_coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1), |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
726 |
_cur_card_in_prt(HeapRegion::CardsPerRegion), |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
727 |
_fine_cur_prt(NULL), |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
728 |
_n_yielded_coarse(0), |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
729 |
_n_yielded_fine(0), |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
730 |
_n_yielded_sparse(0), |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
731 |
_sparse_iter(&hrrs->_other_regions._sparse_table) {} |
1374 | 732 |
|
733 |
bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) { |
|
734 |
if (_hrrs->_other_regions._n_coarse_entries == 0) return false; |
|
735 |
// Go to the next card. |
|
736 |
_coarse_cur_region_cur_card++; |
|
737 |
// Was the last the last card in the current region? |
|
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3262
diff
changeset
|
738 |
if (_coarse_cur_region_cur_card == HeapRegion::CardsPerRegion) { |
1374 | 739 |
// Yes: find the next region. This may leave _coarse_cur_region_index |
740 |
// Set to the last index, in which case there are no more coarse |
|
741 |
// regions. |
|
742 |
_coarse_cur_region_index = |
|
743 |
(int) _coarse_map->get_next_one_offset(_coarse_cur_region_index + 1); |
|
744 |
if ((size_t)_coarse_cur_region_index < _coarse_map->size()) { |
|
745 |
_coarse_cur_region_cur_card = 0; |
|
746 |
HeapWord* r_bot = |
|
12381
1438e0fbfa27
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
10767
diff
changeset
|
747 |
_g1h->region_at((uint) _coarse_cur_region_index)->bottom(); |
35461 | 748 |
_cur_region_card_offset = _bot->index_for(r_bot); |
1374 | 749 |
} else { |
750 |
return false; |
|
751 |
} |
|
752 |
} |
|
753 |
// If we didn't return false above, then we can yield a card. |
|
754 |
card_index = _cur_region_card_offset + _coarse_cur_region_cur_card; |
|
755 |
return true; |
|
756 |
} |
|
757 |
||
758 |
bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) { |
|
759 |
if (fine_has_next()) { |
|
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
760 |
_cur_card_in_prt = |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
761 |
_fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1); |
1374 | 762 |
} |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
763 |
if (_cur_card_in_prt == HeapRegion::CardsPerRegion) { |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
764 |
// _fine_cur_prt may still be NULL in case if there are not PRTs at all for |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
765 |
// the remembered set. |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
766 |
if (_fine_cur_prt == NULL || _fine_cur_prt->next() == NULL) { |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
767 |
return false; |
1374 | 768 |
} |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
769 |
PerRegionTable* next_prt = _fine_cur_prt->next(); |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
770 |
switch_to_prt(next_prt); |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
771 |
_cur_card_in_prt = _fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1); |
1374 | 772 |
} |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
773 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
774 |
card_index = _cur_region_card_offset + _cur_card_in_prt; |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
775 |
guarantee(_cur_card_in_prt < HeapRegion::CardsPerRegion, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
776 |
"Card index " SIZE_FORMAT " must be within the region", _cur_card_in_prt); |
1374 | 777 |
return true; |
778 |
} |
|
779 |
||
780 |
bool HeapRegionRemSetIterator::fine_has_next() { |
|
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
781 |
return _cur_card_in_prt != HeapRegion::CardsPerRegion; |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
782 |
} |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
783 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
784 |
void HeapRegionRemSetIterator::switch_to_prt(PerRegionTable* prt) { |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
785 |
assert(prt != NULL, "Cannot switch to NULL prt"); |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
786 |
_fine_cur_prt = prt; |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
787 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
788 |
HeapWord* r_bot = _fine_cur_prt->hr()->bottom(); |
35461 | 789 |
_cur_region_card_offset = _bot->index_for(r_bot); |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
790 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
791 |
// The bitmap scan for the PRT always scans from _cur_region_cur_card + 1. |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
792 |
// To avoid special-casing this start case, and not miss the first bitmap |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
793 |
// entry, initialize _cur_region_cur_card with -1 instead of 0. |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
794 |
_cur_card_in_prt = (size_t)-1; |
1374 | 795 |
} |
796 |
||
797 |
bool HeapRegionRemSetIterator::has_next(size_t& card_index) { |
|
798 |
switch (_is) { |
|
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
799 |
case Sparse: { |
1374 | 800 |
if (_sparse_iter.has_next(card_index)) { |
801 |
_n_yielded_sparse++; |
|
802 |
return true; |
|
803 |
} |
|
804 |
// Otherwise, deliberate fall-through |
|
805 |
_is = Fine; |
|
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
806 |
PerRegionTable* initial_fine_prt = _hrrs->_other_regions._first_all_fine_prts; |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
807 |
if (initial_fine_prt != NULL) { |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
808 |
switch_to_prt(_hrrs->_other_regions._first_all_fine_prts); |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
809 |
} |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
810 |
} |
1374 | 811 |
case Fine: |
812 |
if (fine_has_next(card_index)) { |
|
813 |
_n_yielded_fine++; |
|
814 |
return true; |
|
815 |
} |
|
816 |
// Otherwise, deliberate fall-through |
|
817 |
_is = Coarse; |
|
818 |
case Coarse: |
|
819 |
if (coarse_has_next(card_index)) { |
|
820 |
_n_yielded_coarse++; |
|
821 |
return true; |
|
822 |
} |
|
823 |
// Otherwise... |
|
824 |
break; |
|
825 |
} |
|
826 |
return false; |
|
827 |
} |
|
828 |
||
8072 | 829 |
void HeapRegionRemSet::reset_for_cleanup_tasks() { |
830 |
SparsePRT::reset_for_cleanup_tasks(); |
|
831 |
} |
|
832 |
||
833 |
void HeapRegionRemSet::do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task) { |
|
834 |
_other_regions.do_cleanup_work(hrrs_cleanup_task); |
|
835 |
} |
|
836 |
||
49632
64f9ebc85e67
8197573: Remove concurrent cleanup and secondary free list handling
tschatzl
parents:
49608
diff
changeset
|
837 |
void HeapRegionRemSet::finish_cleanup_task(HRRSCleanupTask* hrrs_cleanup_task) { |
8072 | 838 |
SparsePRT::finish_cleanup_task(hrrs_cleanup_task); |
839 |
} |
|
840 |
||
1374 | 841 |
#ifndef PRODUCT |
842 |
void HeapRegionRemSet::test() { |
|
843 |
os::sleep(Thread::current(), (jlong)5000, false); |
|
844 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
|
845 |
||
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
846 |
// Run with "-XX:G1LogRSetRegionEntries=2", so that 1 and 5 end up in same |
1374 | 847 |
// hash bucket. |
848 |
HeapRegion* hr0 = g1h->region_at(0); |
|
849 |
HeapRegion* hr1 = g1h->region_at(1); |
|
850 |
HeapRegion* hr2 = g1h->region_at(5); |
|
851 |
HeapRegion* hr3 = g1h->region_at(6); |
|
852 |
HeapRegion* hr4 = g1h->region_at(7); |
|
853 |
HeapRegion* hr5 = g1h->region_at(8); |
|
854 |
||
855 |
HeapWord* hr1_start = hr1->bottom(); |
|
856 |
HeapWord* hr1_mid = hr1_start + HeapRegion::GrainWords/2; |
|
857 |
HeapWord* hr1_last = hr1->end() - 1; |
|
858 |
||
859 |
HeapWord* hr2_start = hr2->bottom(); |
|
860 |
HeapWord* hr2_mid = hr2_start + HeapRegion::GrainWords/2; |
|
861 |
HeapWord* hr2_last = hr2->end() - 1; |
|
862 |
||
863 |
HeapWord* hr3_start = hr3->bottom(); |
|
864 |
HeapWord* hr3_mid = hr3_start + HeapRegion::GrainWords/2; |
|
865 |
HeapWord* hr3_last = hr3->end() - 1; |
|
866 |
||
867 |
HeapRegionRemSet* hrrs = hr0->rem_set(); |
|
868 |
||
869 |
// Make three references from region 0x101... |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
870 |
hrrs->add_reference((OopOrNarrowOopStar)hr1_start); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
871 |
hrrs->add_reference((OopOrNarrowOopStar)hr1_mid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
872 |
hrrs->add_reference((OopOrNarrowOopStar)hr1_last); |
1374 | 873 |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
874 |
hrrs->add_reference((OopOrNarrowOopStar)hr2_start); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
875 |
hrrs->add_reference((OopOrNarrowOopStar)hr2_mid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
876 |
hrrs->add_reference((OopOrNarrowOopStar)hr2_last); |
1374 | 877 |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
878 |
hrrs->add_reference((OopOrNarrowOopStar)hr3_start); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
879 |
hrrs->add_reference((OopOrNarrowOopStar)hr3_mid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
880 |
hrrs->add_reference((OopOrNarrowOopStar)hr3_last); |
1374 | 881 |
|
882 |
// Now cause a coarsening. |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
883 |
hrrs->add_reference((OopOrNarrowOopStar)hr4->bottom()); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
884 |
hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom()); |
1374 | 885 |
|
886 |
// Now, does iteration yield these three? |
|
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
887 |
HeapRegionRemSetIterator iter(hrrs); |
1374 | 888 |
size_t sum = 0; |
889 |
size_t card_index; |
|
890 |
while (iter.has_next(card_index)) { |
|
891 |
HeapWord* card_start = |
|
35461 | 892 |
G1CollectedHeap::heap()->bot()->address_for_index(card_index); |
35061 | 893 |
tty->print_cr(" Card " PTR_FORMAT ".", p2i(card_start)); |
1374 | 894 |
sum++; |
895 |
} |
|
896 |
guarantee(sum == 11 - 3 + 2048, "Failure"); |
|
897 |
guarantee(sum == hrrs->occupied(), "Failure"); |
|
898 |
} |
|
899 |
#endif |