author | brutisso |
Thu, 07 Aug 2014 09:35:08 +0200 | |
changeset 25909 | 571781915421 |
parent 25492 | d27050bdfb04 |
child 26157 | 70eddb655686 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23858
diff
changeset
|
2 |
* Copyright (c) 2001, 2014, 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:
5402
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
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:
5402
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" |
|
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
27 |
#include "gc_implementation/g1/heapRegion.hpp" |
7397 | 28 |
#include "memory/space.hpp" |
29 |
#include "oops/oop.inline.hpp" |
|
30 |
#include "runtime/java.hpp" |
|
13195 | 31 |
#include "services/memTracker.hpp" |
1374 | 32 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23858
diff
changeset
|
33 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23858
diff
changeset
|
34 |
|
1374 | 35 |
////////////////////////////////////////////////////////////////////// |
36 |
// G1BlockOffsetSharedArray |
|
37 |
////////////////////////////////////////////////////////////////////// |
|
38 |
||
39 |
G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion reserved, |
|
40 |
size_t init_word_size) : |
|
41 |
_reserved(reserved), _end(NULL) |
|
42 |
{ |
|
43 |
size_t size = compute_size(reserved.word_size()); |
|
44 |
ReservedSpace rs(ReservedSpace::allocation_align_size_up(size)); |
|
45 |
if (!rs.is_reserved()) { |
|
46 |
vm_exit_during_initialization("Could not reserve enough space for heap offset array"); |
|
47 |
} |
|
48 |
if (!_vs.initialize(rs, 0)) { |
|
49 |
vm_exit_during_initialization("Could not reserve enough space for heap offset array"); |
|
50 |
} |
|
13195 | 51 |
|
52 |
MemTracker::record_virtual_memory_type((address)rs.base(), mtGC); |
|
53 |
||
1374 | 54 |
_offset_array = (u_char*)_vs.low_boundary(); |
55 |
resize(init_word_size); |
|
56 |
if (TraceBlockOffsetTable) { |
|
57 |
gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: "); |
|
58 |
gclog_or_tty->print_cr(" " |
|
59 |
" rs.base(): " INTPTR_FORMAT |
|
60 |
" rs.size(): " INTPTR_FORMAT |
|
61 |
" rs end(): " INTPTR_FORMAT, |
|
62 |
rs.base(), rs.size(), rs.base() + rs.size()); |
|
63 |
gclog_or_tty->print_cr(" " |
|
64 |
" _vs.low_boundary(): " INTPTR_FORMAT |
|
65 |
" _vs.high_boundary(): " INTPTR_FORMAT, |
|
66 |
_vs.low_boundary(), |
|
67 |
_vs.high_boundary()); |
|
68 |
} |
|
69 |
} |
|
70 |
||
71 |
void G1BlockOffsetSharedArray::resize(size_t new_word_size) { |
|
72 |
assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved"); |
|
73 |
size_t new_size = compute_size(new_word_size); |
|
74 |
size_t old_size = _vs.committed_size(); |
|
75 |
size_t delta; |
|
76 |
char* high = _vs.high(); |
|
77 |
_end = _reserved.start() + new_word_size; |
|
78 |
if (new_size > old_size) { |
|
79 |
delta = ReservedSpace::page_align_size_up(new_size - old_size); |
|
80 |
assert(delta > 0, "just checking"); |
|
81 |
if (!_vs.expand_by(delta)) { |
|
82 |
// Do better than this for Merlin |
|
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
14584
diff
changeset
|
83 |
vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion"); |
1374 | 84 |
} |
85 |
assert(_vs.high() == high + delta, "invalid expansion"); |
|
86 |
// Initialization of the contents is left to the |
|
87 |
// G1BlockOffsetArray that uses it. |
|
88 |
} else { |
|
89 |
delta = ReservedSpace::page_align_size_down(old_size - new_size); |
|
90 |
if (delta == 0) return; |
|
91 |
_vs.shrink_by(delta); |
|
92 |
assert(_vs.high() == high - delta, "invalid expansion"); |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const { |
|
97 |
assert(p >= _reserved.start(), "just checking"); |
|
98 |
size_t delta = pointer_delta(p, _reserved.start()); |
|
99 |
return (delta & right_n_bits(LogN_words)) == (size_t)NoBits; |
|
100 |
} |
|
101 |
||
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
102 |
void G1BlockOffsetSharedArray::set_offset_array(HeapWord* left, HeapWord* right, u_char offset) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
103 |
check_index(index_for(right - 1), "right address out of range"); |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
104 |
assert(left < right, "Heap addresses out of order"); |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
105 |
size_t num_cards = pointer_delta(right, left) >> LogN_words; |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
106 |
if (UseMemSetInBOT) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
107 |
memset(&_offset_array[index_for(left)], offset, num_cards); |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
108 |
} else { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
109 |
size_t i = index_for(left); |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
110 |
const size_t end = i + num_cards; |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
111 |
for (; i < end; i++) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
112 |
_offset_array[i] = offset; |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
113 |
} |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
114 |
} |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
115 |
} |
1374 | 116 |
|
117 |
////////////////////////////////////////////////////////////////////// |
|
118 |
// G1BlockOffsetArray |
|
119 |
////////////////////////////////////////////////////////////////////// |
|
120 |
||
121 |
G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array, |
|
122 |
MemRegion mr, bool init_to_zero) : |
|
123 |
G1BlockOffsetTable(mr.start(), mr.end()), |
|
124 |
_unallocated_block(_bottom), |
|
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
125 |
_array(array), _gsp(NULL), |
1374 | 126 |
_init_to_zero(init_to_zero) { |
127 |
assert(_bottom <= _end, "arguments out of order"); |
|
128 |
if (!_init_to_zero) { |
|
129 |
// initialize cards to point back to mr.start() |
|
130 |
set_remainder_to_point_to_start(mr.start() + N_words, mr.end()); |
|
131 |
_array->set_offset_array(0, 0); // set first card to 0 |
|
132 |
} |
|
133 |
} |
|
134 |
||
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
135 |
void G1BlockOffsetArray::set_space(G1OffsetTableContigSpace* sp) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
136 |
_gsp = sp; |
1374 | 137 |
} |
138 |
||
139 |
// The arguments follow the normal convention of denoting |
|
140 |
// a right-open interval: [start, end) |
|
141 |
void |
|
142 |
G1BlockOffsetArray:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) { |
|
143 |
||
144 |
if (start >= end) { |
|
145 |
// The start address is equal to the end address (or to |
|
146 |
// the right of the end address) so there are not cards |
|
147 |
// that need to be updated.. |
|
148 |
return; |
|
149 |
} |
|
150 |
||
151 |
// Write the backskip value for each region. |
|
152 |
// |
|
153 |
// offset |
|
154 |
// card 2nd 3rd |
|
155 |
// | +- 1st | | |
|
156 |
// v v v v |
|
157 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+- |
|
158 |
// |x|0|0|0|0|0|0|0|1|1|1|1|1|1| ... |1|1|1|1|2|2|2|2|2|2| ... |
|
159 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+- |
|
160 |
// 11 19 75 |
|
161 |
// 12 |
|
162 |
// |
|
163 |
// offset card is the card that points to the start of an object |
|
164 |
// x - offset value of offset card |
|
165 |
// 1st - start of first logarithmic region |
|
166 |
// 0 corresponds to logarithmic value N_words + 0 and 2**(3 * 0) = 1 |
|
167 |
// 2nd - start of second logarithmic region |
|
168 |
// 1 corresponds to logarithmic value N_words + 1 and 2**(3 * 1) = 8 |
|
169 |
// 3rd - start of third logarithmic region |
|
170 |
// 2 corresponds to logarithmic value N_words + 2 and 2**(3 * 2) = 64 |
|
171 |
// |
|
172 |
// integer below the block offset entry is an example of |
|
173 |
// the index of the entry |
|
174 |
// |
|
175 |
// Given an address, |
|
176 |
// Find the index for the address |
|
177 |
// Find the block offset table entry |
|
178 |
// Convert the entry to a back slide |
|
179 |
// (e.g., with today's, offset = 0x81 => |
|
180 |
// back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8 |
|
181 |
// Move back N (e.g., 8) entries and repeat with the |
|
182 |
// value of the new entry |
|
183 |
// |
|
184 |
size_t start_card = _array->index_for(start); |
|
185 |
size_t end_card = _array->index_for(end-1); |
|
186 |
assert(start ==_array->address_for_index(start_card), "Precondition"); |
|
187 |
assert(end ==_array->address_for_index(end_card)+N_words, "Precondition"); |
|
188 |
set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval |
|
189 |
} |
|
190 |
||
191 |
// Unlike the normal convention in this code, the argument here denotes |
|
192 |
// a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start() |
|
193 |
// above. |
|
194 |
void |
|
195 |
G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) { |
|
196 |
if (start_card > end_card) { |
|
197 |
return; |
|
198 |
} |
|
199 |
assert(start_card > _array->index_for(_bottom), "Cannot be first card"); |
|
200 |
assert(_array->offset_array(start_card-1) <= N_words, |
|
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
201 |
"Offset card has an unexpected value"); |
1374 | 202 |
size_t start_card_for_region = start_card; |
203 |
u_char offset = max_jubyte; |
|
204 |
for (int i = 0; i < BlockOffsetArray::N_powers; i++) { |
|
205 |
// -1 so that the the card with the actual offset is counted. Another -1 |
|
206 |
// so that the reach ends in this region and not at the start |
|
207 |
// of the next. |
|
208 |
size_t reach = start_card - 1 + (BlockOffsetArray::power_to_cards_back(i+1) - 1); |
|
209 |
offset = N_words + i; |
|
210 |
if (reach >= end_card) { |
|
211 |
_array->set_offset_array(start_card_for_region, end_card, offset); |
|
212 |
start_card_for_region = reach + 1; |
|
213 |
break; |
|
214 |
} |
|
215 |
_array->set_offset_array(start_card_for_region, reach, offset); |
|
216 |
start_card_for_region = reach + 1; |
|
217 |
} |
|
218 |
assert(start_card_for_region > end_card, "Sanity check"); |
|
219 |
DEBUG_ONLY(check_all_cards(start_card, end_card);) |
|
220 |
} |
|
221 |
||
222 |
// The block [blk_start, blk_end) has been allocated; |
|
223 |
// adjust the block offset table to represent this information; |
|
224 |
// right-open interval: [blk_start, blk_end) |
|
225 |
void |
|
226 |
G1BlockOffsetArray::alloc_block(HeapWord* blk_start, HeapWord* blk_end) { |
|
227 |
mark_block(blk_start, blk_end); |
|
228 |
allocated(blk_start, blk_end); |
|
229 |
} |
|
230 |
||
231 |
// Adjust BOT to show that a previously whole block has been split |
|
232 |
// into two. |
|
233 |
void G1BlockOffsetArray::split_block(HeapWord* blk, size_t blk_size, |
|
234 |
size_t left_blk_size) { |
|
235 |
// Verify that the BOT shows [blk, blk + blk_size) to be one block. |
|
236 |
verify_single_block(blk, blk_size); |
|
237 |
// Update the BOT to indicate that [blk + left_blk_size, blk + blk_size) |
|
238 |
// is one single block. |
|
239 |
mark_block(blk + left_blk_size, blk + blk_size); |
|
240 |
} |
|
241 |
||
242 |
||
243 |
// Action_mark - update the BOT for the block [blk_start, blk_end). |
|
244 |
// Current typical use is for splitting a block. |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
245 |
// Action_single - update the BOT for an allocation. |
1374 | 246 |
// Action_verify - BOT verification. |
247 |
void G1BlockOffsetArray::do_block_internal(HeapWord* blk_start, |
|
248 |
HeapWord* blk_end, |
|
249 |
Action action) { |
|
250 |
assert(Universe::heap()->is_in_reserved(blk_start), |
|
251 |
"reference must be into the heap"); |
|
252 |
assert(Universe::heap()->is_in_reserved(blk_end-1), |
|
253 |
"limit must be within the heap"); |
|
254 |
// This is optimized to make the test fast, assuming we only rarely |
|
255 |
// cross boundaries. |
|
256 |
uintptr_t end_ui = (uintptr_t)(blk_end - 1); |
|
257 |
uintptr_t start_ui = (uintptr_t)blk_start; |
|
258 |
// Calculate the last card boundary preceding end of blk |
|
259 |
intptr_t boundary_before_end = (intptr_t)end_ui; |
|
260 |
clear_bits(boundary_before_end, right_n_bits(LogN)); |
|
261 |
if (start_ui <= (uintptr_t)boundary_before_end) { |
|
262 |
// blk starts at or crosses a boundary |
|
263 |
// Calculate index of card on which blk begins |
|
264 |
size_t start_index = _array->index_for(blk_start); |
|
265 |
// Index of card on which blk ends |
|
266 |
size_t end_index = _array->index_for(blk_end - 1); |
|
267 |
// Start address of card on which blk begins |
|
268 |
HeapWord* boundary = _array->address_for_index(start_index); |
|
269 |
assert(boundary <= blk_start, "blk should start at or after boundary"); |
|
270 |
if (blk_start != boundary) { |
|
271 |
// blk starts strictly after boundary |
|
272 |
// adjust card boundary and start_index forward to next card |
|
273 |
boundary += N_words; |
|
274 |
start_index++; |
|
275 |
} |
|
276 |
assert(start_index <= end_index, "monotonicity of index_for()"); |
|
277 |
assert(boundary <= (HeapWord*)boundary_before_end, "tautology"); |
|
278 |
switch (action) { |
|
279 |
case Action_mark: { |
|
280 |
if (init_to_zero()) { |
|
281 |
_array->set_offset_array(start_index, boundary, blk_start); |
|
282 |
break; |
|
283 |
} // Else fall through to the next case |
|
284 |
} |
|
285 |
case Action_single: { |
|
286 |
_array->set_offset_array(start_index, boundary, blk_start); |
|
287 |
// We have finished marking the "offset card". We need to now |
|
288 |
// mark the subsequent cards that this blk spans. |
|
289 |
if (start_index < end_index) { |
|
290 |
HeapWord* rem_st = _array->address_for_index(start_index) + N_words; |
|
291 |
HeapWord* rem_end = _array->address_for_index(end_index) + N_words; |
|
292 |
set_remainder_to_point_to_start(rem_st, rem_end); |
|
293 |
} |
|
294 |
break; |
|
295 |
} |
|
296 |
case Action_check: { |
|
297 |
_array->check_offset_array(start_index, boundary, blk_start); |
|
298 |
// We have finished checking the "offset card". We need to now |
|
299 |
// check the subsequent cards that this blk spans. |
|
300 |
check_all_cards(start_index + 1, end_index); |
|
301 |
break; |
|
302 |
} |
|
303 |
default: |
|
304 |
ShouldNotReachHere(); |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
// The card-interval [start_card, end_card] is a closed interval; this |
|
310 |
// is an expensive check -- use with care and only under protection of |
|
311 |
// suitable flag. |
|
312 |
void G1BlockOffsetArray::check_all_cards(size_t start_card, size_t end_card) const { |
|
313 |
||
314 |
if (end_card < start_card) { |
|
315 |
return; |
|
316 |
} |
|
317 |
guarantee(_array->offset_array(start_card) == N_words, "Wrong value in second card"); |
|
318 |
for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) { |
|
319 |
u_char entry = _array->offset_array(c); |
|
320 |
if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) { |
|
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
321 |
guarantee(entry > N_words, |
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
322 |
err_msg("Should be in logarithmic region - " |
23858
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
323 |
"entry: %u, " |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
324 |
"_array->offset_array(c): %u, " |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
325 |
"N_words: %u", |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
326 |
(uint)entry, (uint)_array->offset_array(c), (uint)N_words)); |
1374 | 327 |
} |
328 |
size_t backskip = BlockOffsetArray::entry_to_cards_back(entry); |
|
329 |
size_t landing_card = c - backskip; |
|
330 |
guarantee(landing_card >= (start_card - 1), "Inv"); |
|
331 |
if (landing_card >= start_card) { |
|
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
332 |
guarantee(_array->offset_array(landing_card) <= entry, |
23858
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
333 |
err_msg("Monotonicity - landing_card offset: %u, " |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
334 |
"entry: %u", |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
335 |
(uint)_array->offset_array(landing_card), (uint)entry)); |
1374 | 336 |
} else { |
337 |
guarantee(landing_card == start_card - 1, "Tautology"); |
|
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
338 |
// Note that N_words is the maximum offset value |
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
339 |
guarantee(_array->offset_array(landing_card) <= N_words, |
23858
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
340 |
err_msg("landing card offset: %u, " |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
341 |
"N_words: %u", |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
342 |
(uint)_array->offset_array(landing_card), (uint)N_words)); |
1374 | 343 |
} |
344 |
} |
|
345 |
} |
|
346 |
||
347 |
// The range [blk_start, blk_end) represents a single contiguous block |
|
348 |
// of storage; modify the block offset table to represent this |
|
349 |
// information; Right-open interval: [blk_start, blk_end) |
|
350 |
// NOTE: this method does _not_ adjust _unallocated_block. |
|
351 |
void |
|
352 |
G1BlockOffsetArray::single_block(HeapWord* blk_start, HeapWord* blk_end) { |
|
353 |
do_block_internal(blk_start, blk_end, Action_single); |
|
354 |
} |
|
355 |
||
356 |
// Mark the BOT such that if [blk_start, blk_end) straddles a card |
|
357 |
// boundary, the card following the first such boundary is marked |
|
358 |
// with the appropriate offset. |
|
359 |
// NOTE: this method does _not_ adjust _unallocated_block or |
|
360 |
// any cards subsequent to the first one. |
|
361 |
void |
|
362 |
G1BlockOffsetArray::mark_block(HeapWord* blk_start, HeapWord* blk_end) { |
|
363 |
do_block_internal(blk_start, blk_end, Action_mark); |
|
364 |
} |
|
365 |
||
366 |
HeapWord* G1BlockOffsetArray::block_start_unsafe(const void* addr) { |
|
367 |
assert(_bottom <= addr && addr < _end, |
|
368 |
"addr must be covered by this Array"); |
|
369 |
// Must read this exactly once because it can be modified by parallel |
|
370 |
// allocation. |
|
371 |
HeapWord* ub = _unallocated_block; |
|
372 |
if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) { |
|
373 |
assert(ub < _end, "tautology (see above)"); |
|
374 |
return ub; |
|
375 |
} |
|
376 |
// Otherwise, find the block start using the table. |
|
377 |
HeapWord* q = block_at_or_preceding(addr, false, 0); |
|
378 |
return forward_to_block_containing_addr(q, addr); |
|
379 |
} |
|
380 |
||
381 |
// This duplicates a little code from the above: unavoidable. |
|
382 |
HeapWord* |
|
383 |
G1BlockOffsetArray::block_start_unsafe_const(const void* addr) const { |
|
384 |
assert(_bottom <= addr && addr < _end, |
|
385 |
"addr must be covered by this Array"); |
|
386 |
// Must read this exactly once because it can be modified by parallel |
|
387 |
// allocation. |
|
388 |
HeapWord* ub = _unallocated_block; |
|
389 |
if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) { |
|
390 |
assert(ub < _end, "tautology (see above)"); |
|
391 |
return ub; |
|
392 |
} |
|
393 |
// Otherwise, find the block start using the table. |
|
394 |
HeapWord* q = block_at_or_preceding(addr, false, 0); |
|
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
395 |
HeapWord* n = q + block_size(q); |
1374 | 396 |
return forward_to_block_containing_addr_const(q, n, addr); |
397 |
} |
|
398 |
||
399 |
||
400 |
HeapWord* |
|
401 |
G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q, |
|
402 |
HeapWord* n, |
|
403 |
const void* addr) { |
|
404 |
// We're not in the normal case. We need to handle an important subcase |
|
405 |
// here: LAB allocation. An allocation previously recorded in the |
|
406 |
// offset table was actually a lab allocation, and was divided into |
|
407 |
// several objects subsequently. Fix this situation as we answer the |
|
408 |
// query, by updating entries as we cross them. |
|
1384
163a4d4fa951
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
1374
diff
changeset
|
409 |
|
163a4d4fa951
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
1374
diff
changeset
|
410 |
// If the fist object's end q is at the card boundary. Start refining |
163a4d4fa951
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
1374
diff
changeset
|
411 |
// with the corresponding card (the value of the entry will be basically |
163a4d4fa951
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
1374
diff
changeset
|
412 |
// set to 0). If the object crosses the boundary -- start from the next card. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
413 |
size_t n_index = _array->index_for(n); |
1384
163a4d4fa951
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
1374
diff
changeset
|
414 |
size_t next_index = _array->index_for(n) + !_array->is_card_boundary(n); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
415 |
// Calculate a consistent next boundary. If "n" is not at the boundary |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
416 |
// already, step to the boundary. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
417 |
HeapWord* next_boundary = _array->address_for_index(n_index) + |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
418 |
(n_index == next_index ? 0 : N_words); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
419 |
assert(next_boundary <= _array->_end, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
420 |
err_msg("next_boundary is beyond the end of the covered region " |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
421 |
" next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
422 |
next_boundary, _array->_end)); |
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
423 |
if (addr >= gsp()->top()) return gsp()->top(); |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
424 |
while (next_boundary < addr) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
425 |
while (n <= next_boundary) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
426 |
q = n; |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
427 |
oop obj = oop(q); |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
428 |
if (obj->klass_or_null() == NULL) return q; |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
429 |
n += block_size(q); |
1374 | 430 |
} |
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
431 |
assert(q <= next_boundary && n > next_boundary, "Consequence of loop"); |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
432 |
// [q, n) is the block that crosses the boundary. |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
433 |
alloc_block_work2(&next_boundary, &next_index, q, n); |
1374 | 434 |
} |
435 |
return forward_to_block_containing_addr_const(q, n, addr); |
|
436 |
} |
|
437 |
||
438 |
HeapWord* G1BlockOffsetArray::block_start_careful(const void* addr) const { |
|
439 |
assert(_array->offset_array(0) == 0, "objects can't cross covered areas"); |
|
440 |
||
441 |
assert(_bottom <= addr && addr < _end, |
|
442 |
"addr must be covered by this Array"); |
|
443 |
// Must read this exactly once because it can be modified by parallel |
|
444 |
// allocation. |
|
445 |
HeapWord* ub = _unallocated_block; |
|
446 |
if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) { |
|
447 |
assert(ub < _end, "tautology (see above)"); |
|
448 |
return ub; |
|
449 |
} |
|
450 |
||
451 |
// Otherwise, find the block start using the table, but taking |
|
452 |
// care (cf block_start_unsafe() above) not to parse any objects/blocks |
|
22551 | 453 |
// on the cards themselves. |
1374 | 454 |
size_t index = _array->index_for(addr); |
455 |
assert(_array->address_for_index(index) == addr, |
|
456 |
"arg should be start of card"); |
|
457 |
||
458 |
HeapWord* q = (HeapWord*)addr; |
|
459 |
uint offset; |
|
460 |
do { |
|
461 |
offset = _array->offset_array(index--); |
|
462 |
q -= offset; |
|
463 |
} while (offset == N_words); |
|
464 |
assert(q <= addr, "block start should be to left of arg"); |
|
465 |
return q; |
|
466 |
} |
|
467 |
||
468 |
// Note that the committed size of the covered space may have changed, |
|
469 |
// so the table size might also wish to change. |
|
470 |
void G1BlockOffsetArray::resize(size_t new_word_size) { |
|
471 |
HeapWord* new_end = _bottom + new_word_size; |
|
472 |
if (_end < new_end && !init_to_zero()) { |
|
473 |
// verify that the old and new boundaries are also card boundaries |
|
474 |
assert(_array->is_card_boundary(_end), |
|
475 |
"_end not a card boundary"); |
|
476 |
assert(_array->is_card_boundary(new_end), |
|
477 |
"new _end would not be a card boundary"); |
|
478 |
// set all the newly added cards |
|
479 |
_array->set_offset_array(_end, new_end, N_words); |
|
480 |
} |
|
481 |
_end = new_end; // update _end |
|
482 |
} |
|
483 |
||
484 |
void G1BlockOffsetArray::set_region(MemRegion mr) { |
|
485 |
_bottom = mr.start(); |
|
486 |
_end = mr.end(); |
|
487 |
} |
|
488 |
||
489 |
// |
|
490 |
// threshold_ |
|
491 |
// | _index_ |
|
492 |
// v v |
|
493 |
// +-------+-------+-------+-------+-------+ |
|
494 |
// | i-1 | i | i+1 | i+2 | i+3 | |
|
495 |
// +-------+-------+-------+-------+-------+ |
|
496 |
// ( ^ ] |
|
497 |
// block-start |
|
498 |
// |
|
499 |
void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_, |
|
500 |
HeapWord* blk_start, HeapWord* blk_end) { |
|
501 |
// For efficiency, do copy-in/copy-out. |
|
502 |
HeapWord* threshold = *threshold_; |
|
503 |
size_t index = *index_; |
|
504 |
||
505 |
assert(blk_start != NULL && blk_end > blk_start, |
|
506 |
"phantom block"); |
|
507 |
assert(blk_end > threshold, "should be past threshold"); |
|
5402
c51fd0c1d005
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
3262
diff
changeset
|
508 |
assert(blk_start <= threshold, "blk_start should be at or before threshold"); |
1374 | 509 |
assert(pointer_delta(threshold, blk_start) <= N_words, |
510 |
"offset should be <= BlockOffsetSharedArray::N"); |
|
511 |
assert(Universe::heap()->is_in_reserved(blk_start), |
|
512 |
"reference must be into the heap"); |
|
513 |
assert(Universe::heap()->is_in_reserved(blk_end-1), |
|
514 |
"limit must be within the heap"); |
|
515 |
assert(threshold == _array->_reserved.start() + index*N_words, |
|
516 |
"index must agree with threshold"); |
|
517 |
||
518 |
DEBUG_ONLY(size_t orig_index = index;) |
|
519 |
||
520 |
// Mark the card that holds the offset into the block. Note |
|
521 |
// that _next_offset_index and _next_offset_threshold are not |
|
522 |
// updated until the end of this method. |
|
523 |
_array->set_offset_array(index, threshold, blk_start); |
|
524 |
||
525 |
// We need to now mark the subsequent cards that this blk spans. |
|
526 |
||
527 |
// Index of card on which blk ends. |
|
528 |
size_t end_index = _array->index_for(blk_end - 1); |
|
529 |
||
530 |
// Are there more cards left to be updated? |
|
531 |
if (index + 1 <= end_index) { |
|
532 |
HeapWord* rem_st = _array->address_for_index(index + 1); |
|
533 |
// Calculate rem_end this way because end_index |
|
534 |
// may be the last valid index in the covered region. |
|
535 |
HeapWord* rem_end = _array->address_for_index(end_index) + N_words; |
|
536 |
set_remainder_to_point_to_start(rem_st, rem_end); |
|
537 |
} |
|
538 |
||
539 |
index = end_index + 1; |
|
540 |
// Calculate threshold_ this way because end_index |
|
541 |
// may be the last valid index in the covered region. |
|
542 |
threshold = _array->address_for_index(end_index) + N_words; |
|
543 |
assert(threshold >= blk_end, "Incorrect offset threshold"); |
|
544 |
||
545 |
// index_ and threshold_ updated here. |
|
546 |
*threshold_ = threshold; |
|
547 |
*index_ = index; |
|
548 |
||
549 |
#ifdef ASSERT |
|
550 |
// The offset can be 0 if the block starts on a boundary. That |
|
551 |
// is checked by an assertion above. |
|
552 |
size_t start_index = _array->index_for(blk_start); |
|
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
553 |
HeapWord* boundary = _array->address_for_index(start_index); |
1374 | 554 |
assert((_array->offset_array(orig_index) == 0 && |
555 |
blk_start == boundary) || |
|
556 |
(_array->offset_array(orig_index) > 0 && |
|
557 |
_array->offset_array(orig_index) <= N_words), |
|
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
558 |
err_msg("offset array should have been set - " |
23858
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
559 |
"orig_index offset: %u, " |
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
560 |
"blk_start: " PTR_FORMAT ", " |
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
561 |
"boundary: " PTR_FORMAT, |
23858
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
562 |
(uint)_array->offset_array(orig_index), |
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
563 |
blk_start, boundary)); |
1374 | 564 |
for (size_t j = orig_index + 1; j <= end_index; j++) { |
565 |
assert(_array->offset_array(j) > 0 && |
|
566 |
_array->offset_array(j) <= |
|
567 |
(u_char) (N_words+BlockOffsetArray::N_powers-1), |
|
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
568 |
err_msg("offset array should have been set - " |
23858
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
569 |
"%u not > 0 OR %u not <= %u", |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
570 |
(uint) _array->offset_array(j), |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
571 |
(uint) _array->offset_array(j), |
dae377f5a7c7
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents:
22551
diff
changeset
|
572 |
(uint) (N_words+BlockOffsetArray::N_powers-1))); |
1374 | 573 |
} |
574 |
#endif |
|
575 |
} |
|
576 |
||
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
577 |
bool |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
578 |
G1BlockOffsetArray::verify_for_object(HeapWord* obj_start, |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
579 |
size_t word_size) const { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
580 |
size_t first_card = _array->index_for(obj_start); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
581 |
size_t last_card = _array->index_for(obj_start + word_size - 1); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
582 |
if (!_array->is_card_boundary(obj_start)) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
583 |
// If the object is not on a card boundary the BOT entry of the |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
584 |
// first card should point to another object so we should not |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
585 |
// check that one. |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
586 |
first_card += 1; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
587 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
588 |
for (size_t card = first_card; card <= last_card; card += 1) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
589 |
HeapWord* card_addr = _array->address_for_index(card); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
590 |
HeapWord* block_start = block_start_const(card_addr); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
591 |
if (block_start != obj_start) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
592 |
gclog_or_tty->print_cr("block start: "PTR_FORMAT" is incorrect - " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
593 |
"card index: "SIZE_FORMAT" " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
594 |
"card addr: "PTR_FORMAT" BOT entry: %u " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
595 |
"obj: "PTR_FORMAT" word size: "SIZE_FORMAT" " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
596 |
"cards: ["SIZE_FORMAT","SIZE_FORMAT"]", |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
597 |
block_start, card, card_addr, |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
598 |
_array->offset_array(card), |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
599 |
obj_start, word_size, first_card, last_card); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
600 |
return false; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
601 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
602 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
603 |
return true; |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
604 |
} |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
605 |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
606 |
#ifndef PRODUCT |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
607 |
void |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
608 |
G1BlockOffsetArray::print_on(outputStream* out) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
609 |
size_t from_index = _array->index_for(_bottom); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
610 |
size_t to_index = _array->index_for(_end); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
611 |
out->print_cr(">> BOT for area ["PTR_FORMAT","PTR_FORMAT") " |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
612 |
"cards ["SIZE_FORMAT","SIZE_FORMAT")", |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
613 |
_bottom, _end, from_index, to_index); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
614 |
for (size_t i = from_index; i < to_index; ++i) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
615 |
out->print_cr(" entry "SIZE_FORMAT_W(8)" | "PTR_FORMAT" : %3u", |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
616 |
i, _array->address_for_index(i), |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
617 |
(uint) _array->offset_array(i)); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
618 |
} |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
619 |
} |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
620 |
#endif // !PRODUCT |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
621 |
|
1374 | 622 |
////////////////////////////////////////////////////////////////////// |
623 |
// G1BlockOffsetArrayContigSpace |
|
624 |
////////////////////////////////////////////////////////////////////// |
|
625 |
||
626 |
HeapWord* |
|
627 |
G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) { |
|
628 |
assert(_bottom <= addr && addr < _end, |
|
629 |
"addr must be covered by this Array"); |
|
630 |
HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1); |
|
631 |
return forward_to_block_containing_addr(q, addr); |
|
632 |
} |
|
633 |
||
634 |
HeapWord* |
|
635 |
G1BlockOffsetArrayContigSpace:: |
|
636 |
block_start_unsafe_const(const void* addr) const { |
|
637 |
assert(_bottom <= addr && addr < _end, |
|
638 |
"addr must be covered by this Array"); |
|
639 |
HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1); |
|
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
640 |
HeapWord* n = q + block_size(q); |
1374 | 641 |
return forward_to_block_containing_addr_const(q, n, addr); |
642 |
} |
|
643 |
||
644 |
G1BlockOffsetArrayContigSpace:: |
|
645 |
G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, |
|
646 |
MemRegion mr) : |
|
647 |
G1BlockOffsetArray(array, mr, true) |
|
648 |
{ |
|
649 |
_next_offset_threshold = NULL; |
|
650 |
_next_offset_index = 0; |
|
651 |
} |
|
652 |
||
653 |
HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() { |
|
654 |
assert(!Universe::heap()->is_in_reserved(_array->_offset_array), |
|
655 |
"just checking"); |
|
656 |
_next_offset_index = _array->index_for(_bottom); |
|
657 |
_next_offset_index++; |
|
658 |
_next_offset_threshold = |
|
659 |
_array->address_for_index(_next_offset_index); |
|
660 |
return _next_offset_threshold; |
|
661 |
} |
|
662 |
||
663 |
void G1BlockOffsetArrayContigSpace::zero_bottom_entry() { |
|
664 |
assert(!Universe::heap()->is_in_reserved(_array->_offset_array), |
|
665 |
"just checking"); |
|
666 |
size_t bottom_index = _array->index_for(_bottom); |
|
667 |
assert(_array->address_for_index(bottom_index) == _bottom, |
|
668 |
"Precondition of call"); |
|
669 |
_array->set_offset_array(bottom_index, 0); |
|
670 |
} |
|
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
671 |
|
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
672 |
void |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
673 |
G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_top) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
674 |
assert(new_top <= _end, "_end should have already been updated"); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
675 |
|
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
676 |
// The first BOT entry should have offset 0. |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
677 |
zero_bottom_entry(); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
678 |
initialize_threshold(); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
679 |
alloc_block(_bottom, new_top); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
680 |
} |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
681 |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
682 |
#ifndef PRODUCT |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
683 |
void |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
684 |
G1BlockOffsetArrayContigSpace::print_on(outputStream* out) { |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
685 |
G1BlockOffsetArray::print_on(out); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
686 |
out->print_cr(" next offset threshold: "PTR_FORMAT, _next_offset_threshold); |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
687 |
out->print_cr(" next offset index: "SIZE_FORMAT, _next_offset_index); |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
688 |
} |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
689 |
#endif // !PRODUCT |