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* volatile _alloc_region; |
58 HeapRegion* volatile _alloc_region; |
59 |
59 |
|
60 // Allocation context associated with this alloc region. |
|
61 AllocationContext_t _allocation_context; |
|
62 |
60 // It keeps track of the distinct number of regions that are used |
63 // It keeps track of the distinct number of regions that are used |
61 // for allocation in the active interval of this object, i.e., |
64 // for allocation in the active interval of this object, i.e., |
62 // between a call to init() and a call to release(). The count |
65 // between a call to init() and a call to release(). The count |
63 // mostly includes regions that are freshly allocated, as well as |
66 // mostly includes regions that are freshly allocated, as well as |
64 // the region that is re-used using the set() method. This count can |
67 // the region that is re-used using the set() method. This count can |
108 // Retire the active allocating region. If fill_up is true then make |
111 // Retire the active allocating region. If fill_up is true then make |
109 // sure that the region is full before we retire it so that noone |
112 // sure that the region is full before we retire it so that noone |
110 // else can allocate out of it. |
113 // else can allocate out of it. |
111 void retire(bool fill_up); |
114 void retire(bool fill_up); |
112 |
115 |
|
116 // After a region is allocated by alloc_new_region, this |
|
117 // method is used to set it as the active alloc_region |
|
118 void update_alloc_region(HeapRegion* alloc_region); |
|
119 |
113 // Allocate a new active region and use it to perform a word_size |
120 // Allocate a new active region and use it to perform a word_size |
114 // allocation. The force parameter will be passed on to |
121 // allocation. The force parameter will be passed on to |
115 // G1CollectedHeap::allocate_new_alloc_region() and tells it to try |
122 // G1CollectedHeap::allocate_new_alloc_region() and tells it to try |
116 // to allocate a new region even if the max has been reached. |
123 // to allocate a new region even if the max has been reached. |
117 HeapWord* new_alloc_region_and_allocate(size_t word_size, bool force); |
124 HeapWord* new_alloc_region_and_allocate(size_t word_size, bool force); |
134 HeapRegion* get() const { |
141 HeapRegion* get() const { |
135 HeapRegion * hr = _alloc_region; |
142 HeapRegion * hr = _alloc_region; |
136 // Make sure that the dummy region does not escape this class. |
143 // Make sure that the dummy region does not escape this class. |
137 return (hr == _dummy_region) ? NULL : hr; |
144 return (hr == _dummy_region) ? NULL : hr; |
138 } |
145 } |
|
146 |
|
147 void set_allocation_context(AllocationContext_t context) { _allocation_context = context; } |
|
148 AllocationContext_t allocation_context() { return _allocation_context; } |
139 |
149 |
140 uint count() { return _count; } |
150 uint count() { return _count; } |
141 |
151 |
142 // The following two are the building blocks for the allocation method. |
152 // The following two are the building blocks for the allocation method. |
143 |
153 |
180 #else // G1_ALLOC_REGION_TRACING |
190 #else // G1_ALLOC_REGION_TRACING |
181 void trace(const char* str, size_t word_size = 0, HeapWord* result = NULL) { } |
191 void trace(const char* str, size_t word_size = 0, HeapWord* result = NULL) { } |
182 #endif // G1_ALLOC_REGION_TRACING |
192 #endif // G1_ALLOC_REGION_TRACING |
183 }; |
193 }; |
184 |
194 |
|
195 class MutatorAllocRegion : public G1AllocRegion { |
|
196 protected: |
|
197 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
|
198 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
|
199 public: |
|
200 MutatorAllocRegion() |
|
201 : G1AllocRegion("Mutator Alloc Region", false /* bot_updates */) { } |
|
202 }; |
|
203 |
|
204 class SurvivorGCAllocRegion : public G1AllocRegion { |
|
205 protected: |
|
206 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
|
207 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
|
208 public: |
|
209 SurvivorGCAllocRegion() |
|
210 : G1AllocRegion("Survivor GC Alloc Region", false /* bot_updates */) { } |
|
211 }; |
|
212 |
|
213 class OldGCAllocRegion : public G1AllocRegion { |
|
214 protected: |
|
215 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
|
216 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
|
217 public: |
|
218 OldGCAllocRegion() |
|
219 : G1AllocRegion("Old GC Alloc Region", true /* bot_updates */) { } |
|
220 |
|
221 // This specialization of release() makes sure that the last card that has |
|
222 // been allocated into has been completely filled by a dummy object. This |
|
223 // avoids races when remembered set scanning wants to update the BOT of the |
|
224 // last card in the retained old gc alloc region, and allocation threads |
|
225 // allocating into that card at the same time. |
|
226 virtual HeapRegion* release(); |
|
227 }; |
|
228 |
185 class ar_ext_msg : public err_msg { |
229 class ar_ext_msg : public err_msg { |
186 public: |
230 public: |
187 ar_ext_msg(G1AllocRegion* alloc_region, const char *message) : err_msg("%s", "") { |
231 ar_ext_msg(G1AllocRegion* alloc_region, const char *message) : err_msg("%s", "") { |
188 alloc_region->fill_in_ext_msg(this, message); |
232 alloc_region->fill_in_ext_msg(this, message); |
189 } |
233 } |