< prev index next >

src/hotspot/share/gc/g1/g1Allocator.hpp

Print this page




  50   virtual void set_old_full(AllocationContext_t context) = 0;
  51 
  52   // Accessors to the allocation regions.
  53   virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) = 0;
  54   virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) = 0;
  55 
  56   // Allocation attempt during GC for a survivor object / PLAB.
  57   inline HeapWord* survivor_attempt_allocation(size_t min_word_size,
  58                                                size_t desired_word_size,
  59                                                size_t* actual_word_size,
  60                                                AllocationContext_t context);
  61   // Allocation attempt during GC for an old object / PLAB.
  62   inline HeapWord* old_attempt_allocation(size_t min_word_size,
  63                                           size_t desired_word_size,
  64                                           size_t* actual_word_size,
  65                                           AllocationContext_t context);
  66 public:
  67   G1Allocator(G1CollectedHeap* heap) : _g1h(heap) { }
  68   virtual ~G1Allocator() { }
  69 
  70   static G1Allocator* create_allocator(G1CollectedHeap* g1h);
  71 
  72 #ifdef ASSERT
  73   // Do we currently have an active mutator region to allocate into?
  74   bool has_mutator_alloc_region(AllocationContext_t context) { return mutator_alloc_region(context)->get() != NULL; }
  75 #endif
  76   virtual void init_mutator_alloc_region() = 0;
  77   virtual void release_mutator_alloc_region() = 0;
  78 
  79   virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
  80   virtual void release_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
  81   virtual void abandon_gc_alloc_regions() = 0;
  82 
  83   // Management of retained regions.
  84 
  85   virtual bool is_retained_old_region(HeapRegion* hr) = 0;
  86   void reuse_retained_old_region(EvacuationInfo& evacuation_info,
  87                                  OldGCAllocRegion* old,
  88                                  HeapRegion** retained);
  89 
  90   // Allocate blocks of memory during mutator time.
  91 


 205   static uint calc_survivor_alignment_bytes() {
 206     assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
 207     if (SurvivorAlignmentInBytes == ObjectAlignmentInBytes) {
 208       // No need to align objects in the survivors differently, return 0
 209       // which means "survivor alignment is not used".
 210       return 0;
 211     } else {
 212       assert(SurvivorAlignmentInBytes > 0, "sanity");
 213       return SurvivorAlignmentInBytes;
 214     }
 215   }
 216 
 217   HeapWord* allocate_new_plab(InCSetState dest,
 218                               size_t word_sz,
 219                               AllocationContext_t context);
 220 
 221   bool may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const;
 222 public:
 223   G1PLABAllocator(G1Allocator* allocator);
 224   virtual ~G1PLABAllocator() { }
 225 
 226   static G1PLABAllocator* create_allocator(G1Allocator* allocator);
 227 
 228   virtual void waste(size_t& wasted, size_t& undo_wasted) = 0;
 229 
 230   // Allocate word_sz words in dest, either directly into the regions or by
 231   // allocating a new PLAB. Returns the address of the allocated memory, NULL if
 232   // not successful. Plab_refill_failed indicates whether an attempt to refill the
 233   // PLAB failed or not.
 234   HeapWord* allocate_direct_or_new_plab(InCSetState dest,
 235                                         size_t word_sz,
 236                                         AllocationContext_t context,
 237                                         bool* plab_refill_failed);
 238 
 239   // Allocate word_sz words in the PLAB of dest.  Returns the address of the
 240   // allocated memory, NULL if not successful.
 241   inline HeapWord* plab_allocate(InCSetState dest,
 242                                  size_t word_sz,
 243                                  AllocationContext_t context);
 244 
 245   HeapWord* allocate(InCSetState dest,
 246                      size_t word_sz,




  50   virtual void set_old_full(AllocationContext_t context) = 0;
  51 
  52   // Accessors to the allocation regions.
  53   virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) = 0;
  54   virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) = 0;
  55 
  56   // Allocation attempt during GC for a survivor object / PLAB.
  57   inline HeapWord* survivor_attempt_allocation(size_t min_word_size,
  58                                                size_t desired_word_size,
  59                                                size_t* actual_word_size,
  60                                                AllocationContext_t context);
  61   // Allocation attempt during GC for an old object / PLAB.
  62   inline HeapWord* old_attempt_allocation(size_t min_word_size,
  63                                           size_t desired_word_size,
  64                                           size_t* actual_word_size,
  65                                           AllocationContext_t context);
  66 public:
  67   G1Allocator(G1CollectedHeap* heap) : _g1h(heap) { }
  68   virtual ~G1Allocator() { }
  69 


  70 #ifdef ASSERT
  71   // Do we currently have an active mutator region to allocate into?
  72   bool has_mutator_alloc_region(AllocationContext_t context) { return mutator_alloc_region(context)->get() != NULL; }
  73 #endif
  74   virtual void init_mutator_alloc_region() = 0;
  75   virtual void release_mutator_alloc_region() = 0;
  76 
  77   virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
  78   virtual void release_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
  79   virtual void abandon_gc_alloc_regions() = 0;
  80 
  81   // Management of retained regions.
  82 
  83   virtual bool is_retained_old_region(HeapRegion* hr) = 0;
  84   void reuse_retained_old_region(EvacuationInfo& evacuation_info,
  85                                  OldGCAllocRegion* old,
  86                                  HeapRegion** retained);
  87 
  88   // Allocate blocks of memory during mutator time.
  89 


 203   static uint calc_survivor_alignment_bytes() {
 204     assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
 205     if (SurvivorAlignmentInBytes == ObjectAlignmentInBytes) {
 206       // No need to align objects in the survivors differently, return 0
 207       // which means "survivor alignment is not used".
 208       return 0;
 209     } else {
 210       assert(SurvivorAlignmentInBytes > 0, "sanity");
 211       return SurvivorAlignmentInBytes;
 212     }
 213   }
 214 
 215   HeapWord* allocate_new_plab(InCSetState dest,
 216                               size_t word_sz,
 217                               AllocationContext_t context);
 218 
 219   bool may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const;
 220 public:
 221   G1PLABAllocator(G1Allocator* allocator);
 222   virtual ~G1PLABAllocator() { }


 223 
 224   virtual void waste(size_t& wasted, size_t& undo_wasted) = 0;
 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. Plab_refill_failed indicates whether an attempt to refill the
 229   // PLAB failed or not.
 230   HeapWord* allocate_direct_or_new_plab(InCSetState dest,
 231                                         size_t word_sz,
 232                                         AllocationContext_t context,
 233                                         bool* plab_refill_failed);
 234 
 235   // Allocate word_sz words in the PLAB of dest.  Returns the address of the
 236   // allocated memory, NULL if not successful.
 237   inline HeapWord* plab_allocate(InCSetState dest,
 238                                  size_t word_sz,
 239                                  AllocationContext_t context);
 240 
 241   HeapWord* allocate(InCSetState dest,
 242                      size_t word_sz,


< prev index next >