237 G1AllocRegion::G1AllocRegion(const char* name,
238 bool bot_updates)
239 : _name(name), _bot_updates(bot_updates),
240 _alloc_region(NULL), _count(0), _used_bytes_before(0),
241 _allocation_context(AllocationContext::system()) { }
242
243
244 HeapRegion* MutatorAllocRegion::allocate_new_region(size_t word_size,
245 bool force) {
246 return _g1h->new_mutator_alloc_region(word_size, force);
247 }
248
249 void MutatorAllocRegion::retire_region(HeapRegion* alloc_region,
250 size_t allocated_bytes) {
251 _g1h->retire_mutator_alloc_region(alloc_region, allocated_bytes);
252 }
253
254 HeapRegion* SurvivorGCAllocRegion::allocate_new_region(size_t word_size,
255 bool force) {
256 assert(!force, "not supported for GC alloc regions");
257 return _g1h->new_gc_alloc_region(word_size, count(), GCAllocForSurvived);
258 }
259
260 void SurvivorGCAllocRegion::retire_region(HeapRegion* alloc_region,
261 size_t allocated_bytes) {
262 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes,
263 GCAllocForSurvived);
264 }
265
266 HeapRegion* OldGCAllocRegion::allocate_new_region(size_t word_size,
267 bool force) {
268 assert(!force, "not supported for GC alloc regions");
269 return _g1h->new_gc_alloc_region(word_size, count(), GCAllocForTenured);
270 }
271
272 void OldGCAllocRegion::retire_region(HeapRegion* alloc_region,
273 size_t allocated_bytes) {
274 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes,
275 GCAllocForTenured);
276 }
277
278 HeapRegion* OldGCAllocRegion::release() {
279 HeapRegion* cur = get();
280 if (cur != NULL) {
281 // Determine how far we are from the next card boundary. If it is smaller than
282 // the minimum object size we can allocate into, expand into the next card.
283 HeapWord* top = cur->top();
284 HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetSharedArray::N_bytes);
285
286 size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize);
287
288 if (to_allocate_words != 0) {
289 // We are not at a card boundary. Fill up, possibly into the next, taking the
290 // end of the region and the minimum object size into account.
291 to_allocate_words = MIN2(pointer_delta(cur->end(), cur->top(), HeapWordSize),
292 MAX2(to_allocate_words, G1CollectedHeap::min_fill_size()));
293
294 // Skip allocation if there is not enough space to allocate even the smallest
295 // possible object. In this case this region will not be retained, so the
|
237 G1AllocRegion::G1AllocRegion(const char* name,
238 bool bot_updates)
239 : _name(name), _bot_updates(bot_updates),
240 _alloc_region(NULL), _count(0), _used_bytes_before(0),
241 _allocation_context(AllocationContext::system()) { }
242
243
244 HeapRegion* MutatorAllocRegion::allocate_new_region(size_t word_size,
245 bool force) {
246 return _g1h->new_mutator_alloc_region(word_size, force);
247 }
248
249 void MutatorAllocRegion::retire_region(HeapRegion* alloc_region,
250 size_t allocated_bytes) {
251 _g1h->retire_mutator_alloc_region(alloc_region, allocated_bytes);
252 }
253
254 HeapRegion* SurvivorGCAllocRegion::allocate_new_region(size_t word_size,
255 bool force) {
256 assert(!force, "not supported for GC alloc regions");
257 return _g1h->new_gc_alloc_region(word_size, count(), InCSetState::Young);
258 }
259
260 void SurvivorGCAllocRegion::retire_region(HeapRegion* alloc_region,
261 size_t allocated_bytes) {
262 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, InCSetState::Young);
263 }
264
265 HeapRegion* OldGCAllocRegion::allocate_new_region(size_t word_size,
266 bool force) {
267 assert(!force, "not supported for GC alloc regions");
268 return _g1h->new_gc_alloc_region(word_size, count(), InCSetState::Old);
269 }
270
271 void OldGCAllocRegion::retire_region(HeapRegion* alloc_region,
272 size_t allocated_bytes) {
273 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, InCSetState::Old);
274 }
275
276 HeapRegion* OldGCAllocRegion::release() {
277 HeapRegion* cur = get();
278 if (cur != NULL) {
279 // Determine how far we are from the next card boundary. If it is smaller than
280 // the minimum object size we can allocate into, expand into the next card.
281 HeapWord* top = cur->top();
282 HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetSharedArray::N_bytes);
283
284 size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize);
285
286 if (to_allocate_words != 0) {
287 // We are not at a card boundary. Fill up, possibly into the next, taking the
288 // end of the region and the minimum object size into account.
289 to_allocate_words = MIN2(pointer_delta(cur->end(), cur->top(), HeapWordSize),
290 MAX2(to_allocate_words, G1CollectedHeap::min_fill_size()));
291
292 // Skip allocation if there is not enough space to allocate even the smallest
293 // possible object. In this case this region will not be retained, so the
|