src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp

Print this page




 114   inline IterationStatus iterate(ParMarkBitMapClosure* live_closure,
 115                                  ParMarkBitMapClosure* dead_closure,
 116                                  HeapWord* range_beg,
 117                                  HeapWord* range_end,
 118                                  HeapWord* dead_range_end) const;
 119 
 120   // Return the number of live words in the range [beg_addr, end_obj) due to
 121   // objects that start in the range.  If a live object extends onto the range,
 122   // the caller must detect and account for any live words due to that object.
 123   // If a live object extends beyond the end of the range, only the words within
 124   // the range are included in the result. The end of the range must be a live object,
 125   // which is the case when updating pointers.  This allows a branch to be removed
 126   // from inside the loop.
 127   size_t live_words_in_range(HeapWord* beg_addr, oop end_obj) const;
 128 
 129   inline HeapWord* region_start() const;
 130   inline HeapWord* region_end() const;
 131   inline size_t    region_size() const;
 132   inline size_t    size() const;
 133 


 134   // Convert a heap address to/from a bit index.
 135   inline idx_t     addr_to_bit(HeapWord* addr) const;
 136   inline HeapWord* bit_to_addr(idx_t bit) const;
 137 
 138   // Return the bit index of the first marked object that begins (or ends,
 139   // respectively) in the range [beg, end).  If no object is found, return end.
 140   inline idx_t find_obj_beg(idx_t beg, idx_t end) const;
 141   inline idx_t find_obj_end(idx_t beg, idx_t end) const;
 142 
 143   inline HeapWord* find_obj_beg(HeapWord* beg, HeapWord* end) const;
 144   inline HeapWord* find_obj_end(HeapWord* beg, HeapWord* end) const;
 145 
 146   // Clear a range of bits or the entire bitmap (both begin and end bits are
 147   // cleared).
 148   inline void clear_range(idx_t beg, idx_t end);
 149 
 150   // Return the number of bits required to represent the specified number of
 151   // HeapWords, or the specified region.
 152   static inline idx_t bits_required(size_t words);
 153   static inline idx_t bits_required(MemRegion covered_region);


 159   }
 160 
 161 #ifdef  ASSERT
 162   void verify_clear() const;
 163   inline void verify_bit(idx_t bit) const;
 164   inline void verify_addr(HeapWord* addr) const;
 165 #endif  // #ifdef ASSERT
 166 
 167 private:
 168   // Each bit in the bitmap represents one unit of 'object granularity.' Objects
 169   // are double-word aligned in 32-bit VMs, but not in 64-bit VMs, so the 32-bit
 170   // granularity is 2, 64-bit is 1.
 171   static inline size_t obj_granularity() { return size_t(MinObjAlignment); }
 172   static inline int obj_granularity_shift() { return LogMinObjAlignment; }
 173 
 174   HeapWord*       _region_start;
 175   size_t          _region_size;
 176   BitMap          _beg_bits;
 177   BitMap          _end_bits;
 178   PSVirtualSpace* _virtual_space;

 179 };
 180 
 181 inline ParMarkBitMap::ParMarkBitMap():
 182   _beg_bits(), _end_bits(), _region_start(NULL), _region_size(0), _virtual_space(NULL)
 183 { }
 184 
 185 inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end)
 186 {
 187   _beg_bits.clear_range(beg, end);
 188   _end_bits.clear_range(beg, end);
 189 }
 190 
 191 inline ParMarkBitMap::idx_t
 192 ParMarkBitMap::bits_required(size_t words)
 193 {
 194   // Need two bits (one begin bit, one end bit) for each unit of 'object
 195   // granularity' in the heap.
 196   return words_to_bits(words * 2);
 197 }
 198 
 199 inline ParMarkBitMap::idx_t
 200 ParMarkBitMap::bits_required(MemRegion covered_region)
 201 {
 202   return bits_required(covered_region.word_size());




 114   inline IterationStatus iterate(ParMarkBitMapClosure* live_closure,
 115                                  ParMarkBitMapClosure* dead_closure,
 116                                  HeapWord* range_beg,
 117                                  HeapWord* range_end,
 118                                  HeapWord* dead_range_end) const;
 119 
 120   // Return the number of live words in the range [beg_addr, end_obj) due to
 121   // objects that start in the range.  If a live object extends onto the range,
 122   // the caller must detect and account for any live words due to that object.
 123   // If a live object extends beyond the end of the range, only the words within
 124   // the range are included in the result. The end of the range must be a live object,
 125   // which is the case when updating pointers.  This allows a branch to be removed
 126   // from inside the loop.
 127   size_t live_words_in_range(HeapWord* beg_addr, oop end_obj) const;
 128 
 129   inline HeapWord* region_start() const;
 130   inline HeapWord* region_end() const;
 131   inline size_t    region_size() const;
 132   inline size_t    size() const;
 133 
 134   size_t reserved_byte_size() const { return _reserved_byte_size; }
 135 
 136   // Convert a heap address to/from a bit index.
 137   inline idx_t     addr_to_bit(HeapWord* addr) const;
 138   inline HeapWord* bit_to_addr(idx_t bit) const;
 139 
 140   // Return the bit index of the first marked object that begins (or ends,
 141   // respectively) in the range [beg, end).  If no object is found, return end.
 142   inline idx_t find_obj_beg(idx_t beg, idx_t end) const;
 143   inline idx_t find_obj_end(idx_t beg, idx_t end) const;
 144 
 145   inline HeapWord* find_obj_beg(HeapWord* beg, HeapWord* end) const;
 146   inline HeapWord* find_obj_end(HeapWord* beg, HeapWord* end) const;
 147 
 148   // Clear a range of bits or the entire bitmap (both begin and end bits are
 149   // cleared).
 150   inline void clear_range(idx_t beg, idx_t end);
 151 
 152   // Return the number of bits required to represent the specified number of
 153   // HeapWords, or the specified region.
 154   static inline idx_t bits_required(size_t words);
 155   static inline idx_t bits_required(MemRegion covered_region);


 161   }
 162 
 163 #ifdef  ASSERT
 164   void verify_clear() const;
 165   inline void verify_bit(idx_t bit) const;
 166   inline void verify_addr(HeapWord* addr) const;
 167 #endif  // #ifdef ASSERT
 168 
 169 private:
 170   // Each bit in the bitmap represents one unit of 'object granularity.' Objects
 171   // are double-word aligned in 32-bit VMs, but not in 64-bit VMs, so the 32-bit
 172   // granularity is 2, 64-bit is 1.
 173   static inline size_t obj_granularity() { return size_t(MinObjAlignment); }
 174   static inline int obj_granularity_shift() { return LogMinObjAlignment; }
 175 
 176   HeapWord*       _region_start;
 177   size_t          _region_size;
 178   BitMap          _beg_bits;
 179   BitMap          _end_bits;
 180   PSVirtualSpace* _virtual_space;
 181   size_t          _reserved_byte_size;
 182 };
 183 
 184 inline ParMarkBitMap::ParMarkBitMap():
 185   _beg_bits(), _end_bits(), _region_start(NULL), _region_size(0), _virtual_space(NULL), _reserved_byte_size(0)
 186 { }
 187 
 188 inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end)
 189 {
 190   _beg_bits.clear_range(beg, end);
 191   _end_bits.clear_range(beg, end);
 192 }
 193 
 194 inline ParMarkBitMap::idx_t
 195 ParMarkBitMap::bits_required(size_t words)
 196 {
 197   // Need two bits (one begin bit, one end bit) for each unit of 'object
 198   // granularity' in the heap.
 199   return words_to_bits(words * 2);
 200 }
 201 
 202 inline ParMarkBitMap::idx_t
 203 ParMarkBitMap::bits_required(MemRegion covered_region)
 204 {
 205   return bits_required(covered_region.word_size());