annotate src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp @ 2025:2250ee17e258

7007068: G1: refine the BOT during evac failure handling Summary: During evacuation failure handling we refine the BOT to reflect the location of all the objects in the regions we scan. The changeset includes some minor cleanup: a) non-product print_on() method on the G1 BOT class, b) added more complete BOT verification during heap / region verification, c) slight modification to the BOT set up for humongous regions to be more consistent with the BOT set up during evac failure handling, and d) removed a couple of unused methods. Reviewed-by: johnc, ysr
author tonyp
date Wed, 12 Jan 2011 13:06:00 -0500
parents f95d63e2154a
children
rev   line source
ysr@342 1 /*
tonyp@2025 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
ysr@342 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@342 4 *
ysr@342 5 * This code is free software; you can redistribute it and/or modify it
ysr@342 6 * under the terms of the GNU General Public License version 2 only, as
ysr@342 7 * published by the Free Software Foundation.
ysr@342 8 *
ysr@342 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@342 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@342 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@342 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@342 13 * accompanied this code).
ysr@342 14 *
ysr@342 15 * You should have received a copy of the GNU General Public License version
ysr@342 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@342 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@342 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
ysr@342 22 *
ysr@342 23 */
ysr@342 24
stefank@1885 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
stefank@1885 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
stefank@1885 27
stefank@1885 28 #include "memory/memRegion.hpp"
stefank@1885 29 #include "runtime/virtualspace.hpp"
stefank@1885 30 #include "utilities/globalDefinitions.hpp"
stefank@1885 31
ysr@342 32 // The CollectedHeap type requires subtypes to implement a method
ysr@342 33 // "block_start". For some subtypes, notably generational
ysr@342 34 // systems using card-table-based write barriers, the efficiency of this
ysr@342 35 // operation may be important. Implementations of the "BlockOffsetArray"
ysr@342 36 // class may be useful in providing such efficient implementations.
ysr@342 37 //
ysr@342 38 // While generally mirroring the structure of the BOT for GenCollectedHeap,
ysr@342 39 // the following types are tailored more towards G1's uses; these should,
ysr@342 40 // however, be merged back into a common BOT to avoid code duplication
ysr@342 41 // and reduce maintenance overhead.
ysr@342 42 //
ysr@342 43 // G1BlockOffsetTable (abstract)
ysr@342 44 // -- G1BlockOffsetArray (uses G1BlockOffsetSharedArray)
ysr@342 45 // -- G1BlockOffsetArrayContigSpace
ysr@342 46 //
ysr@342 47 // A main impediment to the consolidation of this code might be the
ysr@342 48 // effect of making some of the block_start*() calls non-const as
ysr@342 49 // below. Whether that might adversely affect performance optimizations
ysr@342 50 // that compilers might normally perform in the case of non-G1
ysr@342 51 // collectors needs to be carefully investigated prior to any such
ysr@342 52 // consolidation.
ysr@342 53
ysr@342 54 // Forward declarations
ysr@342 55 class ContiguousSpace;
ysr@342 56 class G1BlockOffsetSharedArray;
ysr@342 57
ysr@342 58 class G1BlockOffsetTable VALUE_OBJ_CLASS_SPEC {
ysr@342 59 friend class VMStructs;
ysr@342 60 protected:
ysr@342 61 // These members describe the region covered by the table.
ysr@342 62
ysr@342 63 // The space this table is covering.
ysr@342 64 HeapWord* _bottom; // == reserved.start
ysr@342 65 HeapWord* _end; // End of currently allocated region.
ysr@342 66
ysr@342 67 public:
ysr@342 68 // Initialize the table to cover the given space.
ysr@342 69 // The contents of the initial table are undefined.
ysr@342 70 G1BlockOffsetTable(HeapWord* bottom, HeapWord* end) :
ysr@342 71 _bottom(bottom), _end(end)
ysr@342 72 {
ysr@342 73 assert(_bottom <= _end, "arguments out of order");
ysr@342 74 }
ysr@342 75
ysr@342 76 // Note that the committed size of the covered space may have changed,
ysr@342 77 // so the table size might also wish to change.
ysr@342 78 virtual void resize(size_t new_word_size) = 0;
ysr@342 79
ysr@342 80 virtual void set_bottom(HeapWord* new_bottom) {
ysr@342 81 assert(new_bottom <= _end, "new_bottom > _end");
ysr@342 82 _bottom = new_bottom;
ysr@342 83 resize(pointer_delta(_end, _bottom));
ysr@342 84 }
ysr@342 85
ysr@342 86 // Requires "addr" to be contained by a block, and returns the address of
ysr@342 87 // the start of that block. (May have side effects, namely updating of
ysr@342 88 // shared array entries that "point" too far backwards. This can occur,
ysr@342 89 // for example, when LAB allocation is used in a space covered by the
ysr@342 90 // table.)
ysr@342 91 virtual HeapWord* block_start_unsafe(const void* addr) = 0;
ysr@342 92 // Same as above, but does not have any of the possible side effects
ysr@342 93 // discussed above.
ysr@342 94 virtual HeapWord* block_start_unsafe_const(const void* addr) const = 0;
ysr@342 95
ysr@342 96 // Returns the address of the start of the block containing "addr", or
ysr@342 97 // else "null" if it is covered by no block. (May have side effects,
ysr@342 98 // namely updating of shared array entries that "point" too far
ysr@342 99 // backwards. This can occur, for example, when lab allocation is used
ysr@342 100 // in a space covered by the table.)
ysr@342 101 inline HeapWord* block_start(const void* addr);
ysr@342 102 // Same as above, but does not have any of the possible side effects
ysr@342 103 // discussed above.
ysr@342 104 inline HeapWord* block_start_const(const void* addr) const;
ysr@342 105 };
ysr@342 106
ysr@342 107 // This implementation of "G1BlockOffsetTable" divides the covered region
ysr@342 108 // into "N"-word subregions (where "N" = 2^"LogN". An array with an entry
ysr@342 109 // for each such subregion indicates how far back one must go to find the
ysr@342 110 // start of the chunk that includes the first word of the subregion.
ysr@342 111 //
ysr@342 112 // Each BlockOffsetArray is owned by a Space. However, the actual array
ysr@342 113 // may be shared by several BlockOffsetArrays; this is useful
ysr@342 114 // when a single resizable area (such as a generation) is divided up into
ysr@342 115 // several spaces in which contiguous allocation takes place,
ysr@342 116 // such as, for example, in G1 or in the train generation.)
ysr@342 117
ysr@342 118 // Here is the shared array type.
ysr@342 119
ysr@342 120 class G1BlockOffsetSharedArray: public CHeapObj {
ysr@342 121 friend class G1BlockOffsetArray;
ysr@342 122 friend class G1BlockOffsetArrayContigSpace;
ysr@342 123 friend class VMStructs;
ysr@342 124
ysr@342 125 private:
ysr@342 126 // The reserved region covered by the shared array.
ysr@342 127 MemRegion _reserved;
ysr@342 128
ysr@342 129 // End of the current committed region.
ysr@342 130 HeapWord* _end;
ysr@342 131
ysr@342 132 // Array for keeping offsets for retrieving object start fast given an
ysr@342 133 // address.
ysr@342 134 VirtualSpace _vs;
ysr@342 135 u_char* _offset_array; // byte array keeping backwards offsets
ysr@342 136
ysr@342 137 // Bounds checking accessors:
ysr@342 138 // For performance these have to devolve to array accesses in product builds.
ysr@342 139 u_char offset_array(size_t index) const {
ysr@342 140 assert(index < _vs.committed_size(), "index out of range");
ysr@342 141 return _offset_array[index];
ysr@342 142 }
ysr@342 143
ysr@342 144 void set_offset_array(size_t index, u_char offset) {
ysr@342 145 assert(index < _vs.committed_size(), "index out of range");
ysr@342 146 assert(offset <= N_words, "offset too large");
ysr@342 147 _offset_array[index] = offset;
ysr@342 148 }
ysr@342 149
ysr@342 150 void set_offset_array(size_t index, HeapWord* high, HeapWord* low) {
ysr@342 151 assert(index < _vs.committed_size(), "index out of range");
ysr@342 152 assert(high >= low, "addresses out of order");
ysr@342 153 assert(pointer_delta(high, low) <= N_words, "offset too large");
ysr@342 154 _offset_array[index] = (u_char) pointer_delta(high, low);
ysr@342 155 }
ysr@342 156
ysr@342 157 void set_offset_array(HeapWord* left, HeapWord* right, u_char offset) {
ysr@342 158 assert(index_for(right - 1) < _vs.committed_size(),
ysr@342 159 "right address out of range");
ysr@342 160 assert(left < right, "Heap addresses out of order");
ysr@342 161 size_t num_cards = pointer_delta(right, left) >> LogN_words;
ysr@342 162 memset(&_offset_array[index_for(left)], offset, num_cards);
ysr@342 163 }
ysr@342 164
ysr@342 165 void set_offset_array(size_t left, size_t right, u_char offset) {
ysr@342 166 assert(right < _vs.committed_size(), "right address out of range");
ysr@342 167 assert(left <= right, "indexes out of order");
ysr@342 168 size_t num_cards = right - left + 1;
ysr@342 169 memset(&_offset_array[left], offset, num_cards);
ysr@342 170 }
ysr@342 171
ysr@342 172 void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const {
ysr@342 173 assert(index < _vs.committed_size(), "index out of range");
ysr@342 174 assert(high >= low, "addresses out of order");
ysr@342 175 assert(pointer_delta(high, low) <= N_words, "offset too large");
ysr@342 176 assert(_offset_array[index] == pointer_delta(high, low),
ysr@342 177 "Wrong offset");
ysr@342 178 }
ysr@342 179
ysr@342 180 bool is_card_boundary(HeapWord* p) const;
ysr@342 181
ysr@342 182 // Return the number of slots needed for an offset array
ysr@342 183 // that covers mem_region_words words.
ysr@342 184 // We always add an extra slot because if an object
ysr@342 185 // ends on a card boundary we put a 0 in the next
ysr@342 186 // offset array slot, so we want that slot always
ysr@342 187 // to be reserved.
ysr@342 188
ysr@342 189 size_t compute_size(size_t mem_region_words) {
ysr@342 190 size_t number_of_slots = (mem_region_words / N_words) + 1;
ysr@342 191 return ReservedSpace::page_align_size_up(number_of_slots);
ysr@342 192 }
ysr@342 193
ysr@342 194 public:
ysr@342 195 enum SomePublicConstants {
ysr@342 196 LogN = 9,
ysr@342 197 LogN_words = LogN - LogHeapWordSize,
ysr@342 198 N_bytes = 1 << LogN,
ysr@342 199 N_words = 1 << LogN_words
ysr@342 200 };
ysr@342 201
ysr@342 202 // Initialize the table to cover from "base" to (at least)
ysr@342 203 // "base + init_word_size". In the future, the table may be expanded
ysr@342 204 // (see "resize" below) up to the size of "_reserved" (which must be at
ysr@342 205 // least "init_word_size".) The contents of the initial table are
ysr@342 206 // undefined; it is the responsibility of the constituent
ysr@342 207 // G1BlockOffsetTable(s) to initialize cards.
ysr@342 208 G1BlockOffsetSharedArray(MemRegion reserved, size_t init_word_size);
ysr@342 209
ysr@342 210 // Notes a change in the committed size of the region covered by the
ysr@342 211 // table. The "new_word_size" may not be larger than the size of the
ysr@342 212 // reserved region this table covers.
ysr@342 213 void resize(size_t new_word_size);
ysr@342 214
ysr@342 215 void set_bottom(HeapWord* new_bottom);
ysr@342 216
ysr@342 217 // Updates all the BlockOffsetArray's sharing this shared array to
ysr@342 218 // reflect the current "top"'s of their spaces.
ysr@342 219 void update_offset_arrays();
ysr@342 220
ysr@342 221 // Return the appropriate index into "_offset_array" for "p".
ysr@342 222 inline size_t index_for(const void* p) const;
ysr@342 223
ysr@342 224 // Return the address indicating the start of the region corresponding to
ysr@342 225 // "index" in "_offset_array".
ysr@342 226 inline HeapWord* address_for_index(size_t index) const;
ysr@342 227 };
ysr@342 228
ysr@342 229 // And here is the G1BlockOffsetTable subtype that uses the array.
ysr@342 230
ysr@342 231 class G1BlockOffsetArray: public G1BlockOffsetTable {
ysr@342 232 friend class G1BlockOffsetSharedArray;
ysr@342 233 friend class G1BlockOffsetArrayContigSpace;
ysr@342 234 friend class VMStructs;
ysr@342 235 private:
ysr@342 236 enum SomePrivateConstants {
ysr@342 237 N_words = G1BlockOffsetSharedArray::N_words,
ysr@342 238 LogN = G1BlockOffsetSharedArray::LogN
ysr@342 239 };
ysr@342 240
ysr@342 241 // The following enums are used by do_block_helper
ysr@342 242 enum Action {
ysr@342 243 Action_single, // BOT records a single block (see single_block())
ysr@342 244 Action_mark, // BOT marks the start of a block (see mark_block())
ysr@342 245 Action_check // Check that BOT records block correctly
ysr@342 246 // (see verify_single_block()).
ysr@342 247 };
ysr@342 248
ysr@342 249 // This is the array, which can be shared by several BlockOffsetArray's
ysr@342 250 // servicing different
ysr@342 251 G1BlockOffsetSharedArray* _array;
ysr@342 252
ysr@342 253 // The space that owns this subregion.
ysr@342 254 Space* _sp;
ysr@342 255
ysr@342 256 // If "_sp" is a contiguous space, the field below is the view of "_sp"
ysr@342 257 // as a contiguous space, else NULL.
ysr@342 258 ContiguousSpace* _csp;
ysr@342 259
ysr@342 260 // If true, array entries are initialized to 0; otherwise, they are
ysr@342 261 // initialized to point backwards to the beginning of the covered region.
ysr@342 262 bool _init_to_zero;
ysr@342 263
ysr@342 264 // The portion [_unallocated_block, _sp.end()) of the space that
ysr@342 265 // is a single block known not to contain any objects.
ysr@342 266 // NOTE: See BlockOffsetArrayUseUnallocatedBlock flag.
ysr@342 267 HeapWord* _unallocated_block;
ysr@342 268
ysr@342 269 // Sets the entries
ysr@342 270 // corresponding to the cards starting at "start" and ending at "end"
ysr@342 271 // to point back to the card before "start": the interval [start, end)
ysr@342 272 // is right-open.
ysr@342 273 void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
ysr@342 274 // Same as above, except that the args here are a card _index_ interval
ysr@342 275 // that is closed: [start_index, end_index]
ysr@342 276 void set_remainder_to_point_to_start_incl(size_t start, size_t end);
ysr@342 277
ysr@342 278 // A helper function for BOT adjustment/verification work
ysr@342 279 void do_block_internal(HeapWord* blk_start, HeapWord* blk_end, Action action);
ysr@342 280
ysr@342 281 protected:
ysr@342 282
ysr@342 283 ContiguousSpace* csp() const { return _csp; }
ysr@342 284
ysr@342 285 // Returns the address of a block whose start is at most "addr".
ysr@342 286 // If "has_max_index" is true, "assumes "max_index" is the last valid one
ysr@342 287 // in the array.
ysr@342 288 inline HeapWord* block_at_or_preceding(const void* addr,
ysr@342 289 bool has_max_index,
ysr@342 290 size_t max_index) const;
ysr@342 291
ysr@342 292 // "q" is a block boundary that is <= "addr"; "n" is the address of the
ysr@342 293 // next block (or the end of the space.) Return the address of the
ysr@342 294 // beginning of the block that contains "addr". Does so without side
ysr@342 295 // effects (see, e.g., spec of block_start.)
ysr@342 296 inline HeapWord*
ysr@342 297 forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
ysr@342 298 const void* addr) const;
ysr@342 299
ysr@342 300 // "q" is a block boundary that is <= "addr"; return the address of the
ysr@342 301 // beginning of the block that contains "addr". May have side effects
ysr@342 302 // on "this", by updating imprecise entries.
ysr@342 303 inline HeapWord* forward_to_block_containing_addr(HeapWord* q,
ysr@342 304 const void* addr);
ysr@342 305
ysr@342 306 // "q" is a block boundary that is <= "addr"; "n" is the address of the
ysr@342 307 // next block (or the end of the space.) Return the address of the
ysr@342 308 // beginning of the block that contains "addr". May have side effects
ysr@342 309 // on "this", by updating imprecise entries.
ysr@342 310 HeapWord* forward_to_block_containing_addr_slow(HeapWord* q,
ysr@342 311 HeapWord* n,
ysr@342 312 const void* addr);
ysr@342 313
ysr@342 314 // Requires that "*threshold_" be the first array entry boundary at or
ysr@342 315 // above "blk_start", and that "*index_" be the corresponding array
ysr@342 316 // index. If the block starts at or crosses "*threshold_", records
ysr@342 317 // "blk_start" as the appropriate block start for the array index
ysr@342 318 // starting at "*threshold_", and for any other indices crossed by the
ysr@342 319 // block. Updates "*threshold_" and "*index_" to correspond to the first
ysr@342 320 // index after the block end.
ysr@342 321 void alloc_block_work2(HeapWord** threshold_, size_t* index_,
ysr@342 322 HeapWord* blk_start, HeapWord* blk_end);
ysr@342 323
ysr@342 324 public:
ysr@342 325 // The space may not have it's bottom and top set yet, which is why the
ysr@342 326 // region is passed as a parameter. If "init_to_zero" is true, the
ysr@342 327 // elements of the array are initialized to zero. Otherwise, they are
ysr@342 328 // initialized to point backwards to the beginning.
ysr@342 329 G1BlockOffsetArray(G1BlockOffsetSharedArray* array, MemRegion mr,
ysr@342 330 bool init_to_zero);
ysr@342 331
ysr@342 332 // Note: this ought to be part of the constructor, but that would require
ysr@342 333 // "this" to be passed as a parameter to a member constructor for
ysr@342 334 // the containing concrete subtype of Space.
ysr@342 335 // This would be legal C++, but MS VC++ doesn't allow it.
ysr@342 336 void set_space(Space* sp);
ysr@342 337
ysr@342 338 // Resets the covered region to the given "mr".
ysr@342 339 void set_region(MemRegion mr);
ysr@342 340
ysr@342 341 // Resets the covered region to one with the same _bottom as before but
ysr@342 342 // the "new_word_size".
ysr@342 343 void resize(size_t new_word_size);
ysr@342 344
ysr@342 345 // These must be guaranteed to work properly (i.e., do nothing)
ysr@342 346 // when "blk_start" ("blk" for second version) is "NULL".
ysr@342 347 virtual void alloc_block(HeapWord* blk_start, HeapWord* blk_end);
ysr@342 348 virtual void alloc_block(HeapWord* blk, size_t size) {
ysr@342 349 alloc_block(blk, blk + size);
ysr@342 350 }
ysr@342 351
ysr@342 352 // The following methods are useful and optimized for a
ysr@342 353 // general, non-contiguous space.
ysr@342 354
ysr@342 355 // Given a block [blk_start, blk_start + full_blk_size), and
ysr@342 356 // a left_blk_size < full_blk_size, adjust the BOT to show two
ysr@342 357 // blocks [blk_start, blk_start + left_blk_size) and
ysr@342 358 // [blk_start + left_blk_size, blk_start + full_blk_size).
ysr@342 359 // It is assumed (and verified in the non-product VM) that the
ysr@342 360 // BOT was correct for the original block.
ysr@342 361 void split_block(HeapWord* blk_start, size_t full_blk_size,
ysr@342 362 size_t left_blk_size);
ysr@342 363
ysr@342 364 // Adjust the BOT to show that it has a single block in the
ysr@342 365 // range [blk_start, blk_start + size). All necessary BOT
ysr@342 366 // cards are adjusted, but _unallocated_block isn't.
ysr@342 367 void single_block(HeapWord* blk_start, HeapWord* blk_end);
ysr@342 368 void single_block(HeapWord* blk, size_t size) {
ysr@342 369 single_block(blk, blk + size);
ysr@342 370 }
ysr@342 371
ysr@342 372 // Adjust BOT to show that it has a block in the range
ysr@342 373 // [blk_start, blk_start + size). Only the first card
ysr@342 374 // of BOT is touched. It is assumed (and verified in the
ysr@342 375 // non-product VM) that the remaining cards of the block
ysr@342 376 // are correct.
ysr@342 377 void mark_block(HeapWord* blk_start, HeapWord* blk_end);
ysr@342 378 void mark_block(HeapWord* blk, size_t size) {
ysr@342 379 mark_block(blk, blk + size);
ysr@342 380 }
ysr@342 381
ysr@342 382 // Adjust _unallocated_block to indicate that a particular
ysr@342 383 // block has been newly allocated or freed. It is assumed (and
ysr@342 384 // verified in the non-product VM) that the BOT is correct for
ysr@342 385 // the given block.
ysr@342 386 inline void allocated(HeapWord* blk_start, HeapWord* blk_end) {
ysr@342 387 // Verify that the BOT shows [blk, blk + blk_size) to be one block.
ysr@342 388 verify_single_block(blk_start, blk_end);
ysr@342 389 if (BlockOffsetArrayUseUnallocatedBlock) {
ysr@342 390 _unallocated_block = MAX2(_unallocated_block, blk_end);
ysr@342 391 }
ysr@342 392 }
ysr@342 393
ysr@342 394 inline void allocated(HeapWord* blk, size_t size) {
ysr@342 395 allocated(blk, blk + size);
ysr@342 396 }
ysr@342 397
ysr@342 398 inline void freed(HeapWord* blk_start, HeapWord* blk_end);
ysr@342 399
ysr@342 400 inline void freed(HeapWord* blk, size_t size);
ysr@342 401
ysr@342 402 virtual HeapWord* block_start_unsafe(const void* addr);
ysr@342 403 virtual HeapWord* block_start_unsafe_const(const void* addr) const;
ysr@342 404
ysr@342 405 // Requires "addr" to be the start of a card and returns the
ysr@342 406 // start of the block that contains the given address.
ysr@342 407 HeapWord* block_start_careful(const void* addr) const;
ysr@342 408
ysr@342 409 // If true, initialize array slots with no allocated blocks to zero.
ysr@342 410 // Otherwise, make them point back to the front.
ysr@342 411 bool init_to_zero() { return _init_to_zero; }
ysr@342 412
ysr@342 413 // Verification & debugging - ensure that the offset table reflects the fact
ysr@342 414 // that the block [blk_start, blk_end) or [blk, blk + size) is a
ysr@342 415 // single block of storage. NOTE: can;t const this because of
ysr@342 416 // call to non-const do_block_internal() below.
ysr@342 417 inline void verify_single_block(HeapWord* blk_start, HeapWord* blk_end) {
ysr@342 418 if (VerifyBlockOffsetArray) {
ysr@342 419 do_block_internal(blk_start, blk_end, Action_check);
ysr@342 420 }
ysr@342 421 }
ysr@342 422
ysr@342 423 inline void verify_single_block(HeapWord* blk, size_t size) {
ysr@342 424 verify_single_block(blk, blk + size);
ysr@342 425 }
ysr@342 426
tonyp@2025 427 // Used by region verification. Checks that the contents of the
tonyp@2025 428 // BOT reflect that there's a single object that spans the address
tonyp@2025 429 // range [obj_start, obj_start + word_size); returns true if this is
tonyp@2025 430 // the case, returns false if it's not.
tonyp@2025 431 bool verify_for_object(HeapWord* obj_start, size_t word_size) const;
tonyp@2025 432
ysr@342 433 // Verify that the given block is before _unallocated_block
ysr@342 434 inline void verify_not_unallocated(HeapWord* blk_start,
ysr@342 435 HeapWord* blk_end) const {
ysr@342 436 if (BlockOffsetArrayUseUnallocatedBlock) {
ysr@342 437 assert(blk_start < blk_end, "Block inconsistency?");
ysr@342 438 assert(blk_end <= _unallocated_block, "_unallocated_block problem");
ysr@342 439 }
ysr@342 440 }
ysr@342 441
ysr@342 442 inline void verify_not_unallocated(HeapWord* blk, size_t size) const {
ysr@342 443 verify_not_unallocated(blk, blk + size);
ysr@342 444 }
ysr@342 445
ysr@342 446 void check_all_cards(size_t left_card, size_t right_card) const;
tonyp@1811 447
tonyp@2025 448 virtual void print_on(outputStream* out) PRODUCT_RETURN;
ysr@342 449 };
ysr@342 450
ysr@342 451 // A subtype of BlockOffsetArray that takes advantage of the fact
ysr@342 452 // that its underlying space is a ContiguousSpace, so that its "active"
ysr@342 453 // region can be more efficiently tracked (than for a non-contiguous space).
ysr@342 454 class G1BlockOffsetArrayContigSpace: public G1BlockOffsetArray {
ysr@342 455 friend class VMStructs;
ysr@342 456
ysr@342 457 // allocation boundary at which offset array must be updated
ysr@342 458 HeapWord* _next_offset_threshold;
ysr@342 459 size_t _next_offset_index; // index corresponding to that boundary
ysr@342 460
ysr@342 461 // Work function to be called when allocation start crosses the next
ysr@342 462 // threshold in the contig space.
ysr@342 463 void alloc_block_work1(HeapWord* blk_start, HeapWord* blk_end) {
ysr@342 464 alloc_block_work2(&_next_offset_threshold, &_next_offset_index,
ysr@342 465 blk_start, blk_end);
ysr@342 466 }
ysr@342 467
ysr@342 468
ysr@342 469 public:
ysr@342 470 G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, MemRegion mr);
ysr@342 471
ysr@342 472 // Initialize the threshold to reflect the first boundary after the
ysr@342 473 // bottom of the covered region.
ysr@342 474 HeapWord* initialize_threshold();
ysr@342 475
ysr@342 476 // Zero out the entry for _bottom (offset will be zero).
ysr@342 477 void zero_bottom_entry();
ysr@342 478
ysr@342 479 // Return the next threshold, the point at which the table should be
ysr@342 480 // updated.
ysr@342 481 HeapWord* threshold() const { return _next_offset_threshold; }
ysr@342 482
ysr@342 483 // These must be guaranteed to work properly (i.e., do nothing)
ysr@342 484 // when "blk_start" ("blk" for second version) is "NULL". In this
ysr@342 485 // implementation, that's true because NULL is represented as 0, and thus
ysr@342 486 // never exceeds the "_next_offset_threshold".
ysr@342 487 void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
ysr@342 488 if (blk_end > _next_offset_threshold)
ysr@342 489 alloc_block_work1(blk_start, blk_end);
ysr@342 490 }
ysr@342 491 void alloc_block(HeapWord* blk, size_t size) {
ysr@342 492 alloc_block(blk, blk+size);
ysr@342 493 }
ysr@342 494
ysr@342 495 HeapWord* block_start_unsafe(const void* addr);
ysr@342 496 HeapWord* block_start_unsafe_const(const void* addr) const;
tonyp@1811 497
tonyp@2025 498 void set_for_starts_humongous(HeapWord* new_top);
tonyp@2025 499
tonyp@2025 500 virtual void print_on(outputStream* out) PRODUCT_RETURN;
ysr@342 501 };
stefank@1885 502
stefank@1885 503 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP