24 |
24 |
25 #ifndef SHARE_VM_GC_G1_G1ALLOCREGION_HPP |
25 #ifndef SHARE_VM_GC_G1_G1ALLOCREGION_HPP |
26 #define SHARE_VM_GC_G1_G1ALLOCREGION_HPP |
26 #define SHARE_VM_GC_G1_G1ALLOCREGION_HPP |
27 |
27 |
28 #include "gc/g1/heapRegion.hpp" |
28 #include "gc/g1/heapRegion.hpp" |
|
29 #include "gc/g1/g1EvacStats.hpp" |
|
30 #include "gc/g1/g1InCSetState.hpp" |
29 |
31 |
30 class G1CollectedHeap; |
32 class G1CollectedHeap; |
31 |
33 |
32 // 0 -> no tracing, 1 -> basic tracing, 2 -> basic + allocation tracing |
34 // 0 -> no tracing, 1 -> basic tracing, 2 -> basic + allocation tracing |
33 #define G1_ALLOC_REGION_TRACING 0 |
35 #define G1_ALLOC_REGION_TRACING 0 |
103 size_t word_size, |
105 size_t word_size, |
104 bool bot_updates); |
106 bool bot_updates); |
105 |
107 |
106 // Ensure that the region passed as a parameter has been filled up |
108 // Ensure that the region passed as a parameter has been filled up |
107 // so that noone else can allocate out of it any more. |
109 // so that noone else can allocate out of it any more. |
108 static void fill_up_remaining_space(HeapRegion* alloc_region, |
110 // Returns the number of bytes that have been wasted by filled up |
109 bool bot_updates); |
111 // the space. |
110 |
112 static size_t fill_up_remaining_space(HeapRegion* alloc_region, |
111 // Retire the active allocating region. If fill_up is true then make |
113 bool bot_updates); |
112 // sure that the region is full before we retire it so that noone |
|
113 // else can allocate out of it. |
|
114 void retire(bool fill_up); |
|
115 |
114 |
116 // After a region is allocated by alloc_new_region, this |
115 // After a region is allocated by alloc_new_region, this |
117 // method is used to set it as the active alloc_region |
116 // method is used to set it as the active alloc_region |
118 void update_alloc_region(HeapRegion* alloc_region); |
117 void update_alloc_region(HeapRegion* alloc_region); |
119 |
118 |
124 HeapWord* new_alloc_region_and_allocate(size_t word_size, bool force); |
123 HeapWord* new_alloc_region_and_allocate(size_t word_size, bool force); |
125 |
124 |
126 void fill_in_ext_msg(ar_ext_msg* msg, const char* message); |
125 void fill_in_ext_msg(ar_ext_msg* msg, const char* message); |
127 |
126 |
128 protected: |
127 protected: |
|
128 // Retire the active allocating region. If fill_up is true then make |
|
129 // sure that the region is full before we retire it so that no one |
|
130 // else can allocate out of it. |
|
131 // Returns the number of bytes that have been filled up during retire. |
|
132 virtual size_t retire(bool fill_up); |
|
133 |
129 // For convenience as subclasses use it. |
134 // For convenience as subclasses use it. |
130 static G1CollectedHeap* _g1h; |
135 static G1CollectedHeap* _g1h; |
131 |
136 |
132 virtual HeapRegion* allocate_new_region(size_t word_size, bool force) = 0; |
137 virtual HeapRegion* allocate_new_region(size_t word_size, bool force) = 0; |
133 virtual void retire_region(HeapRegion* alloc_region, |
138 virtual void retire_region(HeapRegion* alloc_region, |
199 public: |
204 public: |
200 MutatorAllocRegion() |
205 MutatorAllocRegion() |
201 : G1AllocRegion("Mutator Alloc Region", false /* bot_updates */) { } |
206 : G1AllocRegion("Mutator Alloc Region", false /* bot_updates */) { } |
202 }; |
207 }; |
203 |
208 |
204 class SurvivorGCAllocRegion : public G1AllocRegion { |
209 // Common base class for allocation regions used during GC. |
|
210 class G1GCAllocRegion : public G1AllocRegion { |
205 protected: |
211 protected: |
|
212 G1EvacStats* _stats; |
|
213 InCSetState::in_cset_state_t _purpose; |
|
214 |
206 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
215 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
207 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
216 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
208 public: |
217 |
209 SurvivorGCAllocRegion() |
218 virtual size_t retire(bool fill_up); |
210 : G1AllocRegion("Survivor GC Alloc Region", false /* bot_updates */) { } |
219 public: |
211 }; |
220 G1GCAllocRegion(const char* name, bool bot_updates, G1EvacStats* stats, InCSetState::in_cset_state_t purpose) |
212 |
221 : G1AllocRegion(name, bot_updates), _stats(stats), _purpose(purpose) { |
213 class OldGCAllocRegion : public G1AllocRegion { |
222 assert(stats != NULL, "Must pass non-NULL PLAB statistics"); |
214 protected: |
223 } |
215 virtual HeapRegion* allocate_new_region(size_t word_size, bool force); |
224 }; |
216 virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes); |
225 |
217 public: |
226 class SurvivorGCAllocRegion : public G1GCAllocRegion { |
218 OldGCAllocRegion() |
227 public: |
219 : G1AllocRegion("Old GC Alloc Region", true /* bot_updates */) { } |
228 SurvivorGCAllocRegion(G1EvacStats* stats) |
|
229 : G1GCAllocRegion("Survivor GC Alloc Region", false /* bot_updates */, stats, InCSetState::Young) { } |
|
230 }; |
|
231 |
|
232 class OldGCAllocRegion : public G1GCAllocRegion { |
|
233 public: |
|
234 OldGCAllocRegion(G1EvacStats* stats) |
|
235 : G1GCAllocRegion("Old GC Alloc Region", true /* bot_updates */, stats, InCSetState::Old) { } |
220 |
236 |
221 // This specialization of release() makes sure that the last card that has |
237 // 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 |
238 // 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 |
239 // 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 |
240 // last card in the retained old gc alloc region, and allocation threads |