278 return obj;
279 }
280 return allocate_direct_or_new_plab(dest, word_sz, context, refill_failed);
281 }
282
283 void undo_allocation(InCSetState dest, HeapWord* obj, size_t word_sz, AllocationContext_t context);
284 };
285
286 // The default PLAB allocator for G1. Keeps the current (single) PLAB for survivor
287 // and old generation allocation.
288 class G1DefaultPLABAllocator : public G1PLABAllocator {
289 G1PLAB _surviving_alloc_buffer;
290 G1PLAB _tenured_alloc_buffer;
291 G1PLAB* _alloc_buffers[InCSetState::Num];
292
293 public:
294 G1DefaultPLABAllocator(G1Allocator* _allocator);
295
296 virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) {
297 assert(dest.is_valid(),
298 err_msg("Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value()));
299 assert(_alloc_buffers[dest.value()] != NULL,
300 err_msg("Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value()));
301 return _alloc_buffers[dest.value()];
302 }
303
304 virtual void flush_and_retire_stats();
305
306 virtual void waste(size_t& wasted, size_t& undo_wasted);
307 };
308
309 // G1ArchiveAllocator is used to allocate memory in archive
310 // regions. Such regions are not modifiable by GC, being neither
311 // scavenged nor compacted, or even marked in the object header.
312 // They can contain no pointers to non-archive heap regions,
313 class G1ArchiveAllocator : public CHeapObj<mtGC> {
314
315 protected:
316 G1CollectedHeap* _g1h;
317
318 // The current allocation region
319 HeapRegion* _allocation_region;
320
|
278 return obj;
279 }
280 return allocate_direct_or_new_plab(dest, word_sz, context, refill_failed);
281 }
282
283 void undo_allocation(InCSetState dest, HeapWord* obj, size_t word_sz, AllocationContext_t context);
284 };
285
286 // The default PLAB allocator for G1. Keeps the current (single) PLAB for survivor
287 // and old generation allocation.
288 class G1DefaultPLABAllocator : public G1PLABAllocator {
289 G1PLAB _surviving_alloc_buffer;
290 G1PLAB _tenured_alloc_buffer;
291 G1PLAB* _alloc_buffers[InCSetState::Num];
292
293 public:
294 G1DefaultPLABAllocator(G1Allocator* _allocator);
295
296 virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) {
297 assert(dest.is_valid(),
298 "Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value());
299 assert(_alloc_buffers[dest.value()] != NULL,
300 "Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value());
301 return _alloc_buffers[dest.value()];
302 }
303
304 virtual void flush_and_retire_stats();
305
306 virtual void waste(size_t& wasted, size_t& undo_wasted);
307 };
308
309 // G1ArchiveAllocator is used to allocate memory in archive
310 // regions. Such regions are not modifiable by GC, being neither
311 // scavenged nor compacted, or even marked in the object header.
312 // They can contain no pointers to non-archive heap regions,
313 class G1ArchiveAllocator : public CHeapObj<mtGC> {
314
315 protected:
316 G1CollectedHeap* _g1h;
317
318 // The current allocation region
319 HeapRegion* _allocation_region;
320
|