< prev index next >

src/hotspot/share/gc/shared/genArguments.cpp

Print this page
rev 56881 : imported patch 8233702-function-to-clamp-value-to-range


 212 // Minimum sizes of the generations may be different than
 213 // the initial sizes.  An inconsistency is permitted here
 214 // in the total size that can be specified explicitly by
 215 // command line specification of OldSize and NewSize and
 216 // also a command line specification of -Xms.  Issue a warning
 217 // but allow the values to pass.
 218 void GenArguments::initialize_size_info() {
 219   GCArguments::initialize_size_info();
 220 
 221   size_t max_young_size = MaxNewSize;
 222 
 223   // Determine maximum size of the young generation.
 224 
 225   if (FLAG_IS_DEFAULT(MaxNewSize)) {
 226     max_young_size = scale_by_NewRatio_aligned(MaxHeapSize, GenAlignment);
 227     // Bound the maximum size by NewSize below (since it historically
 228     // would have been NewSize and because the NewRatio calculation could
 229     // yield a size that is too small) and bound it by MaxNewSize above.
 230     // Ergonomics plays here by previously calculating the desired
 231     // NewSize and MaxNewSize.
 232     max_young_size = MIN2(MAX2(max_young_size, NewSize), MaxNewSize);
 233   }
 234 
 235   // Given the maximum young size, determine the initial and
 236   // minimum young sizes.
 237   size_t initial_young_size = NewSize;
 238 
 239   if (MaxHeapSize == InitialHeapSize) {
 240     // The maximum and initial heap sizes are the same so the generation's
 241     // initial size must be the same as it maximum size. Use NewSize as the
 242     // size if set on command line.
 243     max_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : max_young_size;
 244     initial_young_size = max_young_size;
 245 
 246     // Also update the minimum size if min == initial == max.
 247     if (MaxHeapSize == MinHeapSize) {
 248       MinNewSize = max_young_size;
 249     }
 250   } else {
 251     if (FLAG_IS_CMDLINE(NewSize)) {
 252       // If NewSize is set on the command line, we should use it as
 253       // the initial size, but make sure it is within the heap bounds.
 254       initial_young_size =
 255         MIN2(max_young_size, bound_minus_alignment(NewSize, InitialHeapSize, GenAlignment));
 256       MinNewSize = bound_minus_alignment(initial_young_size, MinHeapSize, GenAlignment);
 257     } else {
 258       // For the case where NewSize is not set on the command line, use
 259       // NewRatio to size the initial generation size. Use the current
 260       // NewSize as the floor, because if NewRatio is overly large, the resulting
 261       // size can be too small.
 262       initial_young_size =
 263         MIN2(max_young_size, MAX2(scale_by_NewRatio_aligned(InitialHeapSize, GenAlignment), NewSize));
 264     }
 265   }
 266 
 267   log_trace(gc, heap)("1: Minimum young " SIZE_FORMAT "  Initial young " SIZE_FORMAT "  Maximum young " SIZE_FORMAT,
 268                       MinNewSize, initial_young_size, max_young_size);
 269 
 270   // At this point the minimum, initial and maximum sizes
 271   // of the overall heap and of the young generation have been determined.
 272   // The maximum old size can be determined from the maximum young
 273   // and maximum heap size since no explicit flags exist
 274   // for setting the old generation maximum.
 275   MaxOldSize = MAX2(MaxHeapSize - max_young_size, GenAlignment);
 276 
 277   size_t initial_old_size = OldSize;
 278 
 279   // If no explicit command line flag has been set for the
 280   // old generation size, use what is left.
 281   if (!FLAG_IS_CMDLINE(OldSize)) {
 282     // The user has not specified any value but the ergonomics
 283     // may have chosen a value (which may or may not be consistent
 284     // with the overall heap size).  In either case make
 285     // the minimum, maximum and initial sizes consistent
 286     // with the young sizes and the overall heap sizes.
 287     MinOldSize = GenAlignment;
 288     initial_old_size = MIN2(MaxOldSize, MAX2(InitialHeapSize - initial_young_size, MinOldSize));
 289     // MaxOldSize has already been made consistent above.
 290   } else {
 291     // OldSize has been explicitly set on the command line. Use it
 292     // for the initial size but make sure the minimum allow a young
 293     // generation to fit as well.
 294     // If the user has explicitly set an OldSize that is inconsistent
 295     // with other command line flags, issue a warning.
 296     // The generation minimums and the overall heap minimum should
 297     // be within one generation alignment.
 298     if (initial_old_size > MaxOldSize) {
 299       log_warning(gc, ergo)("Inconsistency between maximum heap size and maximum "
 300                             "generation sizes: using maximum heap = " SIZE_FORMAT
 301                             ", -XX:OldSize flag is being ignored",
 302                             MaxHeapSize);
 303       initial_old_size = MaxOldSize;
 304     }
 305 
 306     MinOldSize = MIN2(initial_old_size, MinHeapSize - MinNewSize);
 307   }
 308 




 212 // Minimum sizes of the generations may be different than
 213 // the initial sizes.  An inconsistency is permitted here
 214 // in the total size that can be specified explicitly by
 215 // command line specification of OldSize and NewSize and
 216 // also a command line specification of -Xms.  Issue a warning
 217 // but allow the values to pass.
 218 void GenArguments::initialize_size_info() {
 219   GCArguments::initialize_size_info();
 220 
 221   size_t max_young_size = MaxNewSize;
 222 
 223   // Determine maximum size of the young generation.
 224 
 225   if (FLAG_IS_DEFAULT(MaxNewSize)) {
 226     max_young_size = scale_by_NewRatio_aligned(MaxHeapSize, GenAlignment);
 227     // Bound the maximum size by NewSize below (since it historically
 228     // would have been NewSize and because the NewRatio calculation could
 229     // yield a size that is too small) and bound it by MaxNewSize above.
 230     // Ergonomics plays here by previously calculating the desired
 231     // NewSize and MaxNewSize.
 232     max_young_size = clamp(max_young_size, NewSize, MaxNewSize);
 233   }
 234 
 235   // Given the maximum young size, determine the initial and
 236   // minimum young sizes.
 237   size_t initial_young_size = NewSize;
 238 
 239   if (MaxHeapSize == InitialHeapSize) {
 240     // The maximum and initial heap sizes are the same so the generation's
 241     // initial size must be the same as it maximum size. Use NewSize as the
 242     // size if set on command line.
 243     max_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : max_young_size;
 244     initial_young_size = max_young_size;
 245 
 246     // Also update the minimum size if min == initial == max.
 247     if (MaxHeapSize == MinHeapSize) {
 248       MinNewSize = max_young_size;
 249     }
 250   } else {
 251     if (FLAG_IS_CMDLINE(NewSize)) {
 252       // If NewSize is set on the command line, we should use it as
 253       // the initial size, but make sure it is within the heap bounds.
 254       initial_young_size =
 255         MIN2(max_young_size, bound_minus_alignment(NewSize, InitialHeapSize, GenAlignment));
 256       MinNewSize = bound_minus_alignment(initial_young_size, MinHeapSize, GenAlignment);
 257     } else {
 258       // For the case where NewSize is not set on the command line, use
 259       // NewRatio to size the initial generation size. Use the current
 260       // NewSize as the floor, because if NewRatio is overly large, the resulting
 261       // size can be too small.
 262       initial_young_size =
 263         clamp(scale_by_NewRatio_aligned(InitialHeapSize, GenAlignment), NewSize, max_young_size);
 264     }
 265   }
 266 
 267   log_trace(gc, heap)("1: Minimum young " SIZE_FORMAT "  Initial young " SIZE_FORMAT "  Maximum young " SIZE_FORMAT,
 268                       MinNewSize, initial_young_size, max_young_size);
 269 
 270   // At this point the minimum, initial and maximum sizes
 271   // of the overall heap and of the young generation have been determined.
 272   // The maximum old size can be determined from the maximum young
 273   // and maximum heap size since no explicit flags exist
 274   // for setting the old generation maximum.
 275   MaxOldSize = MAX2(MaxHeapSize - max_young_size, GenAlignment);
 276 
 277   size_t initial_old_size = OldSize;
 278 
 279   // If no explicit command line flag has been set for the
 280   // old generation size, use what is left.
 281   if (!FLAG_IS_CMDLINE(OldSize)) {
 282     // The user has not specified any value but the ergonomics
 283     // may have chosen a value (which may or may not be consistent
 284     // with the overall heap size).  In either case make
 285     // the minimum, maximum and initial sizes consistent
 286     // with the young sizes and the overall heap sizes.
 287     MinOldSize = GenAlignment;
 288     initial_old_size = clamp(InitialHeapSize - initial_young_size, MinOldSize, MaxOldSize);
 289     // MaxOldSize has already been made consistent above.
 290   } else {
 291     // OldSize has been explicitly set on the command line. Use it
 292     // for the initial size but make sure the minimum allow a young
 293     // generation to fit as well.
 294     // If the user has explicitly set an OldSize that is inconsistent
 295     // with other command line flags, issue a warning.
 296     // The generation minimums and the overall heap minimum should
 297     // be within one generation alignment.
 298     if (initial_old_size > MaxOldSize) {
 299       log_warning(gc, ergo)("Inconsistency between maximum heap size and maximum "
 300                             "generation sizes: using maximum heap = " SIZE_FORMAT
 301                             ", -XX:OldSize flag is being ignored",
 302                             MaxHeapSize);
 303       initial_old_size = MaxOldSize;
 304     }
 305 
 306     MinOldSize = MIN2(initial_old_size, MinHeapSize - MinNewSize);
 307   }
 308 


< prev index next >