Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/collectorPolicy.cpp @ 10241:d17700c82d7d
8006088: Incompatible heap size flags accepted by VM
Summary: Make processing of minimum, initial and maximum heap size more intiutive by removing previous limitations on allowed values, and make error reporting consistent. Further, fix errors in ergonomic heap sizing.
Reviewed-by: johnc, jwilhelm, tamao
author | tschatzl |
---|---|
date | Mon, 06 May 2013 17:19:42 +0200 |
parents | f14063dcd52a |
children | f9be75d21404 7a95933197d0 |
comparison
equal
deleted
inserted
replaced
10240:30860066ae8f | 10241:d17700c82d7d |
---|---|
53 max_alignment(), min_alignment())); | 53 max_alignment(), min_alignment())); |
54 assert(max_alignment() % min_alignment() == 0, | 54 assert(max_alignment() % min_alignment() == 0, |
55 err_msg("max_alignment: " SIZE_FORMAT " not aligned by min_alignment: " SIZE_FORMAT, | 55 err_msg("max_alignment: " SIZE_FORMAT " not aligned by min_alignment: " SIZE_FORMAT, |
56 max_alignment(), min_alignment())); | 56 max_alignment(), min_alignment())); |
57 | 57 |
58 if (MaxHeapSize < InitialHeapSize) { | |
59 vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified"); | |
60 } | |
61 | |
58 if (MetaspaceSize > MaxMetaspaceSize) { | 62 if (MetaspaceSize > MaxMetaspaceSize) { |
59 MaxMetaspaceSize = MetaspaceSize; | 63 MaxMetaspaceSize = MetaspaceSize; |
60 } | 64 } |
61 MetaspaceSize = MAX2(min_alignment(), align_size_down_(MetaspaceSize, min_alignment())); | 65 MetaspaceSize = MAX2(min_alignment(), align_size_down_(MetaspaceSize, min_alignment())); |
62 // Don't increase Metaspace size limit above specified. | 66 // Don't increase Metaspace size limit above specified. |
76 vm_exit_during_initialization("Too small initial Metaspace size"); | 80 vm_exit_during_initialization("Too small initial Metaspace size"); |
77 } | 81 } |
78 } | 82 } |
79 | 83 |
80 void CollectorPolicy::initialize_size_info() { | 84 void CollectorPolicy::initialize_size_info() { |
81 // User inputs from -mx and ms are aligned | 85 // User inputs from -mx and ms must be aligned |
82 set_initial_heap_byte_size(InitialHeapSize); | 86 set_min_heap_byte_size(align_size_up(Arguments::min_heap_size(), min_alignment())); |
83 if (initial_heap_byte_size() == 0) { | 87 set_initial_heap_byte_size(align_size_up(InitialHeapSize, min_alignment())); |
84 set_initial_heap_byte_size(NewSize + OldSize); | |
85 } | |
86 set_initial_heap_byte_size(align_size_up(_initial_heap_byte_size, | |
87 min_alignment())); | |
88 | |
89 set_min_heap_byte_size(Arguments::min_heap_size()); | |
90 if (min_heap_byte_size() == 0) { | |
91 set_min_heap_byte_size(NewSize + OldSize); | |
92 } | |
93 set_min_heap_byte_size(align_size_up(_min_heap_byte_size, | |
94 min_alignment())); | |
95 | |
96 set_max_heap_byte_size(align_size_up(MaxHeapSize, max_alignment())); | 88 set_max_heap_byte_size(align_size_up(MaxHeapSize, max_alignment())); |
97 | 89 |
98 // Check heap parameter properties | 90 // Check heap parameter properties |
99 if (initial_heap_byte_size() < M) { | 91 if (initial_heap_byte_size() < M) { |
100 vm_exit_during_initialization("Too small initial heap"); | 92 vm_exit_during_initialization("Too small initial heap"); |
235 | 227 |
236 void TwoGenerationCollectorPolicy::initialize_flags() { | 228 void TwoGenerationCollectorPolicy::initialize_flags() { |
237 GenCollectorPolicy::initialize_flags(); | 229 GenCollectorPolicy::initialize_flags(); |
238 | 230 |
239 OldSize = align_size_down(OldSize, min_alignment()); | 231 OldSize = align_size_down(OldSize, min_alignment()); |
240 if (NewSize + OldSize > MaxHeapSize) { | |
241 MaxHeapSize = NewSize + OldSize; | |
242 } | |
243 | 232 |
244 if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(NewSize)) { | 233 if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(NewSize)) { |
245 // NewRatio will be used later to set the young generation size so we use | 234 // NewRatio will be used later to set the young generation size so we use |
246 // it to calculate how big the heap should be based on the requested OldSize | 235 // it to calculate how big the heap should be based on the requested OldSize |
247 // and NewRatio. | 236 // and NewRatio. |
250 | 239 |
251 calculated_heapsize = align_size_up(calculated_heapsize, max_alignment()); | 240 calculated_heapsize = align_size_up(calculated_heapsize, max_alignment()); |
252 MaxHeapSize = calculated_heapsize; | 241 MaxHeapSize = calculated_heapsize; |
253 InitialHeapSize = calculated_heapsize; | 242 InitialHeapSize = calculated_heapsize; |
254 } | 243 } |
244 MaxHeapSize = align_size_up(MaxHeapSize, max_alignment()); | |
245 | |
246 // adjust max heap size if necessary | |
247 if (NewSize + OldSize > MaxHeapSize) { | |
248 if (FLAG_IS_CMDLINE(MaxHeapSize)) { | |
249 // somebody set a maximum heap size with the intention that we should not | |
250 // exceed it. Adjust New/OldSize as necessary. | |
251 uintx calculated_size = NewSize + OldSize; | |
252 double shrink_factor = (double) MaxHeapSize / calculated_size; | |
253 // align | |
254 NewSize = align_size_down((uintx) (NewSize * shrink_factor), min_alignment()); | |
255 // OldSize is already aligned because above we aligned MaxHeapSize to | |
256 // max_alignment(), and we just made sure that NewSize is aligned to | |
257 // min_alignment(). In initialize_flags() we verified that max_alignment() | |
258 // is a multiple of min_alignment(). | |
259 OldSize = MaxHeapSize - NewSize; | |
260 } else { | |
261 MaxHeapSize = NewSize + OldSize; | |
262 } | |
263 } | |
264 // need to do this again | |
255 MaxHeapSize = align_size_up(MaxHeapSize, max_alignment()); | 265 MaxHeapSize = align_size_up(MaxHeapSize, max_alignment()); |
256 | 266 |
257 always_do_update_barrier = UseConcMarkSweepGC; | 267 always_do_update_barrier = UseConcMarkSweepGC; |
258 | 268 |
259 // Check validity of heap flags | 269 // Check validity of heap flags |