< prev index next >

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

Print this page
rev 8979 : [mq]: vmerr_static


  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_G1ALLOCREGION_HPP
  26 #define SHARE_VM_GC_G1_G1ALLOCREGION_HPP
  27 
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "gc/g1/g1EvacStats.hpp"
  30 #include "gc/g1/g1InCSetState.hpp"
  31 
  32 class G1CollectedHeap;
  33 
  34 // 0 -> no tracing, 1 -> basic tracing, 2 -> basic + allocation tracing
  35 #define G1_ALLOC_REGION_TRACING 0
  36 
  37 class ar_ext_msg;



  38 
  39 // A class that holds a region that is active in satisfying allocation
  40 // requests, potentially issued in parallel. When the active region is
  41 // full it will be retired and replaced with a new one. The
  42 // implementation assumes that fast-path allocations will be lock-free
  43 // and a lock will need to be taken when the active region needs to be
  44 // replaced.
  45 
  46 class G1AllocRegion VALUE_OBJ_CLASS_SPEC {
  47   friend class ar_ext_msg;
  48 
  49 private:
  50   // The active allocating region we are currently allocating out
  51   // of. The invariant is that if this object is initialized (i.e.,
  52   // init() has been called and release() has not) then _alloc_region
  53   // is either an active allocating region or the dummy region (i.e.,
  54   // it can never be NULL) and this object can be used to satisfy
  55   // allocation requests. If this object is not initialized
  56   // (i.e. init() has not been called or release() has been called)
  57   // then _alloc_region is NULL and this object should not be used to


 114                                        size_t* actual_word_size,
 115                                        bool bot_updates);
 116 
 117   // Ensure that the region passed as a parameter has been filled up
 118   // so that noone else can allocate out of it any more.
 119   // Returns the number of bytes that have been wasted by filled up
 120   // the space.
 121   static size_t fill_up_remaining_space(HeapRegion* alloc_region,
 122                                         bool bot_updates);
 123 
 124   // After a region is allocated by alloc_new_region, this
 125   // method is used to set it as the active alloc_region
 126   void update_alloc_region(HeapRegion* alloc_region);
 127 
 128   // Allocate a new active region and use it to perform a word_size
 129   // allocation. The force parameter will be passed on to
 130   // G1CollectedHeap::allocate_new_alloc_region() and tells it to try
 131   // to allocate a new region even if the max has been reached.
 132   HeapWord* new_alloc_region_and_allocate(size_t word_size, bool force);
 133 
 134   void fill_in_ext_msg(ar_ext_msg* msg, const char* message);
 135 
 136 protected:
 137   // Retire the active allocating region. If fill_up is true then make
 138   // sure that the region is full before we retire it so that no one
 139   // else can allocate out of it.
 140   // Returns the number of bytes that have been filled up during retire.
 141   virtual size_t retire(bool fill_up);
 142 
 143   // For convenience as subclasses use it.
 144   static G1CollectedHeap* _g1h;
 145 
 146   virtual HeapRegion* allocate_new_region(size_t word_size, bool force) = 0;
 147   virtual void retire_region(HeapRegion* alloc_region,
 148                              size_t allocated_bytes) = 0;
 149 
 150   G1AllocRegion(const char* name, bool bot_updates);
 151 
 152 public:
 153   static void setup(G1CollectedHeap* g1h, HeapRegion* dummy_region);
 154 
 155   HeapRegion* get() const {


 259   }
 260 };
 261 
 262 class SurvivorGCAllocRegion : public G1GCAllocRegion {
 263 public:
 264   SurvivorGCAllocRegion(G1EvacStats* stats)
 265   : G1GCAllocRegion("Survivor GC Alloc Region", false /* bot_updates */, stats, InCSetState::Young) { }
 266 };
 267 
 268 class OldGCAllocRegion : public G1GCAllocRegion {
 269 public:
 270   OldGCAllocRegion(G1EvacStats* stats)
 271   : G1GCAllocRegion("Old GC Alloc Region", true /* bot_updates */, stats, InCSetState::Old) { }
 272 
 273   // This specialization of release() makes sure that the last card that has
 274   // been allocated into has been completely filled by a dummy object.  This
 275   // avoids races when remembered set scanning wants to update the BOT of the
 276   // last card in the retained old gc alloc region, and allocation threads
 277   // allocating into that card at the same time.
 278   virtual HeapRegion* release();
 279 };
 280 
 281 class ar_ext_msg : public err_msg {
 282 public:
 283   ar_ext_msg(G1AllocRegion* alloc_region, const char *message) : err_msg("%s", "") {
 284     alloc_region->fill_in_ext_msg(this, message);
 285   }
 286 };
 287 
 288 #endif // SHARE_VM_GC_G1_G1ALLOCREGION_HPP


  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_G1ALLOCREGION_HPP
  26 #define SHARE_VM_GC_G1_G1ALLOCREGION_HPP
  27 
  28 #include "gc/g1/heapRegion.hpp"
  29 #include "gc/g1/g1EvacStats.hpp"
  30 #include "gc/g1/g1InCSetState.hpp"
  31 
  32 class G1CollectedHeap;
  33 
  34 // 0 -> no tracing, 1 -> basic tracing, 2 -> basic + allocation tracing
  35 #define G1_ALLOC_REGION_TRACING 0
  36 
  37 #define G1_ALLOC_REGION_MSG(message)                         \
  38   "[%s] %s c: %u b: %s r: " PTR_FORMAT " u: " SIZE_FORMAT, \
  39   _name, message, _count, BOOL_TO_STR(_bot_updates),       \
  40   p2i(_alloc_region), _used_bytes_before
  41 
  42 // A class that holds a region that is active in satisfying allocation
  43 // requests, potentially issued in parallel. When the active region is
  44 // full it will be retired and replaced with a new one. The
  45 // implementation assumes that fast-path allocations will be lock-free
  46 // and a lock will need to be taken when the active region needs to be
  47 // replaced.
  48 
  49 class G1AllocRegion VALUE_OBJ_CLASS_SPEC {
  50   friend class ar_ext_msg;
  51 
  52 private:
  53   // The active allocating region we are currently allocating out
  54   // of. The invariant is that if this object is initialized (i.e.,
  55   // init() has been called and release() has not) then _alloc_region
  56   // is either an active allocating region or the dummy region (i.e.,
  57   // it can never be NULL) and this object can be used to satisfy
  58   // allocation requests. If this object is not initialized
  59   // (i.e. init() has not been called or release() has been called)
  60   // then _alloc_region is NULL and this object should not be used to


 117                                        size_t* actual_word_size,
 118                                        bool bot_updates);
 119 
 120   // Ensure that the region passed as a parameter has been filled up
 121   // so that noone else can allocate out of it any more.
 122   // Returns the number of bytes that have been wasted by filled up
 123   // the space.
 124   static size_t fill_up_remaining_space(HeapRegion* alloc_region,
 125                                         bool bot_updates);
 126 
 127   // After a region is allocated by alloc_new_region, this
 128   // method is used to set it as the active alloc_region
 129   void update_alloc_region(HeapRegion* alloc_region);
 130 
 131   // Allocate a new active region and use it to perform a word_size
 132   // allocation. The force parameter will be passed on to
 133   // G1CollectedHeap::allocate_new_alloc_region() and tells it to try
 134   // to allocate a new region even if the max has been reached.
 135   HeapWord* new_alloc_region_and_allocate(size_t word_size, bool force);
 136 


 137 protected:
 138   // Retire the active allocating region. If fill_up is true then make
 139   // sure that the region is full before we retire it so that no one
 140   // else can allocate out of it.
 141   // Returns the number of bytes that have been filled up during retire.
 142   virtual size_t retire(bool fill_up);
 143 
 144   // For convenience as subclasses use it.
 145   static G1CollectedHeap* _g1h;
 146 
 147   virtual HeapRegion* allocate_new_region(size_t word_size, bool force) = 0;
 148   virtual void retire_region(HeapRegion* alloc_region,
 149                              size_t allocated_bytes) = 0;
 150 
 151   G1AllocRegion(const char* name, bool bot_updates);
 152 
 153 public:
 154   static void setup(G1CollectedHeap* g1h, HeapRegion* dummy_region);
 155 
 156   HeapRegion* get() const {


 260   }
 261 };
 262 
 263 class SurvivorGCAllocRegion : public G1GCAllocRegion {
 264 public:
 265   SurvivorGCAllocRegion(G1EvacStats* stats)
 266   : G1GCAllocRegion("Survivor GC Alloc Region", false /* bot_updates */, stats, InCSetState::Young) { }
 267 };
 268 
 269 class OldGCAllocRegion : public G1GCAllocRegion {
 270 public:
 271   OldGCAllocRegion(G1EvacStats* stats)
 272   : G1GCAllocRegion("Old GC Alloc Region", true /* bot_updates */, stats, InCSetState::Old) { }
 273 
 274   // This specialization of release() makes sure that the last card that has
 275   // been allocated into has been completely filled by a dummy object.  This
 276   // avoids races when remembered set scanning wants to update the BOT of the
 277   // last card in the retained old gc alloc region, and allocation threads
 278   // allocating into that card at the same time.
 279   virtual HeapRegion* release();







 280 };
 281 
 282 #endif // SHARE_VM_GC_G1_G1ALLOCREGION_HPP
< prev index next >