< prev index next >
src/share/vm/gc_implementation/g1/g1Allocator.hpp
Print this page
rev 7902 : [mq]: 8073052-Rename-and-clean-up-the-allocation-manager-hierarchy-in-g1Allocator
*** 28,52 ****
#include "gc_implementation/g1/g1AllocationContext.hpp"
#include "gc_implementation/g1/g1AllocRegion.hpp"
#include "gc_implementation/g1/g1InCSetState.hpp"
#include "gc_implementation/shared/parGCAllocBuffer.hpp"
! // Base class for G1 allocators.
! class G1Allocator : public CHeapObj<mtGC> {
friend class VMStructs;
! protected:
G1CollectedHeap* _g1h;
// Outside of GC pauses, the number of bytes used in all regions other
// than the current allocation region.
size_t _summary_bytes_used;
! public:
! G1Allocator(G1CollectedHeap* heap) :
_g1h(heap), _summary_bytes_used(0) { }
! static G1Allocator* create_allocator(G1CollectedHeap* g1h);
virtual void init_mutator_alloc_region() = 0;
virtual void release_mutator_alloc_region() = 0;
virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
--- 28,52 ----
#include "gc_implementation/g1/g1AllocationContext.hpp"
#include "gc_implementation/g1/g1AllocRegion.hpp"
#include "gc_implementation/g1/g1InCSetState.hpp"
#include "gc_implementation/shared/parGCAllocBuffer.hpp"
! // Interface to keep track of which regions G1 is currently allocating into.
! class AllocRegionManager : public CHeapObj<mtGC> {
friend class VMStructs;
! protected:
G1CollectedHeap* _g1h;
// Outside of GC pauses, the number of bytes used in all regions other
// than the current allocation region.
size_t _summary_bytes_used;
! public:
! AllocRegionManager(G1CollectedHeap* heap) :
_g1h(heap), _summary_bytes_used(0) { }
! static AllocRegionManager* create_allocator(G1CollectedHeap* g1h);
virtual void init_mutator_alloc_region() = 0;
virtual void release_mutator_alloc_region() = 0;
virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
*** 87,99 ****
MemRegion mr) {
return new HeapRegion(hrs_index, sharedOffsetArray, mr);
}
};
! // The default allocator for G1.
! class G1DefaultAllocator : public G1Allocator {
! protected:
// Alloc region used to satisfy mutator allocation requests.
MutatorAllocRegion _mutator_alloc_region;
// Alloc region used to satisfy allocation requests by the GC for
// survivor objects.
--- 87,101 ----
MemRegion mr) {
return new HeapRegion(hrs_index, sharedOffsetArray, mr);
}
};
! // The default allocation region manager for G1. Provides a single mutator, survivor
! // and old generation allocation region.
! // Can retain the old generation allocation region across GCs.
! class DefaultAllocRegionManager : public AllocRegionManager {
! protected:
// Alloc region used to satisfy mutator allocation requests.
MutatorAllocRegion _mutator_alloc_region;
// Alloc region used to satisfy allocation requests by the GC for
// survivor objects.
*** 102,113 ****
// Alloc region used to satisfy allocation requests by the GC for
// old objects.
OldGCAllocRegion _old_gc_alloc_region;
HeapRegion* _retained_old_gc_alloc_region;
! public:
! G1DefaultAllocator(G1CollectedHeap* heap) : G1Allocator(heap), _retained_old_gc_alloc_region(NULL) { }
virtual void init_mutator_alloc_region();
virtual void release_mutator_alloc_region();
virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info);
--- 104,115 ----
// Alloc region used to satisfy allocation requests by the GC for
// old objects.
OldGCAllocRegion _old_gc_alloc_region;
HeapRegion* _retained_old_gc_alloc_region;
! public:
! DefaultAllocRegionManager(G1CollectedHeap* heap) : AllocRegionManager(heap), _retained_old_gc_alloc_region(NULL) { }
virtual void init_mutator_alloc_region();
virtual void release_mutator_alloc_region();
virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info);
*** 142,158 ****
}
return result;
}
};
! class G1ParGCAllocBuffer: public ParGCAllocBuffer {
! private:
bool _retired;
! public:
! G1ParGCAllocBuffer(size_t gclab_word_size);
! virtual ~G1ParGCAllocBuffer() {
guarantee(_retired, "Allocation buffer has not been retired");
}
virtual void set_buf(HeapWord* buf) {
ParGCAllocBuffer::set_buf(buf);
--- 144,161 ----
}
return result;
}
};
! // A PLAB used during garbage collection that is specific to G1.
! class G1PLAB: public ParGCAllocBuffer {
! private:
bool _retired;
! public:
! G1PLAB(size_t gclab_word_size);
! virtual ~G1PLAB() {
guarantee(_retired, "Allocation buffer has not been retired");
}
virtual void set_buf(HeapWord* buf) {
ParGCAllocBuffer::set_buf(buf);
*** 166,178 ****
ParGCAllocBuffer::retire();
_retired = true;
}
};
! class G1ParGCAllocator : public CHeapObj<mtGC> {
friend class G1ParScanThreadState;
! protected:
G1CollectedHeap* _g1h;
// The survivor alignment in effect in bytes.
// == 0 : don't align survivors
// != 0 : align survivors to that alignment
--- 169,184 ----
ParGCAllocBuffer::retire();
_retired = true;
}
};
! // Manages the PLABs used during garbage collection. Interface for allocation from PLABs.
! // Needs to handle multiple contexts, extra alignment in any "survivor" area and some
! // statistics.
! class PLABAllocator : public CHeapObj<mtGC> {
friend class G1ParScanThreadState;
! protected:
G1CollectedHeap* _g1h;
// The survivor alignment in effect in bytes.
// == 0 : don't align survivors
// != 0 : align survivors to that alignment
*** 185,195 ****
void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
void add_to_undo_waste(size_t waste) { _undo_waste += waste; }
virtual void retire_alloc_buffers() = 0;
! virtual G1ParGCAllocBuffer* alloc_buffer(InCSetState dest, AllocationContext_t context) = 0;
// Calculate the survivor space object alignment in bytes. Returns that or 0 if
// there are no restrictions on survivor alignment.
static uint calc_survivor_alignment_bytes() {
assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
--- 191,201 ----
void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
void add_to_undo_waste(size_t waste) { _undo_waste += waste; }
virtual void retire_alloc_buffers() = 0;
! virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) = 0;
// Calculate the survivor space object alignment in bytes. Returns that or 0 if
// there are no restrictions on survivor alignment.
static uint calc_survivor_alignment_bytes() {
assert(SurvivorAlignmentInBytes >= ObjectAlignmentInBytes, "sanity");
*** 201,217 ****
assert(SurvivorAlignmentInBytes > 0, "sanity");
return SurvivorAlignmentInBytes;
}
}
! public:
! G1ParGCAllocator(G1CollectedHeap* g1h) :
_g1h(g1h), _survivor_alignment_bytes(calc_survivor_alignment_bytes()),
_alloc_buffer_waste(0), _undo_waste(0) {
}
! static G1ParGCAllocator* create_allocator(G1CollectedHeap* g1h);
size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
size_t undo_waste() {return _undo_waste; }
// Allocate word_sz words in dest, either directly into the regions or by
--- 207,223 ----
assert(SurvivorAlignmentInBytes > 0, "sanity");
return SurvivorAlignmentInBytes;
}
}
! public:
! PLABAllocator(G1CollectedHeap* g1h) :
_g1h(g1h), _survivor_alignment_bytes(calc_survivor_alignment_bytes()),
_alloc_buffer_waste(0), _undo_waste(0) {
}
! static PLABAllocator* create_allocator(G1CollectedHeap* g1h);
size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
size_t undo_waste() {return _undo_waste; }
// Allocate word_sz words in dest, either directly into the regions or by
*** 224,234 ****
// Allocate word_sz words in the PLAB of dest. Returns the address of the
// allocated memory, NULL if not successful.
HeapWord* plab_allocate(InCSetState dest,
size_t word_sz,
AllocationContext_t context) {
! G1ParGCAllocBuffer* buffer = alloc_buffer(dest, context);
if (_survivor_alignment_bytes == 0) {
return buffer->allocate(word_sz);
} else {
return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
}
--- 230,240 ----
// Allocate word_sz words in the PLAB of dest. Returns the address of the
// allocated memory, NULL if not successful.
HeapWord* plab_allocate(InCSetState dest,
size_t word_sz,
AllocationContext_t context) {
! G1PLAB* buffer = alloc_buffer(dest, context);
if (_survivor_alignment_bytes == 0) {
return buffer->allocate(word_sz);
} else {
return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
}
*** 253,271 ****
add_to_undo_waste(word_sz);
}
}
};
! class G1DefaultParGCAllocator : public G1ParGCAllocator {
! G1ParGCAllocBuffer _surviving_alloc_buffer;
! G1ParGCAllocBuffer _tenured_alloc_buffer;
! G1ParGCAllocBuffer* _alloc_buffers[InCSetState::Num];
! public:
! G1DefaultParGCAllocator(G1CollectedHeap* g1h);
! virtual G1ParGCAllocBuffer* alloc_buffer(InCSetState dest, AllocationContext_t context) {
assert(dest.is_valid(),
err_msg("Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value()));
assert(_alloc_buffers[dest.value()] != NULL,
err_msg("Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value()));
return _alloc_buffers[dest.value()];
--- 259,279 ----
add_to_undo_waste(word_sz);
}
}
};
! // The default PLAB allocator for G1. Keeps the current (single) PLAB for survivor
! // and old generation allocation.
! class DefaultPLABAllocator : public PLABAllocator {
! G1PLAB _surviving_alloc_buffer;
! G1PLAB _tenured_alloc_buffer;
! G1PLAB* _alloc_buffers[InCSetState::Num];
! public:
! DefaultPLABAllocator(G1CollectedHeap* g1h);
! virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) {
assert(dest.is_valid(),
err_msg("Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value()));
assert(_alloc_buffers[dest.value()] != NULL,
err_msg("Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value()));
return _alloc_buffers[dest.value()];
< prev index next >