114 if (UseAdaptiveSizePolicy) { |
114 if (UseAdaptiveSizePolicy) { |
115 max_survivor_size = size / MinSurvivorRatio; |
115 max_survivor_size = size / MinSurvivorRatio; |
116 |
116 |
117 // round the survivor space size down to the nearest alignment |
117 // round the survivor space size down to the nearest alignment |
118 // and make sure its size is greater than 0. |
118 // and make sure its size is greater than 0. |
119 max_survivor_size = align_size_down(max_survivor_size, alignment); |
119 max_survivor_size = align_down(max_survivor_size, alignment); |
120 max_survivor_size = MAX2(max_survivor_size, alignment); |
120 max_survivor_size = MAX2(max_survivor_size, alignment); |
121 |
121 |
122 // set the maximum size of eden to be the size of the young gen |
122 // set the maximum size of eden to be the size of the young gen |
123 // less two times the minimum survivor size. The minimum survivor |
123 // less two times the minimum survivor size. The minimum survivor |
124 // size for UseAdaptiveSizePolicy is one alignment. |
124 // size for UseAdaptiveSizePolicy is one alignment. |
126 } else { |
126 } else { |
127 max_survivor_size = size / InitialSurvivorRatio; |
127 max_survivor_size = size / InitialSurvivorRatio; |
128 |
128 |
129 // round the survivor space size down to the nearest alignment |
129 // round the survivor space size down to the nearest alignment |
130 // and make sure its size is greater than 0. |
130 // and make sure its size is greater than 0. |
131 max_survivor_size = align_size_down(max_survivor_size, alignment); |
131 max_survivor_size = align_down(max_survivor_size, alignment); |
132 max_survivor_size = MAX2(max_survivor_size, alignment); |
132 max_survivor_size = MAX2(max_survivor_size, alignment); |
133 |
133 |
134 // set the maximum size of eden to be the size of the young gen |
134 // set the maximum size of eden to be the size of the young gen |
135 // less two times the survivor size when the generation is 100% |
135 // less two times the survivor size when the generation is 100% |
136 // committed. The minimum survivor size for -UseAdaptiveSizePolicy |
136 // committed. The minimum survivor size for -UseAdaptiveSizePolicy |
160 size_t alignment = heap->space_alignment(); |
160 size_t alignment = heap->space_alignment(); |
161 size_t size = virtual_space()->committed_size(); |
161 size_t size = virtual_space()->committed_size(); |
162 assert(size >= 3 * alignment, "Young space is not large enough for eden + 2 survivors"); |
162 assert(size >= 3 * alignment, "Young space is not large enough for eden + 2 survivors"); |
163 |
163 |
164 size_t survivor_size = size / InitialSurvivorRatio; |
164 size_t survivor_size = size / InitialSurvivorRatio; |
165 survivor_size = align_size_down(survivor_size, alignment); |
165 survivor_size = align_down(survivor_size, alignment); |
166 // ... but never less than an alignment |
166 // ... but never less than an alignment |
167 survivor_size = MAX2(survivor_size, alignment); |
167 survivor_size = MAX2(survivor_size, alignment); |
168 |
168 |
169 // Young generation is eden + 2 survivor spaces |
169 // Young generation is eden + 2 survivor spaces |
170 size_t eden_size = size - (2 * survivor_size); |
170 size_t eden_size = size - (2 * survivor_size); |
191 char *to_start = eden_start + eden_size; |
191 char *to_start = eden_start + eden_size; |
192 char *from_start = to_start + survivor_size; |
192 char *from_start = to_start + survivor_size; |
193 char *from_end = from_start + survivor_size; |
193 char *from_end = from_start + survivor_size; |
194 |
194 |
195 assert(from_end == virtual_space()->high(), "just checking"); |
195 assert(from_end == virtual_space()->high(), "just checking"); |
196 assert(is_ptr_object_aligned(eden_start), "checking alignment"); |
196 assert(is_object_aligned(eden_start), "checking alignment"); |
197 assert(is_ptr_object_aligned(to_start), "checking alignment"); |
197 assert(is_object_aligned(to_start), "checking alignment"); |
198 assert(is_ptr_object_aligned(from_start), "checking alignment"); |
198 assert(is_object_aligned(from_start), "checking alignment"); |
199 |
199 |
200 MemRegion eden_mr((HeapWord*)eden_start, (HeapWord*)to_start); |
200 MemRegion eden_mr((HeapWord*)eden_start, (HeapWord*)to_start); |
201 MemRegion to_mr ((HeapWord*)to_start, (HeapWord*)from_start); |
201 MemRegion to_mr ((HeapWord*)to_start, (HeapWord*)from_start); |
202 MemRegion from_mr((HeapWord*)from_start, (HeapWord*)from_end); |
202 MemRegion from_mr((HeapWord*)from_start, (HeapWord*)from_end); |
203 |
203 |
292 |
292 |
293 assert(min_gen_size() <= orig_size && orig_size <= max_size(), "just checking"); |
293 assert(min_gen_size() <= orig_size && orig_size <= max_size(), "just checking"); |
294 |
294 |
295 // Adjust new generation size |
295 // Adjust new generation size |
296 const size_t eden_plus_survivors = |
296 const size_t eden_plus_survivors = |
297 align_size_up(eden_size + 2 * survivor_size, alignment); |
297 align_up(eden_size + 2 * survivor_size, alignment); |
298 size_t desired_size = MAX2(MIN2(eden_plus_survivors, max_size()), |
298 size_t desired_size = MAX2(MIN2(eden_plus_survivors, max_size()), |
299 min_gen_size()); |
299 min_gen_size()); |
300 assert(desired_size <= max_size(), "just checking"); |
300 assert(desired_size <= max_size(), "just checking"); |
301 |
301 |
302 if (desired_size > orig_size) { |
302 if (desired_size > orig_size) { |
526 |
526 |
527 // Should we be in this method if from_space is empty? Why not the set_space method? FIX ME! |
527 // Should we be in this method if from_space is empty? Why not the set_space method? FIX ME! |
528 if (from_size == 0) { |
528 if (from_size == 0) { |
529 from_size = alignment; |
529 from_size = alignment; |
530 } else { |
530 } else { |
531 from_size = align_size_up(from_size, alignment); |
531 from_size = align_up(from_size, alignment); |
532 } |
532 } |
533 |
533 |
534 from_end = from_start + from_size; |
534 from_end = from_start + from_size; |
535 assert(from_end > from_start, "addition overflow or from_size problem"); |
535 assert(from_end > from_start, "addition overflow or from_size problem"); |
536 |
536 |
609 |
609 |
610 guarantee((HeapWord*)from_start <= from_space()->bottom(), |
610 guarantee((HeapWord*)from_start <= from_space()->bottom(), |
611 "from start moved to the right"); |
611 "from start moved to the right"); |
612 guarantee((HeapWord*)from_end >= from_space()->top(), |
612 guarantee((HeapWord*)from_end >= from_space()->top(), |
613 "from end moved into live data"); |
613 "from end moved into live data"); |
614 assert(is_ptr_object_aligned(eden_start), "checking alignment"); |
614 assert(is_object_aligned(eden_start), "checking alignment"); |
615 assert(is_ptr_object_aligned(from_start), "checking alignment"); |
615 assert(is_object_aligned(from_start), "checking alignment"); |
616 assert(is_ptr_object_aligned(to_start), "checking alignment"); |
616 assert(is_object_aligned(to_start), "checking alignment"); |
617 |
617 |
618 MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end); |
618 MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end); |
619 MemRegion toMR ((HeapWord*)to_start, (HeapWord*)to_end); |
619 MemRegion toMR ((HeapWord*)to_start, (HeapWord*)to_end); |
620 MemRegion fromMR((HeapWord*)from_start, (HeapWord*)from_end); |
620 MemRegion fromMR((HeapWord*)from_start, (HeapWord*)from_end); |
621 |
621 |
813 space_shrinking->top(), |
813 space_shrinking->top(), |
814 sizeof(char)); |
814 sizeof(char)); |
815 } |
815 } |
816 |
816 |
817 size_t delta_in_bytes = unused_committed + delta_in_survivor; |
817 size_t delta_in_bytes = unused_committed + delta_in_survivor; |
818 delta_in_bytes = align_size_down(delta_in_bytes, gen_alignment); |
818 delta_in_bytes = align_down(delta_in_bytes, gen_alignment); |
819 return delta_in_bytes; |
819 return delta_in_bytes; |
820 } |
820 } |
821 |
821 |
822 // Return the number of bytes available for resizing down the young |
822 // Return the number of bytes available for resizing down the young |
823 // generation. This is the minimum of |
823 // generation. This is the minimum of |
826 // bytes to the size currently being used + some small extra |
826 // bytes to the size currently being used + some small extra |
827 size_t PSYoungGen::limit_gen_shrink(size_t bytes) { |
827 size_t PSYoungGen::limit_gen_shrink(size_t bytes) { |
828 // Allow shrinkage into the current eden but keep eden large enough |
828 // Allow shrinkage into the current eden but keep eden large enough |
829 // to maintain the minimum young gen size |
829 // to maintain the minimum young gen size |
830 bytes = MIN3(bytes, available_to_min_gen(), available_to_live()); |
830 bytes = MIN3(bytes, available_to_min_gen(), available_to_live()); |
831 return align_size_down(bytes, virtual_space()->alignment()); |
831 return align_down(bytes, virtual_space()->alignment()); |
832 } |
832 } |
833 |
833 |
834 void PSYoungGen::reset_after_change() { |
834 void PSYoungGen::reset_after_change() { |
835 ShouldNotReachHere(); |
835 ShouldNotReachHere(); |
836 } |
836 } |