author | tschatzl |
Mon, 03 Jun 2019 10:50:14 +0200 | |
changeset 55148 | 0dab93cb3b0c |
parent 54623 | 1126f0607c70 |
child 55510 | 3e31a8beaae4 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52716
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, 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), |
|
51332 | 71 |
_bm(HeapRegion::CardsPerRegion, mtGC), |
1374 | 72 |
_occupied(0), |
51332 | 73 |
_next(NULL), _prev(NULL), |
74 |
_collision_list_next(NULL) |
|
1374 | 75 |
{} |
76 |
||
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
77 |
void add_card_work(CardIdx_t from_card, bool par) { |
1374 | 78 |
if (!_bm.at(from_card)) { |
79 |
if (par) { |
|
80 |
if (_bm.par_at_put(from_card, 1)) { |
|
81 |
Atomic::inc(&_occupied); |
|
82 |
} |
|
83 |
} else { |
|
84 |
_bm.at_put(from_card, 1); |
|
85 |
_occupied++; |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
90 |
void add_reference_work(OopOrNarrowOopStar from, bool par) { |
1374 | 91 |
// Must make this robust in case "from" is not in "_hr", because of |
92 |
// concurrency. |
|
93 |
||
94 |
HeapRegion* loc_hr = hr(); |
|
95 |
// If the test below fails, then this table was reused concurrently |
|
96 |
// with this operation. This is OK, since the old table was coarsened, |
|
97 |
// 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
|
98 |
if (loc_hr->is_in_reserved(from)) { |
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
99 |
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
|
100 |
add_card_work(from_card, par); |
1374 | 101 |
} |
102 |
} |
|
103 |
||
104 |
public: |
|
105 |
||
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
106 |
HeapRegion* hr() const { return OrderAccess::load_acquire(&_hr); } |
1374 | 107 |
|
108 |
jint occupied() const { |
|
109 |
// Overkill, but if we ever need it... |
|
110 |
// guarantee(_occupied == _bm.count_one_bits(), "Check"); |
|
111 |
return _occupied; |
|
112 |
} |
|
113 |
||
13335 | 114 |
void init(HeapRegion* hr, bool clear_links_to_all_list) { |
115 |
if (clear_links_to_all_list) { |
|
116 |
set_next(NULL); |
|
117 |
set_prev(NULL); |
|
118 |
} |
|
119 |
_collision_list_next = NULL; |
|
1374 | 120 |
_occupied = 0; |
121 |
_bm.clear(); |
|
35875
8ea0b4b0bcc8
8147087: Race when reusing PerRegionTable bitmaps may result in dropped remembered set entries
tschatzl
parents:
35461
diff
changeset
|
122 |
// 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
|
123 |
// this PRT to concurrent threads. |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
124 |
OrderAccess::release_store(&_hr, hr); |
1374 | 125 |
} |
126 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
127 |
void add_reference(OopOrNarrowOopStar from) { |
1374 | 128 |
add_reference_work(from, /*parallel*/ true); |
129 |
} |
|
130 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
131 |
void seq_add_reference(OopOrNarrowOopStar from) { |
1374 | 132 |
add_reference_work(from, /*parallel*/ false); |
133 |
} |
|
134 |
||
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
135 |
void add_card(CardIdx_t from_card_index) { |
1374 | 136 |
add_card_work(from_card_index, /*parallel*/ true); |
137 |
} |
|
138 |
||
2996
1097030e5ec3
6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents:
2882
diff
changeset
|
139 |
void seq_add_card(CardIdx_t from_card_index) { |
1374 | 140 |
add_card_work(from_card_index, /*parallel*/ false); |
141 |
} |
|
142 |
||
143 |
// (Destructively) union the bitmap of the current table into the given |
|
144 |
// bitmap (which is assumed to be of the same size.) |
|
145 |
void union_bitmap_into(BitMap* bm) { |
|
146 |
bm->set_union(_bm); |
|
147 |
} |
|
148 |
||
149 |
// Mem size in bytes. |
|
150 |
size_t mem_size() const { |
|
24108
dfc2242fc6b0
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
24106
diff
changeset
|
151 |
return sizeof(PerRegionTable) + _bm.size_in_words() * HeapWordSize; |
1374 | 152 |
} |
153 |
||
154 |
// Requires "from" to be in "hr()". |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
155 |
bool contains_reference(OopOrNarrowOopStar from) const { |
1374 | 156 |
assert(hr()->is_in_reserved(from), "Precondition."); |
157 |
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
|
158 |
G1CardTable::card_size); |
1374 | 159 |
return _bm.at(card_ind); |
160 |
} |
|
161 |
||
13335 | 162 |
// Bulk-free the PRTs from prt to last, assumes that they are |
163 |
// linked together using their _next field. |
|
164 |
static void bulk_free(PerRegionTable* prt, PerRegionTable* last) { |
|
1374 | 165 |
while (true) { |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
166 |
PerRegionTable* fl = _free_list; |
13335 | 167 |
last->set_next(fl); |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
168 |
PerRegionTable* res = Atomic::cmpxchg(prt, &_free_list, fl); |
13335 | 169 |
if (res == fl) { |
170 |
return; |
|
171 |
} |
|
1374 | 172 |
} |
173 |
ShouldNotReachHere(); |
|
174 |
} |
|
175 |
||
13335 | 176 |
static void free(PerRegionTable* prt) { |
177 |
bulk_free(prt, prt); |
|
178 |
} |
|
179 |
||
180 |
// 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
|
181 |
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
|
182 |
PerRegionTable* fl = _free_list; |
1374 | 183 |
while (fl != NULL) { |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
184 |
PerRegionTable* nxt = fl->next(); |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
185 |
PerRegionTable* res = Atomic::cmpxchg(nxt, &_free_list, fl); |
1374 | 186 |
if (res == fl) { |
13335 | 187 |
fl->init(hr, true); |
1374 | 188 |
return fl; |
189 |
} else { |
|
190 |
fl = _free_list; |
|
191 |
} |
|
192 |
} |
|
193 |
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
|
194 |
return new PerRegionTable(hr); |
1374 | 195 |
} |
196 |
||
13335 | 197 |
PerRegionTable* next() const { return _next; } |
198 |
void set_next(PerRegionTable* next) { _next = next; } |
|
199 |
PerRegionTable* prev() const { return _prev; } |
|
200 |
void set_prev(PerRegionTable* prev) { _prev = prev; } |
|
201 |
||
202 |
// Accessor and Modification routines for the pointer for the |
|
203 |
// singly linked collision list that links the PRTs within the |
|
204 |
// OtherRegionsTable::_fine_grain_regions hash table. |
|
205 |
// |
|
206 |
// It might be useful to also make the collision list doubly linked |
|
207 |
// to avoid iteration over the collisions list during scrubbing/deletion. |
|
208 |
// OTOH there might not be many collisions. |
|
209 |
||
210 |
PerRegionTable* collision_list_next() const { |
|
211 |
return _collision_list_next; |
|
212 |
} |
|
213 |
||
214 |
void set_collision_list_next(PerRegionTable* next) { |
|
215 |
_collision_list_next = next; |
|
216 |
} |
|
217 |
||
218 |
PerRegionTable** collision_list_next_addr() { |
|
219 |
return &_collision_list_next; |
|
220 |
} |
|
221 |
||
1374 | 222 |
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
|
223 |
PerRegionTable* cur = _free_list; |
1374 | 224 |
size_t res = 0; |
225 |
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
|
226 |
res += cur->mem_size(); |
1374 | 227 |
cur = cur->next(); |
228 |
} |
|
229 |
return res; |
|
230 |
} |
|
17631
17992863b0ab
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
17398
diff
changeset
|
231 |
|
17992863b0ab
8014405: G1: PerRegionTable::fl_mem_size() calculates size of the free list using wrong element sizes
tschatzl
parents:
17398
diff
changeset
|
232 |
static void test_fl_mem_size(); |
1374 | 233 |
}; |
234 |
||
41283
2615c024f3eb
8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents:
40655
diff
changeset
|
235 |
PerRegionTable* volatile PerRegionTable::_free_list = NULL; |
1374 | 236 |
|
237 |
size_t OtherRegionsTable::_max_fine_entries = 0; |
|
238 |
size_t OtherRegionsTable::_mod_max_fine_entries_mask = 0; |
|
239 |
size_t OtherRegionsTable::_fine_eviction_stride = 0; |
|
240 |
size_t OtherRegionsTable::_fine_eviction_sample_size = 0; |
|
241 |
||
52347
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
242 |
OtherRegionsTable::OtherRegionsTable(Mutex* m) : |
1374 | 243 |
_g1h(G1CollectedHeap::heap()), |
51332 | 244 |
_m(m), |
46745
f7b9bb98bb72
8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents:
46560
diff
changeset
|
245 |
_coarse_map(G1CollectedHeap::heap()->max_regions(), mtGC), |
51332 | 246 |
_n_coarse_entries(0), |
1374 | 247 |
_fine_grain_regions(NULL), |
51332 | 248 |
_n_fine_entries(0), |
249 |
_first_all_fine_prts(NULL), |
|
250 |
_last_all_fine_prts(NULL), |
|
1374 | 251 |
_fine_eviction_start(0), |
52347
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
252 |
_sparse_table() |
1374 | 253 |
{ |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
254 |
typedef PerRegionTable* PerRegionTablePtr; |
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
255 |
|
1374 | 256 |
if (_max_fine_entries == 0) { |
257 |
assert(_mod_max_fine_entries_mask == 0, "Both or none."); |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
258 |
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
|
259 |
_max_fine_entries = (size_t)1 << max_entries_log; |
1374 | 260 |
_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
|
261 |
|
1374 | 262 |
assert(_fine_eviction_sample_size == 0 |
263 |
&& _fine_eviction_stride == 0, "All init at same time."); |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
264 |
_fine_eviction_sample_size = MAX2((size_t)4, max_entries_log); |
1374 | 265 |
_fine_eviction_stride = _max_fine_entries / _fine_eviction_sample_size; |
266 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
267 |
|
17376
4ee999c3c007
8012902: remove use of global operator new - take 2
minqi
parents:
17119
diff
changeset
|
268 |
_fine_grain_regions = NEW_C_HEAP_ARRAY3(PerRegionTablePtr, _max_fine_entries, |
25946 | 269 |
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
|
270 |
|
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
271 |
if (_fine_grain_regions == NULL) { |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
17031
diff
changeset
|
272 |
vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, OOM_MALLOC_ERROR, |
1374 | 273 |
"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
|
274 |
} |
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
275 |
|
1374 | 276 |
for (size_t i = 0; i < _max_fine_entries; i++) { |
277 |
_fine_grain_regions[i] = NULL; |
|
278 |
} |
|
279 |
} |
|
280 |
||
13335 | 281 |
void OtherRegionsTable::link_to_all(PerRegionTable* prt) { |
282 |
// We always append to the beginning of the list for convenience; |
|
283 |
// the order of entries in this list does not matter. |
|
284 |
if (_first_all_fine_prts != NULL) { |
|
285 |
assert(_first_all_fine_prts->prev() == NULL, "invariant"); |
|
286 |
_first_all_fine_prts->set_prev(prt); |
|
287 |
prt->set_next(_first_all_fine_prts); |
|
288 |
} else { |
|
289 |
// this is the first element we insert. Adjust the "last" pointer |
|
290 |
_last_all_fine_prts = prt; |
|
291 |
assert(prt->next() == NULL, "just checking"); |
|
292 |
} |
|
293 |
// the new element is always the first element without a predecessor |
|
294 |
prt->set_prev(NULL); |
|
295 |
_first_all_fine_prts = prt; |
|
296 |
||
297 |
assert(prt->prev() == NULL, "just checking"); |
|
298 |
assert(_first_all_fine_prts == prt, "just checking"); |
|
299 |
assert((_first_all_fine_prts == NULL && _last_all_fine_prts == NULL) || |
|
300 |
(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL), |
|
301 |
"just checking"); |
|
302 |
assert(_last_all_fine_prts == NULL || _last_all_fine_prts->next() == NULL, |
|
303 |
"just checking"); |
|
304 |
assert(_first_all_fine_prts == NULL || _first_all_fine_prts->prev() == NULL, |
|
305 |
"just checking"); |
|
306 |
} |
|
307 |
||
308 |
void OtherRegionsTable::unlink_from_all(PerRegionTable* prt) { |
|
309 |
if (prt->prev() != NULL) { |
|
310 |
assert(_first_all_fine_prts != prt, "just checking"); |
|
311 |
prt->prev()->set_next(prt->next()); |
|
312 |
// removing the last element in the list? |
|
313 |
if (_last_all_fine_prts == prt) { |
|
314 |
_last_all_fine_prts = prt->prev(); |
|
315 |
} |
|
316 |
} else { |
|
317 |
assert(_first_all_fine_prts == prt, "just checking"); |
|
318 |
_first_all_fine_prts = prt->next(); |
|
319 |
// list is empty now? |
|
320 |
if (_first_all_fine_prts == NULL) { |
|
321 |
_last_all_fine_prts = NULL; |
|
322 |
} |
|
323 |
} |
|
324 |
||
325 |
if (prt->next() != NULL) { |
|
326 |
prt->next()->set_prev(prt->prev()); |
|
327 |
} |
|
328 |
||
329 |
prt->set_next(NULL); |
|
330 |
prt->set_prev(NULL); |
|
331 |
||
332 |
assert((_first_all_fine_prts == NULL && _last_all_fine_prts == NULL) || |
|
333 |
(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL), |
|
334 |
"just checking"); |
|
335 |
assert(_last_all_fine_prts == NULL || _last_all_fine_prts->next() == NULL, |
|
336 |
"just checking"); |
|
337 |
assert(_first_all_fine_prts == NULL || _first_all_fine_prts->prev() == NULL, |
|
338 |
"just checking"); |
|
339 |
} |
|
340 |
||
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
341 |
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
|
342 |
assert(hr->is_in_reserved(within_region), |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
343 |
"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
|
344 |
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
|
345 |
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
|
346 |
return result; |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
347 |
} |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
348 |
|
26850
515ff48cf5f0
8036116: Fix thread-id types in G1 remembered set implementations
brutisso
parents:
26424
diff
changeset
|
349 |
void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, uint tid) { |
1374 | 350 |
// 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
|
351 |
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
|
352 |
RegionIdx_t from_hrm_ind = (RegionIdx_t) from_hr->hrm_index(); |
1374 | 353 |
|
354 |
// 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
|
355 |
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
|
356 |
assert(contains_reference(from), "We just found " PTR_FORMAT " in the Coarse table", p2i(from)); |
1374 | 357 |
return; |
358 |
} |
|
359 |
||
360 |
// 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
|
361 |
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
|
362 |
PerRegionTable* prt = find_region_table(ind, from_hr); |
1374 | 363 |
if (prt == NULL) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52716
diff
changeset
|
364 |
MutexLocker x(_m, Mutex::_no_safepoint_check_flag); |
1374 | 365 |
// Confirm that it's really not there... |
366 |
prt = find_region_table(ind, from_hr); |
|
367 |
if (prt == NULL) { |
|
368 |
||
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
369 |
CardIdx_t card_index = card_within_region(from, from_hr); |
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
370 |
|
52656 | 371 |
if (_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
|
372 |
assert(contains_reference_locked(from), "We just added " PTR_FORMAT " to the Sparse table", p2i(from)); |
1374 | 373 |
return; |
374 |
} |
|
375 |
||
376 |
if (_n_fine_entries == _max_fine_entries) { |
|
377 |
prt = delete_region_table(); |
|
13335 | 378 |
// There is no need to clear the links to the 'all' list here: |
379 |
// prt will be reused immediately, i.e. remain in the 'all' list. |
|
380 |
prt->init(from_hr, false /* clear_links_to_all_list */); |
|
1374 | 381 |
} else { |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
382 |
prt = PerRegionTable::alloc(from_hr); |
13335 | 383 |
link_to_all(prt); |
1374 | 384 |
} |
385 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
386 |
PerRegionTable* first_prt = _fine_grain_regions[ind]; |
13335 | 387 |
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
|
388 |
// 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
|
389 |
// 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
|
390 |
// 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
|
391 |
// 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
|
392 |
// 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
|
393 |
// 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
|
394 |
// 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
|
395 |
// zeroing becomes visible). This requires store ordering. |
47634
6a0c42c40cd1
8188220: Remove Atomic::*_ptr() uses and overloads from hotspot
coleenp
parents:
47216
diff
changeset
|
396 |
OrderAccess::release_store(&_fine_grain_regions[ind], prt); |
1374 | 397 |
_n_fine_entries++; |
398 |
||
52656 | 399 |
// Transfer from sparse to fine-grain. |
400 |
SparsePRTEntry *sprt_entry = _sparse_table.get_entry(from_hrm_ind); |
|
401 |
assert(sprt_entry != NULL, "There should have been an entry"); |
|
402 |
for (int i = 0; i < sprt_entry->num_valid_cards(); i++) { |
|
403 |
CardIdx_t c = sprt_entry->card(i); |
|
404 |
prt->add_card(c); |
|
1374 | 405 |
} |
52656 | 406 |
// Now we can delete the sparse entry. |
407 |
bool res = _sparse_table.delete_entry(from_hrm_ind); |
|
408 |
assert(res, "It should have been there."); |
|
1374 | 409 |
} |
410 |
assert(prt != NULL && prt->hr() == from_hr, "consequence"); |
|
411 |
} |
|
412 |
// Note that we can't assert "prt->hr() == from_hr", because of the |
|
413 |
// possibility of concurrent reuse. But see head comment of |
|
414 |
// OtherRegionsTable for why this is OK. |
|
415 |
assert(prt != NULL, "Inv"); |
|
416 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
417 |
prt->add_reference(from); |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
418 |
assert(contains_reference(from), "We just added " PTR_FORMAT " to the PRT (%d)", p2i(from), prt->contains_reference(from)); |
1374 | 419 |
} |
420 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
421 |
PerRegionTable* |
1374 | 422 |
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
|
423 |
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
|
424 |
PerRegionTable* prt = _fine_grain_regions[ind]; |
1374 | 425 |
while (prt != NULL && prt->hr() != hr) { |
13335 | 426 |
prt = prt->collision_list_next(); |
1374 | 427 |
} |
428 |
// Loop postcondition is the method postcondition. |
|
429 |
return prt; |
|
430 |
} |
|
431 |
||
432 |
jint OtherRegionsTable::_n_coarsenings = 0; |
|
433 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
434 |
PerRegionTable* OtherRegionsTable::delete_region_table() { |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
435 |
assert(_m->owned_by_self(), "Precondition"); |
1374 | 436 |
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
|
437 |
PerRegionTable* max = NULL; |
1374 | 438 |
jint max_occ = 0; |
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
33105
diff
changeset
|
439 |
PerRegionTable** max_prev = NULL; |
1374 | 440 |
size_t max_ind; |
441 |
||
442 |
size_t i = _fine_eviction_start; |
|
443 |
for (size_t k = 0; k < _fine_eviction_sample_size; k++) { |
|
444 |
size_t ii = i; |
|
445 |
// Make sure we get a non-NULL sample. |
|
446 |
while (_fine_grain_regions[ii] == NULL) { |
|
447 |
ii++; |
|
448 |
if (ii == _max_fine_entries) ii = 0; |
|
449 |
guarantee(ii != i, "We must find one."); |
|
450 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
451 |
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
|
452 |
PerRegionTable* cur = *prev; |
1374 | 453 |
while (cur != NULL) { |
454 |
jint cur_occ = cur->occupied(); |
|
455 |
if (max == NULL || cur_occ > max_occ) { |
|
456 |
max = cur; |
|
457 |
max_prev = prev; |
|
458 |
max_ind = i; |
|
459 |
max_occ = cur_occ; |
|
460 |
} |
|
13335 | 461 |
prev = cur->collision_list_next_addr(); |
462 |
cur = cur->collision_list_next(); |
|
1374 | 463 |
} |
464 |
i = i + _fine_eviction_stride; |
|
465 |
if (i >= _n_fine_entries) i = i - _n_fine_entries; |
|
466 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
467 |
|
1374 | 468 |
_fine_eviction_start++; |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
469 |
|
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
470 |
if (_fine_eviction_start >= _n_fine_entries) { |
1374 | 471 |
_fine_eviction_start -= _n_fine_entries; |
472 |
} |
|
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
473 |
|
1374 | 474 |
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
|
475 |
guarantee(max_prev != NULL, "Since max != NULL."); |
1374 | 476 |
|
477 |
// Set the corresponding coarse bit. |
|
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
478 |
size_t max_hrm_index = (size_t) max->hr()->hrm_index(); |
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
479 |
if (!_coarse_map.at(max_hrm_index)) { |
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
480 |
_coarse_map.at_put(max_hrm_index, true); |
1374 | 481 |
_n_coarse_entries++; |
482 |
} |
|
483 |
||
484 |
// Unsplice. |
|
13335 | 485 |
*max_prev = max->collision_list_next(); |
1374 | 486 |
Atomic::inc(&_n_coarsenings); |
487 |
_n_fine_entries--; |
|
488 |
return max; |
|
489 |
} |
|
490 |
||
28379
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
491 |
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
|
492 |
if (limit <= (size_t)G1RSetSparseRegionEntries) { |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
493 |
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
|
494 |
} else { |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
495 |
// 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
|
496 |
// 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
|
497 |
// at this time. |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
498 |
Unimplemented(); |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
499 |
return false; |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
500 |
} |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
501 |
} |
e6784fc8fff2
8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents:
28170
diff
changeset
|
502 |
|
25889
221296ac4359
8027959: Early reclamation of large objects in G1
tschatzl
parents:
25492
diff
changeset
|
503 |
bool OtherRegionsTable::is_empty() const { |
221296ac4359
8027959: Early reclamation of large objects in G1
tschatzl
parents:
25492
diff
changeset
|
504 |
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
|
505 |
} |
1374 | 506 |
|
507 |
size_t OtherRegionsTable::occupied() const { |
|
508 |
size_t sum = occ_fine(); |
|
509 |
sum += occ_sparse(); |
|
510 |
sum += occ_coarse(); |
|
511 |
return sum; |
|
512 |
} |
|
513 |
||
514 |
size_t OtherRegionsTable::occ_fine() const { |
|
515 |
size_t sum = 0; |
|
13335 | 516 |
|
517 |
size_t num = 0; |
|
518 |
PerRegionTable * cur = _first_all_fine_prts; |
|
519 |
while (cur != NULL) { |
|
520 |
sum += cur->occupied(); |
|
521 |
cur = cur->next(); |
|
522 |
num++; |
|
1374 | 523 |
} |
13335 | 524 |
guarantee(num == _n_fine_entries, "just checking"); |
1374 | 525 |
return sum; |
526 |
} |
|
527 |
||
528 |
size_t OtherRegionsTable::occ_coarse() const { |
|
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3262
diff
changeset
|
529 |
return (_n_coarse_entries * HeapRegion::CardsPerRegion); |
1374 | 530 |
} |
531 |
||
532 |
size_t OtherRegionsTable::occ_sparse() const { |
|
533 |
return _sparse_table.occupied(); |
|
534 |
} |
|
535 |
||
536 |
size_t OtherRegionsTable::mem_size() const { |
|
537 |
size_t sum = 0; |
|
17395
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
538 |
// 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
|
539 |
if (_first_all_fine_prts != NULL) { |
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
540 |
assert(_last_all_fine_prts != NULL && |
2cd3ef1be718
8014240: G1: Add remembered set size information to output of G1PrintRegionLivenessInfo
tschatzl
parents:
17119
diff
changeset
|
541 |
_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
|
542 |
sum += _first_all_fine_prts->mem_size() * _n_fine_entries; |
1374 | 543 |
} |
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
544 |
sum += (sizeof(PerRegionTable*) * _max_fine_entries); |
1374 | 545 |
sum += (_coarse_map.size_in_words() * HeapWordSize); |
546 |
sum += (_sparse_table.mem_size()); |
|
24108
dfc2242fc6b0
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
tschatzl
parents:
24106
diff
changeset
|
547 |
sum += sizeof(OtherRegionsTable) - sizeof(_sparse_table); // Avoid double counting above. |
1374 | 548 |
return sum; |
549 |
} |
|
550 |
||
551 |
size_t OtherRegionsTable::static_mem_size() { |
|
35200
7802299b31e7
8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents:
35199
diff
changeset
|
552 |
return G1FromCardCache::static_mem_size(); |
1374 | 553 |
} |
554 |
||
555 |
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
|
556 |
return PerRegionTable::fl_mem_size(); |
1374 | 557 |
} |
558 |
||
559 |
void OtherRegionsTable::clear() { |
|
13335 | 560 |
// if there are no entries, skip this step |
561 |
if (_first_all_fine_prts != NULL) { |
|
562 |
guarantee(_first_all_fine_prts != NULL && _last_all_fine_prts != NULL, "just checking"); |
|
563 |
PerRegionTable::bulk_free(_first_all_fine_prts, _last_all_fine_prts); |
|
564 |
memset(_fine_grain_regions, 0, _max_fine_entries * sizeof(_fine_grain_regions[0])); |
|
565 |
} else { |
|
566 |
guarantee(_first_all_fine_prts == NULL && _last_all_fine_prts == NULL, "just checking"); |
|
1374 | 567 |
} |
13335 | 568 |
|
569 |
_first_all_fine_prts = _last_all_fine_prts = NULL; |
|
1374 | 570 |
_sparse_table.clear(); |
38161
1c7dd1e39fcf
8155811: Remove HeapRegionRemSet::_coarse_dirty flag
tschatzl
parents:
38156
diff
changeset
|
571 |
if (_n_coarse_entries > 0) { |
38156 | 572 |
_coarse_map.clear(); |
573 |
} |
|
1374 | 574 |
_n_fine_entries = 0; |
575 |
_n_coarse_entries = 0; |
|
576 |
} |
|
577 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
578 |
bool OtherRegionsTable::contains_reference(OopOrNarrowOopStar from) const { |
1374 | 579 |
// Cast away const in this case. |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52716
diff
changeset
|
580 |
MutexLocker x((Mutex*)_m, Mutex::_no_safepoint_check_flag); |
1374 | 581 |
return contains_reference_locked(from); |
582 |
} |
|
583 |
||
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
584 |
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
|
585 |
HeapRegion* hr = _g1h->heap_region_containing(from); |
26316
93f6b40c038b
8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents:
26160
diff
changeset
|
586 |
RegionIdx_t hr_ind = (RegionIdx_t) hr->hrm_index(); |
1374 | 587 |
// Is this region in the coarse map? |
588 |
if (_coarse_map.at(hr_ind)) return true; |
|
589 |
||
13113
ab3870a79b18
6921087: G1: remove per-GC-thread expansion tables from the fine-grain remembered sets
johnc
parents:
12779
diff
changeset
|
590 |
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
|
591 |
hr); |
1374 | 592 |
if (prt != NULL) { |
593 |
return prt->contains_reference(from); |
|
594 |
||
595 |
} else { |
|
49608
1852b17b0efc
8196485: FromCardCache default card index can cause crashes
tschatzl
parents:
49607
diff
changeset
|
596 |
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
|
597 |
return _sparse_table.contains_card(hr_ind, card_index); |
1374 | 598 |
} |
599 |
} |
|
600 |
||
35461 | 601 |
HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetTable* bot, |
1374 | 602 |
HeapRegion* hr) |
35461 | 603 |
: _bot(bot), |
51332 | 604 |
_code_roots(), |
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
26850
diff
changeset
|
605 |
_m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never), |
52347
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
606 |
_other_regions(&_m), |
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
607 |
_hr(hr), |
51332 | 608 |
_state(Untracked) |
609 |
{ |
|
10000
5bbb58b0dbb9
7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents:
9989
diff
changeset
|
610 |
} |
1374 | 611 |
|
52347
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
612 |
void HeapRegionRemSet::clear_fcc() { |
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
613 |
G1FromCardCache::clear(_hr->hrm_index()); |
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
614 |
} |
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
615 |
|
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
616 |
void HeapRegionRemSet::setup_remset_size() { |
12779
06778de5193e
7171936: LOG_G incorrectly defined in globalDefinitions.hpp
brutisso
parents:
12381
diff
changeset
|
617 |
const int LOG_M = 20; |
55148
0dab93cb3b0c
8223162: Improve ergonomics for Sparse PRT entry sizing
tschatzl
parents:
54623
diff
changeset
|
618 |
guarantee(HeapRegion::LogOfHRGrainBytes >= LOG_M, "Code assumes the region size >= 1M, but is " SIZE_FORMAT "B", HeapRegion::GrainBytes); |
0dab93cb3b0c
8223162: Improve ergonomics for Sparse PRT entry sizing
tschatzl
parents:
54623
diff
changeset
|
619 |
|
0dab93cb3b0c
8223162: Improve ergonomics for Sparse PRT entry sizing
tschatzl
parents:
54623
diff
changeset
|
620 |
int region_size_log_mb = HeapRegion::LogOfHRGrainBytes - LOG_M; |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
621 |
if (FLAG_IS_DEFAULT(G1RSetSparseRegionEntries)) { |
55148
0dab93cb3b0c
8223162: Improve ergonomics for Sparse PRT entry sizing
tschatzl
parents:
54623
diff
changeset
|
622 |
G1RSetSparseRegionEntries = G1RSetSparseRegionEntriesBase * ((size_t)1 << (region_size_log_mb + 1)); |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
623 |
} |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
624 |
if (FLAG_IS_DEFAULT(G1RSetRegionEntries)) { |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
625 |
G1RSetRegionEntries = G1RSetRegionEntriesBase * (region_size_log_mb + 1); |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
626 |
} |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
627 |
guarantee(G1RSetSparseRegionEntries > 0 && G1RSetRegionEntries > 0 , "Sanity"); |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
628 |
} |
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
629 |
|
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
630 |
void HeapRegionRemSet::clear(bool only_cardset) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52716
diff
changeset
|
631 |
MutexLocker x(&_m, Mutex::_no_safepoint_check_flag); |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
632 |
clear_locked(only_cardset); |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
633 |
} |
19339 | 634 |
|
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
635 |
void HeapRegionRemSet::clear_locked(bool only_cardset) { |
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
636 |
if (!only_cardset) { |
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
637 |
_code_roots.clear(); |
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
638 |
} |
52347
14ef0f74667b
8211388: Make OtherRegionsTable independent of the region it is for
tschatzl
parents:
52345
diff
changeset
|
639 |
clear_fcc(); |
1374 | 640 |
_other_regions.clear(); |
49607
acffe6ff3ae7
8180415: Rebuild remembered sets during the concurrent cycle
tschatzl
parents:
49164
diff
changeset
|
641 |
set_state_empty(); |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
642 |
assert(occupied_locked() == 0, "Should be clear."); |
1374 | 643 |
} |
644 |
||
19339 | 645 |
// Code roots support |
26422 | 646 |
// |
647 |
// The code root set is protected by two separate locking schemes |
|
648 |
// When at safepoint the per-hrrs lock must be held during modifications |
|
649 |
// except when doing a full gc. |
|
650 |
// When not at safepoint the CodeCache_lock must be held during modifications. |
|
651 |
// When concurrent readers access the contains() function |
|
652 |
// (during the evacuation phase) no removals are allowed. |
|
19339 | 653 |
|
654 |
void HeapRegionRemSet::add_strong_code_root(nmethod* nm) { |
|
655 |
assert(nm != NULL, "sanity"); |
|
35879 | 656 |
assert((!CodeCache_lock->owned_by_self() || SafepointSynchronize::is_at_safepoint()), |
657 |
"should call add_strong_code_root_locked instead. CodeCache_lock->owned_by_self(): %s, is_at_safepoint(): %s", |
|
658 |
BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint())); |
|
26422 | 659 |
// Optimistic unlocked contains-check |
660 |
if (!_code_roots.contains(nm)) { |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52716
diff
changeset
|
661 |
MutexLocker ml(&_m, Mutex::_no_safepoint_check_flag); |
26422 | 662 |
add_strong_code_root_locked(nm); |
663 |
} |
|
664 |
} |
|
665 |
||
666 |
void HeapRegionRemSet::add_strong_code_root_locked(nmethod* nm) { |
|
667 |
assert(nm != NULL, "sanity"); |
|
35879 | 668 |
assert((CodeCache_lock->owned_by_self() || |
669 |
(SafepointSynchronize::is_at_safepoint() && |
|
670 |
(_m.owned_by_self() || Thread::current()->is_VM_thread()))), |
|
671 |
"not safely locked. CodeCache_lock->owned_by_self(): %s, is_at_safepoint(): %s, _m.owned_by_self(): %s, Thread::current()->is_VM_thread(): %s", |
|
672 |
BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()), |
|
673 |
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
|
674 |
_code_roots.add(nm); |
19339 | 675 |
} |
676 |
||
677 |
void HeapRegionRemSet::remove_strong_code_root(nmethod* nm) { |
|
678 |
assert(nm != NULL, "sanity"); |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
679 |
assert_locked_or_safepoint(CodeCache_lock); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
680 |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
52716
diff
changeset
|
681 |
MutexLocker ml(CodeCache_lock->owned_by_self() ? NULL : &_m, Mutex::_no_safepoint_check_flag); |
26422 | 682 |
_code_roots.remove(nm); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
683 |
|
19339 | 684 |
// Check that there were no duplicates |
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
685 |
guarantee(!_code_roots.contains(nm), "duplicate entry found"); |
19339 | 686 |
} |
687 |
||
26422 | 688 |
void HeapRegionRemSet::strong_code_roots_do(CodeBlobClosure* blk) const { |
689 |
_code_roots.nmethods_do(blk); |
|
19339 | 690 |
} |
691 |
||
26422 | 692 |
void HeapRegionRemSet::clean_strong_code_roots(HeapRegion* hr) { |
693 |
_code_roots.clean(hr); |
|
19339 | 694 |
} |
695 |
||
696 |
size_t HeapRegionRemSet::strong_code_roots_mem_size() { |
|
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
697 |
return _code_roots.mem_size(); |
19339 | 698 |
} |
699 |
||
23451
ed2b8bb28fed
8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
21563
diff
changeset
|
700 |
HeapRegionRemSetIterator:: HeapRegionRemSetIterator(HeapRegionRemSet* hrrs) : |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
701 |
_hrrs(hrrs), |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
702 |
_coarse_map(&hrrs->_other_regions._coarse_map), |
35461 | 703 |
_bot(hrrs->_bot), |
51332 | 704 |
_g1h(G1CollectedHeap::heap()), |
705 |
_n_yielded_fine(0), |
|
706 |
_n_yielded_coarse(0), |
|
707 |
_n_yielded_sparse(0), |
|
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
708 |
_is(Sparse), |
51332 | 709 |
_cur_region_card_offset(0), |
1374 | 710 |
// 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
|
711 |
_coarse_cur_region_index(-1), |
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
712 |
_coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1), |
51332 | 713 |
_fine_cur_prt(NULL), |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
714 |
_cur_card_in_prt(HeapRegion::CardsPerRegion), |
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
715 |
_sparse_iter(&hrrs->_other_regions._sparse_table) {} |
1374 | 716 |
|
717 |
bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) { |
|
718 |
if (_hrrs->_other_regions._n_coarse_entries == 0) return false; |
|
719 |
// Go to the next card. |
|
720 |
_coarse_cur_region_cur_card++; |
|
721 |
// 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
|
722 |
if (_coarse_cur_region_cur_card == HeapRegion::CardsPerRegion) { |
1374 | 723 |
// Yes: find the next region. This may leave _coarse_cur_region_index |
724 |
// Set to the last index, in which case there are no more coarse |
|
725 |
// regions. |
|
726 |
_coarse_cur_region_index = |
|
727 |
(int) _coarse_map->get_next_one_offset(_coarse_cur_region_index + 1); |
|
728 |
if ((size_t)_coarse_cur_region_index < _coarse_map->size()) { |
|
729 |
_coarse_cur_region_cur_card = 0; |
|
730 |
HeapWord* r_bot = |
|
12381
1438e0fbfa27
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
10767
diff
changeset
|
731 |
_g1h->region_at((uint) _coarse_cur_region_index)->bottom(); |
52345
418fb8bb5151
8071913: Filter out entries to free/uncommitted regions during iteration
tschatzl
parents:
51332
diff
changeset
|
732 |
_cur_region_card_offset = _bot->index_for_raw(r_bot); |
1374 | 733 |
} else { |
734 |
return false; |
|
735 |
} |
|
736 |
} |
|
737 |
// If we didn't return false above, then we can yield a card. |
|
738 |
card_index = _cur_region_card_offset + _coarse_cur_region_cur_card; |
|
739 |
return true; |
|
740 |
} |
|
741 |
||
742 |
bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) { |
|
743 |
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
|
744 |
_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
|
745 |
_fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1); |
1374 | 746 |
} |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
747 |
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
|
748 |
// _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
|
749 |
// 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
|
750 |
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
|
751 |
return false; |
1374 | 752 |
} |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
753 |
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
|
754 |
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
|
755 |
_cur_card_in_prt = _fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1); |
1374 | 756 |
} |
24101
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
757 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
758 |
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
|
759 |
guarantee(_cur_card_in_prt < HeapRegion::CardsPerRegion, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
760 |
"Card index " SIZE_FORMAT " must be within the region", _cur_card_in_prt); |
1374 | 761 |
return true; |
762 |
} |
|
763 |
||
764 |
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
|
765 |
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
|
766 |
} |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
767 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
768 |
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
|
769 |
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
|
770 |
_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
|
771 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
772 |
HeapWord* r_bot = _fine_cur_prt->hr()->bottom(); |
52345
418fb8bb5151
8071913: Filter out entries to free/uncommitted regions during iteration
tschatzl
parents:
51332
diff
changeset
|
773 |
_cur_region_card_offset = _bot->index_for_raw(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
|
774 |
|
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
775 |
// 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
|
776 |
// 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
|
777 |
// 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
|
778 |
_cur_card_in_prt = (size_t)-1; |
1374 | 779 |
} |
780 |
||
781 |
bool HeapRegionRemSetIterator::has_next(size_t& card_index) { |
|
782 |
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
|
783 |
case Sparse: { |
1374 | 784 |
if (_sparse_iter.has_next(card_index)) { |
785 |
_n_yielded_sparse++; |
|
786 |
return true; |
|
787 |
} |
|
788 |
// Otherwise, deliberate fall-through |
|
789 |
_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
|
790 |
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
|
791 |
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
|
792 |
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
|
793 |
} |
bd1a2ee20760
8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
tschatzl
parents:
24092
diff
changeset
|
794 |
} |
1374 | 795 |
case Fine: |
796 |
if (fine_has_next(card_index)) { |
|
797 |
_n_yielded_fine++; |
|
798 |
return true; |
|
799 |
} |
|
800 |
// Otherwise, deliberate fall-through |
|
801 |
_is = Coarse; |
|
802 |
case Coarse: |
|
803 |
if (coarse_has_next(card_index)) { |
|
804 |
_n_yielded_coarse++; |
|
805 |
return true; |
|
806 |
} |
|
807 |
// Otherwise... |
|
808 |
break; |
|
809 |
} |
|
810 |
return false; |
|
811 |
} |
|
812 |
||
813 |
#ifndef PRODUCT |
|
814 |
void HeapRegionRemSet::test() { |
|
815 |
os::sleep(Thread::current(), (jlong)5000, false); |
|
816 |
G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
|
817 |
||
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4900
diff
changeset
|
818 |
// Run with "-XX:G1LogRSetRegionEntries=2", so that 1 and 5 end up in same |
1374 | 819 |
// hash bucket. |
820 |
HeapRegion* hr0 = g1h->region_at(0); |
|
821 |
HeapRegion* hr1 = g1h->region_at(1); |
|
822 |
HeapRegion* hr2 = g1h->region_at(5); |
|
823 |
HeapRegion* hr3 = g1h->region_at(6); |
|
824 |
HeapRegion* hr4 = g1h->region_at(7); |
|
825 |
HeapRegion* hr5 = g1h->region_at(8); |
|
826 |
||
827 |
HeapWord* hr1_start = hr1->bottom(); |
|
828 |
HeapWord* hr1_mid = hr1_start + HeapRegion::GrainWords/2; |
|
829 |
HeapWord* hr1_last = hr1->end() - 1; |
|
830 |
||
831 |
HeapWord* hr2_start = hr2->bottom(); |
|
832 |
HeapWord* hr2_mid = hr2_start + HeapRegion::GrainWords/2; |
|
833 |
HeapWord* hr2_last = hr2->end() - 1; |
|
834 |
||
835 |
HeapWord* hr3_start = hr3->bottom(); |
|
836 |
HeapWord* hr3_mid = hr3_start + HeapRegion::GrainWords/2; |
|
837 |
HeapWord* hr3_last = hr3->end() - 1; |
|
838 |
||
839 |
HeapRegionRemSet* hrrs = hr0->rem_set(); |
|
840 |
||
841 |
// Make three references from region 0x101... |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
842 |
hrrs->add_reference((OopOrNarrowOopStar)hr1_start); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
843 |
hrrs->add_reference((OopOrNarrowOopStar)hr1_mid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
844 |
hrrs->add_reference((OopOrNarrowOopStar)hr1_last); |
1374 | 845 |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
846 |
hrrs->add_reference((OopOrNarrowOopStar)hr2_start); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
847 |
hrrs->add_reference((OopOrNarrowOopStar)hr2_mid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
848 |
hrrs->add_reference((OopOrNarrowOopStar)hr2_last); |
1374 | 849 |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
850 |
hrrs->add_reference((OopOrNarrowOopStar)hr3_start); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
851 |
hrrs->add_reference((OopOrNarrowOopStar)hr3_mid); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
852 |
hrrs->add_reference((OopOrNarrowOopStar)hr3_last); |
1374 | 853 |
|
854 |
// Now cause a coarsening. |
|
3262
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
855 |
hrrs->add_reference((OopOrNarrowOopStar)hr4->bottom()); |
30d1c247fc25
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
2996
diff
changeset
|
856 |
hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom()); |
1374 | 857 |
|
858 |
// Now, does iteration yield these three? |
|
17108
cf72dcf9a8f2
8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents:
13752
diff
changeset
|
859 |
HeapRegionRemSetIterator iter(hrrs); |
1374 | 860 |
size_t sum = 0; |
861 |
size_t card_index; |
|
862 |
while (iter.has_next(card_index)) { |
|
49806 | 863 |
HeapWord* card_start = g1h->bot()->address_for_index(card_index); |
35061 | 864 |
tty->print_cr(" Card " PTR_FORMAT ".", p2i(card_start)); |
1374 | 865 |
sum++; |
866 |
} |
|
867 |
guarantee(sum == 11 - 3 + 2048, "Failure"); |
|
868 |
guarantee(sum == hrrs->occupied(), "Failure"); |
|
869 |
} |
|
870 |
#endif |