src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp

Thu, 14 Jun 2018 09:15:08 -0700

author
kevinw
date
Thu, 14 Jun 2018 09:15:08 -0700
changeset 9327
f96fcd9e1e1b
parent 7256
0fcaab91d485
child 9448
73d689add964
child 9697
cfe3264deba4
permissions
-rw-r--r--

8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
Summary: Need to add a space between macro identifier and string literal
Reviewed-by: bpittore, stefank, dholmes, kbarrett

ysr@777 1 /*
drchase@6680 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
mgerdin@6987 27 #include "gc_implementation/g1/heapRegion.hpp"
stefank@2314 28 #include "memory/space.hpp"
stefank@2314 29 #include "oops/oop.inline.hpp"
stefank@2314 30 #include "runtime/java.hpp"
zgu@3900 31 #include "services/memTracker.hpp"
ysr@777 32
drchase@6680 33 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
drchase@6680 34
ysr@777 35 //////////////////////////////////////////////////////////////////////
ysr@777 36 // G1BlockOffsetSharedArray
ysr@777 37 //////////////////////////////////////////////////////////////////////
ysr@777 38
tschatzl@7051 39 G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage) :
tschatzl@7051 40 _reserved(), _end(NULL), _listener(), _offset_array(NULL) {
zgu@3900 41
tschatzl@7051 42 _reserved = heap;
tschatzl@7051 43 _end = NULL;
zgu@3900 44
tschatzl@7051 45 MemRegion bot_reserved = storage->reserved();
tschatzl@7051 46
tschatzl@7051 47 _offset_array = (u_char*)bot_reserved.start();
tschatzl@7051 48 _end = _reserved.end();
tschatzl@7051 49
tschatzl@7051 50 storage->set_mapping_changed_listener(&_listener);
tschatzl@7051 51
ysr@777 52 if (TraceBlockOffsetTable) {
ysr@777 53 gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
ysr@777 54 gclog_or_tty->print_cr(" "
ysr@777 55 " rs.base(): " INTPTR_FORMAT
ysr@777 56 " rs.size(): " INTPTR_FORMAT
ysr@777 57 " rs end(): " INTPTR_FORMAT,
tschatzl@7051 58 bot_reserved.start(), bot_reserved.byte_size(), bot_reserved.end());
ysr@777 59 }
ysr@777 60 }
ysr@777 61
ysr@777 62 bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
ysr@777 63 assert(p >= _reserved.start(), "just checking");
ysr@777 64 size_t delta = pointer_delta(p, _reserved.start());
ysr@777 65 return (delta & right_n_bits(LogN_words)) == (size_t)NoBits;
ysr@777 66 }
ysr@777 67
ysr@777 68 //////////////////////////////////////////////////////////////////////
ysr@777 69 // G1BlockOffsetArray
ysr@777 70 //////////////////////////////////////////////////////////////////////
ysr@777 71
ysr@777 72 G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array,
brutisso@7256 73 MemRegion mr) :
ysr@777 74 G1BlockOffsetTable(mr.start(), mr.end()),
ysr@777 75 _unallocated_block(_bottom),
brutisso@7256 76 _array(array), _gsp(NULL) {
ysr@777 77 assert(_bottom <= _end, "arguments out of order");
ysr@777 78 }
ysr@777 79
mgerdin@6987 80 void G1BlockOffsetArray::set_space(G1OffsetTableContigSpace* sp) {
mgerdin@6987 81 _gsp = sp;
ysr@777 82 }
ysr@777 83
ysr@777 84 // The arguments follow the normal convention of denoting
ysr@777 85 // a right-open interval: [start, end)
ysr@777 86 void
ysr@777 87 G1BlockOffsetArray:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) {
ysr@777 88
ysr@777 89 if (start >= end) {
ysr@777 90 // The start address is equal to the end address (or to
ysr@777 91 // the right of the end address) so there are not cards
ysr@777 92 // that need to be updated..
ysr@777 93 return;
ysr@777 94 }
ysr@777 95
ysr@777 96 // Write the backskip value for each region.
ysr@777 97 //
ysr@777 98 // offset
ysr@777 99 // card 2nd 3rd
ysr@777 100 // | +- 1st | |
ysr@777 101 // v v v v
ysr@777 102 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
ysr@777 103 // |x|0|0|0|0|0|0|0|1|1|1|1|1|1| ... |1|1|1|1|2|2|2|2|2|2| ...
ysr@777 104 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
ysr@777 105 // 11 19 75
ysr@777 106 // 12
ysr@777 107 //
ysr@777 108 // offset card is the card that points to the start of an object
ysr@777 109 // x - offset value of offset card
ysr@777 110 // 1st - start of first logarithmic region
ysr@777 111 // 0 corresponds to logarithmic value N_words + 0 and 2**(3 * 0) = 1
ysr@777 112 // 2nd - start of second logarithmic region
ysr@777 113 // 1 corresponds to logarithmic value N_words + 1 and 2**(3 * 1) = 8
ysr@777 114 // 3rd - start of third logarithmic region
ysr@777 115 // 2 corresponds to logarithmic value N_words + 2 and 2**(3 * 2) = 64
ysr@777 116 //
ysr@777 117 // integer below the block offset entry is an example of
ysr@777 118 // the index of the entry
ysr@777 119 //
ysr@777 120 // Given an address,
ysr@777 121 // Find the index for the address
ysr@777 122 // Find the block offset table entry
ysr@777 123 // Convert the entry to a back slide
ysr@777 124 // (e.g., with today's, offset = 0x81 =>
ysr@777 125 // back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8
ysr@777 126 // Move back N (e.g., 8) entries and repeat with the
ysr@777 127 // value of the new entry
ysr@777 128 //
ysr@777 129 size_t start_card = _array->index_for(start);
ysr@777 130 size_t end_card = _array->index_for(end-1);
ysr@777 131 assert(start ==_array->address_for_index(start_card), "Precondition");
ysr@777 132 assert(end ==_array->address_for_index(end_card)+N_words, "Precondition");
ysr@777 133 set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval
ysr@777 134 }
ysr@777 135
ysr@777 136 // Unlike the normal convention in this code, the argument here denotes
ysr@777 137 // a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start()
ysr@777 138 // above.
ysr@777 139 void
ysr@777 140 G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) {
ysr@777 141 if (start_card > end_card) {
ysr@777 142 return;
ysr@777 143 }
ysr@777 144 assert(start_card > _array->index_for(_bottom), "Cannot be first card");
ysr@777 145 assert(_array->offset_array(start_card-1) <= N_words,
tonyp@2241 146 "Offset card has an unexpected value");
ysr@777 147 size_t start_card_for_region = start_card;
ysr@777 148 u_char offset = max_jubyte;
ysr@777 149 for (int i = 0; i < BlockOffsetArray::N_powers; i++) {
ysr@777 150 // -1 so that the the card with the actual offset is counted. Another -1
ysr@777 151 // so that the reach ends in this region and not at the start
ysr@777 152 // of the next.
ysr@777 153 size_t reach = start_card - 1 + (BlockOffsetArray::power_to_cards_back(i+1) - 1);
ysr@777 154 offset = N_words + i;
ysr@777 155 if (reach >= end_card) {
ysr@777 156 _array->set_offset_array(start_card_for_region, end_card, offset);
ysr@777 157 start_card_for_region = reach + 1;
ysr@777 158 break;
ysr@777 159 }
ysr@777 160 _array->set_offset_array(start_card_for_region, reach, offset);
ysr@777 161 start_card_for_region = reach + 1;
ysr@777 162 }
ysr@777 163 assert(start_card_for_region > end_card, "Sanity check");
ysr@777 164 DEBUG_ONLY(check_all_cards(start_card, end_card);)
ysr@777 165 }
ysr@777 166
ysr@777 167 // The card-interval [start_card, end_card] is a closed interval; this
ysr@777 168 // is an expensive check -- use with care and only under protection of
ysr@777 169 // suitable flag.
ysr@777 170 void G1BlockOffsetArray::check_all_cards(size_t start_card, size_t end_card) const {
ysr@777 171
ysr@777 172 if (end_card < start_card) {
ysr@777 173 return;
ysr@777 174 }
ysr@777 175 guarantee(_array->offset_array(start_card) == N_words, "Wrong value in second card");
ysr@777 176 for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
ysr@777 177 u_char entry = _array->offset_array(c);
ysr@777 178 if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) {
johnc@4300 179 guarantee(entry > N_words,
johnc@4300 180 err_msg("Should be in logarithmic region - "
johnc@4300 181 "entry: " UINT32_FORMAT ", "
johnc@4300 182 "_array->offset_array(c): " UINT32_FORMAT ", "
johnc@4300 183 "N_words: " UINT32_FORMAT,
johnc@4300 184 entry, _array->offset_array(c), N_words));
ysr@777 185 }
ysr@777 186 size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
ysr@777 187 size_t landing_card = c - backskip;
ysr@777 188 guarantee(landing_card >= (start_card - 1), "Inv");
ysr@777 189 if (landing_card >= start_card) {
johnc@4300 190 guarantee(_array->offset_array(landing_card) <= entry,
johnc@4300 191 err_msg("Monotonicity - landing_card offset: " UINT32_FORMAT ", "
johnc@4300 192 "entry: " UINT32_FORMAT,
johnc@4300 193 _array->offset_array(landing_card), entry));
ysr@777 194 } else {
ysr@777 195 guarantee(landing_card == start_card - 1, "Tautology");
johnc@4300 196 // Note that N_words is the maximum offset value
johnc@4300 197 guarantee(_array->offset_array(landing_card) <= N_words,
johnc@4300 198 err_msg("landing card offset: " UINT32_FORMAT ", "
johnc@4300 199 "N_words: " UINT32_FORMAT,
johnc@4300 200 _array->offset_array(landing_card), N_words));
ysr@777 201 }
ysr@777 202 }
ysr@777 203 }
ysr@777 204
ysr@777 205 HeapWord* G1BlockOffsetArray::block_start_unsafe(const void* addr) {
ysr@777 206 assert(_bottom <= addr && addr < _end,
ysr@777 207 "addr must be covered by this Array");
ysr@777 208 // Must read this exactly once because it can be modified by parallel
ysr@777 209 // allocation.
ysr@777 210 HeapWord* ub = _unallocated_block;
ysr@777 211 if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
ysr@777 212 assert(ub < _end, "tautology (see above)");
ysr@777 213 return ub;
ysr@777 214 }
ysr@777 215 // Otherwise, find the block start using the table.
ysr@777 216 HeapWord* q = block_at_or_preceding(addr, false, 0);
ysr@777 217 return forward_to_block_containing_addr(q, addr);
ysr@777 218 }
ysr@777 219
ysr@777 220 // This duplicates a little code from the above: unavoidable.
ysr@777 221 HeapWord*
ysr@777 222 G1BlockOffsetArray::block_start_unsafe_const(const void* addr) const {
ysr@777 223 assert(_bottom <= addr && addr < _end,
ysr@777 224 "addr must be covered by this Array");
ysr@777 225 // Must read this exactly once because it can be modified by parallel
ysr@777 226 // allocation.
ysr@777 227 HeapWord* ub = _unallocated_block;
ysr@777 228 if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
ysr@777 229 assert(ub < _end, "tautology (see above)");
ysr@777 230 return ub;
ysr@777 231 }
ysr@777 232 // Otherwise, find the block start using the table.
ysr@777 233 HeapWord* q = block_at_or_preceding(addr, false, 0);
mgerdin@6987 234 HeapWord* n = q + block_size(q);
ysr@777 235 return forward_to_block_containing_addr_const(q, n, addr);
ysr@777 236 }
ysr@777 237
ysr@777 238
ysr@777 239 HeapWord*
ysr@777 240 G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q,
ysr@777 241 HeapWord* n,
ysr@777 242 const void* addr) {
ysr@777 243 // We're not in the normal case. We need to handle an important subcase
ysr@777 244 // here: LAB allocation. An allocation previously recorded in the
ysr@777 245 // offset table was actually a lab allocation, and was divided into
ysr@777 246 // several objects subsequently. Fix this situation as we answer the
ysr@777 247 // query, by updating entries as we cross them.
iveresov@787 248
iveresov@787 249 // If the fist object's end q is at the card boundary. Start refining
iveresov@787 250 // with the corresponding card (the value of the entry will be basically
iveresov@787 251 // set to 0). If the object crosses the boundary -- start from the next card.
coleenp@4037 252 size_t n_index = _array->index_for(n);
iveresov@787 253 size_t next_index = _array->index_for(n) + !_array->is_card_boundary(n);
coleenp@4037 254 // Calculate a consistent next boundary. If "n" is not at the boundary
coleenp@4037 255 // already, step to the boundary.
coleenp@4037 256 HeapWord* next_boundary = _array->address_for_index(n_index) +
coleenp@4037 257 (n_index == next_index ? 0 : N_words);
coleenp@4037 258 assert(next_boundary <= _array->_end,
coleenp@4037 259 err_msg("next_boundary is beyond the end of the covered region "
coleenp@4037 260 " next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT,
coleenp@4037 261 next_boundary, _array->_end));
mgerdin@6987 262 if (addr >= gsp()->top()) return gsp()->top();
mgerdin@6987 263 while (next_boundary < addr) {
mgerdin@6987 264 while (n <= next_boundary) {
mgerdin@6987 265 q = n;
mgerdin@6987 266 oop obj = oop(q);
mgerdin@6987 267 if (obj->klass_or_null() == NULL) return q;
stefank@6992 268 n += block_size(q);
ysr@777 269 }
mgerdin@6987 270 assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
mgerdin@6987 271 // [q, n) is the block that crosses the boundary.
mgerdin@6987 272 alloc_block_work2(&next_boundary, &next_index, q, n);
ysr@777 273 }
ysr@777 274 return forward_to_block_containing_addr_const(q, n, addr);
ysr@777 275 }
ysr@777 276
ysr@777 277 // Note that the committed size of the covered space may have changed,
ysr@777 278 // so the table size might also wish to change.
ysr@777 279 void G1BlockOffsetArray::resize(size_t new_word_size) {
ysr@777 280 HeapWord* new_end = _bottom + new_word_size;
ysr@777 281 _end = new_end; // update _end
ysr@777 282 }
ysr@777 283
ysr@777 284 //
ysr@777 285 // threshold_
ysr@777 286 // | _index_
ysr@777 287 // v v
ysr@777 288 // +-------+-------+-------+-------+-------+
ysr@777 289 // | i-1 | i | i+1 | i+2 | i+3 |
ysr@777 290 // +-------+-------+-------+-------+-------+
ysr@777 291 // ( ^ ]
ysr@777 292 // block-start
ysr@777 293 //
ysr@777 294 void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_,
ysr@777 295 HeapWord* blk_start, HeapWord* blk_end) {
ysr@777 296 // For efficiency, do copy-in/copy-out.
ysr@777 297 HeapWord* threshold = *threshold_;
ysr@777 298 size_t index = *index_;
ysr@777 299
ysr@777 300 assert(blk_start != NULL && blk_end > blk_start,
ysr@777 301 "phantom block");
ysr@777 302 assert(blk_end > threshold, "should be past threshold");
jcoomes@1844 303 assert(blk_start <= threshold, "blk_start should be at or before threshold");
ysr@777 304 assert(pointer_delta(threshold, blk_start) <= N_words,
ysr@777 305 "offset should be <= BlockOffsetSharedArray::N");
ysr@777 306 assert(Universe::heap()->is_in_reserved(blk_start),
ysr@777 307 "reference must be into the heap");
ysr@777 308 assert(Universe::heap()->is_in_reserved(blk_end-1),
ysr@777 309 "limit must be within the heap");
ysr@777 310 assert(threshold == _array->_reserved.start() + index*N_words,
ysr@777 311 "index must agree with threshold");
ysr@777 312
ysr@777 313 DEBUG_ONLY(size_t orig_index = index;)
ysr@777 314
ysr@777 315 // Mark the card that holds the offset into the block. Note
ysr@777 316 // that _next_offset_index and _next_offset_threshold are not
ysr@777 317 // updated until the end of this method.
ysr@777 318 _array->set_offset_array(index, threshold, blk_start);
ysr@777 319
ysr@777 320 // We need to now mark the subsequent cards that this blk spans.
ysr@777 321
ysr@777 322 // Index of card on which blk ends.
ysr@777 323 size_t end_index = _array->index_for(blk_end - 1);
ysr@777 324
ysr@777 325 // Are there more cards left to be updated?
ysr@777 326 if (index + 1 <= end_index) {
ysr@777 327 HeapWord* rem_st = _array->address_for_index(index + 1);
ysr@777 328 // Calculate rem_end this way because end_index
ysr@777 329 // may be the last valid index in the covered region.
ysr@777 330 HeapWord* rem_end = _array->address_for_index(end_index) + N_words;
ysr@777 331 set_remainder_to_point_to_start(rem_st, rem_end);
ysr@777 332 }
ysr@777 333
ysr@777 334 index = end_index + 1;
ysr@777 335 // Calculate threshold_ this way because end_index
ysr@777 336 // may be the last valid index in the covered region.
ysr@777 337 threshold = _array->address_for_index(end_index) + N_words;
ysr@777 338 assert(threshold >= blk_end, "Incorrect offset threshold");
ysr@777 339
ysr@777 340 // index_ and threshold_ updated here.
ysr@777 341 *threshold_ = threshold;
ysr@777 342 *index_ = index;
ysr@777 343
ysr@777 344 #ifdef ASSERT
ysr@777 345 // The offset can be 0 if the block starts on a boundary. That
ysr@777 346 // is checked by an assertion above.
ysr@777 347 size_t start_index = _array->index_for(blk_start);
johnc@4300 348 HeapWord* boundary = _array->address_for_index(start_index);
ysr@777 349 assert((_array->offset_array(orig_index) == 0 &&
ysr@777 350 blk_start == boundary) ||
ysr@777 351 (_array->offset_array(orig_index) > 0 &&
ysr@777 352 _array->offset_array(orig_index) <= N_words),
johnc@4300 353 err_msg("offset array should have been set - "
johnc@4300 354 "orig_index offset: " UINT32_FORMAT ", "
johnc@4300 355 "blk_start: " PTR_FORMAT ", "
johnc@4300 356 "boundary: " PTR_FORMAT,
johnc@4300 357 _array->offset_array(orig_index),
johnc@4300 358 blk_start, boundary));
ysr@777 359 for (size_t j = orig_index + 1; j <= end_index; j++) {
ysr@777 360 assert(_array->offset_array(j) > 0 &&
ysr@777 361 _array->offset_array(j) <=
ysr@777 362 (u_char) (N_words+BlockOffsetArray::N_powers-1),
johnc@4300 363 err_msg("offset array should have been set - "
johnc@4300 364 UINT32_FORMAT " not > 0 OR "
johnc@4300 365 UINT32_FORMAT " not <= " UINT32_FORMAT,
johnc@4300 366 _array->offset_array(j),
johnc@4300 367 _array->offset_array(j),
johnc@4300 368 (u_char) (N_words+BlockOffsetArray::N_powers-1)));
ysr@777 369 }
ysr@777 370 #endif
ysr@777 371 }
ysr@777 372
tonyp@2453 373 bool
tonyp@2453 374 G1BlockOffsetArray::verify_for_object(HeapWord* obj_start,
tonyp@2453 375 size_t word_size) const {
tonyp@2453 376 size_t first_card = _array->index_for(obj_start);
tonyp@2453 377 size_t last_card = _array->index_for(obj_start + word_size - 1);
tonyp@2453 378 if (!_array->is_card_boundary(obj_start)) {
tonyp@2453 379 // If the object is not on a card boundary the BOT entry of the
tonyp@2453 380 // first card should point to another object so we should not
tonyp@2453 381 // check that one.
tonyp@2453 382 first_card += 1;
tonyp@2453 383 }
tonyp@2453 384 for (size_t card = first_card; card <= last_card; card += 1) {
tonyp@2453 385 HeapWord* card_addr = _array->address_for_index(card);
tonyp@2453 386 HeapWord* block_start = block_start_const(card_addr);
tonyp@2453 387 if (block_start != obj_start) {
kevinw@9327 388 gclog_or_tty->print_cr("block start: " PTR_FORMAT " is incorrect - "
kevinw@9327 389 "card index: " SIZE_FORMAT " "
kevinw@9327 390 "card addr: " PTR_FORMAT " BOT entry: %u "
kevinw@9327 391 "obj: " PTR_FORMAT " word size: " SIZE_FORMAT " "
kevinw@9327 392 "cards: [" SIZE_FORMAT "," SIZE_FORMAT "]",
tonyp@2453 393 block_start, card, card_addr,
tonyp@2453 394 _array->offset_array(card),
tonyp@2453 395 obj_start, word_size, first_card, last_card);
tonyp@2453 396 return false;
tonyp@2453 397 }
tonyp@2453 398 }
tonyp@2453 399 return true;
tonyp@2453 400 }
tonyp@2453 401
tonyp@2453 402 #ifndef PRODUCT
tonyp@2241 403 void
tonyp@2453 404 G1BlockOffsetArray::print_on(outputStream* out) {
tonyp@2453 405 size_t from_index = _array->index_for(_bottom);
tonyp@2453 406 size_t to_index = _array->index_for(_end);
kevinw@9327 407 out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") "
kevinw@9327 408 "cards [" SIZE_FORMAT "," SIZE_FORMAT ")",
tonyp@2453 409 _bottom, _end, from_index, to_index);
tonyp@2453 410 for (size_t i = from_index; i < to_index; ++i) {
kevinw@9327 411 out->print_cr(" entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u",
tonyp@2453 412 i, _array->address_for_index(i),
tonyp@2453 413 (uint) _array->offset_array(i));
tonyp@2453 414 }
tonyp@2241 415 }
tonyp@2453 416 #endif // !PRODUCT
tonyp@2241 417
ysr@777 418 //////////////////////////////////////////////////////////////////////
ysr@777 419 // G1BlockOffsetArrayContigSpace
ysr@777 420 //////////////////////////////////////////////////////////////////////
ysr@777 421
ysr@777 422 HeapWord*
ysr@777 423 G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) {
ysr@777 424 assert(_bottom <= addr && addr < _end,
ysr@777 425 "addr must be covered by this Array");
ysr@777 426 HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
ysr@777 427 return forward_to_block_containing_addr(q, addr);
ysr@777 428 }
ysr@777 429
ysr@777 430 HeapWord*
ysr@777 431 G1BlockOffsetArrayContigSpace::
ysr@777 432 block_start_unsafe_const(const void* addr) const {
ysr@777 433 assert(_bottom <= addr && addr < _end,
ysr@777 434 "addr must be covered by this Array");
ysr@777 435 HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
mgerdin@6987 436 HeapWord* n = q + block_size(q);
ysr@777 437 return forward_to_block_containing_addr_const(q, n, addr);
ysr@777 438 }
ysr@777 439
ysr@777 440 G1BlockOffsetArrayContigSpace::
ysr@777 441 G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array,
ysr@777 442 MemRegion mr) :
brutisso@7256 443 G1BlockOffsetArray(array, mr)
ysr@777 444 {
ysr@777 445 _next_offset_threshold = NULL;
ysr@777 446 _next_offset_index = 0;
ysr@777 447 }
ysr@777 448
tschatzl@7051 449 HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold_raw() {
tschatzl@7051 450 assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
tschatzl@7051 451 "just checking");
tschatzl@7051 452 _next_offset_index = _array->index_for_raw(_bottom);
tschatzl@7051 453 _next_offset_index++;
tschatzl@7051 454 _next_offset_threshold =
tschatzl@7051 455 _array->address_for_index_raw(_next_offset_index);
tschatzl@7051 456 return _next_offset_threshold;
tschatzl@7051 457 }
tschatzl@7051 458
tschatzl@7051 459 void G1BlockOffsetArrayContigSpace::zero_bottom_entry_raw() {
tschatzl@7051 460 assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
tschatzl@7051 461 "just checking");
tschatzl@7051 462 size_t bottom_index = _array->index_for_raw(_bottom);
tschatzl@7051 463 assert(_array->address_for_index_raw(bottom_index) == _bottom,
tschatzl@7051 464 "Precondition of call");
tschatzl@7051 465 _array->set_offset_array_raw(bottom_index, 0);
tschatzl@7051 466 }
tschatzl@7051 467
ysr@777 468 HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() {
ysr@777 469 assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
ysr@777 470 "just checking");
ysr@777 471 _next_offset_index = _array->index_for(_bottom);
ysr@777 472 _next_offset_index++;
ysr@777 473 _next_offset_threshold =
ysr@777 474 _array->address_for_index(_next_offset_index);
ysr@777 475 return _next_offset_threshold;
ysr@777 476 }
ysr@777 477
tonyp@2241 478 void
tonyp@2453 479 G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_top) {
tonyp@2453 480 assert(new_top <= _end, "_end should have already been updated");
tonyp@2241 481
tonyp@2453 482 // The first BOT entry should have offset 0.
tschatzl@7050 483 reset_bot();
tonyp@2453 484 alloc_block(_bottom, new_top);
tonyp@2453 485 }
tonyp@2453 486
tonyp@2453 487 #ifndef PRODUCT
tonyp@2453 488 void
tonyp@2453 489 G1BlockOffsetArrayContigSpace::print_on(outputStream* out) {
tonyp@2453 490 G1BlockOffsetArray::print_on(out);
kevinw@9327 491 out->print_cr(" next offset threshold: " PTR_FORMAT, _next_offset_threshold);
kevinw@9327 492 out->print_cr(" next offset index: " SIZE_FORMAT, _next_offset_index);
tonyp@2241 493 }
tonyp@2453 494 #endif // !PRODUCT

mercurial