hotspot/src/share/vm/gc/g1/g1AllocRegion.hpp
changeset 32389 626f27450e12
parent 32379 aa14adafaf0f
child 33105 294e48b4f704
equal deleted inserted replaced
32388:81663b0d3631 32389:626f27450e12
   102 
   102 
   103   // Perform a MT-safe allocation out of the given region.
   103   // Perform a MT-safe allocation out of the given region.
   104   static inline HeapWord* par_allocate(HeapRegion* alloc_region,
   104   static inline HeapWord* par_allocate(HeapRegion* alloc_region,
   105                                        size_t word_size,
   105                                        size_t word_size,
   106                                        bool bot_updates);
   106                                        bool bot_updates);
       
   107   // Perform a MT-safe allocation out of the given region, with the given
       
   108   // minimum and desired size. Returns the actual size allocated (between
       
   109   // minimum and desired size) in actual_word_size if the allocation has been
       
   110   // successful.
       
   111   static inline HeapWord* par_allocate(HeapRegion* alloc_region,
       
   112                                        size_t min_word_size,
       
   113                                        size_t desired_word_size,
       
   114                                        size_t* actual_word_size,
       
   115                                        bool bot_updates);
   107 
   116 
   108   // Ensure that the region passed as a parameter has been filled up
   117   // Ensure that the region passed as a parameter has been filled up
   109   // so that noone else can allocate out of it any more.
   118   // so that noone else can allocate out of it any more.
   110   // Returns the number of bytes that have been wasted by filled up
   119   // Returns the number of bytes that have been wasted by filled up
   111   // the space.
   120   // the space.
   157   // The following two are the building blocks for the allocation method.
   166   // The following two are the building blocks for the allocation method.
   158 
   167 
   159   // First-level allocation: Should be called without holding a
   168   // First-level allocation: Should be called without holding a
   160   // lock. It will try to allocate lock-free out of the active region,
   169   // lock. It will try to allocate lock-free out of the active region,
   161   // or return NULL if it was unable to.
   170   // or return NULL if it was unable to.
   162   inline HeapWord* attempt_allocation(size_t word_size, bool bot_updates);
   171   inline HeapWord* attempt_allocation(size_t word_size,
       
   172                                       bool bot_updates);
       
   173   // Perform an allocation out of the current allocation region, with the given
       
   174   // minimum and desired size. Returns the actual size allocated (between
       
   175   // minimum and desired size) in actual_word_size if the allocation has been
       
   176   // successful.
       
   177   // Should be called without holding a lock. It will try to allocate lock-free
       
   178   // out of the active region, or return NULL if it was unable to.
       
   179   inline HeapWord* attempt_allocation(size_t min_word_size,
       
   180                                       size_t desired_word_size,
       
   181                                       size_t* actual_word_size,
       
   182                                       bool bot_updates);
   163 
   183 
   164   // Second-level allocation: Should be called while holding a
   184   // Second-level allocation: Should be called while holding a
   165   // lock. It will try to first allocate lock-free out of the active
   185   // lock. It will try to first allocate lock-free out of the active
   166   // region or, if it's unable to, it will try to replace the active
   186   // region or, if it's unable to, it will try to replace the active
   167   // alloc region with a new one. We require that the caller takes the
   187   // alloc region with a new one. We require that the caller takes the
   168   // appropriate lock before calling this so that it is easier to make
   188   // appropriate lock before calling this so that it is easier to make
   169   // it conform to its locking protocol.
   189   // it conform to its locking protocol.
   170   inline HeapWord* attempt_allocation_locked(size_t word_size,
   190   inline HeapWord* attempt_allocation_locked(size_t word_size,
   171                                              bool bot_updates);
   191                                              bool bot_updates);
       
   192   // Same as attempt_allocation_locked(size_t, bool), but allowing specification
       
   193   // of minimum word size of the block in min_word_size, and the maximum word
       
   194   // size of the allocation in desired_word_size. The actual size of the block is
       
   195   // returned in actual_word_size.
       
   196   inline HeapWord* attempt_allocation_locked(size_t min_word_size,
       
   197                                              size_t desired_word_size,
       
   198                                              size_t* actual_word_size,
       
   199                                              bool bot_updates);
   172 
   200 
   173   // Should be called to allocate a new region even if the max of this
   201   // Should be called to allocate a new region even if the max of this
   174   // type of regions has been reached. Should only be called if other
   202   // type of regions has been reached. Should only be called if other
   175   // allocation attempts have failed and we are not holding a valid
   203   // allocation attempts have failed and we are not holding a valid
   176   // active region.
   204   // active region.
   189   // Should be called when we want to release the active region which
   217   // Should be called when we want to release the active region which
   190   // is returned after it's been retired.
   218   // is returned after it's been retired.
   191   virtual HeapRegion* release();
   219   virtual HeapRegion* release();
   192 
   220 
   193 #if G1_ALLOC_REGION_TRACING
   221 #if G1_ALLOC_REGION_TRACING
   194   void trace(const char* str, size_t word_size = 0, HeapWord* result = NULL);
   222   void trace(const char* str,
       
   223              size_t min_word_size = 0,
       
   224              size_t desired_word_size = 0,
       
   225              size_t actual_word_size = 0,
       
   226              HeapWord* result = NULL);
   195 #else // G1_ALLOC_REGION_TRACING
   227 #else // G1_ALLOC_REGION_TRACING
   196   void trace(const char* str, size_t word_size = 0, HeapWord* result = NULL) { }
   228   void trace(const char* str,
       
   229              size_t min_word_size = 0,
       
   230              size_t desired_word_size = 0,
       
   231              size_t actual_word_size = 0,
       
   232              HeapWord* result = NULL) { }
   197 #endif // G1_ALLOC_REGION_TRACING
   233 #endif // G1_ALLOC_REGION_TRACING
   198 };
   234 };
   199 
   235 
   200 class MutatorAllocRegion : public G1AllocRegion {
   236 class MutatorAllocRegion : public G1AllocRegion {
   201 protected:
   237 protected: