21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_G1_G1ALLOCATOR_HPP
26 #define SHARE_VM_GC_G1_G1ALLOCATOR_HPP
27
28 #include "gc/g1/g1AllocRegion.hpp"
29 #include "gc/g1/g1AllocationContext.hpp"
30 #include "gc/g1/g1InCSetState.hpp"
31 #include "gc/shared/collectedHeap.hpp"
32 #include "gc/shared/plab.hpp"
33
34 class EvacuationInfo;
35
36 // Interface to keep track of which regions G1 is currently allocating into. Provides
37 // some accessors (e.g. allocating into them, or getting their occupancy).
38 // Also keeps track of retained regions across GCs.
39 class G1Allocator : public CHeapObj<mtGC> {
40 friend class VMStructs;
41 protected:
42 G1CollectedHeap* _g1h;
43
44 virtual MutatorAllocRegion* mutator_alloc_region(AllocationContext_t context) = 0;
45
46 // Accessors to the allocation regions.
47 virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) = 0;
48 virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) = 0;
49
50 // Allocation attempt during GC for a survivor object / PLAB.
51 inline HeapWord* survivor_attempt_allocation(size_t word_size,
52 AllocationContext_t context);
53 // Allocation attempt during GC for an old object / PLAB.
54 inline HeapWord* old_attempt_allocation(size_t word_size,
55 AllocationContext_t context);
56 public:
57 G1Allocator(G1CollectedHeap* heap) : _g1h(heap) { }
58 virtual ~G1Allocator() { }
59
60 static G1Allocator* create_allocator(G1CollectedHeap* g1h);
61
62 #ifdef ASSERT
63 // Do we currently have an active mutator region to allocate into?
64 bool has_mutator_alloc_region(AllocationContext_t context) { return mutator_alloc_region(context)->get() != NULL; }
65 #endif
66 virtual void init_mutator_alloc_region() = 0;
67 virtual void release_mutator_alloc_region() = 0;
68
69 virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
70 virtual void release_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
71 virtual void abandon_gc_alloc_regions() = 0;
72
73 // Management of retained regions.
74
75 virtual bool is_retained_old_region(HeapRegion* hr) = 0;
76 void reuse_retained_old_region(EvacuationInfo& evacuation_info,
77 OldGCAllocRegion* old,
78 HeapRegion** retained);
79
80 // Allocate blocks of memory during mutator time.
81
82 inline HeapWord* attempt_allocation(size_t word_size, AllocationContext_t context);
83 inline HeapWord* attempt_allocation_locked(size_t word_size, AllocationContext_t context);
84 inline HeapWord* attempt_allocation_force(size_t word_size, AllocationContext_t context);
85
86 size_t unsafe_max_tlab_alloc(AllocationContext_t context);
87
88 // Allocate blocks of memory during garbage collection. Will ensure an
89 // allocation region, either by picking one or expanding the
|
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_G1_G1ALLOCATOR_HPP
26 #define SHARE_VM_GC_G1_G1ALLOCATOR_HPP
27
28 #include "gc/g1/g1AllocRegion.hpp"
29 #include "gc/g1/g1AllocationContext.hpp"
30 #include "gc/g1/g1InCSetState.hpp"
31 #include "gc/shared/collectedHeap.hpp"
32 #include "gc/shared/plab.hpp"
33
34 class EvacuationInfo;
35
36 // Interface to keep track of which regions G1 is currently allocating into. Provides
37 // some accessors (e.g. allocating into them, or getting their occupancy).
38 // Also keeps track of retained regions across GCs.
39 class G1Allocator : public CHeapObj<mtGC> {
40 friend class VMStructs;
41 private:
42 bool _survivor_is_full;
43 bool _old_is_full;
44 protected:
45 G1CollectedHeap* _g1h;
46
47 virtual MutatorAllocRegion* mutator_alloc_region(AllocationContext_t context) = 0;
48
49 virtual bool survivor_is_full(AllocationContext_t context) const;
50 virtual bool old_is_full(AllocationContext_t context) const;
51
52 virtual void set_survivor_full(AllocationContext_t context);
53 virtual void set_old_full(AllocationContext_t context);
54
55 // Accessors to the allocation regions.
56 virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) = 0;
57 virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) = 0;
58
59 // Allocation attempt during GC for a survivor object / PLAB.
60 inline HeapWord* survivor_attempt_allocation(size_t word_size,
61 AllocationContext_t context);
62 // Allocation attempt during GC for an old object / PLAB.
63 inline HeapWord* old_attempt_allocation(size_t word_size,
64 AllocationContext_t context);
65 public:
66 G1Allocator(G1CollectedHeap* heap) : _g1h(heap), _survivor_is_full(false), _old_is_full(false) { }
67 virtual ~G1Allocator() { }
68
69 static G1Allocator* create_allocator(G1CollectedHeap* g1h);
70
71 #ifdef ASSERT
72 // Do we currently have an active mutator region to allocate into?
73 bool has_mutator_alloc_region(AllocationContext_t context) { return mutator_alloc_region(context)->get() != NULL; }
74 #endif
75 virtual void init_mutator_alloc_region() = 0;
76 virtual void release_mutator_alloc_region() = 0;
77
78 virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info);
79 virtual void release_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0;
80 virtual void abandon_gc_alloc_regions() = 0;
81
82 // Management of retained regions.
83
84 virtual bool is_retained_old_region(HeapRegion* hr) = 0;
85 void reuse_retained_old_region(EvacuationInfo& evacuation_info,
86 OldGCAllocRegion* old,
87 HeapRegion** retained);
88
89 // Allocate blocks of memory during mutator time.
90
91 inline HeapWord* attempt_allocation(size_t word_size, AllocationContext_t context);
92 inline HeapWord* attempt_allocation_locked(size_t word_size, AllocationContext_t context);
93 inline HeapWord* attempt_allocation_force(size_t word_size, AllocationContext_t context);
94
95 size_t unsafe_max_tlab_alloc(AllocationContext_t context);
96
97 // Allocate blocks of memory during garbage collection. Will ensure an
98 // allocation region, either by picking one or expanding the
|