comparison src/share/vm/gc_implementation/g1/g1AllocRegion.hpp @ 3830:f44782f04dd4

7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally Summary: Refactor the allocation code during GC to use the G1AllocRegion abstraction. Use separate subclasses of G1AllocRegion for survivor and old regions. Avoid BOT updates and dirty survivor cards incrementally for the former. Reviewed-by: brutisso, johnc, ysr
author tonyp
date Fri, 12 Aug 2011 11:31:06 -0400
parents abdfc822206f
children 720b6a76dd9d
comparison
equal deleted inserted replaced
3829:87e40b34bc2b 3830:f44782f04dd4
34 34
35 class ar_ext_msg; 35 class ar_ext_msg;
36 36
37 // A class that holds a region that is active in satisfying allocation 37 // A class that holds a region that is active in satisfying allocation
38 // requests, potentially issued in parallel. When the active region is 38 // requests, potentially issued in parallel. When the active region is
39 // full it will be retired it replaced with a new one. The 39 // full it will be retired and replaced with a new one. The
40 // implementation assumes that fast-path allocations will be lock-free 40 // implementation assumes that fast-path allocations will be lock-free
41 // and a lock will need to be taken when the active region needs to be 41 // and a lock will need to be taken when the active region needs to be
42 // replaced. 42 // replaced.
43 43
44 class G1AllocRegion VALUE_OBJ_CLASS_SPEC { 44 class G1AllocRegion VALUE_OBJ_CLASS_SPEC {
55 // then _alloc_region is NULL and this object should not be used to 55 // then _alloc_region is NULL and this object should not be used to
56 // satisfy allocation requests (it was done this way to force the 56 // satisfy allocation requests (it was done this way to force the
57 // correct use of init() and release()). 57 // correct use of init() and release()).
58 HeapRegion* _alloc_region; 58 HeapRegion* _alloc_region;
59 59
60 // It keeps track of the distinct number of regions that are used
61 // for allocation in the active interval of this object, i.e.,
62 // between a call to init() and a call to release(). The count
63 // mostly includes regions that are freshly allocated, as well as
64 // the region that is re-used using the set() method. This count can
65 // be used in any heuristics that might want to bound how many
66 // distinct regions this object can used during an active interval.
67 size_t _count;
68
60 // When we set up a new active region we save its used bytes in this 69 // When we set up a new active region we save its used bytes in this
61 // field so that, when we retire it, we can calculate how much space 70 // field so that, when we retire it, we can calculate how much space
62 // we allocated in it. 71 // we allocated in it.
63 size_t _used_bytes_before; 72 size_t _used_bytes_before;
64 73
65 // Specifies whether the allocate calls will do BOT updates or not. 74 // When true, indicates that allocate calls should do BOT updates.
66 bool _bot_updates; 75 const bool _bot_updates;
67 76
68 // Useful for debugging and tracing. 77 // Useful for debugging and tracing.
69 const char* _name; 78 const char* _name;
70 79
71 // A dummy region (i.e., it's been allocated specially for this 80 // A dummy region (i.e., it's been allocated specially for this
125 HeapRegion* get() const { 134 HeapRegion* get() const {
126 // Make sure that the dummy region does not escape this class. 135 // Make sure that the dummy region does not escape this class.
127 return (_alloc_region == _dummy_region) ? NULL : _alloc_region; 136 return (_alloc_region == _dummy_region) ? NULL : _alloc_region;
128 } 137 }
129 138
139 size_t count() { return _count; }
140
130 // The following two are the building blocks for the allocation method. 141 // The following two are the building blocks for the allocation method.
131 142
132 // First-level allocation: Should be called without holding a 143 // First-level allocation: Should be called without holding a
133 // lock. It will try to allocate lock-free out of the active region, 144 // lock. It will try to allocate lock-free out of the active region,
134 // or return NULL if it was unable to. 145 // or return NULL if it was unable to.
151 bool bot_updates); 162 bool bot_updates);
152 163
153 // Should be called before we start using this object. 164 // Should be called before we start using this object.
154 void init(); 165 void init();
155 166
167 // This can be used to set the active region to a specific
168 // region. (Use Example: we try to retain the last old GC alloc
169 // region that we've used during a GC and we can use set() to
170 // re-instate it at the beginning of the next GC.)
171 void set(HeapRegion* alloc_region);
172
156 // Should be called when we want to release the active region which 173 // Should be called when we want to release the active region which
157 // is returned after it's been retired. 174 // is returned after it's been retired.
158 HeapRegion* release(); 175 HeapRegion* release();
159 176
160 #if G1_ALLOC_REGION_TRACING 177 #if G1_ALLOC_REGION_TRACING