author | kbarrett |
Tue, 12 Jun 2018 18:12:59 -0400 | |
changeset 50532 | a18c60527166 |
parent 47216 | 71c04702a3d5 |
child 51332 | c25572739e7c |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
46286
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
2 |
* Copyright (c) 2001, 2017, 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" |
30764 | 26 |
#include "gc/g1/g1BlockOffsetTable.inline.hpp" |
27 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
|
28 |
#include "gc/g1/heapRegion.hpp" |
|
29 |
#include "gc/shared/space.hpp" |
|
35061 | 30 |
#include "logging/log.hpp" |
7397 | 31 |
#include "oops/oop.inline.hpp" |
32 |
#include "runtime/java.hpp" |
|
13195 | 33 |
#include "services/memTracker.hpp" |
1374 | 34 |
|
26313
9baebbfc62dd
8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents:
26160
diff
changeset
|
35 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23858
diff
changeset
|
36 |
|
1374 | 37 |
////////////////////////////////////////////////////////////////////// |
35461 | 38 |
// G1BlockOffsetTable |
1374 | 39 |
////////////////////////////////////////////////////////////////////// |
40 |
||
35461 | 41 |
G1BlockOffsetTable::G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage) : |
42 |
_reserved(heap), _offset_array(NULL) { |
|
13195 | 43 |
|
26160 | 44 |
MemRegion bot_reserved = storage->reserved(); |
13195 | 45 |
|
26160 | 46 |
_offset_array = (u_char*)bot_reserved.start(); |
47 |
||
35461 | 48 |
log_trace(gc, bot)("G1BlockOffsetTable::G1BlockOffsetTable: "); |
35061 | 49 |
log_trace(gc, bot)(" rs.base(): " PTR_FORMAT " rs.size(): " SIZE_FORMAT " rs end(): " PTR_FORMAT, |
50 |
p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end())); |
|
1374 | 51 |
} |
52 |
||
35461 | 53 |
bool G1BlockOffsetTable::is_card_boundary(HeapWord* p) const { |
1374 | 54 |
assert(p >= _reserved.start(), "just checking"); |
55 |
size_t delta = pointer_delta(p, _reserved.start()); |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
56 |
return (delta & right_n_bits((int)BOTConstants::LogN_words)) == (size_t)NoBits; |
1374 | 57 |
} |
58 |
||
30583
74ff3d21d616
8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents:
30173
diff
changeset
|
59 |
#ifdef ASSERT |
35461 | 60 |
void G1BlockOffsetTable::check_index(size_t index, const char* msg) const { |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
61 |
assert((index) < (_reserved.word_size() >> BOTConstants::LogN_words), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
62 |
"%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT, |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
63 |
msg, (index), (_reserved.word_size() >> BOTConstants::LogN_words)); |
30583
74ff3d21d616
8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents:
30173
diff
changeset
|
64 |
assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
65 |
"Index " SIZE_FORMAT " corresponding to " PTR_FORMAT |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
66 |
" (%u) is not in committed area.", |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
67 |
(index), |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
68 |
p2i(address_for_index_raw(index)), |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
69 |
G1CollectedHeap::heap()->addr_to_region(address_for_index_raw(index))); |
30583
74ff3d21d616
8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents:
30173
diff
changeset
|
70 |
} |
74ff3d21d616
8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents:
30173
diff
changeset
|
71 |
#endif // ASSERT |
74ff3d21d616
8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents:
30173
diff
changeset
|
72 |
|
1374 | 73 |
////////////////////////////////////////////////////////////////////// |
35461 | 74 |
// G1BlockOffsetTablePart |
1374 | 75 |
////////////////////////////////////////////////////////////////////// |
76 |
||
35461 | 77 |
G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, G1ContiguousSpace* gsp) : |
78 |
_bot(array), |
|
79 |
_space(gsp), |
|
80 |
_next_offset_threshold(NULL), |
|
81 |
_next_offset_index(0) |
|
46286
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
82 |
{ |
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
83 |
debug_only(_object_can_span = false;) |
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
84 |
} |
1374 | 85 |
|
86 |
// The arguments follow the normal convention of denoting |
|
87 |
// a right-open interval: [start, end) |
|
35461 | 88 |
void G1BlockOffsetTablePart:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) { |
1374 | 89 |
|
90 |
if (start >= end) { |
|
91 |
// The start address is equal to the end address (or to |
|
92 |
// the right of the end address) so there are not cards |
|
93 |
// that need to be updated.. |
|
94 |
return; |
|
95 |
} |
|
96 |
||
97 |
// Write the backskip value for each region. |
|
98 |
// |
|
99 |
// offset |
|
100 |
// card 2nd 3rd |
|
101 |
// | +- 1st | | |
|
102 |
// v v v v |
|
103 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+- |
|
104 |
// |x|0|0|0|0|0|0|0|1|1|1|1|1|1| ... |1|1|1|1|2|2|2|2|2|2| ... |
|
105 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+- |
|
106 |
// 11 19 75 |
|
107 |
// 12 |
|
108 |
// |
|
109 |
// offset card is the card that points to the start of an object |
|
110 |
// x - offset value of offset card |
|
111 |
// 1st - start of first logarithmic region |
|
112 |
// 0 corresponds to logarithmic value N_words + 0 and 2**(3 * 0) = 1 |
|
113 |
// 2nd - start of second logarithmic region |
|
114 |
// 1 corresponds to logarithmic value N_words + 1 and 2**(3 * 1) = 8 |
|
115 |
// 3rd - start of third logarithmic region |
|
116 |
// 2 corresponds to logarithmic value N_words + 2 and 2**(3 * 2) = 64 |
|
117 |
// |
|
118 |
// integer below the block offset entry is an example of |
|
119 |
// the index of the entry |
|
120 |
// |
|
121 |
// Given an address, |
|
122 |
// Find the index for the address |
|
123 |
// Find the block offset table entry |
|
124 |
// Convert the entry to a back slide |
|
125 |
// (e.g., with today's, offset = 0x81 => |
|
126 |
// back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8 |
|
127 |
// Move back N (e.g., 8) entries and repeat with the |
|
128 |
// value of the new entry |
|
129 |
// |
|
35461 | 130 |
size_t start_card = _bot->index_for(start); |
131 |
size_t end_card = _bot->index_for(end-1); |
|
132 |
assert(start ==_bot->address_for_index(start_card), "Precondition"); |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
133 |
assert(end ==_bot->address_for_index(end_card)+BOTConstants::N_words, "Precondition"); |
1374 | 134 |
set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval |
135 |
} |
|
136 |
||
137 |
// Unlike the normal convention in this code, the argument here denotes |
|
138 |
// a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start() |
|
139 |
// above. |
|
35461 | 140 |
void G1BlockOffsetTablePart::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) { |
1374 | 141 |
if (start_card > end_card) { |
142 |
return; |
|
143 |
} |
|
35461 | 144 |
assert(start_card > _bot->index_for(_space->bottom()), "Cannot be first card"); |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
145 |
assert(_bot->offset_array(start_card-1) <= BOTConstants::N_words, |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
146 |
"Offset card has an unexpected value"); |
1374 | 147 |
size_t start_card_for_region = start_card; |
148 |
u_char offset = max_jubyte; |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
149 |
for (uint i = 0; i < BOTConstants::N_powers; i++) { |
1374 | 150 |
// -1 so that the the card with the actual offset is counted. Another -1 |
151 |
// so that the reach ends in this region and not at the start |
|
152 |
// of the next. |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
153 |
size_t reach = start_card - 1 + (BOTConstants::power_to_cards_back(i+1) - 1); |
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
154 |
offset = BOTConstants::N_words + i; |
1374 | 155 |
if (reach >= end_card) { |
35461 | 156 |
_bot->set_offset_array(start_card_for_region, end_card, offset); |
1374 | 157 |
start_card_for_region = reach + 1; |
158 |
break; |
|
159 |
} |
|
35461 | 160 |
_bot->set_offset_array(start_card_for_region, reach, offset); |
1374 | 161 |
start_card_for_region = reach + 1; |
162 |
} |
|
163 |
assert(start_card_for_region > end_card, "Sanity check"); |
|
164 |
DEBUG_ONLY(check_all_cards(start_card, end_card);) |
|
165 |
} |
|
166 |
||
167 |
// The card-interval [start_card, end_card] is a closed interval; this |
|
168 |
// is an expensive check -- use with care and only under protection of |
|
169 |
// suitable flag. |
|
35461 | 170 |
void G1BlockOffsetTablePart::check_all_cards(size_t start_card, size_t end_card) const { |
1374 | 171 |
|
172 |
if (end_card < start_card) { |
|
173 |
return; |
|
174 |
} |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
175 |
guarantee(_bot->offset_array(start_card) == BOTConstants::N_words, "Wrong value in second card"); |
1374 | 176 |
for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) { |
35461 | 177 |
u_char entry = _bot->offset_array(c); |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
178 |
if (c - start_card > BOTConstants::power_to_cards_back(1)) { |
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
179 |
guarantee(entry > BOTConstants::N_words, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
180 |
"Should be in logarithmic region - " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
181 |
"entry: %u, " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
182 |
"_array->offset_array(c): %u, " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
183 |
"N_words: %u", |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
184 |
(uint)entry, (uint)_bot->offset_array(c), BOTConstants::N_words); |
1374 | 185 |
} |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
186 |
size_t backskip = BOTConstants::entry_to_cards_back(entry); |
1374 | 187 |
size_t landing_card = c - backskip; |
188 |
guarantee(landing_card >= (start_card - 1), "Inv"); |
|
189 |
if (landing_card >= start_card) { |
|
35461 | 190 |
guarantee(_bot->offset_array(landing_card) <= entry, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
191 |
"Monotonicity - landing_card offset: %u, " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
192 |
"entry: %u", |
35461 | 193 |
(uint)_bot->offset_array(landing_card), (uint)entry); |
1374 | 194 |
} else { |
195 |
guarantee(landing_card == start_card - 1, "Tautology"); |
|
14584
bd4290e6d0a5
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
13728
diff
changeset
|
196 |
// Note that N_words is the maximum offset value |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
197 |
guarantee(_bot->offset_array(landing_card) <= BOTConstants::N_words, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
198 |
"landing card offset: %u, " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
199 |
"N_words: %u", |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
200 |
(uint)_bot->offset_array(landing_card), (uint)BOTConstants::N_words); |
1374 | 201 |
} |
202 |
} |
|
203 |
} |
|
204 |
||
35461 | 205 |
HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_slow(HeapWord* q, |
206 |
HeapWord* n, |
|
207 |
const void* addr) { |
|
1374 | 208 |
// We're not in the normal case. We need to handle an important subcase |
209 |
// here: LAB allocation. An allocation previously recorded in the |
|
210 |
// offset table was actually a lab allocation, and was divided into |
|
211 |
// several objects subsequently. Fix this situation as we answer the |
|
212 |
// 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
|
213 |
|
163a4d4fa951
6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents:
1374
diff
changeset
|
214 |
// 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
|
215 |
// 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
|
216 |
// set to 0). If the object crosses the boundary -- start from the next card. |
35461 | 217 |
size_t n_index = _bot->index_for(n); |
218 |
size_t next_index = _bot->index_for(n) + !_bot->is_card_boundary(n); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
219 |
// 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
|
220 |
// already, step to the boundary. |
35461 | 221 |
HeapWord* next_boundary = _bot->address_for_index(n_index) + |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
222 |
(n_index == next_index ? 0 : BOTConstants::N_words); |
35461 | 223 |
assert(next_boundary <= _bot->_reserved.end(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
224 |
"next_boundary is beyond the end of the covered region " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
225 |
" next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT, |
35461 | 226 |
p2i(next_boundary), p2i(_bot->_reserved.end())); |
227 |
if (addr >= _space->top()) return _space->top(); |
|
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
228 |
while (next_boundary < addr) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
229 |
while (n <= next_boundary) { |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
230 |
q = n; |
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
231 |
oop obj = oop(q); |
42588 | 232 |
if (obj->klass_or_null_acquire() == NULL) return q; |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
233 |
n += block_size(q); |
1374 | 234 |
} |
25361
5146d1e12a2f
8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents:
24424
diff
changeset
|
235 |
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
|
236 |
// [q, n) is the block that crosses the boundary. |
35461 | 237 |
alloc_block_work(&next_boundary, &next_index, q, n); |
1374 | 238 |
} |
239 |
return forward_to_block_containing_addr_const(q, n, addr); |
|
240 |
} |
|
241 |
||
242 |
// |
|
243 |
// threshold_ |
|
244 |
// | _index_ |
|
245 |
// v v |
|
246 |
// +-------+-------+-------+-------+-------+ |
|
247 |
// | i-1 | i | i+1 | i+2 | i+3 | |
|
248 |
// +-------+-------+-------+-------+-------+ |
|
249 |
// ( ^ ] |
|
250 |
// block-start |
|
251 |
// |
|
35461 | 252 |
void G1BlockOffsetTablePart::alloc_block_work(HeapWord** threshold_, size_t* index_, |
253 |
HeapWord* blk_start, HeapWord* blk_end) { |
|
1374 | 254 |
// For efficiency, do copy-in/copy-out. |
255 |
HeapWord* threshold = *threshold_; |
|
256 |
size_t index = *index_; |
|
257 |
||
258 |
assert(blk_start != NULL && blk_end > blk_start, |
|
259 |
"phantom block"); |
|
260 |
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
|
261 |
assert(blk_start <= threshold, "blk_start should be at or before threshold"); |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
262 |
assert(pointer_delta(threshold, blk_start) <= BOTConstants::N_words, |
1374 | 263 |
"offset should be <= BlockOffsetSharedArray::N"); |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
26572
diff
changeset
|
264 |
assert(G1CollectedHeap::heap()->is_in_reserved(blk_start), |
1374 | 265 |
"reference must be into the heap"); |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
26572
diff
changeset
|
266 |
assert(G1CollectedHeap::heap()->is_in_reserved(blk_end-1), |
1374 | 267 |
"limit must be within the heap"); |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
268 |
assert(threshold == _bot->_reserved.start() + index*BOTConstants::N_words, |
1374 | 269 |
"index must agree with threshold"); |
270 |
||
271 |
DEBUG_ONLY(size_t orig_index = index;) |
|
272 |
||
273 |
// Mark the card that holds the offset into the block. Note |
|
274 |
// that _next_offset_index and _next_offset_threshold are not |
|
275 |
// updated until the end of this method. |
|
35461 | 276 |
_bot->set_offset_array(index, threshold, blk_start); |
1374 | 277 |
|
278 |
// We need to now mark the subsequent cards that this blk spans. |
|
279 |
||
280 |
// Index of card on which blk ends. |
|
35461 | 281 |
size_t end_index = _bot->index_for(blk_end - 1); |
1374 | 282 |
|
283 |
// Are there more cards left to be updated? |
|
284 |
if (index + 1 <= end_index) { |
|
35461 | 285 |
HeapWord* rem_st = _bot->address_for_index(index + 1); |
1374 | 286 |
// Calculate rem_end this way because end_index |
287 |
// may be the last valid index in the covered region. |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
288 |
HeapWord* rem_end = _bot->address_for_index(end_index) + BOTConstants::N_words; |
1374 | 289 |
set_remainder_to_point_to_start(rem_st, rem_end); |
290 |
} |
|
291 |
||
292 |
index = end_index + 1; |
|
293 |
// Calculate threshold_ this way because end_index |
|
294 |
// may be the last valid index in the covered region. |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
295 |
threshold = _bot->address_for_index(end_index) + BOTConstants::N_words; |
1374 | 296 |
assert(threshold >= blk_end, "Incorrect offset threshold"); |
297 |
||
298 |
// index_ and threshold_ updated here. |
|
299 |
*threshold_ = threshold; |
|
300 |
*index_ = index; |
|
301 |
||
302 |
#ifdef ASSERT |
|
303 |
// The offset can be 0 if the block starts on a boundary. That |
|
304 |
// is checked by an assertion above. |
|
35461 | 305 |
size_t start_index = _bot->index_for(blk_start); |
306 |
HeapWord* boundary = _bot->address_for_index(start_index); |
|
307 |
assert((_bot->offset_array(orig_index) == 0 && blk_start == boundary) || |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
308 |
(_bot->offset_array(orig_index) > 0 && _bot->offset_array(orig_index) <= BOTConstants::N_words), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
309 |
"offset array should have been set - " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
310 |
"orig_index offset: %u, " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
311 |
"blk_start: " PTR_FORMAT ", " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
312 |
"boundary: " PTR_FORMAT, |
35461 | 313 |
(uint)_bot->offset_array(orig_index), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
314 |
p2i(blk_start), p2i(boundary)); |
1374 | 315 |
for (size_t j = orig_index + 1; j <= end_index; j++) { |
35461 | 316 |
assert(_bot->offset_array(j) > 0 && |
317 |
_bot->offset_array(j) <= |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
318 |
(u_char) (BOTConstants::N_words+BOTConstants::N_powers-1), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
319 |
"offset array should have been set - " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
320 |
"%u not > 0 OR %u not <= %u", |
35461 | 321 |
(uint) _bot->offset_array(j), |
322 |
(uint) _bot->offset_array(j), |
|
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
323 |
(uint) (BOTConstants::N_words+BOTConstants::N_powers-1)); |
1374 | 324 |
} |
325 |
#endif |
|
326 |
} |
|
327 |
||
35461 | 328 |
void G1BlockOffsetTablePart::verify() const { |
329 |
assert(_space->bottom() < _space->top(), "Only non-empty regions should be verified."); |
|
330 |
size_t start_card = _bot->index_for(_space->bottom()); |
|
331 |
size_t end_card = _bot->index_for(_space->top() - 1); |
|
26571
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
332 |
|
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
333 |
for (size_t current_card = start_card; current_card < end_card; current_card++) { |
35461 | 334 |
u_char entry = _bot->offset_array(current_card); |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
335 |
if (entry < BOTConstants::N_words) { |
26571
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
336 |
// The entry should point to an object before the current card. Verify that |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
337 |
// it is possible to walk from that object in to the current card by just |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
338 |
// iterating over the objects following it. |
35461 | 339 |
HeapWord* card_address = _bot->address_for_index(current_card); |
26571
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
340 |
HeapWord* obj_end = card_address - entry; |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
341 |
while (obj_end < card_address) { |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
342 |
HeapWord* obj = obj_end; |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
343 |
size_t obj_size = block_size(obj); |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
344 |
obj_end = obj + obj_size; |
35461 | 345 |
guarantee(obj_end > obj && obj_end <= _space->top(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
346 |
"Invalid object end. obj: " PTR_FORMAT " obj_size: " SIZE_FORMAT " obj_end: " PTR_FORMAT " top: " PTR_FORMAT, |
35461 | 347 |
p2i(obj), obj_size, p2i(obj_end), p2i(_space->top())); |
26571
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
348 |
} |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
349 |
} else { |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
350 |
// Because we refine the BOT based on which cards are dirty there is not much we can verify here. |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
351 |
// We need to make sure that we are going backwards and that we don't pass the start of the |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
352 |
// corresponding heap region. But that is about all we can verify. |
35469
17ea1b453dd5
8146694: Break out shared constants and static BOT functions.
david
parents:
35461
diff
changeset
|
353 |
size_t backskip = BOTConstants::entry_to_cards_back(entry); |
26571
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
354 |
guarantee(backskip >= 1, "Must be going back at least one card."); |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
355 |
|
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
356 |
size_t max_backskip = current_card - start_card; |
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
357 |
guarantee(backskip <= max_backskip, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
358 |
"Going backwards beyond the start_card. start_card: " SIZE_FORMAT " current_card: " SIZE_FORMAT " backskip: " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
359 |
start_card, current_card, backskip); |
26571
5fe42815e865
8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents:
26322
diff
changeset
|
360 |
|
35461 | 361 |
HeapWord* backskip_address = _bot->address_for_index(current_card - backskip); |
362 |
guarantee(backskip_address >= _space->bottom(), |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31592
diff
changeset
|
363 |
"Going backwards beyond bottom of the region: bottom: " PTR_FORMAT ", backskip_address: " PTR_FORMAT, |
35461 | 364 |
p2i(_space->bottom()), p2i(backskip_address)); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
365 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
366 |
} |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
367 |
} |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
368 |
|
46286
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
369 |
#ifdef ASSERT |
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
370 |
void G1BlockOffsetTablePart::set_object_can_span(bool can_span) { |
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
371 |
_object_can_span = can_span; |
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
372 |
} |
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
373 |
#endif |
c112671e114e
8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents:
42588
diff
changeset
|
374 |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
375 |
#ifndef PRODUCT |
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
376 |
void |
35461 | 377 |
G1BlockOffsetTablePart::print_on(outputStream* out) { |
378 |
size_t from_index = _bot->index_for(_space->bottom()); |
|
379 |
size_t to_index = _bot->index_for(_space->end()); |
|
31592
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
30764
diff
changeset
|
380 |
out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") " |
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
30764
diff
changeset
|
381 |
"cards [" SIZE_FORMAT "," SIZE_FORMAT ")", |
35461 | 382 |
p2i(_space->bottom()), p2i(_space->end()), from_index, to_index); |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
383 |
for (size_t i = from_index; i < to_index; ++i) { |
31592
43f48e165466
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents:
30764
diff
changeset
|
384 |
out->print_cr(" entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u", |
35461 | 385 |
i, p2i(_bot->address_for_index(i)), |
386 |
(uint) _bot->offset_array(i)); |
|
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
387 |
} |
35461 | 388 |
out->print_cr(" next offset threshold: " PTR_FORMAT, p2i(_next_offset_threshold)); |
389 |
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
|
390 |
} |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
391 |
#endif // !PRODUCT |
6983
a8c50cedbce9
6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents:
5547
diff
changeset
|
392 |
|
35461 | 393 |
HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() { |
394 |
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array), |
|
26160 | 395 |
"just checking"); |
35461 | 396 |
_next_offset_index = _bot->index_for_raw(_space->bottom()); |
26160 | 397 |
_next_offset_index++; |
398 |
_next_offset_threshold = |
|
35461 | 399 |
_bot->address_for_index_raw(_next_offset_index); |
26160 | 400 |
return _next_offset_threshold; |
401 |
} |
|
402 |
||
35461 | 403 |
void G1BlockOffsetTablePart::zero_bottom_entry_raw() { |
404 |
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array), |
|
26160 | 405 |
"just checking"); |
35461 | 406 |
size_t bottom_index = _bot->index_for_raw(_space->bottom()); |
407 |
assert(_bot->address_for_index_raw(bottom_index) == _space->bottom(), |
|
26160 | 408 |
"Precondition of call"); |
35461 | 409 |
_bot->set_offset_array_raw(bottom_index, 0); |
26160 | 410 |
} |
411 |
||
35461 | 412 |
HeapWord* G1BlockOffsetTablePart::initialize_threshold() { |
413 |
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array), |
|
1374 | 414 |
"just checking"); |
35461 | 415 |
_next_offset_index = _bot->index_for(_space->bottom()); |
1374 | 416 |
_next_offset_index++; |
417 |
_next_offset_threshold = |
|
35461 | 418 |
_bot->address_for_index(_next_offset_index); |
1374 | 419 |
return _next_offset_threshold; |
420 |
} |
|
421 |
||
35461 | 422 |
void G1BlockOffsetTablePart::set_for_starts_humongous(HeapWord* obj_top, size_t fill_size) { |
7904
e90e097fced4
7007068: G1: refine the BOT during evac failure handling
tonyp
parents:
7397
diff
changeset
|
423 |
// The first BOT entry should have offset 0. |
26157
70eddb655686
8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents:
25492
diff
changeset
|
424 |
reset_bot(); |
35461 | 425 |
alloc_block(_space->bottom(), obj_top); |
34249
a015a11067a2
8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents:
33786
diff
changeset
|
426 |
if (fill_size > 0) { |
a015a11067a2
8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents:
33786
diff
changeset
|
427 |
alloc_block(obj_top, fill_size); |
a015a11067a2
8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents:
33786
diff
changeset
|
428 |
} |
a015a11067a2
8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents:
33786
diff
changeset
|
429 |
} |