26 #include "gc/g1/g1Allocator.inline.hpp" |
26 #include "gc/g1/g1Allocator.inline.hpp" |
27 #include "gc/g1/g1AllocRegion.inline.hpp" |
27 #include "gc/g1/g1AllocRegion.inline.hpp" |
28 #include "gc/g1/g1EvacStats.inline.hpp" |
28 #include "gc/g1/g1EvacStats.inline.hpp" |
29 #include "gc/g1/g1EvacuationInfo.hpp" |
29 #include "gc/g1/g1EvacuationInfo.hpp" |
30 #include "gc/g1/g1CollectedHeap.inline.hpp" |
30 #include "gc/g1/g1CollectedHeap.inline.hpp" |
|
31 #include "gc/g1/g1NUMA.hpp" |
31 #include "gc/g1/g1Policy.hpp" |
32 #include "gc/g1/g1Policy.hpp" |
32 #include "gc/g1/heapRegion.inline.hpp" |
33 #include "gc/g1/heapRegion.inline.hpp" |
33 #include "gc/g1/heapRegionSet.inline.hpp" |
34 #include "gc/g1/heapRegionSet.inline.hpp" |
34 #include "gc/g1/heapRegionType.hpp" |
35 #include "gc/g1/heapRegionType.hpp" |
35 #include "utilities/align.hpp" |
36 #include "utilities/align.hpp" |
36 |
37 |
37 G1Allocator::G1Allocator(G1CollectedHeap* heap) : |
38 G1Allocator::G1Allocator(G1CollectedHeap* heap) : |
38 _g1h(heap), |
39 _g1h(heap), |
|
40 _numa(heap->numa()), |
39 _survivor_is_full(false), |
41 _survivor_is_full(false), |
40 _old_is_full(false), |
42 _old_is_full(false), |
41 _mutator_alloc_region(), |
43 _num_alloc_regions(_numa->num_active_nodes()), |
|
44 _mutator_alloc_regions(NULL), |
42 _survivor_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Young)), |
45 _survivor_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Young)), |
43 _old_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Old)), |
46 _old_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Old)), |
44 _retained_old_gc_alloc_region(NULL) { |
47 _retained_old_gc_alloc_region(NULL) { |
45 } |
48 |
46 |
49 _mutator_alloc_regions = NEW_C_HEAP_ARRAY(MutatorAllocRegion, _num_alloc_regions, mtGC); |
47 void G1Allocator::init_mutator_alloc_region() { |
50 for (uint i = 0; i < _num_alloc_regions; i++) { |
48 assert(_mutator_alloc_region.get() == NULL, "pre-condition"); |
51 ::new(_mutator_alloc_regions + i) MutatorAllocRegion(i); |
49 _mutator_alloc_region.init(); |
52 } |
50 } |
53 } |
51 |
54 |
52 void G1Allocator::release_mutator_alloc_region() { |
55 G1Allocator::~G1Allocator() { |
53 _mutator_alloc_region.release(); |
56 for (uint i = 0; i < _num_alloc_regions; i++) { |
54 assert(_mutator_alloc_region.get() == NULL, "post-condition"); |
57 _mutator_alloc_regions[i].~MutatorAllocRegion(); |
|
58 } |
|
59 FREE_C_HEAP_ARRAY(MutatorAllocRegion, _mutator_alloc_regions); |
|
60 } |
|
61 |
|
62 #ifdef ASSERT |
|
63 bool G1Allocator::has_mutator_alloc_region() { |
|
64 uint node_index = current_node_index(); |
|
65 return mutator_alloc_region(node_index)->get() != NULL; |
|
66 } |
|
67 #endif |
|
68 |
|
69 void G1Allocator::init_mutator_alloc_regions() { |
|
70 for (uint i = 0; i < _num_alloc_regions; i++) { |
|
71 assert(mutator_alloc_region(i)->get() == NULL, "pre-condition"); |
|
72 mutator_alloc_region(i)->init(); |
|
73 } |
|
74 } |
|
75 |
|
76 void G1Allocator::release_mutator_alloc_regions() { |
|
77 for (uint i = 0; i < _num_alloc_regions; i++) { |
|
78 mutator_alloc_region(i)->release(); |
|
79 assert(mutator_alloc_region(i)->get() == NULL, "post-condition"); |
|
80 } |
55 } |
81 } |
56 |
82 |
57 bool G1Allocator::is_retained_old_region(HeapRegion* hr) { |
83 bool G1Allocator::is_retained_old_region(HeapRegion* hr) { |
58 return _retained_old_gc_alloc_region == hr; |
84 return _retained_old_gc_alloc_region == hr; |
59 } |
85 } |
144 |
170 |
145 // Also, this value can be at most the humongous object threshold, |
171 // Also, this value can be at most the humongous object threshold, |
146 // since we can't allow tlabs to grow big enough to accommodate |
172 // since we can't allow tlabs to grow big enough to accommodate |
147 // humongous objects. |
173 // humongous objects. |
148 |
174 |
149 HeapRegion* hr = mutator_alloc_region()->get(); |
175 uint node_index = current_node_index(); |
|
176 HeapRegion* hr = mutator_alloc_region(node_index)->get(); |
150 size_t max_tlab = _g1h->max_tlab_size() * wordSize; |
177 size_t max_tlab = _g1h->max_tlab_size() * wordSize; |
151 if (hr == NULL) { |
178 if (hr == NULL) { |
152 return max_tlab; |
179 return max_tlab; |
153 } else { |
180 } else { |
154 return MIN2(MAX2(hr->free(), (size_t) MinTLABSize), max_tlab); |
181 return MIN2(MAX2(hr->free(), (size_t) MinTLABSize), max_tlab); |
155 } |
182 } |
156 } |
183 } |
157 |
184 |
158 size_t G1Allocator::used_in_alloc_regions() { |
185 size_t G1Allocator::used_in_alloc_regions() { |
159 assert(Heap_lock->owner() != NULL, "Should be owned on this thread's behalf."); |
186 assert(Heap_lock->owner() != NULL, "Should be owned on this thread's behalf."); |
160 return mutator_alloc_region()->used_in_alloc_regions(); |
187 size_t used = 0; |
|
188 for (uint i = 0; i < _num_alloc_regions; i++) { |
|
189 used += mutator_alloc_region(i)->used_in_alloc_regions(); |
|
190 } |
|
191 return used; |
161 } |
192 } |
162 |
193 |
163 |
194 |
164 HeapWord* G1Allocator::par_allocate_during_gc(G1HeapRegionAttr dest, |
195 HeapWord* G1Allocator::par_allocate_during_gc(G1HeapRegionAttr dest, |
165 size_t word_size) { |
196 size_t word_size) { |