comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 20423:5248357b7113

8057710: Refactor G1 heap region default sizes Summary: Refactored the defines to instead be static const in a HeapRegionBounds class. Reviewed-by: mgerdin, tschatzl
author sjohanss
date Tue, 09 Sep 2014 04:48:41 +0200
parents d35872270666
children c02ec279b062
comparison
equal deleted inserted replaced
20422:3153adbad1e9 20423:5248357b7113
26 #include "code/nmethod.hpp" 26 #include "code/nmethod.hpp"
27 #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" 27 #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
28 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 28 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
29 #include "gc_implementation/g1/g1OopClosures.inline.hpp" 29 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
30 #include "gc_implementation/g1/heapRegion.inline.hpp" 30 #include "gc_implementation/g1/heapRegion.inline.hpp"
31 #include "gc_implementation/g1/heapRegionBounds.inline.hpp"
31 #include "gc_implementation/g1/heapRegionRemSet.hpp" 32 #include "gc_implementation/g1/heapRegionRemSet.hpp"
32 #include "gc_implementation/g1/heapRegionManager.inline.hpp" 33 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
33 #include "gc_implementation/shared/liveRange.hpp" 34 #include "gc_implementation/shared/liveRange.hpp"
34 #include "memory/genOopClosures.inline.hpp" 35 #include "memory/genOopClosures.inline.hpp"
35 #include "memory/iterator.hpp" 36 #include "memory/iterator.hpp"
135 oop(bottom)->oop_iterate(cl2, mr); 136 oop(bottom)->oop_iterate(cl2, mr);
136 } 137 }
137 } 138 }
138 } 139 }
139 140
140 // Minimum region size; we won't go lower than that.
141 // We might want to decrease this in the future, to deal with small
142 // heaps a bit more efficiently.
143 #define MIN_REGION_SIZE ( 1024 * 1024 )
144
145 // Maximum region size; we don't go higher than that. There's a good
146 // reason for having an upper bound. We don't want regions to get too
147 // large, otherwise cleanup's effectiveness would decrease as there
148 // will be fewer opportunities to find totally empty regions after
149 // marking.
150 #define MAX_REGION_SIZE ( 32 * 1024 * 1024 )
151
152 // The automatic region size calculation will try to have around this
153 // many regions in the heap (based on the min heap size).
154 #define TARGET_REGION_NUMBER 2048
155
156 size_t HeapRegion::max_region_size() { 141 size_t HeapRegion::max_region_size() {
157 return (size_t)MAX_REGION_SIZE; 142 return HeapRegionBounds::max_size();
158 } 143 }
159 144
160 void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) { 145 void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) {
161 uintx region_size = G1HeapRegionSize; 146 uintx region_size = G1HeapRegionSize;
162 if (FLAG_IS_DEFAULT(G1HeapRegionSize)) { 147 if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
163 size_t average_heap_size = (initial_heap_size + max_heap_size) / 2; 148 size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
164 region_size = MAX2(average_heap_size / TARGET_REGION_NUMBER, 149 region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(),
165 (uintx) MIN_REGION_SIZE); 150 (uintx) HeapRegionBounds::min_size());
166 } 151 }
167 152
168 int region_size_log = log2_long((jlong) region_size); 153 int region_size_log = log2_long((jlong) region_size);
169 // Recalculate the region size to make sure it's a power of 154 // Recalculate the region size to make sure it's a power of
170 // 2. This means that region_size is the largest power of 2 that's 155 // 2. This means that region_size is the largest power of 2 that's
171 // <= what we've calculated so far. 156 // <= what we've calculated so far.
172 region_size = ((uintx)1 << region_size_log); 157 region_size = ((uintx)1 << region_size_log);
173 158
174 // Now make sure that we don't go over or under our limits. 159 // Now make sure that we don't go over or under our limits.
175 if (region_size < MIN_REGION_SIZE) { 160 if (region_size < HeapRegionBounds::min_size()) {
176 region_size = MIN_REGION_SIZE; 161 region_size = HeapRegionBounds::min_size();
177 } else if (region_size > MAX_REGION_SIZE) { 162 } else if (region_size > HeapRegionBounds::max_size()) {
178 region_size = MAX_REGION_SIZE; 163 region_size = HeapRegionBounds::max_size();
179 } 164 }
180 165
181 // And recalculate the log. 166 // And recalculate the log.
182 region_size_log = log2_long((jlong) region_size); 167 region_size_log = log2_long((jlong) region_size);
183 168