src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hs-gc9 Sdiff src/share/vm/gc_implementation/g1

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

Print this page




  92   // for example, when LAB allocation is used in a space covered by the
  93   // table.)
  94   virtual HeapWord* block_start_unsafe(const void* addr) = 0;
  95   // Same as above, but does not have any of the possible side effects
  96   // discussed above.
  97   virtual HeapWord* block_start_unsafe_const(const void* addr) const = 0;
  98 
  99   // Returns the address of the start of the block containing "addr", or
 100   // else "null" if it is covered by no block.  (May have side effects,
 101   // namely updating of shared array entries that "point" too far
 102   // backwards.  This can occur, for example, when lab allocation is used
 103   // in a space covered by the table.)
 104   inline HeapWord* block_start(const void* addr);
 105   // Same as above, but does not have any of the possible side effects
 106   // discussed above.
 107   inline HeapWord* block_start_const(const void* addr) const;
 108 };
 109 
 110 class G1BlockOffsetSharedArrayMappingChangedListener : public G1MappingChangedListener {
 111  public:
 112   virtual void on_commit(uint start_idx, size_t num_regions);





 113 };
 114 
 115 // This implementation of "G1BlockOffsetTable" divides the covered region
 116 // into "N"-word subregions (where "N" = 2^"LogN".  An array with an entry
 117 // for each such subregion indicates how far back one must go to find the
 118 // start of the chunk that includes the first word of the subregion.
 119 //
 120 // Each BlockOffsetArray is owned by a Space.  However, the actual array
 121 // may be shared by several BlockOffsetArrays; this is useful
 122 // when a single resizable area (such as a generation) is divided up into
 123 // several spaces in which contiguous allocation takes place,
 124 // such as, for example, in G1 or in the train generation.)
 125 
 126 // Here is the shared array type.
 127 
 128 class G1BlockOffsetSharedArray: public CHeapObj<mtGC> {
 129   friend class G1BlockOffsetArray;
 130   friend class G1BlockOffsetArrayContigSpace;
 131   friend class VMStructs;
 132 


 136   MemRegion _reserved;
 137 
 138   // End of the current committed region.
 139   HeapWord* _end;
 140 
 141   // Array for keeping offsets for retrieving object start fast given an
 142   // address.
 143   u_char* _offset_array;          // byte array keeping backwards offsets
 144 
 145   void check_offset(size_t offset, const char* msg) const {
 146     assert(offset <= N_words,
 147            err_msg("%s - "
 148                    "offset: " SIZE_FORMAT", N_words: %u",
 149                    msg, offset, (uint)N_words));
 150   }
 151 
 152   // Bounds checking accessors:
 153   // For performance these have to devolve to array accesses in product builds.
 154   inline u_char offset_array(size_t index) const;
 155 
 156   void set_offset_array(HeapWord* left, HeapWord* right, u_char offset);
 157 
 158   void set_offset_array_raw(size_t index, u_char offset) {
 159     _offset_array[index] = offset;
 160   }
 161 
 162   inline void set_offset_array(size_t index, u_char offset);
 163 
 164   inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
 165 
 166   inline void set_offset_array(size_t left, size_t right, u_char offset);
 167 
 168   inline void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const;
 169 
 170   bool is_card_boundary(HeapWord* p) const;
 171 
 172 public:
 173 
 174   // Return the number of slots needed for an offset array
 175   // that covers mem_region_words words.
 176   static size_t compute_size(size_t mem_region_words) {
 177     size_t number_of_slots = (mem_region_words / N_words);
 178     return ReservedSpace::allocation_align_size_up(number_of_slots);
 179   }
 180 
 181   enum SomePublicConstants {
 182     LogN = 9,
 183     LogN_words = LogN - LogHeapWordSize,
 184     N_bytes = 1 << LogN,
 185     N_words = 1 << LogN_words
 186   };
 187 
 188   // Initialize the table to cover from "base" to (at least)
 189   // "base + init_word_size".  In the future, the table may be expanded
 190   // (see "resize" below) up to the size of "_reserved" (which must be at
 191   // least "init_word_size".) The contents of the initial table are
 192   // undefined; it is the responsibility of the constituent
 193   // G1BlockOffsetTable(s) to initialize cards.
 194   G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage);
 195 
 196   void set_bottom(HeapWord* new_bottom);
 197 
 198   // Return the appropriate index into "_offset_array" for "p".
 199   inline size_t index_for(const void* p) const;
 200   inline size_t index_for_raw(const void* p) const;
 201 
 202   // Return the address indicating the start of the region corresponding to
 203   // "index" in "_offset_array".
 204   inline HeapWord* address_for_index(size_t index) const;
 205   // Variant of address_for_index that does not check the index for validity.
 206   inline HeapWord* address_for_index_raw(size_t index) const {
 207     return _reserved.start() + (index << LogN_words);
 208   }
 209 };
 210 
 211 // And here is the G1BlockOffsetTable subtype that uses the array.
 212 
 213 class G1BlockOffsetArray: public G1BlockOffsetTable {
 214   friend class G1BlockOffsetSharedArray;
 215   friend class G1BlockOffsetArrayContigSpace;
 216   friend class VMStructs;
 217 private:
 218   enum SomePrivateConstants {
 219     N_words = G1BlockOffsetSharedArray::N_words,
 220     LogN    = G1BlockOffsetSharedArray::LogN
 221   };
 222 
 223   // The following enums are used by do_block_helper
 224   enum Action {
 225     Action_single,      // BOT records a single block (see single_block())
 226     Action_mark,        // BOT marks the start of a block (see mark_block())
 227     Action_check        // Check that BOT records block correctly
 228                         // (see verify_single_block()).
 229   };
 230 
 231   // This is the array, which can be shared by several BlockOffsetArray's
 232   // servicing different
 233   G1BlockOffsetSharedArray* _array;
 234 
 235   // The space that owns this subregion.
 236   G1OffsetTableContigSpace* _gsp;
 237 
 238   // If true, array entries are initialized to 0; otherwise, they are
 239   // initialized to point backwards to the beginning of the covered region.
 240   bool _init_to_zero;
 241 
 242   // The portion [_unallocated_block, _sp.end()) of the space that
 243   // is a single block known not to contain any objects.
 244   // NOTE: See BlockOffsetArrayUseUnallocatedBlock flag.
 245   HeapWord* _unallocated_block;
 246 
 247   // Sets the entries
 248   // corresponding to the cards starting at "start" and ending at "end"
 249   // to point back to the card before "start": the interval [start, end)
 250   // is right-open.
 251   void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
 252   // Same as above, except that the args here are a card _index_ interval
 253   // that is closed: [start_index, end_index]
 254   void set_remainder_to_point_to_start_incl(size_t start, size_t end);
 255 
 256   // A helper function for BOT adjustment/verification work
 257   void do_block_internal(HeapWord* blk_start, HeapWord* blk_end, Action action);
 258 
 259 protected:
 260 
 261   G1OffsetTableContigSpace* gsp() const { return _gsp; }
 262 
 263   inline size_t block_size(const HeapWord* p) const;
 264 
 265   // Returns the address of a block whose start is at most "addr".
 266   // If "has_max_index" is true, "assumes "max_index" is the last valid one
 267   // in the array.
 268   inline HeapWord* block_at_or_preceding(const void* addr,
 269                                          bool has_max_index,
 270                                          size_t max_index) const;
 271 
 272   // "q" is a block boundary that is <= "addr"; "n" is the address of the
 273   // next block (or the end of the space.)  Return the address of the
 274   // beginning of the block that contains "addr".  Does so without side
 275   // effects (see, e.g., spec of  block_start.)
 276   inline HeapWord*
 277   forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
 278                                          const void* addr) const;


 286   // "q" is a block boundary that is <= "addr"; "n" is the address of the
 287   // next block (or the end of the space.)  Return the address of the
 288   // beginning of the block that contains "addr".  May have side effects
 289   // on "this", by updating imprecise entries.
 290   HeapWord* forward_to_block_containing_addr_slow(HeapWord* q,
 291                                                   HeapWord* n,
 292                                                   const void* addr);
 293 
 294   // Requires that "*threshold_" be the first array entry boundary at or
 295   // above "blk_start", and that "*index_" be the corresponding array
 296   // index.  If the block starts at or crosses "*threshold_", records
 297   // "blk_start" as the appropriate block start for the array index
 298   // starting at "*threshold_", and for any other indices crossed by the
 299   // block.  Updates "*threshold_" and "*index_" to correspond to the first
 300   // index after the block end.
 301   void alloc_block_work2(HeapWord** threshold_, size_t* index_,
 302                          HeapWord* blk_start, HeapWord* blk_end);
 303 
 304 public:
 305   // The space may not have it's bottom and top set yet, which is why the
 306   // region is passed as a parameter.  If "init_to_zero" is true, the
 307   // elements of the array are initialized to zero.  Otherwise, they are
 308   // initialized to point backwards to the beginning.
 309   G1BlockOffsetArray(G1BlockOffsetSharedArray* array, MemRegion mr,
 310                      bool init_to_zero);
 311 
 312   // Note: this ought to be part of the constructor, but that would require
 313   // "this" to be passed as a parameter to a member constructor for
 314   // the containing concrete subtype of Space.
 315   // This would be legal C++, but MS VC++ doesn't allow it.
 316   void set_space(G1OffsetTableContigSpace* sp);
 317 
 318   // Resets the covered region to the given "mr".
 319   void set_region(MemRegion mr);
 320 
 321   // Resets the covered region to one with the same _bottom as before but
 322   // the "new_word_size".
 323   void resize(size_t new_word_size);
 324 
 325   // These must be guaranteed to work properly (i.e., do nothing)
 326   // when "blk_start" ("blk" for second version) is "NULL".
 327   virtual void alloc_block(HeapWord* blk_start, HeapWord* blk_end);
 328   virtual void alloc_block(HeapWord* blk, size_t size) {
 329     alloc_block(blk, blk + size);
 330   }
 331 
 332   // The following methods are useful and optimized for a
 333   // general, non-contiguous space.
 334 
 335   // Given a block [blk_start, blk_start + full_blk_size), and
 336   // a left_blk_size < full_blk_size, adjust the BOT to show two
 337   // blocks [blk_start, blk_start + left_blk_size) and
 338   // [blk_start + left_blk_size, blk_start + full_blk_size).
 339   // It is assumed (and verified in the non-product VM) that the
 340   // BOT was correct for the original block.
 341   void split_block(HeapWord* blk_start, size_t full_blk_size,
 342                            size_t left_blk_size);
 343 
 344   // Adjust the BOT to show that it has a single block in the
 345   // range [blk_start, blk_start + size). All necessary BOT
 346   // cards are adjusted, but _unallocated_block isn't.
 347   void single_block(HeapWord* blk_start, HeapWord* blk_end);
 348   void single_block(HeapWord* blk, size_t size) {
 349     single_block(blk, blk + size);
 350   }
 351 
 352   // Adjust BOT to show that it has a block in the range
 353   // [blk_start, blk_start + size). Only the first card
 354   // of BOT is touched. It is assumed (and verified in the
 355   // non-product VM) that the remaining cards of the block
 356   // are correct.
 357   void mark_block(HeapWord* blk_start, HeapWord* blk_end);
 358   void mark_block(HeapWord* blk, size_t size) {
 359     mark_block(blk, blk + size);
 360   }
 361 
 362   // Adjust _unallocated_block to indicate that a particular
 363   // block has been newly allocated or freed. It is assumed (and
 364   // verified in the non-product VM) that the BOT is correct for
 365   // the given block.
 366   inline void allocated(HeapWord* blk_start, HeapWord* blk_end) {
 367     // Verify that the BOT shows [blk, blk + blk_size) to be one block.
 368     verify_single_block(blk_start, blk_end);
 369     if (BlockOffsetArrayUseUnallocatedBlock) {
 370       _unallocated_block = MAX2(_unallocated_block, blk_end);
 371     }
 372   }
 373 
 374   inline void allocated(HeapWord* blk, size_t size) {
 375     allocated(blk, blk + size);
 376   }
 377 
 378   inline void freed(HeapWord* blk_start, HeapWord* blk_end);
 379 
 380   inline void freed(HeapWord* blk, size_t size);
 381 
 382   virtual HeapWord* block_start_unsafe(const void* addr);
 383   virtual HeapWord* block_start_unsafe_const(const void* addr) const;
 384 
 385   // Requires "addr" to be the start of a card and returns the
 386   // start of the block that contains the given address.
 387   HeapWord* block_start_careful(const void* addr) const;
 388 
 389   // If true, initialize array slots with no allocated blocks to zero.
 390   // Otherwise, make them point back to the front.
 391   bool init_to_zero() { return _init_to_zero; }
 392 
 393   // Verification & debugging - ensure that the offset table reflects the fact
 394   // that the block [blk_start, blk_end) or [blk, blk + size) is a
 395   // single block of storage. NOTE: can;t const this because of
 396   // call to non-const do_block_internal() below.
 397   inline void verify_single_block(HeapWord* blk_start, HeapWord* blk_end) {
 398     if (VerifyBlockOffsetArray) {
 399       do_block_internal(blk_start, blk_end, Action_check);
 400     }
 401   }
 402 
 403   inline void verify_single_block(HeapWord* blk, size_t size) {
 404     verify_single_block(blk, blk + size);
 405   }
 406 
 407   // Used by region verification. Checks that the contents of the
 408   // BOT reflect that there's a single object that spans the address
 409   // range [obj_start, obj_start + word_size); returns true if this is
 410   // the case, returns false if it's not.
 411   bool verify_for_object(HeapWord* obj_start, size_t word_size) const;
 412 
 413   // Verify that the given block is before _unallocated_block
 414   inline void verify_not_unallocated(HeapWord* blk_start,
 415                                      HeapWord* blk_end) const {
 416     if (BlockOffsetArrayUseUnallocatedBlock) {
 417       assert(blk_start < blk_end, "Block inconsistency?");
 418       assert(blk_end <= _unallocated_block, "_unallocated_block problem");
 419     }
 420   }
 421 
 422   inline void verify_not_unallocated(HeapWord* blk, size_t size) const {
 423     verify_not_unallocated(blk, blk + size);
 424   }
 425 
 426   void check_all_cards(size_t left_card, size_t right_card) const;
 427 
 428   virtual void print_on(outputStream* out) PRODUCT_RETURN;
 429 };
 430 
 431 // A subtype of BlockOffsetArray that takes advantage of the fact
 432 // that its underlying space is a ContiguousSpace, so that its "active"
 433 // region can be more efficiently tracked (than for a non-contiguous space).
 434 class G1BlockOffsetArrayContigSpace: public G1BlockOffsetArray {
 435   friend class VMStructs;
 436 
 437   // allocation boundary at which offset array must be updated
 438   HeapWord* _next_offset_threshold;
 439   size_t    _next_offset_index;      // index corresponding to that boundary
 440 
 441   // Work function to be called when allocation start crosses the next
 442   // threshold in the contig space.
 443   void alloc_block_work1(HeapWord* blk_start, HeapWord* blk_end) {
 444     alloc_block_work2(&_next_offset_threshold, &_next_offset_index,
 445                       blk_start, blk_end);
 446   }
 447 
 448   // Variant of zero_bottom_entry that does not check for availability of the
 449   // memory first.
 450   void zero_bottom_entry_raw();
 451   // Variant of initialize_threshold that does not check for availability of the
 452   // memory first.
 453   HeapWord* initialize_threshold_raw();
 454   // Zero out the entry for _bottom (offset will be zero).
 455   void zero_bottom_entry();
 456  public:
 457   G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, MemRegion mr);
 458 
 459   // Initialize the threshold to reflect the first boundary after the
 460   // bottom of the covered region.
 461   HeapWord* initialize_threshold();
 462 
 463   void reset_bot() {
 464     zero_bottom_entry_raw();
 465     initialize_threshold_raw();
 466   }
 467 
 468   // Return the next threshold, the point at which the table should be
 469   // updated.
 470   HeapWord* threshold() const { return _next_offset_threshold; }
 471 
 472   // These must be guaranteed to work properly (i.e., do nothing)
 473   // when "blk_start" ("blk" for second version) is "NULL".  In this
 474   // implementation, that's true because NULL is represented as 0, and thus
 475   // never exceeds the "_next_offset_threshold".


  92   // for example, when LAB allocation is used in a space covered by the
  93   // table.)
  94   virtual HeapWord* block_start_unsafe(const void* addr) = 0;
  95   // Same as above, but does not have any of the possible side effects
  96   // discussed above.
  97   virtual HeapWord* block_start_unsafe_const(const void* addr) const = 0;
  98 
  99   // Returns the address of the start of the block containing "addr", or
 100   // else "null" if it is covered by no block.  (May have side effects,
 101   // namely updating of shared array entries that "point" too far
 102   // backwards.  This can occur, for example, when lab allocation is used
 103   // in a space covered by the table.)
 104   inline HeapWord* block_start(const void* addr);
 105   // Same as above, but does not have any of the possible side effects
 106   // discussed above.
 107   inline HeapWord* block_start_const(const void* addr) const;
 108 };
 109 
 110 class G1BlockOffsetSharedArrayMappingChangedListener : public G1MappingChangedListener {
 111  public:
 112   virtual void on_commit(uint start_idx, size_t num_regions) {
 113     // Nothing to do. The BOT is hard-wired to be part of the HeapRegion, and we cannot
 114     // retrieve it here since this would cause firing of several asserts. The code
 115     // executed after commit of a region already needs to do some re-initialization of
 116     // the HeapRegion, so we combine that.
 117   }
 118 };
 119 
 120 // This implementation of "G1BlockOffsetTable" divides the covered region
 121 // into "N"-word subregions (where "N" = 2^"LogN".  An array with an entry
 122 // for each such subregion indicates how far back one must go to find the
 123 // start of the chunk that includes the first word of the subregion.
 124 //
 125 // Each BlockOffsetArray is owned by a Space.  However, the actual array
 126 // may be shared by several BlockOffsetArrays; this is useful
 127 // when a single resizable area (such as a generation) is divided up into
 128 // several spaces in which contiguous allocation takes place,
 129 // such as, for example, in G1 or in the train generation.)
 130 
 131 // Here is the shared array type.
 132 
 133 class G1BlockOffsetSharedArray: public CHeapObj<mtGC> {
 134   friend class G1BlockOffsetArray;
 135   friend class G1BlockOffsetArrayContigSpace;
 136   friend class VMStructs;
 137 


 141   MemRegion _reserved;
 142 
 143   // End of the current committed region.
 144   HeapWord* _end;
 145 
 146   // Array for keeping offsets for retrieving object start fast given an
 147   // address.
 148   u_char* _offset_array;          // byte array keeping backwards offsets
 149 
 150   void check_offset(size_t offset, const char* msg) const {
 151     assert(offset <= N_words,
 152            err_msg("%s - "
 153                    "offset: " SIZE_FORMAT", N_words: %u",
 154                    msg, offset, (uint)N_words));
 155   }
 156 
 157   // Bounds checking accessors:
 158   // For performance these have to devolve to array accesses in product builds.
 159   inline u_char offset_array(size_t index) const;
 160 


 161   void set_offset_array_raw(size_t index, u_char offset) {
 162     _offset_array[index] = offset;
 163   }
 164 
 165   inline void set_offset_array(size_t index, u_char offset);
 166 
 167   inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
 168 
 169   inline void set_offset_array(size_t left, size_t right, u_char offset);
 170 


 171   bool is_card_boundary(HeapWord* p) const;
 172 
 173 public:
 174 
 175   // Return the number of slots needed for an offset array
 176   // that covers mem_region_words words.
 177   static size_t compute_size(size_t mem_region_words) {
 178     size_t number_of_slots = (mem_region_words / N_words);
 179     return ReservedSpace::allocation_align_size_up(number_of_slots);
 180   }
 181 
 182   enum SomePublicConstants {
 183     LogN = 9,
 184     LogN_words = LogN - LogHeapWordSize,
 185     N_bytes = 1 << LogN,
 186     N_words = 1 << LogN_words
 187   };
 188 
 189   // Initialize the table to cover from "base" to (at least)
 190   // "base + init_word_size".  In the future, the table may be expanded
 191   // (see "resize" below) up to the size of "_reserved" (which must be at
 192   // least "init_word_size".) The contents of the initial table are
 193   // undefined; it is the responsibility of the constituent
 194   // G1BlockOffsetTable(s) to initialize cards.
 195   G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage);
 196 


 197   // Return the appropriate index into "_offset_array" for "p".
 198   inline size_t index_for(const void* p) const;
 199   inline size_t index_for_raw(const void* p) const;
 200 
 201   // Return the address indicating the start of the region corresponding to
 202   // "index" in "_offset_array".
 203   inline HeapWord* address_for_index(size_t index) const;
 204   // Variant of address_for_index that does not check the index for validity.
 205   inline HeapWord* address_for_index_raw(size_t index) const {
 206     return _reserved.start() + (index << LogN_words);
 207   }
 208 };
 209 
 210 // And here is the G1BlockOffsetTable subtype that uses the array.
 211 
 212 class G1BlockOffsetArray: public G1BlockOffsetTable {
 213   friend class G1BlockOffsetSharedArray;
 214   friend class G1BlockOffsetArrayContigSpace;
 215   friend class VMStructs;
 216 private:
 217   enum SomePrivateConstants {
 218     N_words = G1BlockOffsetSharedArray::N_words,
 219     LogN    = G1BlockOffsetSharedArray::LogN
 220   };
 221 








 222   // This is the array, which can be shared by several BlockOffsetArray's
 223   // servicing different
 224   G1BlockOffsetSharedArray* _array;
 225 
 226   // The space that owns this subregion.
 227   G1OffsetTableContigSpace* _gsp;
 228 




 229   // The portion [_unallocated_block, _sp.end()) of the space that
 230   // is a single block known not to contain any objects.
 231   // NOTE: See BlockOffsetArrayUseUnallocatedBlock flag.
 232   HeapWord* _unallocated_block;
 233 
 234   // Sets the entries
 235   // corresponding to the cards starting at "start" and ending at "end"
 236   // to point back to the card before "start": the interval [start, end)
 237   // is right-open.
 238   void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
 239   // Same as above, except that the args here are a card _index_ interval
 240   // that is closed: [start_index, end_index]
 241   void set_remainder_to_point_to_start_incl(size_t start, size_t end);
 242 



 243 protected:
 244 
 245   G1OffsetTableContigSpace* gsp() const { return _gsp; }
 246 
 247   inline size_t block_size(const HeapWord* p) const;
 248 
 249   // Returns the address of a block whose start is at most "addr".
 250   // If "has_max_index" is true, "assumes "max_index" is the last valid one
 251   // in the array.
 252   inline HeapWord* block_at_or_preceding(const void* addr,
 253                                          bool has_max_index,
 254                                          size_t max_index) const;
 255 
 256   // "q" is a block boundary that is <= "addr"; "n" is the address of the
 257   // next block (or the end of the space.)  Return the address of the
 258   // beginning of the block that contains "addr".  Does so without side
 259   // effects (see, e.g., spec of  block_start.)
 260   inline HeapWord*
 261   forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
 262                                          const void* addr) const;


 270   // "q" is a block boundary that is <= "addr"; "n" is the address of the
 271   // next block (or the end of the space.)  Return the address of the
 272   // beginning of the block that contains "addr".  May have side effects
 273   // on "this", by updating imprecise entries.
 274   HeapWord* forward_to_block_containing_addr_slow(HeapWord* q,
 275                                                   HeapWord* n,
 276                                                   const void* addr);
 277 
 278   // Requires that "*threshold_" be the first array entry boundary at or
 279   // above "blk_start", and that "*index_" be the corresponding array
 280   // index.  If the block starts at or crosses "*threshold_", records
 281   // "blk_start" as the appropriate block start for the array index
 282   // starting at "*threshold_", and for any other indices crossed by the
 283   // block.  Updates "*threshold_" and "*index_" to correspond to the first
 284   // index after the block end.
 285   void alloc_block_work2(HeapWord** threshold_, size_t* index_,
 286                          HeapWord* blk_start, HeapWord* blk_end);
 287 
 288 public:
 289   // The space may not have it's bottom and top set yet, which is why the
 290   // region is passed as a parameter. The elements of the array are
 291   // initialized to zero.
 292   G1BlockOffsetArray(G1BlockOffsetSharedArray* array, MemRegion mr);


 293 
 294   // Note: this ought to be part of the constructor, but that would require
 295   // "this" to be passed as a parameter to a member constructor for
 296   // the containing concrete subtype of Space.
 297   // This would be legal C++, but MS VC++ doesn't allow it.
 298   void set_space(G1OffsetTableContigSpace* sp);
 299 



 300   // Resets the covered region to one with the same _bottom as before but
 301   // the "new_word_size".
 302   void resize(size_t new_word_size);
 303 

























































 304   virtual HeapWord* block_start_unsafe(const void* addr);
 305   virtual HeapWord* block_start_unsafe_const(const void* addr) const;
 306 






















 307   // Used by region verification. Checks that the contents of the
 308   // BOT reflect that there's a single object that spans the address
 309   // range [obj_start, obj_start + word_size); returns true if this is
 310   // the case, returns false if it's not.
 311   bool verify_for_object(HeapWord* obj_start, size_t word_size) const;
 312 













 313   void check_all_cards(size_t left_card, size_t right_card) const;
 314 
 315   virtual void print_on(outputStream* out) PRODUCT_RETURN;
 316 };
 317 
 318 // A subtype of BlockOffsetArray that takes advantage of the fact
 319 // that its underlying space is a ContiguousSpace, so that its "active"
 320 // region can be more efficiently tracked (than for a non-contiguous space).
 321 class G1BlockOffsetArrayContigSpace: public G1BlockOffsetArray {
 322   friend class VMStructs;
 323 
 324   // allocation boundary at which offset array must be updated
 325   HeapWord* _next_offset_threshold;
 326   size_t    _next_offset_index;      // index corresponding to that boundary
 327 
 328   // Work function to be called when allocation start crosses the next
 329   // threshold in the contig space.
 330   void alloc_block_work1(HeapWord* blk_start, HeapWord* blk_end) {
 331     alloc_block_work2(&_next_offset_threshold, &_next_offset_index,
 332                       blk_start, blk_end);
 333   }
 334 
 335   // Variant of zero_bottom_entry that does not check for availability of the
 336   // memory first.
 337   void zero_bottom_entry_raw();
 338   // Variant of initialize_threshold that does not check for availability of the
 339   // memory first.
 340   HeapWord* initialize_threshold_raw();


 341  public:
 342   G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, MemRegion mr);
 343 
 344   // Initialize the threshold to reflect the first boundary after the
 345   // bottom of the covered region.
 346   HeapWord* initialize_threshold();
 347 
 348   void reset_bot() {
 349     zero_bottom_entry_raw();
 350     initialize_threshold_raw();
 351   }
 352 
 353   // Return the next threshold, the point at which the table should be
 354   // updated.
 355   HeapWord* threshold() const { return _next_offset_threshold; }
 356 
 357   // These must be guaranteed to work properly (i.e., do nothing)
 358   // when "blk_start" ("blk" for second version) is "NULL".  In this
 359   // implementation, that's true because NULL is represented as 0, and thus
 360   // never exceeds the "_next_offset_threshold".
src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File