< prev index next >

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

Print this page
rev 8137 : 8077836: Make sure G1ParGCAllocBuffer are marked as retired
Reviewed-by:


 152   bool _retired;
 153 
 154 public:
 155   G1ParGCAllocBuffer(size_t gclab_word_size);
 156   virtual ~G1ParGCAllocBuffer() {
 157     guarantee(_retired, "Allocation buffer has not been retired");
 158   }
 159 
 160   virtual void set_buf(HeapWord* buf) {
 161     ParGCAllocBuffer::set_buf(buf);
 162     _retired = false;
 163   }
 164 
 165   virtual void retire() {
 166     if (_retired) {
 167       return;
 168     }
 169     ParGCAllocBuffer::retire();
 170     _retired = true;
 171   }





 172 };
 173 
 174 class G1ParGCAllocator : public CHeapObj<mtGC> {
 175   friend class G1ParScanThreadState;
 176 protected:
 177   G1CollectedHeap* _g1h;
 178 
 179   // The survivor alignment in effect in bytes.
 180   // == 0 : don't align survivors
 181   // != 0 : align survivors to that alignment
 182   // These values were chosen to favor the non-alignment case since some
 183   // architectures have a special compare against zero instructions.
 184   const uint _survivor_alignment_bytes;
 185 
 186   size_t _alloc_buffer_waste;
 187   size_t _undo_waste;
 188 
 189   void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
 190   void add_to_undo_waste(size_t waste)         { _undo_waste += waste; }
 191 


 194 
 195   // Calculate the survivor space object alignment in bytes. Returns that or 0 if
 196   // there are no restrictions on survivor alignment.
 197   static uint calc_survivor_alignment_bytes() {
 198     assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
 199     if (SurvivorAlignmentInBytes == ObjectAlignmentInBytes) {
 200       // No need to align objects in the survivors differently, return 0
 201       // which means "survivor alignment is not used".
 202       return 0;
 203     } else {
 204       assert(SurvivorAlignmentInBytes > 0, "sanity");
 205       return SurvivorAlignmentInBytes;
 206     }
 207   }
 208 
 209 public:
 210   G1ParGCAllocator(G1CollectedHeap* g1h) :
 211     _g1h(g1h), _survivor_alignment_bytes(calc_survivor_alignment_bytes()),
 212     _alloc_buffer_waste(0), _undo_waste(0) {
 213   }

 214 
 215   static G1ParGCAllocator* create_allocator(G1CollectedHeap* g1h);
 216 
 217   size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
 218   size_t undo_waste() {return _undo_waste; }
 219 
 220   // Allocate word_sz words in dest, either directly into the regions or by
 221   // allocating a new PLAB. Returns the address of the allocated memory, NULL if
 222   // not successful.
 223   HeapWord* allocate_direct_or_new_plab(InCSetState dest,
 224                                         size_t word_sz,
 225                                         AllocationContext_t context);
 226 
 227   // Allocate word_sz words in the PLAB of dest.  Returns the address of the
 228   // allocated memory, NULL if not successful.
 229   HeapWord* plab_allocate(InCSetState dest,
 230                           size_t word_sz,
 231                           AllocationContext_t context) {
 232     G1ParGCAllocBuffer* buffer = alloc_buffer(dest, context);
 233     if (_survivor_alignment_bytes == 0) {




 152   bool _retired;
 153 
 154 public:
 155   G1ParGCAllocBuffer(size_t gclab_word_size);
 156   virtual ~G1ParGCAllocBuffer() {
 157     guarantee(_retired, "Allocation buffer has not been retired");
 158   }
 159 
 160   virtual void set_buf(HeapWord* buf) {
 161     ParGCAllocBuffer::set_buf(buf);
 162     _retired = false;
 163   }
 164 
 165   virtual void retire() {
 166     if (_retired) {
 167       return;
 168     }
 169     ParGCAllocBuffer::retire();
 170     _retired = true;
 171   }
 172 
 173   virtual void flush_and_retire_stats(PLABStats* stats) {
 174     ParGCAllocBuffer::flush_and_retire_stats(stats);
 175     _retired = true;
 176   }
 177 };
 178 
 179 class G1ParGCAllocator : public CHeapObj<mtGC> {
 180   friend class G1ParScanThreadState;
 181 protected:
 182   G1CollectedHeap* _g1h;
 183 
 184   // The survivor alignment in effect in bytes.
 185   // == 0 : don't align survivors
 186   // != 0 : align survivors to that alignment
 187   // These values were chosen to favor the non-alignment case since some
 188   // architectures have a special compare against zero instructions.
 189   const uint _survivor_alignment_bytes;
 190 
 191   size_t _alloc_buffer_waste;
 192   size_t _undo_waste;
 193 
 194   void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
 195   void add_to_undo_waste(size_t waste)         { _undo_waste += waste; }
 196 


 199 
 200   // Calculate the survivor space object alignment in bytes. Returns that or 0 if
 201   // there are no restrictions on survivor alignment.
 202   static uint calc_survivor_alignment_bytes() {
 203     assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
 204     if (SurvivorAlignmentInBytes == ObjectAlignmentInBytes) {
 205       // No need to align objects in the survivors differently, return 0
 206       // which means "survivor alignment is not used".
 207       return 0;
 208     } else {
 209       assert(SurvivorAlignmentInBytes > 0, "sanity");
 210       return SurvivorAlignmentInBytes;
 211     }
 212   }
 213 
 214 public:
 215   G1ParGCAllocator(G1CollectedHeap* g1h) :
 216     _g1h(g1h), _survivor_alignment_bytes(calc_survivor_alignment_bytes()),
 217     _alloc_buffer_waste(0), _undo_waste(0) {
 218   }
 219   virtual ~G1ParGCAllocator() { }
 220 
 221   static G1ParGCAllocator* create_allocator(G1CollectedHeap* g1h);
 222 
 223   size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
 224   size_t undo_waste() {return _undo_waste; }
 225 
 226   // Allocate word_sz words in dest, either directly into the regions or by
 227   // allocating a new PLAB. Returns the address of the allocated memory, NULL if
 228   // not successful.
 229   HeapWord* allocate_direct_or_new_plab(InCSetState dest,
 230                                         size_t word_sz,
 231                                         AllocationContext_t context);
 232 
 233   // Allocate word_sz words in the PLAB of dest.  Returns the address of the
 234   // allocated memory, NULL if not successful.
 235   HeapWord* plab_allocate(InCSetState dest,
 236                           size_t word_sz,
 237                           AllocationContext_t context) {
 238     G1ParGCAllocBuffer* buffer = alloc_buffer(dest, context);
 239     if (_survivor_alignment_bytes == 0) {


< prev index next >