119
120 // set the maximum size of eden to be the size of the young gen
121 // less two times the minimum survivor size. The minimum survivor
122 // size for UseAdaptiveSizePolicy is one alignment.
123 max_eden_size = size - 2 * alignment;
124 } else {
125 max_survivor_size = size / InitialSurvivorRatio;
126
127 // round the survivor space size down to the nearest alignment
128 // and make sure its size is greater than 0.
129 max_survivor_size = align_size_down(max_survivor_size, alignment);
130 max_survivor_size = MAX2(max_survivor_size, alignment);
131
132 // set the maximum size of eden to be the size of the young gen
133 // less two times the survivor size when the generation is 100%
134 // committed. The minimum survivor size for -UseAdaptiveSizePolicy
135 // is dependent on the committed portion (current capacity) of the
136 // generation - the less space committed, the smaller the survivor
137 // space, possibly as small as an alignment. However, we are interested
138 // in the case where the young generation is 100% committed, as this
139 // is the point where eden reachs its maximum size. At this point,
140 // the size of a survivor space is max_survivor_size.
141 max_eden_size = size - 2 * max_survivor_size;
142 }
143
144 _eden_counters = new SpaceCounters("eden", 0, max_eden_size, _eden_space,
145 _gen_counters);
146 _from_counters = new SpaceCounters("s0", 1, max_survivor_size, _from_space,
147 _gen_counters);
148 _to_counters = new SpaceCounters("s1", 2, max_survivor_size, _to_space,
149 _gen_counters);
150
151 compute_initial_space_boundaries();
152 }
153
154 void PSYoungGen::compute_initial_space_boundaries() {
155 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
156 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
157
158 // Compute sizes
159 size_t alignment = heap->space_alignment();
271 if (PrintAdaptiveSizePolicy && Verbose) {
272 gclog_or_tty->print_cr("Young generation size: "
273 "desired eden: " SIZE_FORMAT " survivor: " SIZE_FORMAT
274 " used: " SIZE_FORMAT " capacity: " SIZE_FORMAT
275 " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT,
276 eden_size, survivor_size, used_in_bytes(), capacity_in_bytes(),
277 _max_gen_size, min_gen_size());
278 }
279 }
280 }
281
282
283 bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) {
284 const size_t alignment = virtual_space()->alignment();
285 size_t orig_size = virtual_space()->committed_size();
286 bool size_changed = false;
287
288 // There used to be this guarantee there.
289 // guarantee ((eden_size + 2*survivor_size) <= _max_gen_size, "incorrect input arguments");
290 // Code below forces this requirement. In addition the desired eden
291 // size and disired survivor sizes are desired goals and may
292 // exceed the total generation size.
293
294 assert(min_gen_size() <= orig_size && orig_size <= max_size(), "just checking");
295
296 // Adjust new generation size
297 const size_t eden_plus_survivors =
298 align_size_up(eden_size + 2 * survivor_size, alignment);
299 size_t desired_size = MAX2(MIN2(eden_plus_survivors, max_size()),
300 min_gen_size());
301 assert(desired_size <= max_size(), "just checking");
302
303 if (desired_size > orig_size) {
304 // Grow the generation
305 size_t change = desired_size - orig_size;
306 assert(change % alignment == 0, "just checking");
307 HeapWord* prev_high = (HeapWord*) virtual_space()->high();
308 if (!virtual_space()->expand_by(change)) {
309 return false; // Error if we fail to resize!
310 }
311 if (ZapUnusedHeapArea) {
|
119
120 // set the maximum size of eden to be the size of the young gen
121 // less two times the minimum survivor size. The minimum survivor
122 // size for UseAdaptiveSizePolicy is one alignment.
123 max_eden_size = size - 2 * alignment;
124 } else {
125 max_survivor_size = size / InitialSurvivorRatio;
126
127 // round the survivor space size down to the nearest alignment
128 // and make sure its size is greater than 0.
129 max_survivor_size = align_size_down(max_survivor_size, alignment);
130 max_survivor_size = MAX2(max_survivor_size, alignment);
131
132 // set the maximum size of eden to be the size of the young gen
133 // less two times the survivor size when the generation is 100%
134 // committed. The minimum survivor size for -UseAdaptiveSizePolicy
135 // is dependent on the committed portion (current capacity) of the
136 // generation - the less space committed, the smaller the survivor
137 // space, possibly as small as an alignment. However, we are interested
138 // in the case where the young generation is 100% committed, as this
139 // is the point where eden reaches its maximum size. At this point,
140 // the size of a survivor space is max_survivor_size.
141 max_eden_size = size - 2 * max_survivor_size;
142 }
143
144 _eden_counters = new SpaceCounters("eden", 0, max_eden_size, _eden_space,
145 _gen_counters);
146 _from_counters = new SpaceCounters("s0", 1, max_survivor_size, _from_space,
147 _gen_counters);
148 _to_counters = new SpaceCounters("s1", 2, max_survivor_size, _to_space,
149 _gen_counters);
150
151 compute_initial_space_boundaries();
152 }
153
154 void PSYoungGen::compute_initial_space_boundaries() {
155 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
156 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
157
158 // Compute sizes
159 size_t alignment = heap->space_alignment();
271 if (PrintAdaptiveSizePolicy && Verbose) {
272 gclog_or_tty->print_cr("Young generation size: "
273 "desired eden: " SIZE_FORMAT " survivor: " SIZE_FORMAT
274 " used: " SIZE_FORMAT " capacity: " SIZE_FORMAT
275 " gen limits: " SIZE_FORMAT " / " SIZE_FORMAT,
276 eden_size, survivor_size, used_in_bytes(), capacity_in_bytes(),
277 _max_gen_size, min_gen_size());
278 }
279 }
280 }
281
282
283 bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) {
284 const size_t alignment = virtual_space()->alignment();
285 size_t orig_size = virtual_space()->committed_size();
286 bool size_changed = false;
287
288 // There used to be this guarantee there.
289 // guarantee ((eden_size + 2*survivor_size) <= _max_gen_size, "incorrect input arguments");
290 // Code below forces this requirement. In addition the desired eden
291 // size and desired survivor sizes are desired goals and may
292 // exceed the total generation size.
293
294 assert(min_gen_size() <= orig_size && orig_size <= max_size(), "just checking");
295
296 // Adjust new generation size
297 const size_t eden_plus_survivors =
298 align_size_up(eden_size + 2 * survivor_size, alignment);
299 size_t desired_size = MAX2(MIN2(eden_plus_survivors, max_size()),
300 min_gen_size());
301 assert(desired_size <= max_size(), "just checking");
302
303 if (desired_size > orig_size) {
304 // Grow the generation
305 size_t change = desired_size - orig_size;
306 assert(change % alignment == 0, "just checking");
307 HeapWord* prev_high = (HeapWord*) virtual_space()->high();
308 if (!virtual_space()->expand_by(change)) {
309 return false; // Error if we fail to resize!
310 }
311 if (ZapUnusedHeapArea) {
|