10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_G1_G1ALLOCATOR_HPP
26 #define SHARE_GC_G1_G1ALLOCATOR_HPP
27
28 #include "gc/g1/g1AllocRegion.hpp"
29 #include "gc/g1/g1HeapRegionAttr.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "gc/shared/plab.hpp"
32
33 class G1EvacuationInfo;
34
35 // Interface to keep track of which regions G1 is currently allocating into. Provides
36 // some accessors (e.g. allocating into them, or getting their occupancy).
37 // Also keeps track of retained regions across GCs.
38 class G1Allocator : public CHeapObj<mtGC> {
39 friend class VMStructs;
40
41 private:
42 G1CollectedHeap* _g1h;
43
44 bool _survivor_is_full;
45 bool _old_is_full;
46
47 // Alloc region used to satisfy mutator allocation requests.
48 MutatorAllocRegion _mutator_alloc_region;
49
50 // Alloc region used to satisfy allocation requests by the GC for
51 // survivor objects.
52 SurvivorGCAllocRegion _survivor_gc_alloc_region;
53
54 // Alloc region used to satisfy allocation requests by the GC for
55 // old objects.
56 OldGCAllocRegion _old_gc_alloc_region;
57
58 HeapRegion* _retained_old_gc_alloc_region;
59
60 bool survivor_is_full() const;
61 bool old_is_full() const;
62
63 void set_survivor_full();
64 void set_old_full();
65
66 void reuse_retained_old_region(G1EvacuationInfo& evacuation_info,
67 OldGCAllocRegion* old,
68 HeapRegion** retained);
69
70 // Accessors to the allocation regions.
71 inline MutatorAllocRegion* mutator_alloc_region();
72 inline SurvivorGCAllocRegion* survivor_gc_alloc_region();
73 inline OldGCAllocRegion* old_gc_alloc_region();
74
75 // Allocation attempt during GC for a survivor object / PLAB.
76 HeapWord* survivor_attempt_allocation(size_t min_word_size,
77 size_t desired_word_size,
78 size_t* actual_word_size);
79
80 // Allocation attempt during GC for an old object / PLAB.
81 HeapWord* old_attempt_allocation(size_t min_word_size,
82 size_t desired_word_size,
83 size_t* actual_word_size);
84 public:
85 G1Allocator(G1CollectedHeap* heap);
86
87 #ifdef ASSERT
88 // Do we currently have an active mutator region to allocate into?
89 bool has_mutator_alloc_region() { return mutator_alloc_region()->get() != NULL; }
90 #endif
91
92 void init_mutator_alloc_region();
93 void release_mutator_alloc_region();
94
95 void init_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
96 void release_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
97 void abandon_gc_alloc_regions();
98 bool is_retained_old_region(HeapRegion* hr);
99
100 // Allocate blocks of memory during mutator time.
101
102 inline HeapWord* attempt_allocation(size_t min_word_size,
103 size_t desired_word_size,
104 size_t* actual_word_size);
105 inline HeapWord* attempt_allocation_locked(size_t word_size);
106 inline HeapWord* attempt_allocation_force(size_t word_size);
107
108 size_t unsafe_max_tlab_alloc();
109 size_t used_in_alloc_regions();
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_GC_G1_G1ALLOCATOR_HPP
26 #define SHARE_GC_G1_G1ALLOCATOR_HPP
27
28 #include "gc/g1/g1AllocRegion.hpp"
29 #include "gc/g1/g1HeapRegionAttr.hpp"
30 #include "gc/g1/g1NUMA.hpp"
31 #include "gc/shared/collectedHeap.hpp"
32 #include "gc/shared/plab.hpp"
33
34 class G1EvacuationInfo;
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
42 private:
43 G1CollectedHeap* _g1h;
44
45 bool _survivor_is_full;
46 bool _old_is_full;
47
48 // The number of MutatorAllocRegions used, one per memory node.
49 size_t _num_alloc_region;
50
51 // Alloc region used to satisfy mutator allocation requests.
52 MutatorAllocRegion* _mutator_alloc_region;
53
54 // Alloc region used to satisfy allocation requests by the GC for
55 // survivor objects.
56 SurvivorGCAllocRegion _survivor_gc_alloc_region;
57
58 // Alloc region used to satisfy allocation requests by the GC for
59 // old objects.
60 OldGCAllocRegion _old_gc_alloc_region;
61
62 HeapRegion* _retained_old_gc_alloc_region;
63
64 bool survivor_is_full() const;
65 bool old_is_full() const;
66
67 void set_survivor_full();
68 void set_old_full();
69
70 void reuse_retained_old_region(G1EvacuationInfo& evacuation_info,
71 OldGCAllocRegion* old,
72 HeapRegion** retained);
73
74 // Accessors to the allocation regions.
75 inline MutatorAllocRegion* mutator_alloc_region(uint node_index);
76 inline SurvivorGCAllocRegion* survivor_gc_alloc_region();
77 inline OldGCAllocRegion* old_gc_alloc_region();
78
79 // Allocation attempt during GC for a survivor object / PLAB.
80 HeapWord* survivor_attempt_allocation(size_t min_word_size,
81 size_t desired_word_size,
82 size_t* actual_word_size);
83
84 // Allocation attempt during GC for an old object / PLAB.
85 HeapWord* old_attempt_allocation(size_t min_word_size,
86 size_t desired_word_size,
87 size_t* actual_word_size);
88 public:
89 G1Allocator(G1CollectedHeap* heap);
90 ~G1Allocator();
91
92 #ifdef ASSERT
93 // Do we currently have an active mutator region to allocate into?
94 bool has_mutator_alloc_region();
95 #endif
96
97 void init_mutator_alloc_region();
98 void release_mutator_alloc_region();
99
100 void init_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
101 void release_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
102 void abandon_gc_alloc_regions();
103 bool is_retained_old_region(HeapRegion* hr);
104
105 // Allocate blocks of memory during mutator time.
106
107 inline HeapWord* attempt_allocation(size_t min_word_size,
108 size_t desired_word_size,
109 size_t* actual_word_size);
110 inline HeapWord* attempt_allocation_locked(size_t word_size);
111 inline HeapWord* attempt_allocation_force(size_t word_size);
112
113 size_t unsafe_max_tlab_alloc();
114 size_t used_in_alloc_regions();
|