< prev index next >

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

Print this page




   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP
  26 #define SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP
  27 
  28 #include "gc/g1/g1RegionToSpaceMapper.hpp"

  29 #include "memory/memRegion.hpp"
  30 #include "memory/virtualspace.hpp"
  31 #include "utilities/globalDefinitions.hpp"
  32 
  33 // Forward declarations
  34 class G1BlockOffsetTable;
  35 class G1ContiguousSpace;
  36 
  37 // This implementation of "G1BlockOffsetTable" divides the covered region
  38 // into "N"-word subregions (where "N" = 2^"LogN".  An array with an entry
  39 // for each such subregion indicates how far back one must go to find the
  40 // start of the chunk that includes the first word of the subregion.
  41 //
  42 // Each G1BlockOffsetTablePart is owned by a G1ContiguousSpace.
  43 
  44 class G1BlockOffsetTable: public CHeapObj<mtGC> {
  45   friend class G1BlockOffsetTablePart;
  46   friend class VMStructs;
  47 
  48 private:
  49   // The reserved region covered by the table.
  50   MemRegion _reserved;
  51 
  52   // Array for keeping offsets for retrieving object start fast given an
  53   // address.
  54   u_char* _offset_array;          // byte array keeping backwards offsets
  55 
  56   void check_offset(size_t offset, const char* msg) const {
  57     assert(offset <= N_words,
  58            "%s - offset: " SIZE_FORMAT ", N_words: %u",
  59            msg, offset, (uint)N_words);
  60   }
  61 
  62   // Bounds checking accessors:
  63   // For performance these have to devolve to array accesses in product builds.
  64   inline u_char offset_array(size_t index) const;
  65 
  66   void set_offset_array_raw(size_t index, u_char offset) {
  67     _offset_array[index] = offset;
  68   }
  69 
  70   inline void set_offset_array(size_t index, u_char offset);
  71 
  72   inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
  73 
  74   inline void set_offset_array(size_t left, size_t right, u_char offset);
  75 
  76   bool is_card_boundary(HeapWord* p) const;
  77 
  78   void check_index(size_t index, const char* msg) const NOT_DEBUG_RETURN;
  79 
  80 public:
  81 
  82   // Return the number of slots needed for an offset array
  83   // that covers mem_region_words words.
  84   static size_t compute_size(size_t mem_region_words) {
  85     size_t number_of_slots = (mem_region_words / N_words);
  86     return ReservedSpace::allocation_align_size_up(number_of_slots);
  87   }
  88 
  89   // Returns how many bytes of the heap a single byte of the BOT corresponds to.
  90   static size_t heap_map_factor() {
  91     return N_bytes;
  92   }
  93 
  94   enum SomePublicConstants {
  95     LogN = 9,
  96     LogN_words = LogN - LogHeapWordSize,
  97     N_bytes = 1 << LogN,
  98     N_words = 1 << LogN_words
  99   };
 100 
 101   // Initialize the Block Offset Table to cover the memory region passed
 102   // in the heap parameter.
 103   G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage);
 104 
 105   // Return the appropriate index into "_offset_array" for "p".
 106   inline size_t index_for(const void* p) const;
 107   inline size_t index_for_raw(const void* p) const;
 108 
 109   // Return the address indicating the start of the region corresponding to
 110   // "index" in "_offset_array".
 111   inline HeapWord* address_for_index(size_t index) const;
 112   // Variant of address_for_index that does not check the index for validity.
 113   inline HeapWord* address_for_index_raw(size_t index) const {
 114     return _reserved.start() + (index << LogN_words);
 115   }
 116 };
 117 
 118 class G1BlockOffsetTablePart VALUE_OBJ_CLASS_SPEC {
 119   friend class G1BlockOffsetTable;
 120   friend class VMStructs;
 121 private:
 122   enum SomePrivateConstants {
 123     N_words = G1BlockOffsetTable::N_words,
 124     LogN    = G1BlockOffsetTable::LogN
 125   };
 126 
 127   // allocation boundary at which offset array must be updated
 128   HeapWord* _next_offset_threshold;
 129   size_t    _next_offset_index;      // index corresponding to that boundary
 130 
 131   // This is the global BlockOffsetTable.
 132   G1BlockOffsetTable* _bot;
 133 
 134   // The space that owns this subregion.
 135   G1ContiguousSpace* _space;
 136 
 137   // Sets the entries
 138   // corresponding to the cards starting at "start" and ending at "end"
 139   // to point back to the card before "start": the interval [start, end)
 140   // is right-open.
 141   void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
 142   // Same as above, except that the args here are a card _index_ interval
 143   // that is closed: [start_index, end_index]
 144   void set_remainder_to_point_to_start_incl(size_t start, size_t end);
 145 
 146   // Zero out the entry for _bottom (offset will be zero). Does not check for availability of the




   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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP
  26 #define SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP
  27 
  28 #include "gc/g1/g1RegionToSpaceMapper.hpp"
  29 #include "gc/shared/blockOffsetTable.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "memory/virtualspace.hpp"
  32 #include "utilities/globalDefinitions.hpp"
  33 
  34 // Forward declarations
  35 class G1BlockOffsetTable;
  36 class G1ContiguousSpace;
  37 
  38 // This implementation of "G1BlockOffsetTable" divides the covered region
  39 // into "N"-word subregions (where "N" = 2^"LogN".  An array with an entry
  40 // for each such subregion indicates how far back one must go to find the
  41 // start of the chunk that includes the first word of the subregion.
  42 //
  43 // Each G1BlockOffsetTablePart is owned by a G1ContiguousSpace.
  44 
  45 class G1BlockOffsetTable: public CHeapObj<mtGC> {
  46   friend class G1BlockOffsetTablePart;
  47   friend class VMStructs;
  48 
  49 private:
  50   // The reserved region covered by the table.
  51   MemRegion _reserved;
  52 
  53   // Array for keeping offsets for retrieving object start fast given an
  54   // address.
  55   u_char* _offset_array;          // byte array keeping backwards offsets
  56 
  57   void check_offset(size_t offset, const char* msg) const {
  58     assert(offset <= BOTConstants::N_words,
  59            "%s - offset: " SIZE_FORMAT ", N_words: %u",
  60            msg, offset, BOTConstants::N_words);
  61   }
  62 
  63   // Bounds checking accessors:
  64   // For performance these have to devolve to array accesses in product builds.
  65   inline u_char offset_array(size_t index) const;
  66 
  67   void set_offset_array_raw(size_t index, u_char offset) {
  68     _offset_array[index] = offset;
  69   }
  70 
  71   inline void set_offset_array(size_t index, u_char offset);
  72 
  73   inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
  74 
  75   inline void set_offset_array(size_t left, size_t right, u_char offset);
  76 
  77   bool is_card_boundary(HeapWord* p) const;
  78 
  79   void check_index(size_t index, const char* msg) const NOT_DEBUG_RETURN;
  80 
  81 public:
  82 
  83   // Return the number of slots needed for an offset array
  84   // that covers mem_region_words words.
  85   static size_t compute_size(size_t mem_region_words) {
  86     size_t number_of_slots = (mem_region_words / BOTConstants::N_words);
  87     return ReservedSpace::allocation_align_size_up(number_of_slots);
  88   }
  89 
  90   // Returns how many bytes of the heap a single byte of the BOT corresponds to.
  91   static size_t heap_map_factor() {
  92     return BOTConstants::N_bytes;
  93   }
  94 







  95   // Initialize the Block Offset Table to cover the memory region passed
  96   // in the heap parameter.
  97   G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage);
  98 
  99   // Return the appropriate index into "_offset_array" for "p".
 100   inline size_t index_for(const void* p) const;
 101   inline size_t index_for_raw(const void* p) const;
 102 
 103   // Return the address indicating the start of the region corresponding to
 104   // "index" in "_offset_array".
 105   inline HeapWord* address_for_index(size_t index) const;
 106   // Variant of address_for_index that does not check the index for validity.
 107   inline HeapWord* address_for_index_raw(size_t index) const {
 108     return _reserved.start() + (index << BOTConstants::LogN_words);
 109   }
 110 };
 111 
 112 class G1BlockOffsetTablePart VALUE_OBJ_CLASS_SPEC {
 113   friend class G1BlockOffsetTable;
 114   friend class VMStructs;
 115 private:





 116   // allocation boundary at which offset array must be updated
 117   HeapWord* _next_offset_threshold;
 118   size_t    _next_offset_index;      // index corresponding to that boundary
 119 
 120   // This is the global BlockOffsetTable.
 121   G1BlockOffsetTable* _bot;
 122 
 123   // The space that owns this subregion.
 124   G1ContiguousSpace* _space;
 125 
 126   // Sets the entries
 127   // corresponding to the cards starting at "start" and ending at "end"
 128   // to point back to the card before "start": the interval [start, end)
 129   // is right-open.
 130   void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
 131   // Same as above, except that the args here are a card _index_ interval
 132   // that is closed: [start_index, end_index]
 133   void set_remainder_to_point_to_start_incl(size_t start, size_t end);
 134 
 135   // Zero out the entry for _bottom (offset will be zero). Does not check for availability of the


< prev index next >