src/share/vm/memory/collectorPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/memory

src/share/vm/memory/collectorPolicy.cpp

Print this page




  43 #if INCLUDE_ALL_GCS
  44 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
  45 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp"
  46 #endif // INCLUDE_ALL_GCS
  47 
  48 // CollectorPolicy methods.
  49 
  50 // Align down. If the aligning result in 0, return 'alignment'.
  51 static size_t restricted_align_down(size_t size, size_t alignment) {
  52   return MAX2(alignment, align_size_down_(size, alignment));
  53 }
  54 
  55 void CollectorPolicy::initialize_flags() {
  56   assert(_max_alignment >= _min_alignment,
  57          err_msg("max_alignment: " SIZE_FORMAT " less than min_alignment: " SIZE_FORMAT,
  58                  _max_alignment, _min_alignment));
  59   assert(_max_alignment % _min_alignment == 0,
  60          err_msg("max_alignment: " SIZE_FORMAT " not aligned by min_alignment: " SIZE_FORMAT,
  61                  _max_alignment, _min_alignment));
  62 
  63   if (MaxHeapSize < InitialHeapSize) {

  64     vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified");
  65   }



































  66 
  67   if (!is_size_aligned(MaxMetaspaceSize, _max_alignment)) {
  68     FLAG_SET_ERGO(uintx, MaxMetaspaceSize,
  69         restricted_align_down(MaxMetaspaceSize, _max_alignment));
  70   }
  71 
  72   if (MetaspaceSize > MaxMetaspaceSize) {
  73     FLAG_SET_ERGO(uintx, MetaspaceSize, MaxMetaspaceSize);
  74   }
  75 
  76   if (!is_size_aligned(MetaspaceSize, _min_alignment)) {
  77     FLAG_SET_ERGO(uintx, MetaspaceSize,
  78         restricted_align_down(MetaspaceSize, _min_alignment));
  79   }
  80 
  81   assert(MetaspaceSize <= MaxMetaspaceSize, "Must be");
  82 
  83   MinMetaspaceExpansion = restricted_align_down(MinMetaspaceExpansion, _min_alignment);
  84   MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, _min_alignment);
  85 
  86   MinHeapDeltaBytes = align_size_up(MinHeapDeltaBytes, _min_alignment);
  87 
  88   assert(MetaspaceSize    % _min_alignment == 0, "metapace alignment");
  89   assert(MaxMetaspaceSize % _max_alignment == 0, "maximum metaspace alignment");
  90   if (MetaspaceSize < 256*K) {
  91     vm_exit_during_initialization("Too small initial Metaspace size");
  92   }
  93 }
  94 
  95 void CollectorPolicy::initialize_size_info() {
  96   // User inputs from -mx and ms must be aligned
  97   _min_heap_byte_size = align_size_up(Arguments::min_heap_size(), _min_alignment);
  98   _initial_heap_byte_size = align_size_up(InitialHeapSize, _min_alignment);
  99   _max_heap_byte_size = align_size_up(MaxHeapSize, _max_alignment);
 100 
 101   // Check heap parameter properties
 102   if (_initial_heap_byte_size < M) {
 103     vm_exit_during_initialization("Too small initial heap");
 104   }
 105   // Check heap parameter properties
 106   if (_min_heap_byte_size < M) {
 107     vm_exit_during_initialization("Too small minimum heap");
 108   }
 109   if (_initial_heap_byte_size <= NewSize) {
 110      // make sure there is at least some room in old space
 111     vm_exit_during_initialization("Too small initial heap for new size specified");
 112   }
 113   if (_max_heap_byte_size < _min_heap_byte_size) {
 114     vm_exit_during_initialization("Incompatible minimum and maximum heap sizes specified");
 115   }
 116   if (_initial_heap_byte_size < _min_heap_byte_size) {
 117     vm_exit_during_initialization("Incompatible minimum and initial heap sizes specified");
 118   }
 119   if (_max_heap_byte_size < _initial_heap_byte_size) {
 120     vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified");
 121   }
 122 
 123   if (PrintGCDetails && Verbose) {
 124     gclog_or_tty->print_cr("Minimum heap " SIZE_FORMAT "  Initial heap "
 125       SIZE_FORMAT "  Maximum heap " SIZE_FORMAT,
 126       _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size);
 127   }
 128 }
 129 
 130 bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) {
 131   bool result = _should_clear_all_soft_refs;
 132   set_should_clear_all_soft_refs(false);
 133   return result;
 134 }
 135 
 136 GenRemSet* CollectorPolicy::create_rem_set(MemRegion whole_heap,
 137                                            int max_covered_regions) {
 138   switch (rem_set_name()) {
 139   case GenRemSet::CardTable: {
 140     CardTableRS* res = new CardTableRS(whole_heap, max_covered_regions);
 141     return res;


 192 
 193 size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size,
 194                                                  size_t maximum_size) {
 195   size_t alignment = _min_alignment;
 196   size_t max_minus = maximum_size - alignment;
 197   return desired_size < max_minus ? desired_size : max_minus;
 198 }
 199 
 200 
 201 void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size,
 202                                                 size_t init_promo_size,
 203                                                 size_t init_survivor_size) {
 204   const double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
 205   _size_policy = new AdaptiveSizePolicy(init_eden_size,
 206                                         init_promo_size,
 207                                         init_survivor_size,
 208                                         max_gc_pause_sec,
 209                                         GCTimeRatio);
 210 }
 211 























 212 void GenCollectorPolicy::initialize_flags() {
 213   // All sizes must be multiples of the generation granularity.
 214   _min_alignment = (uintx) Generation::GenGrain;
 215   _max_alignment = compute_max_alignment();
 216 
 217   CollectorPolicy::initialize_flags();
 218 












 219   // All generational heaps have a youngest gen; handle those flags here.
 220 
 221   // Adjust max size parameters
 222   if (NewSize > MaxNewSize) {
 223     MaxNewSize = NewSize;
 224   }
 225   NewSize = align_size_down(NewSize, _min_alignment);
 226   MaxNewSize = align_size_down(MaxNewSize, _min_alignment);
 227 
 228   // Check validity of heap flags
 229   assert(NewSize     % _min_alignment == 0, "eden space alignment");
 230   assert(MaxNewSize  % _min_alignment == 0, "survivor space alignment");

















 231 
 232   if (NewSize < 3 * _min_alignment) {
 233      // make sure there room for eden and two survivor spaces
 234     vm_exit_during_initialization("Too small new size specified");



 235   }





















 236   if (SurvivorRatio < 1 || NewRatio < 1) {
 237     vm_exit_during_initialization("Invalid young gen ratio specified");
 238   }
 239 }
 240 
 241 void TwoGenerationCollectorPolicy::initialize_flags() {
 242   GenCollectorPolicy::initialize_flags();
 243 
 244   OldSize = align_size_down(OldSize, _min_alignment);


 245 
 246   if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(NewSize)) {
 247     // NewRatio will be used later to set the young generation size so we use
 248     // it to calculate how big the heap should be based on the requested OldSize
 249     // and NewRatio.
 250     assert(NewRatio > 0, "NewRatio should have been set up earlier");
 251     size_t calculated_heapsize = (OldSize / NewRatio) * (NewRatio + 1);
 252 
 253     calculated_heapsize = align_size_up(calculated_heapsize, _max_alignment);
 254     MaxHeapSize = calculated_heapsize;
 255     InitialHeapSize = calculated_heapsize;
 256   }
 257   MaxHeapSize = align_size_up(MaxHeapSize, _max_alignment);
 258 
 259   // adjust max heap size if necessary
 260   if (NewSize + OldSize > MaxHeapSize) {
 261     if (FLAG_IS_CMDLINE(MaxHeapSize)) {
 262       // Somebody has set a maximum heap size with the intention that we should not
 263       // exceed it. Adjust New/OldSize as necessary.
 264       uintx calculated_size = NewSize + OldSize;
 265       double shrink_factor = (double) MaxHeapSize / calculated_size;
 266       // align
 267       NewSize = align_size_down((uintx) (NewSize * shrink_factor), _min_alignment);
 268       // OldSize is already aligned because above we aligned MaxHeapSize to
 269       // _max_alignment, and we just made sure that NewSize is aligned to
 270       // _min_alignment. In initialize_flags() we verified that _max_alignment
 271       // is a multiple of _min_alignment.
 272       OldSize = MaxHeapSize - NewSize;
 273     } else {
 274       MaxHeapSize = NewSize + OldSize;
 275     }
 276   }
 277   // need to do this again
 278   MaxHeapSize = align_size_up(MaxHeapSize, _max_alignment);
 279 
 280   // adjust max heap size if necessary
 281   if (NewSize + OldSize > MaxHeapSize) {
 282     if (FLAG_IS_CMDLINE(MaxHeapSize)) {
 283       // somebody set a maximum heap size with the intention that we should not
 284       // exceed it. Adjust New/OldSize as necessary.
 285       uintx calculated_size = NewSize + OldSize;
 286       double shrink_factor = (double) MaxHeapSize / calculated_size;
 287       // align
 288       NewSize = align_size_down((uintx) (NewSize * shrink_factor), _min_alignment);
 289       // OldSize is already aligned because above we aligned MaxHeapSize to
 290       // _max_alignment, and we just made sure that NewSize is aligned to
 291       // _min_alignment. In initialize_flags() we verified that _max_alignment
 292       // is a multiple of _min_alignment.
 293       OldSize = MaxHeapSize - NewSize;
 294     } else {
 295       MaxHeapSize = NewSize + OldSize;
 296     }
 297   }
 298   // need to do this again
 299   MaxHeapSize = align_size_up(MaxHeapSize, _max_alignment);
 300 
 301   always_do_update_barrier = UseConcMarkSweepGC;
 302 
 303   // Check validity of heap flags
 304   assert(OldSize     % _min_alignment == 0, "old space alignment");
 305   assert(MaxHeapSize % _max_alignment == 0, "maximum heap alignment");








 306 }
 307 
 308 // Values set on the command line win over any ergonomically
 309 // set command line parameters.
 310 // Ergonomic choice of parameters are done before this
 311 // method is called.  Values for command line parameters such as NewSize
 312 // and MaxNewSize feed those ergonomic choices into this method.
 313 // This method makes the final generation sizings consistent with
 314 // themselves and with overall heap sizings.
 315 // In the absence of explicitly set command line flags, policies
 316 // such as the use of NewRatio are used to size the generation.
 317 void GenCollectorPolicy::initialize_size_info() {
 318   CollectorPolicy::initialize_size_info();
 319 
 320   // _min_alignment is used for alignment within a generation.
 321   // There is additional alignment done down stream for some
 322   // collectors that sometimes causes unwanted rounding up of
 323   // generations sizes.
 324 
 325   // Determine maximum size of gen0
 326 
 327   size_t max_new_size = 0;
 328   if (FLAG_IS_CMDLINE(MaxNewSize) || FLAG_IS_ERGO(MaxNewSize)) {
 329     if (MaxNewSize < _min_alignment) {
 330       max_new_size = _min_alignment;
 331     }
 332     if (MaxNewSize >= _max_heap_byte_size) {
 333       max_new_size = align_size_down(_max_heap_byte_size - _min_alignment,
 334                                      _min_alignment);
 335       warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or "
 336         "greater than the entire heap (" SIZE_FORMAT "k).  A "
 337         "new generation size of " SIZE_FORMAT "k will be used.",
 338         MaxNewSize/K, _max_heap_byte_size/K, max_new_size/K);
 339     } else {
 340       max_new_size = align_size_down(MaxNewSize, _min_alignment);
 341     }
 342 
 343   // The case for FLAG_IS_ERGO(MaxNewSize) could be treated
 344   // specially at this point to just use an ergonomically set
 345   // MaxNewSize to set max_new_size.  For cases with small
 346   // heaps such a policy often did not work because the MaxNewSize
 347   // was larger than the entire heap.  The interpretation given
 348   // to ergonomically set flags is that the flags are set
 349   // by different collectors for their own special needs but
 350   // are not allowed to badly shape the heap.  This allows the
 351   // different collectors to decide what's best for themselves
 352   // without having to factor in the overall heap shape.  It
 353   // can be the case in the future that the collectors would
 354   // only make "wise" ergonomics choices and this policy could
 355   // just accept those choices.  The choices currently made are
 356   // not always "wise".
 357   } else {
 358     max_new_size = scale_by_NewRatio_aligned(_max_heap_byte_size);
 359     // Bound the maximum size by NewSize below (since it historically
 360     // would have been NewSize and because the NewRatio calculation could
 361     // yield a size that is too small) and bound it by MaxNewSize above.
 362     // Ergonomics plays here by previously calculating the desired
 363     // NewSize and MaxNewSize.
 364     max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize);
 365   }
 366   assert(max_new_size > 0, "All paths should set max_new_size");
 367 
 368   // Given the maximum gen0 size, determine the initial and
 369   // minimum gen0 sizes.
 370 
 371   if (_max_heap_byte_size == _min_heap_byte_size) {
 372     // The maximum and minimum heap sizes are the same so
 373     // the generations minimum and initial must be the
 374     // same as its maximum.
 375     _min_gen0_size = max_new_size;
 376     _initial_gen0_size = max_new_size;


 405     _max_gen0_size = max_new_size;
 406 
 407     // At this point the desirable initial and minimum sizes have been
 408     // determined without regard to the maximum sizes.
 409 
 410     // Bound the sizes by the corresponding overall heap sizes.
 411     _min_gen0_size = bound_minus_alignment(_min_gen0_size, _min_heap_byte_size);
 412     _initial_gen0_size = bound_minus_alignment(_initial_gen0_size, _initial_heap_byte_size);
 413     _max_gen0_size = bound_minus_alignment(_max_gen0_size, _max_heap_byte_size);
 414 
 415     // At this point all three sizes have been checked against the
 416     // maximum sizes but have not been checked for consistency
 417     // among the three.
 418 
 419     // Final check min <= initial <= max
 420     _min_gen0_size = MIN2(_min_gen0_size, _max_gen0_size);
 421     _initial_gen0_size = MAX2(MIN2(_initial_gen0_size, _max_gen0_size), _min_gen0_size);
 422     _min_gen0_size = MIN2(_min_gen0_size, _initial_gen0_size);
 423   }
 424 

















 425   if (PrintGCDetails && Verbose) {
 426     gclog_or_tty->print_cr("1: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
 427       SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
 428       _min_gen0_size, _initial_gen0_size, _max_gen0_size);
 429   }
 430 }
 431 
 432 // Call this method during the sizing of the gen1 to make
 433 // adjustments to gen0 because of gen1 sizing policy.  gen0 initially has
 434 // the most freedom in sizing because it is done before the
 435 // policy for gen1 is applied.  Once gen1 policies have been applied,
 436 // there may be conflicts in the shape of the heap and this method
 437 // is used to make the needed adjustments.  The application of the
 438 // policies could be more sophisticated (iterative for example) but
 439 // keeping it simple also seems a worthwhile goal.
 440 bool TwoGenerationCollectorPolicy::adjust_gen0_sizes(size_t* gen0_size_ptr,
 441                                                      size_t* gen1_size_ptr,
 442                                                      const size_t heap_size,
 443                                                      const size_t min_gen1_size) {
 444   bool result = false;


 459     }
 460   }
 461   return result;
 462 }
 463 
 464 // Minimum sizes of the generations may be different than
 465 // the initial sizes.  An inconsistency is permitted here
 466 // in the total size that can be specified explicitly by
 467 // command line specification of OldSize and NewSize and
 468 // also a command line specification of -Xms.  Issue a warning
 469 // but allow the values to pass.
 470 
 471 void TwoGenerationCollectorPolicy::initialize_size_info() {
 472   GenCollectorPolicy::initialize_size_info();
 473 
 474   // At this point the minimum, initial and maximum sizes
 475   // of the overall heap and of gen0 have been determined.
 476   // The maximum gen1 size can be determined from the maximum gen0
 477   // and maximum heap size since no explicit flags exist
 478   // for setting the gen1 maximum.
 479   _max_gen1_size = _max_heap_byte_size - _max_gen0_size;
 480   _max_gen1_size =
 481     MAX2((uintx)align_size_down(_max_gen1_size, _min_alignment), _min_alignment);
 482 
 483   // If no explicit command line flag has been set for the
 484   // gen1 size, use what is left for gen1.
 485   if (FLAG_IS_DEFAULT(OldSize) || FLAG_IS_ERGO(OldSize)) {
 486     // The user has not specified any value or ergonomics
 487     // has chosen a value (which may or may not be consistent
 488     // with the overall heap size).  In either case make
 489     // the minimum, maximum and initial sizes consistent
 490     // with the gen0 sizes and the overall heap sizes.
 491     assert(_min_heap_byte_size > _min_gen0_size,
 492       "gen0 has an unexpected minimum size");
 493     _min_gen1_size = _min_heap_byte_size - _min_gen0_size;
 494     _min_gen1_size = MAX2((uintx)align_size_down(_min_gen1_size, _min_alignment),
 495            _min_alignment);
 496     _initial_gen1_size = _initial_heap_byte_size - _initial_gen0_size;
 497     _initial_gen1_size = MAX2((uintx)align_size_down(_initial_gen1_size, _min_alignment),
 498            _min_alignment);
 499   } else {
 500     // OldSize has been explicitly set on the command line. Use the
 501     // OldSize and then determine the consequences.
 502     _min_gen1_size = OldSize;
 503     _initial_gen1_size = OldSize;
 504 
 505     // If the user has explicitly set an OldSize that is inconsistent
 506     // with other command line flags, issue a warning.
 507     // The generation minimums and the overall heap minimum should
 508     // be within one heap alignment.
 509     if ((_min_gen1_size + _min_gen0_size + _min_alignment) < _min_heap_byte_size) {
 510       warning("Inconsistency between minimum heap size and minimum "
 511               "generation sizes: using minimum heap = " SIZE_FORMAT,
 512               _min_heap_byte_size);
 513     }
 514     if (OldSize > _max_gen1_size) {
 515       warning("Inconsistency between maximum heap size and maximum "
 516               "generation sizes: using maximum heap = " SIZE_FORMAT
 517               " -XX:OldSize flag is being ignored",
 518               _max_heap_byte_size);
 519     }
 520     // If there is an inconsistency between the OldSize and the minimum and/or
 521     // initial size of gen0, since OldSize was explicitly set, OldSize wins.
 522     if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size,
 523                           _min_heap_byte_size, OldSize)) {
 524       if (PrintGCDetails && Verbose) {
 525         gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
 526               SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
 527               _min_gen0_size, _initial_gen0_size, _max_gen0_size);
 528       }
 529     }
 530     // The same as above for the old gen initial size
 531     if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size,
 532                           _initial_heap_byte_size, OldSize)) {
 533       if (PrintGCDetails && Verbose) {
 534         gclog_or_tty->print_cr("3: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
 535           SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
 536           _min_gen0_size, _initial_gen0_size, _max_gen0_size);
 537       }
 538     }


 539   }
 540   // Enforce the maximum gen1 size.
 541   _min_gen1_size = MIN2(_min_gen1_size, _max_gen1_size);
 542 
 543   // Check that min gen1 <= initial gen1 <= max gen1
 544   _initial_gen1_size = MAX2(_initial_gen1_size, _min_gen1_size);
 545   _initial_gen1_size = MIN2(_initial_gen1_size, _max_gen1_size);
 546 


















 547   if (PrintGCDetails && Verbose) {
 548     gclog_or_tty->print_cr("Minimum gen1 " SIZE_FORMAT "  Initial gen1 "
 549       SIZE_FORMAT "  Maximum gen1 " SIZE_FORMAT,
 550       _min_gen1_size, _initial_gen1_size, _max_gen1_size);
 551   }
 552 }
 553 
 554 HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size,
 555                                         bool is_tlab,
 556                                         bool* gc_overhead_limit_was_exceeded) {
 557   GenCollectedHeap *gch = GenCollectedHeap::heap();
 558 
 559   debug_only(gch->check_for_valid_allocation_state());
 560   assert(gch->no_gc_in_progress(), "Allocation during gc not allowed");
 561 
 562   // In general gc_overhead_limit_was_exceeded should be false so
 563   // set it so here and reset it to true only if the gc time
 564   // limit is being exceeded as checked below.
 565   *gc_overhead_limit_was_exceeded = false;
 566 




  43 #if INCLUDE_ALL_GCS
  44 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
  45 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp"
  46 #endif // INCLUDE_ALL_GCS
  47 
  48 // CollectorPolicy methods.
  49 
  50 // Align down. If the aligning result in 0, return 'alignment'.
  51 static size_t restricted_align_down(size_t size, size_t alignment) {
  52   return MAX2(alignment, align_size_down_(size, alignment));
  53 }
  54 
  55 void CollectorPolicy::initialize_flags() {
  56   assert(_max_alignment >= _min_alignment,
  57          err_msg("max_alignment: " SIZE_FORMAT " less than min_alignment: " SIZE_FORMAT,
  58                  _max_alignment, _min_alignment));
  59   assert(_max_alignment % _min_alignment == 0,
  60          err_msg("max_alignment: " SIZE_FORMAT " not aligned by min_alignment: " SIZE_FORMAT,
  61                  _max_alignment, _min_alignment));
  62 
  63   if (FLAG_IS_CMDLINE(MaxHeapSize)) {
  64     if (FLAG_IS_CMDLINE(InitialHeapSize) && InitialHeapSize > MaxHeapSize) {
  65       vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified");
  66     }
  67     if (Arguments::min_heap_size() != 0 && MaxHeapSize < Arguments::min_heap_size()) {
  68       vm_exit_during_initialization("Incompatible minimum and maximum heap sizes specified");
  69     }
  70     _max_heap_size_cmdline = true;
  71   }
  72 
  73   if (FLAG_IS_CMDLINE(InitialHeapSize) && Arguments::min_heap_size() != 0 &&
  74       InitialHeapSize < Arguments::min_heap_size()) {
  75     vm_exit_during_initialization("Incompatible minimum and initial heap sizes specified");
  76   }
  77   if (!FLAG_IS_DEFAULT(InitialHeapSize) && InitialHeapSize > MaxHeapSize) {
  78     FLAG_SET_ERGO(uintx, MaxHeapSize, InitialHeapSize);
  79   } else if (!FLAG_IS_DEFAULT(MaxHeapSize) && InitialHeapSize > MaxHeapSize) {
  80     FLAG_SET_ERGO(uintx, InitialHeapSize, MaxHeapSize);
  81     if (InitialHeapSize < Arguments::min_heap_size()) {
  82       Arguments::set_min_heap_size(InitialHeapSize);
  83     }
  84   }
  85 
  86   // User inputs from -Xmx and -Xms must be aligned
  87   Arguments::set_min_heap_size(align_size_up(Arguments::min_heap_size(), _min_alignment));
  88   uintx alignedInitialHeapSize = align_size_up(InitialHeapSize, _min_alignment);
  89   uintx alignedMaxHeapSize = align_size_up(MaxHeapSize, _max_alignment);
  90 
  91   // Write back to flags if the values was changed
  92   if (alignedInitialHeapSize != InitialHeapSize) {
  93     FLAG_SET_ERGO(uintx, InitialHeapSize, alignedInitialHeapSize);
  94   }
  95   if (alignedMaxHeapSize != MaxHeapSize) {
  96     FLAG_SET_ERGO(uintx, MaxHeapSize, alignedMaxHeapSize);
  97   }
  98 
  99   assert(InitialHeapSize <= MaxHeapSize, "Ergonomics decided on incompatible initial and maximum heap sizes");
 100   assert(InitialHeapSize % _min_alignment == 0, "InitialHeapSize alignment");
 101   assert(MaxHeapSize % _max_alignment == 0, "MaxHeapSize alignment");
 102 
 103   if (!is_size_aligned(MaxMetaspaceSize, _max_alignment)) {
 104     FLAG_SET_ERGO(uintx, MaxMetaspaceSize,
 105         restricted_align_down(MaxMetaspaceSize, _max_alignment));
 106   }
 107 
 108   if (MetaspaceSize > MaxMetaspaceSize) {
 109     FLAG_SET_ERGO(uintx, MetaspaceSize, MaxMetaspaceSize);
 110   }
 111 
 112   if (!is_size_aligned(MetaspaceSize, _min_alignment)) {
 113     FLAG_SET_ERGO(uintx, MetaspaceSize,
 114         restricted_align_down(MetaspaceSize, _min_alignment));
 115   }
 116 
 117   assert(MetaspaceSize <= MaxMetaspaceSize, "Must be");
 118 
 119   MinMetaspaceExpansion = restricted_align_down(MinMetaspaceExpansion, _min_alignment);
 120   MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, _min_alignment);
 121 
 122   MinHeapDeltaBytes = align_size_up(MinHeapDeltaBytes, _min_alignment);
 123 
 124   assert(MetaspaceSize    % _min_alignment == 0, "metapace alignment");
 125   assert(MaxMetaspaceSize % _max_alignment == 0, "maximum metaspace alignment");
 126   if (MetaspaceSize < 256*K) {
 127     vm_exit_during_initialization("Too small initial Metaspace size");
 128   }
 129 }
 130 
 131 void CollectorPolicy::initialize_size_info() {
 132   _min_heap_byte_size = Arguments::min_heap_size();
 133   _initial_heap_byte_size = InitialHeapSize;
 134   _max_heap_byte_size = MaxHeapSize;

 135 
 136   // Check heap parameter properties
 137   if (_initial_heap_byte_size < M) {
 138     vm_exit_during_initialization("Too small initial heap");
 139   }
 140   // Check heap parameter properties
 141   if (_min_heap_byte_size < M) {
 142     vm_exit_during_initialization("Too small minimum heap");
 143   }
 144 
 145   assert(_max_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible minimum and maximum heap sizes");
 146   assert(_initial_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible initial and minimum heap sizes");
 147   assert(_max_heap_byte_size >= _initial_heap_byte_size, "Ergonomics decided on incompatible initial and maximum heap sizes");
 148   assert(_min_heap_byte_size % _min_alignment == 0, "min_heap_byte_size alignment");
 149   assert(_initial_heap_byte_size % _min_alignment == 0, "initial_heap_byte_size alignment");
 150   assert(_max_heap_byte_size % _max_alignment == 0, "max_heap_byte_size alignment");






 151 
 152   if (PrintGCDetails && Verbose) {
 153     gclog_or_tty->print_cr("Minimum heap " SIZE_FORMAT "  Initial heap "
 154       SIZE_FORMAT "  Maximum heap " SIZE_FORMAT,
 155       _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size);
 156   }
 157 }
 158 
 159 bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) {
 160   bool result = _should_clear_all_soft_refs;
 161   set_should_clear_all_soft_refs(false);
 162   return result;
 163 }
 164 
 165 GenRemSet* CollectorPolicy::create_rem_set(MemRegion whole_heap,
 166                                            int max_covered_regions) {
 167   switch (rem_set_name()) {
 168   case GenRemSet::CardTable: {
 169     CardTableRS* res = new CardTableRS(whole_heap, max_covered_regions);
 170     return res;


 221 
 222 size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size,
 223                                                  size_t maximum_size) {
 224   size_t alignment = _min_alignment;
 225   size_t max_minus = maximum_size - alignment;
 226   return desired_size < max_minus ? desired_size : max_minus;
 227 }
 228 
 229 
 230 void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size,
 231                                                 size_t init_promo_size,
 232                                                 size_t init_survivor_size) {
 233   const double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
 234   _size_policy = new AdaptiveSizePolicy(init_eden_size,
 235                                         init_promo_size,
 236                                         init_survivor_size,
 237                                         max_gc_pause_sec,
 238                                         GCTimeRatio);
 239 }
 240 
 241 size_t GenCollectorPolicy::compute_max_alignment() {
 242   // The card marking array and the offset arrays for old generations are
 243   // committed in os pages as well. Make sure they are entirely full (to
 244   // avoid partial page problems), e.g. if 512 bytes heap corresponds to 1
 245   // byte entry and the os page size is 4096, the maximum heap size should
 246   // be 512*4096 = 2MB aligned.
 247   size_t alignment = GenRemSet::max_alignment_constraint(rem_set_name());
 248 
 249   // Parallel GC does its own alignment of the generations to avoid requiring a
 250   // large page (256M on some platforms) for the permanent generation.  The
 251   // other collectors should also be updated to do their own alignment and then
 252   // this use of lcm() should be removed.
 253   if (UseLargePages && !UseParallelGC) {
 254       // in presence of large pages we have to make sure that our
 255       // alignment is large page aware
 256       alignment = lcm(os::large_page_size(), alignment);
 257   }
 258 
 259   assert(alignment >= _min_alignment, "Must be");
 260 
 261   return alignment;
 262 }
 263 
 264 void GenCollectorPolicy::initialize_flags() {
 265   // All sizes must be multiples of the generation granularity.
 266   _min_alignment = (uintx) Generation::GenGrain;
 267   _max_alignment = compute_max_alignment();
 268 
 269   CollectorPolicy::initialize_flags();
 270 
 271   // This is the absolute minimum for the young generation. It has to hold two
 272   // survivor areas and the eden. We set it here since it is used repeatedly
 273   // throughout the initialization. However this is not necessarily the final
 274   // value of _min_gen0_size.
 275   _min_gen0_size = 3 * intra_heap_alignment();
 276 
 277   // Make sure the heap is large enough for two generations.
 278   uintx smallestHeapSize = _min_gen0_size + intra_heap_alignment();
 279   if (MaxHeapSize < smallestHeapSize) {
 280     FLAG_SET_ERGO(uintx, MaxHeapSize, align_size_up(smallestHeapSize, _max_alignment));
 281   }
 282 
 283   // All generational heaps have a youngest gen; handle those flags here.
 284 
 285   if (FLAG_IS_CMDLINE(NewSize) && FLAG_IS_CMDLINE(MaxNewSize) && NewSize > MaxNewSize) {
 286     vm_exit_during_initialization("Incompatible initial and maximum young gen sizes specified");

 287   }


 288 
 289   if (!FLAG_IS_DEFAULT(MaxNewSize)) {
 290     uintx minNewSize = MAX2(_min_alignment, _min_gen0_size);
 291 
 292     if (MaxNewSize >= MaxHeapSize) {
 293       uintx smallerMaxNewSize = align_size_down(MaxHeapSize - _min_alignment, _min_alignment);
 294       if (FLAG_IS_CMDLINE(MaxNewSize)) {
 295         warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or greater than the entire "
 296                 "heap (" SIZE_FORMAT "k).  A new max generation size of " SIZE_FORMAT "k will be used.",
 297                 MaxNewSize/K, MaxHeapSize/K, smallerMaxNewSize/K);
 298       }
 299       FLAG_SET_ERGO(uintx, MaxNewSize, smallerMaxNewSize);
 300       if (NewSize > MaxNewSize) {
 301         FLAG_SET_ERGO(uintx, NewSize, MaxNewSize);
 302       }
 303     } else if (MaxNewSize < minNewSize) {
 304       FLAG_SET_ERGO(uintx, MaxNewSize, align_size_up(minNewSize, _min_alignment));
 305     } else if (!is_size_aligned(MaxNewSize, _min_alignment)) {
 306       FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _min_alignment));
 307     }
 308   }
 309 
 310   // Young space must be aligned and have room for eden + two survivors.
 311   // We will silently increase the NewSize even if the user specified a smaller value.
 312   uintx smallestNewSize = MAX2(align_size_up(_min_gen0_size, _min_alignment),
 313                                align_size_down(NewSize, _min_alignment));
 314   if (smallestNewSize != NewSize) {
 315     FLAG_SET_ERGO(uintx, NewSize, smallestNewSize);
 316   }
 317 
 318   if (NewSize > MaxNewSize) {
 319     // At this point this should only happen if the user specifies a large NewSize or
 320     // a small (but not too small) MaxNewSize.
 321     if (FLAG_IS_CMDLINE(NewSize)) {
 322       warning("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). "
 323               "A new generation size of " SIZE_FORMAT "k will be used.",
 324               NewSize/K, MaxNewSize/K, MaxNewSize/K);
 325     }
 326     FLAG_SET_ERGO(uintx, NewSize, MaxNewSize);
 327   }
 328 
 329   assert(InitialHeapSize <= MaxHeapSize, "Ergonomics decided on incompatible initial and maximum heap sizes");
 330   assert(NewSize >= _min_gen0_size, "Ergonomics decided on a too small young gen size");
 331   assert(NewSize <= MaxNewSize, "Ergonomics decided on incompatible initial and maximum young gen sizes");
 332   assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young gen and heap sizes");
 333   assert(InitialHeapSize % _min_alignment == 0, "InitialHeapSize alignment");
 334   assert(MaxHeapSize % _max_alignment == 0, "MaxHeapSize alignment");
 335   assert(NewSize % _min_alignment == 0, "NewSize alignment");
 336   assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize % _min_alignment == 0, "MaxNewSize alignment");
 337 
 338   if (SurvivorRatio < 1 || NewRatio < 1) {
 339     vm_exit_during_initialization("Invalid young gen ratio specified");
 340   }
 341 }
 342 
 343 void TwoGenerationCollectorPolicy::initialize_flags() {
 344   GenCollectorPolicy::initialize_flags();
 345 
 346   if (!is_size_aligned(OldSize, _min_alignment)) {
 347     FLAG_SET_ERGO(uintx, OldSize, align_size_down(OldSize, _min_alignment));
 348   }
 349 
 350   if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(MaxHeapSize)) {
 351     // NewRatio will be used later to set the young generation size so we use
 352     // it to calculate how big the heap should be based on the requested OldSize
 353     // and NewRatio.
 354     assert(NewRatio > 0, "NewRatio should have been set up earlier");
 355     size_t calculated_heapsize = (OldSize / NewRatio) * (NewRatio + 1);
 356 
 357     calculated_heapsize = align_size_up(calculated_heapsize, _max_alignment);
 358     FLAG_SET_ERGO(uintx, MaxHeapSize, calculated_heapsize);
 359     FLAG_SET_ERGO(uintx, InitialHeapSize, calculated_heapsize);
 360   }

 361 
 362   // adjust max heap size if necessary
 363   if (NewSize + OldSize > MaxHeapSize) {
 364     if (_max_heap_size_cmdline) {
 365       // Somebody has set a maximum heap size with the intention that we should not
 366       // exceed it. Adjust New/OldSize as necessary.
 367       uintx calculated_size = NewSize + OldSize;
 368       double shrink_factor = (double) MaxHeapSize / calculated_size;
 369       // align
 370       FLAG_SET_ERGO(uintx, NewSize, MAX2(_min_gen0_size, (uintx)align_size_down((uintx)(NewSize * shrink_factor), _min_alignment)));











 371 









 372       // OldSize is already aligned because above we aligned MaxHeapSize to
 373       // _max_alignment, and we just made sure that NewSize is aligned to
 374       // _min_alignment. In initialize_flags() we verified that _max_alignment
 375       // is a multiple of _min_alignment.
 376       FLAG_SET_ERGO(uintx, OldSize, MaxHeapSize - NewSize);
 377     } else {
 378       FLAG_SET_ERGO(uintx, MaxHeapSize, align_size_up(NewSize + OldSize, _max_alignment));
 379     }
 380   }


 381 
 382   always_do_update_barrier = UseConcMarkSweepGC;
 383 
 384   // Check validity of heap flags
 385   assert(InitialHeapSize <= MaxHeapSize, "Ergonomics decided on incompatible initial and maximum heap sizes");
 386   assert(NewSize >= _min_gen0_size, "Ergonomics decided on a too small young gen size");
 387   assert(NewSize <= MaxNewSize, "Ergonomics decided on incompatible initial and maximum young gen sizes");
 388   assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young gen and heap sizes");
 389   assert(OldSize + NewSize <= MaxHeapSize, "Ergonomics decided on incompatible generation and heap sizes");
 390   assert(InitialHeapSize % _min_alignment == 0, "InitialHeapSize alignment");
 391   assert(MaxHeapSize % _max_alignment == 0, "MaxHeapSize alignment");
 392   assert(NewSize % _min_alignment == 0, "NewSize alignment");
 393   assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize % _min_alignment == 0, "MaxNewSize alignment");
 394   assert(OldSize % _min_alignment == 0, "OldSize alignment");
 395 }
 396 
 397 // Values set on the command line win over any ergonomically
 398 // set command line parameters.
 399 // Ergonomic choice of parameters are done before this
 400 // method is called.  Values for command line parameters such as NewSize
 401 // and MaxNewSize feed those ergonomic choices into this method.
 402 // This method makes the final generation sizings consistent with
 403 // themselves and with overall heap sizings.
 404 // In the absence of explicitly set command line flags, policies
 405 // such as the use of NewRatio are used to size the generation.
 406 void GenCollectorPolicy::initialize_size_info() {
 407   CollectorPolicy::initialize_size_info();
 408 
 409   // _min_alignment is used for alignment within a generation.
 410   // There is additional alignment done down stream for some
 411   // collectors that sometimes causes unwanted rounding up of
 412   // generations sizes.
 413 
 414   // Determine maximum size of gen0
 415 
 416   size_t max_new_size = 0;
 417   if (!FLAG_IS_DEFAULT(MaxNewSize)) {
 418     max_new_size = MaxNewSize;



























 419   } else {
 420     max_new_size = scale_by_NewRatio_aligned(_max_heap_byte_size);
 421     // Bound the maximum size by NewSize below (since it historically
 422     // would have been NewSize and because the NewRatio calculation could
 423     // yield a size that is too small) and bound it by MaxNewSize above.
 424     // Ergonomics plays here by previously calculating the desired
 425     // NewSize and MaxNewSize.
 426     max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize);
 427   }
 428   assert(max_new_size > 0, "All paths should set max_new_size");
 429 
 430   // Given the maximum gen0 size, determine the initial and
 431   // minimum gen0 sizes.
 432 
 433   if (_max_heap_byte_size == _min_heap_byte_size) {
 434     // The maximum and minimum heap sizes are the same so
 435     // the generations minimum and initial must be the
 436     // same as its maximum.
 437     _min_gen0_size = max_new_size;
 438     _initial_gen0_size = max_new_size;


 467     _max_gen0_size = max_new_size;
 468 
 469     // At this point the desirable initial and minimum sizes have been
 470     // determined without regard to the maximum sizes.
 471 
 472     // Bound the sizes by the corresponding overall heap sizes.
 473     _min_gen0_size = bound_minus_alignment(_min_gen0_size, _min_heap_byte_size);
 474     _initial_gen0_size = bound_minus_alignment(_initial_gen0_size, _initial_heap_byte_size);
 475     _max_gen0_size = bound_minus_alignment(_max_gen0_size, _max_heap_byte_size);
 476 
 477     // At this point all three sizes have been checked against the
 478     // maximum sizes but have not been checked for consistency
 479     // among the three.
 480 
 481     // Final check min <= initial <= max
 482     _min_gen0_size = MIN2(_min_gen0_size, _max_gen0_size);
 483     _initial_gen0_size = MAX2(MIN2(_initial_gen0_size, _max_gen0_size), _min_gen0_size);
 484     _min_gen0_size = MIN2(_min_gen0_size, _initial_gen0_size);
 485   }
 486 
 487   // Write back to flag if necessary
 488   if (MaxNewSize != _min_gen0_size) {
 489     FLAG_SET_ERGO(uintx, MaxNewSize, _max_gen0_size);
 490   }
 491   assert(MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young and heap sizes");
 492   assert(_max_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible minimum and maximum heap sizes");
 493   assert(_initial_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible initial and minimum heap sizes");
 494   assert(_max_heap_byte_size >= _initial_heap_byte_size, "Ergonomics decided on incompatible initial and maximum heap sizes");
 495   assert(_min_gen0_size <= _initial_gen0_size, "Ergonomics decided on incompatible minimum and initial young gen sizes");
 496   assert(_initial_gen0_size <= _max_gen0_size, "Ergonomics decided on incompatible initial and maximum young gen sizes");
 497   assert(_min_heap_byte_size % _min_alignment == 0, "min_heap_byte_size alignment");
 498   assert(_initial_heap_byte_size % _min_alignment == 0, "initial_heap_byte_size alignment");
 499   assert(_max_heap_byte_size % _max_alignment == 0, "max_heap_byte_size alignment");
 500   assert(_min_gen0_size % _min_alignment == 0, "_min_gen0_size alignment");
 501   assert(_initial_gen0_size % _min_alignment == 0, "_initial_gen0_size alignment");
 502   assert(_max_gen0_size % _min_alignment == 0, "_max_gen0_size alignment");
 503 
 504   if (PrintGCDetails && Verbose) {
 505     gclog_or_tty->print_cr("1: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
 506       SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
 507       _min_gen0_size, _initial_gen0_size, _max_gen0_size);
 508   }
 509 }
 510 
 511 // Call this method during the sizing of the gen1 to make
 512 // adjustments to gen0 because of gen1 sizing policy.  gen0 initially has
 513 // the most freedom in sizing because it is done before the
 514 // policy for gen1 is applied.  Once gen1 policies have been applied,
 515 // there may be conflicts in the shape of the heap and this method
 516 // is used to make the needed adjustments.  The application of the
 517 // policies could be more sophisticated (iterative for example) but
 518 // keeping it simple also seems a worthwhile goal.
 519 bool TwoGenerationCollectorPolicy::adjust_gen0_sizes(size_t* gen0_size_ptr,
 520                                                      size_t* gen1_size_ptr,
 521                                                      const size_t heap_size,
 522                                                      const size_t min_gen1_size) {
 523   bool result = false;


 538     }
 539   }
 540   return result;
 541 }
 542 
 543 // Minimum sizes of the generations may be different than
 544 // the initial sizes.  An inconsistency is permitted here
 545 // in the total size that can be specified explicitly by
 546 // command line specification of OldSize and NewSize and
 547 // also a command line specification of -Xms.  Issue a warning
 548 // but allow the values to pass.
 549 
 550 void TwoGenerationCollectorPolicy::initialize_size_info() {
 551   GenCollectorPolicy::initialize_size_info();
 552 
 553   // At this point the minimum, initial and maximum sizes
 554   // of the overall heap and of gen0 have been determined.
 555   // The maximum gen1 size can be determined from the maximum gen0
 556   // and maximum heap size since no explicit flags exist
 557   // for setting the gen1 maximum.
 558   _max_gen1_size = MAX2(_max_heap_byte_size - _max_gen0_size, _min_alignment);


 559 
 560   // If no explicit command line flag has been set for the
 561   // gen1 size, use what is left for gen1.
 562   if (!FLAG_IS_CMDLINE(OldSize)) {
 563     // The user has not specified any value but the ergonomics
 564     // may have chosen a value (which may or may not be consistent
 565     // with the overall heap size).  In either case make
 566     // the minimum, maximum and initial sizes consistent
 567     // with the gen0 sizes and the overall heap sizes.
 568     _min_gen1_size = MAX2(_min_heap_byte_size - _min_gen0_size, _min_alignment);
 569     _initial_gen1_size = MAX2(_initial_heap_byte_size - _initial_gen0_size, _min_alignment);
 570     // _max_gen1_size has already been made consistent above
 571     FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size);




 572   } else {
 573     // OldSize has been explicitly set on the command line. Use the
 574     // OldSize and then determine the consequences.
 575     _min_gen1_size = MIN2(OldSize, _min_heap_byte_size - _min_gen0_size);
 576     _initial_gen1_size = OldSize;
 577 
 578     // If the user has explicitly set an OldSize that is inconsistent
 579     // with other command line flags, issue a warning.
 580     // The generation minimums and the overall heap minimum should
 581     // be within one heap alignment.
 582     if ((_min_gen1_size + _min_gen0_size + _min_alignment) < _min_heap_byte_size) {
 583       warning("Inconsistency between minimum heap size and minimum "
 584               "generation sizes: using minimum heap = " SIZE_FORMAT,
 585               _min_heap_byte_size);
 586     }
 587     if (OldSize > _max_gen1_size) {
 588       warning("Inconsistency between maximum heap size and maximum "
 589               "generation sizes: using maximum heap = " SIZE_FORMAT
 590               " -XX:OldSize flag is being ignored",
 591               _max_heap_byte_size);
 592     }
 593     // If there is an inconsistency between the OldSize and the minimum and/or
 594     // initial size of gen0, since OldSize was explicitly set, OldSize wins.
 595     if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size,
 596                           _min_heap_byte_size, _min_gen1_size)) {
 597       if (PrintGCDetails && Verbose) {
 598         gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
 599               SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
 600               _min_gen0_size, _initial_gen0_size, _max_gen0_size);
 601       }
 602     }
 603     // The same as above for the old gen initial size
 604     if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size,
 605                           _initial_heap_byte_size, _initial_gen1_size)) {
 606       if (PrintGCDetails && Verbose) {
 607         gclog_or_tty->print_cr("3: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
 608           SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
 609           _min_gen0_size, _initial_gen0_size, _max_gen0_size);
 610       }
 611     }
 612     // update OldSize
 613     FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size);
 614   }
 615 
 616   _min_gen1_size = MIN2(_min_gen1_size, _max_gen1_size);
 617 
 618   // Make sure that min gen1 <= initial gen1 <= max gen1
 619   _initial_gen1_size = MAX2(_initial_gen1_size, _min_gen1_size);
 620   _initial_gen1_size = MIN2(_initial_gen1_size, _max_gen1_size);
 621 
 622   // check
 623   assert(_max_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible minimum and maximum heap sizes");
 624   assert(_initial_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible initial and minimum heap sizes");
 625   assert(_max_heap_byte_size >= _initial_heap_byte_size, "Ergonomics decided on incompatible initial and maximum heap sizes");
 626   assert(_min_gen0_size <= _initial_gen0_size, "Ergonomics decided on incompatible minimum and initial young gen sizes");
 627   assert(_initial_gen0_size <= _max_gen0_size, "Ergonomics decided on incompatible initial and maximum young gen sizes");
 628   assert(_min_gen1_size <= _initial_gen1_size, "Ergonomics decided on incompatible minimum and initial old gen sizes");
 629   assert(_initial_gen1_size <= _max_gen1_size, "Ergonomics decided on incompatible initial and maximum old gen sizes");
 630   assert(_min_heap_byte_size % _min_alignment == 0, "min_heap_byte_size alignment");
 631   assert(_initial_heap_byte_size % _min_alignment == 0, "initial_heap_byte_size alignment");
 632   assert(_max_heap_byte_size % _max_alignment == 0, "max_heap_byte_size alignment");
 633   assert(_min_gen0_size % _min_alignment == 0, "_min_gen0_size alignment");
 634   assert(_initial_gen0_size % _min_alignment == 0, "_initial_gen0_size alignment");
 635   assert(_max_gen0_size % _min_alignment == 0, "_max_gen0_size alignment");
 636   assert(_max_gen1_size % _min_alignment == 0, "_max_gen1_size alignment");
 637 
 638   assert(_max_heap_byte_size <= (_max_gen0_size + _max_gen1_size), "Total maximum heap sizes must be sum of generation maximum sizes");
 639 
 640   if (PrintGCDetails && Verbose) {
 641     gclog_or_tty->print_cr("Minimum gen1 " SIZE_FORMAT "  Initial gen1 "
 642       SIZE_FORMAT "  Maximum gen1 " SIZE_FORMAT,
 643       _min_gen1_size, _initial_gen1_size, _max_gen1_size);
 644   }
 645 }
 646 
 647 HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size,
 648                                         bool is_tlab,
 649                                         bool* gc_overhead_limit_was_exceeded) {
 650   GenCollectedHeap *gch = GenCollectedHeap::heap();
 651 
 652   debug_only(gch->check_for_valid_allocation_state());
 653   assert(gch->no_gc_in_progress(), "Allocation during gc not allowed");
 654 
 655   // In general gc_overhead_limit_was_exceeded should be false so
 656   // set it so here and reset it to true only if the gc time
 657   // limit is being exceeded as checked below.
 658   *gc_overhead_limit_was_exceeded = false;
 659 


src/share/vm/memory/collectorPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File