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

src/share/vm/memory/collectorPolicy.cpp

Print this page

        

*** 50,70 **** // Align down. If the aligning result in 0, return 'alignment'. static size_t restricted_align_down(size_t size, size_t alignment) { return MAX2(alignment, align_size_down_(size, alignment)); } void CollectorPolicy::initialize_flags() { assert(_max_alignment >= _min_alignment, err_msg("max_alignment: " SIZE_FORMAT " less than min_alignment: " SIZE_FORMAT, _max_alignment, _min_alignment)); assert(_max_alignment % _min_alignment == 0, err_msg("max_alignment: " SIZE_FORMAT " not aligned by min_alignment: " SIZE_FORMAT, _max_alignment, _min_alignment)); ! if (MaxHeapSize < InitialHeapSize) { vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified"); } if (!is_size_aligned(MaxMetaspaceSize, _max_alignment)) { FLAG_SET_ERGO(uintx, MaxMetaspaceSize, restricted_align_down(MaxMetaspaceSize, _max_alignment)); } --- 50,117 ---- // Align down. If the aligning result in 0, return 'alignment'. static size_t restricted_align_down(size_t size, size_t alignment) { return MAX2(alignment, align_size_down_(size, alignment)); } + void CollectorPolicy::assert_flags() { + assert(InitialHeapSize <= MaxHeapSize, "Ergonomics decided on incompatible initial and maximum heap sizes"); + assert(InitialHeapSize % _min_alignment == 0, "InitialHeapSize alignment"); + assert(MaxHeapSize % _max_alignment == 0, "MaxHeapSize alignment"); + } + + void CollectorPolicy::assert_size_info() { + assert(_max_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible minimum and maximum heap sizes"); + assert(_initial_heap_byte_size >= _min_heap_byte_size, "Ergonomics decided on incompatible initial and minimum heap sizes"); + assert(_max_heap_byte_size >= _initial_heap_byte_size, "Ergonomics decided on incompatible initial and maximum heap sizes"); + assert(_min_heap_byte_size % _min_alignment == 0, "min_heap_byte_size alignment"); + assert(_initial_heap_byte_size % _min_alignment == 0, "initial_heap_byte_size alignment"); + assert(_max_heap_byte_size % _max_alignment == 0, "max_heap_byte_size alignment"); + } + void CollectorPolicy::initialize_flags() { assert(_max_alignment >= _min_alignment, err_msg("max_alignment: " SIZE_FORMAT " less than min_alignment: " SIZE_FORMAT, _max_alignment, _min_alignment)); assert(_max_alignment % _min_alignment == 0, err_msg("max_alignment: " SIZE_FORMAT " not aligned by min_alignment: " SIZE_FORMAT, _max_alignment, _min_alignment)); ! if (FLAG_IS_CMDLINE(MaxHeapSize)) { ! if (FLAG_IS_CMDLINE(InitialHeapSize) && InitialHeapSize > MaxHeapSize) { vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified"); } + if (Arguments::min_heap_size() != 0 && MaxHeapSize < Arguments::min_heap_size()) { + vm_exit_during_initialization("Incompatible minimum and maximum heap sizes specified"); + } + _max_heap_size_cmdline = true; + } + + if (FLAG_IS_CMDLINE(InitialHeapSize) && Arguments::min_heap_size() != 0 && + InitialHeapSize < Arguments::min_heap_size()) { + vm_exit_during_initialization("Incompatible minimum and initial heap sizes specified"); + } + if (!FLAG_IS_DEFAULT(InitialHeapSize) && InitialHeapSize > MaxHeapSize) { + FLAG_SET_ERGO(uintx, MaxHeapSize, InitialHeapSize); + } else if (!FLAG_IS_DEFAULT(MaxHeapSize) && InitialHeapSize > MaxHeapSize) { + FLAG_SET_ERGO(uintx, InitialHeapSize, MaxHeapSize); + if (InitialHeapSize < Arguments::min_heap_size()) { + Arguments::set_min_heap_size(InitialHeapSize); + } + } + + // User inputs from -Xmx and -Xms must be aligned + Arguments::set_min_heap_size(align_size_up(Arguments::min_heap_size(), _min_alignment)); + uintx alignedInitialHeapSize = align_size_up(InitialHeapSize, _min_alignment); + uintx alignedMaxHeapSize = align_size_up(MaxHeapSize, _max_alignment); + + // Write back to flags if the values changed + if (alignedInitialHeapSize != InitialHeapSize) { + FLAG_SET_ERGO(uintx, InitialHeapSize, alignedInitialHeapSize); + } + if (alignedMaxHeapSize != MaxHeapSize) { + FLAG_SET_ERGO(uintx, MaxHeapSize, alignedMaxHeapSize); + } if (!is_size_aligned(MaxMetaspaceSize, _max_alignment)) { FLAG_SET_ERGO(uintx, MaxMetaspaceSize, restricted_align_down(MaxMetaspaceSize, _max_alignment)); }
*** 88,132 **** assert(MetaspaceSize % _min_alignment == 0, "metapace alignment"); assert(MaxMetaspaceSize % _max_alignment == 0, "maximum metaspace alignment"); if (MetaspaceSize < 256*K) { vm_exit_during_initialization("Too small initial Metaspace size"); } } void CollectorPolicy::initialize_size_info() { ! // User inputs from -mx and ms must be aligned ! _min_heap_byte_size = align_size_up(Arguments::min_heap_size(), _min_alignment); ! _initial_heap_byte_size = align_size_up(InitialHeapSize, _min_alignment); ! _max_heap_byte_size = align_size_up(MaxHeapSize, _max_alignment); // Check heap parameter properties if (_initial_heap_byte_size < M) { vm_exit_during_initialization("Too small initial heap"); } // Check heap parameter properties if (_min_heap_byte_size < M) { vm_exit_during_initialization("Too small minimum heap"); } - if (_initial_heap_byte_size <= NewSize) { - // make sure there is at least some room in old space - vm_exit_during_initialization("Too small initial heap for new size specified"); - } - if (_max_heap_byte_size < _min_heap_byte_size) { - vm_exit_during_initialization("Incompatible minimum and maximum heap sizes specified"); - } - if (_initial_heap_byte_size < _min_heap_byte_size) { - vm_exit_during_initialization("Incompatible minimum and initial heap sizes specified"); - } - if (_max_heap_byte_size < _initial_heap_byte_size) { - vm_exit_during_initialization("Incompatible initial and maximum heap sizes specified"); - } if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("Minimum heap " SIZE_FORMAT " Initial heap " SIZE_FORMAT " Maximum heap " SIZE_FORMAT, _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size); } } bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) { bool result = _should_clear_all_soft_refs; set_should_clear_all_soft_refs(false); --- 135,169 ---- assert(MetaspaceSize % _min_alignment == 0, "metapace alignment"); assert(MaxMetaspaceSize % _max_alignment == 0, "maximum metaspace alignment"); if (MetaspaceSize < 256*K) { vm_exit_during_initialization("Too small initial Metaspace size"); } + + CollectorPolicy::assert_flags(); } void CollectorPolicy::initialize_size_info() { ! _min_heap_byte_size = Arguments::min_heap_size(); ! _initial_heap_byte_size = InitialHeapSize; ! _max_heap_byte_size = MaxHeapSize; // Check heap parameter properties if (_initial_heap_byte_size < M) { vm_exit_during_initialization("Too small initial heap"); } // Check heap parameter properties if (_min_heap_byte_size < M) { vm_exit_during_initialization("Too small minimum heap"); } if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("Minimum heap " SIZE_FORMAT " Initial heap " SIZE_FORMAT " Maximum heap " SIZE_FORMAT, _min_heap_byte_size, _initial_heap_byte_size, _max_heap_byte_size); } + + CollectorPolicy::assert_size_info(); } bool CollectorPolicy::use_should_clear_all_soft_refs(bool v) { bool result = _should_clear_all_soft_refs; set_should_clear_all_soft_refs(false);
*** 175,189 **** } // GenCollectorPolicy methods. size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) { ! size_t x = base_size / (NewRatio+1); ! size_t new_gen_size = x > _min_alignment ? ! align_size_down(x, _min_alignment) : ! _min_alignment; ! return new_gen_size; } size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size, size_t maximum_size) { size_t alignment = _min_alignment; --- 212,222 ---- } // GenCollectorPolicy methods. size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) { ! return restricted_align_down(base_size / (NewRatio + 1), _min_alignment); } size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size, size_t maximum_size) { size_t alignment = _min_alignment;
*** 201,304 **** init_survivor_size, max_gc_pause_sec, GCTimeRatio); } void GenCollectorPolicy::initialize_flags() { // All sizes must be multiples of the generation granularity. _min_alignment = (uintx) Generation::GenGrain; _max_alignment = compute_max_alignment(); CollectorPolicy::initialize_flags(); // All generational heaps have a youngest gen; handle those flags here. ! // Adjust max size parameters if (NewSize > MaxNewSize) { ! MaxNewSize = NewSize; } - NewSize = align_size_down(NewSize, _min_alignment); - MaxNewSize = align_size_down(MaxNewSize, _min_alignment); ! // Check validity of heap flags ! assert(NewSize % _min_alignment == 0, "eden space alignment"); ! assert(MaxNewSize % _min_alignment == 0, "survivor space alignment"); ! ! if (NewSize < 3 * _min_alignment) { ! // make sure there room for eden and two survivor spaces ! vm_exit_during_initialization("Too small new size specified"); } if (SurvivorRatio < 1 || NewRatio < 1) { vm_exit_during_initialization("Invalid young gen ratio specified"); } } void TwoGenerationCollectorPolicy::initialize_flags() { GenCollectorPolicy::initialize_flags(); ! OldSize = align_size_down(OldSize, _min_alignment); ! if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(NewSize)) { // NewRatio will be used later to set the young generation size so we use // it to calculate how big the heap should be based on the requested OldSize // and NewRatio. assert(NewRatio > 0, "NewRatio should have been set up earlier"); size_t calculated_heapsize = (OldSize / NewRatio) * (NewRatio + 1); calculated_heapsize = align_size_up(calculated_heapsize, _max_alignment); ! MaxHeapSize = calculated_heapsize; ! InitialHeapSize = calculated_heapsize; } - MaxHeapSize = align_size_up(MaxHeapSize, _max_alignment); // adjust max heap size if necessary if (NewSize + OldSize > MaxHeapSize) { ! if (FLAG_IS_CMDLINE(MaxHeapSize)) { ! // somebody set a maximum heap size with the intention that we should not // exceed it. Adjust New/OldSize as necessary. uintx calculated_size = NewSize + OldSize; double shrink_factor = (double) MaxHeapSize / calculated_size; // align ! NewSize = align_size_down((uintx) (NewSize * shrink_factor), _min_alignment); ! // OldSize is already aligned because above we aligned MaxHeapSize to ! // _max_alignment, and we just made sure that NewSize is aligned to ! // _min_alignment. In initialize_flags() we verified that _max_alignment ! // is a multiple of _min_alignment. ! OldSize = MaxHeapSize - NewSize; ! } else { ! MaxHeapSize = NewSize + OldSize; ! } ! } ! // need to do this again ! MaxHeapSize = align_size_up(MaxHeapSize, _max_alignment); - // adjust max heap size if necessary - if (NewSize + OldSize > MaxHeapSize) { - if (FLAG_IS_CMDLINE(MaxHeapSize)) { - // somebody set a maximum heap size with the intention that we should not - // exceed it. Adjust New/OldSize as necessary. - uintx calculated_size = NewSize + OldSize; - double shrink_factor = (double) MaxHeapSize / calculated_size; - // align - NewSize = align_size_down((uintx) (NewSize * shrink_factor), _min_alignment); // OldSize is already aligned because above we aligned MaxHeapSize to // _max_alignment, and we just made sure that NewSize is aligned to // _min_alignment. In initialize_flags() we verified that _max_alignment // is a multiple of _min_alignment. ! OldSize = MaxHeapSize - NewSize; } else { ! MaxHeapSize = NewSize + OldSize; } } - // need to do this again - MaxHeapSize = align_size_up(MaxHeapSize, _max_alignment); always_do_update_barrier = UseConcMarkSweepGC; ! ! // Check validity of heap flags ! assert(OldSize % _min_alignment == 0, "old space alignment"); ! assert(MaxHeapSize % _max_alignment == 0, "maximum heap alignment"); } // Values set on the command line win over any ergonomically // set command line parameters. // Ergonomic choice of parameters are done before this --- 234,414 ---- init_survivor_size, max_gc_pause_sec, GCTimeRatio); } + size_t GenCollectorPolicy::compute_max_alignment() { + // The card marking array and the offset arrays for old generations are + // committed in os pages as well. Make sure they are entirely full (to + // avoid partial page problems), e.g. if 512 bytes heap corresponds to 1 + // byte entry and the os page size is 4096, the maximum heap size should + // be 512*4096 = 2MB aligned. + size_t alignment = GenRemSet::max_alignment_constraint(rem_set_name()); + + // Parallel GC does its own alignment of the generations to avoid requiring a + // large page (256M on some platforms) for the permanent generation. The + // other collectors should also be updated to do their own alignment and then + // this use of lcm() should be removed. + if (UseLargePages && !UseParallelGC) { + // in presence of large pages we have to make sure that our + // alignment is large page aware + alignment = lcm(os::large_page_size(), alignment); + } + + assert(alignment >= _min_alignment, "Must be"); + + return alignment; + } + + void GenCollectorPolicy::assert_flags() { + CollectorPolicy::assert_flags(); + assert(NewSize >= _min_gen0_size, "Ergonomics decided on a too small young gen size"); + assert(NewSize <= MaxNewSize, "Ergonomics decided on incompatible initial and maximum young gen sizes"); + assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young gen and heap sizes"); + assert(NewSize % _min_alignment == 0, "NewSize alignment"); + assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize % _min_alignment == 0, "MaxNewSize alignment"); + } + + void TwoGenerationCollectorPolicy::assert_flags() { + GenCollectorPolicy::assert_flags(); + assert(OldSize + NewSize <= MaxHeapSize, "Ergonomics decided on incompatible generation and heap sizes"); + assert(OldSize % _min_alignment == 0, "OldSize alignment"); + } + + void GenCollectorPolicy::assert_size_info() { + CollectorPolicy::assert_size_info(); + // GenCollectorPolicy::initialize_size_info may update the MaxNewSize + assert(MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young and heap sizes"); + assert(_min_gen0_size <= _initial_gen0_size, "Ergonomics decided on incompatible minimum and initial young gen sizes"); + assert(_initial_gen0_size <= _max_gen0_size, "Ergonomics decided on incompatible initial and maximum young gen sizes"); + assert(_min_gen0_size % _min_alignment == 0, "_min_gen0_size alignment"); + assert(_initial_gen0_size % _min_alignment == 0, "_initial_gen0_size alignment"); + assert(_max_gen0_size % _min_alignment == 0, "_max_gen0_size alignment"); + } + + void TwoGenerationCollectorPolicy::assert_size_info() { + GenCollectorPolicy::assert_size_info(); + assert(_min_gen1_size <= _initial_gen1_size, "Ergonomics decided on incompatible minimum and initial old gen sizes"); + assert(_initial_gen1_size <= _max_gen1_size, "Ergonomics decided on incompatible initial and maximum old gen sizes"); + assert(_max_gen1_size % _min_alignment == 0, "_max_gen1_size alignment"); + assert(_initial_gen1_size % _min_alignment == 0, "_initial_gen1_size alignment"); + assert(_max_heap_byte_size <= (_max_gen0_size + _max_gen1_size), "Total maximum heap sizes must be sum of generation maximum sizes"); + } + void GenCollectorPolicy::initialize_flags() { // All sizes must be multiples of the generation granularity. _min_alignment = (uintx) Generation::GenGrain; _max_alignment = compute_max_alignment(); CollectorPolicy::initialize_flags(); + // This is the absolute minimum for the young generation. It has to hold two + // survivor areas and the eden. We set it here since it is used repeatedly + // throughout the initialization. However this is not necessarily the final + // value of _min_gen0_size. + _min_gen0_size = 3 * intra_heap_alignment(); + + // Make sure the heap is large enough for two generations. + uintx smallestHeapSize = _min_gen0_size + intra_heap_alignment(); + if (MaxHeapSize < smallestHeapSize) { + FLAG_SET_ERGO(uintx, MaxHeapSize, align_size_up(smallestHeapSize, _max_alignment)); + } + // All generational heaps have a youngest gen; handle those flags here. ! if (FLAG_IS_CMDLINE(NewSize) && FLAG_IS_CMDLINE(MaxNewSize) && NewSize > MaxNewSize) { ! vm_exit_during_initialization("Incompatible initial and maximum young gen sizes specified"); ! } ! ! if (!FLAG_IS_DEFAULT(MaxNewSize)) { ! uintx minNewSize = MAX2(_min_alignment, _min_gen0_size); ! ! if (MaxNewSize >= MaxHeapSize) { ! uintx smallerMaxNewSize = MaxHeapSize - _min_alignment; ! if (FLAG_IS_CMDLINE(MaxNewSize)) { ! warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or greater than the entire " ! "heap (" SIZE_FORMAT "k). A new max generation size of " SIZE_FORMAT "k will be used.", ! MaxNewSize/K, MaxHeapSize/K, smallerMaxNewSize/K); ! } ! FLAG_SET_ERGO(uintx, MaxNewSize, smallerMaxNewSize); if (NewSize > MaxNewSize) { ! FLAG_SET_ERGO(uintx, NewSize, MaxNewSize); ! } ! } else if (MaxNewSize < minNewSize) { ! FLAG_SET_ERGO(uintx, MaxNewSize, minNewSize); ! } else if (!is_size_aligned(MaxNewSize, _min_alignment)) { ! FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _min_alignment)); ! } } ! // Young space must be aligned and have room for eden + two survivors. ! // We will silently increase the NewSize even if the user specified a smaller value. ! uintx smallestNewSize = MAX2(align_size_up(_min_gen0_size, _min_alignment), ! align_size_down(NewSize, _min_alignment)); ! if (smallestNewSize != NewSize) { ! FLAG_SET_ERGO(uintx, NewSize, smallestNewSize); ! } ! ! if (NewSize > MaxNewSize) { ! // At this point this should only happen if the user specifies a large NewSize or ! // a small (but not too small) MaxNewSize. ! if (FLAG_IS_CMDLINE(NewSize)) { ! warning("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). " ! "A new generation size of " SIZE_FORMAT "k will be used.", ! NewSize/K, MaxNewSize/K, MaxNewSize/K); } + FLAG_SET_ERGO(uintx, NewSize, MaxNewSize); + } + if (SurvivorRatio < 1 || NewRatio < 1) { vm_exit_during_initialization("Invalid young gen ratio specified"); } + + GenCollectorPolicy::assert_flags(); } void TwoGenerationCollectorPolicy::initialize_flags() { GenCollectorPolicy::initialize_flags(); ! if (!is_size_aligned(OldSize, _min_alignment)) { ! FLAG_SET_ERGO(uintx, OldSize, align_size_down(OldSize, _min_alignment)); ! } ! if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(MaxHeapSize)) { // NewRatio will be used later to set the young generation size so we use // it to calculate how big the heap should be based on the requested OldSize // and NewRatio. assert(NewRatio > 0, "NewRatio should have been set up earlier"); size_t calculated_heapsize = (OldSize / NewRatio) * (NewRatio + 1); calculated_heapsize = align_size_up(calculated_heapsize, _max_alignment); ! FLAG_SET_ERGO(uintx, MaxHeapSize, calculated_heapsize); ! FLAG_SET_ERGO(uintx, InitialHeapSize, calculated_heapsize); } // adjust max heap size if necessary if (NewSize + OldSize > MaxHeapSize) { ! if (_max_heap_size_cmdline) { ! // Somebody has set a maximum heap size with the intention that we should not // exceed it. Adjust New/OldSize as necessary. uintx calculated_size = NewSize + OldSize; double shrink_factor = (double) MaxHeapSize / calculated_size; // align ! FLAG_SET_ERGO(uintx, NewSize, MAX2(_min_gen0_size, (uintx)align_size_down((uintx)(NewSize * shrink_factor), _min_alignment))); // OldSize is already aligned because above we aligned MaxHeapSize to // _max_alignment, and we just made sure that NewSize is aligned to // _min_alignment. In initialize_flags() we verified that _max_alignment // is a multiple of _min_alignment. ! FLAG_SET_ERGO(uintx, OldSize, MaxHeapSize - NewSize); } else { ! FLAG_SET_ERGO(uintx, MaxHeapSize, align_size_up(NewSize + OldSize, _max_alignment)); } } always_do_update_barrier = UseConcMarkSweepGC; ! TwoGenerationCollectorPolicy::assert_flags(); } // Values set on the command line win over any ergonomically // set command line parameters. // Ergonomic choice of parameters are done before this
*** 317,355 **** // generations sizes. // Determine maximum size of gen0 size_t max_new_size = 0; ! if (FLAG_IS_CMDLINE(MaxNewSize) || FLAG_IS_ERGO(MaxNewSize)) { ! if (MaxNewSize < _min_alignment) { ! max_new_size = _min_alignment; ! } ! if (MaxNewSize >= _max_heap_byte_size) { ! max_new_size = align_size_down(_max_heap_byte_size - _min_alignment, ! _min_alignment); ! warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or " ! "greater than the entire heap (" SIZE_FORMAT "k). A " ! "new generation size of " SIZE_FORMAT "k will be used.", ! MaxNewSize/K, _max_heap_byte_size/K, max_new_size/K); ! } else { ! max_new_size = align_size_down(MaxNewSize, _min_alignment); ! } ! ! // The case for FLAG_IS_ERGO(MaxNewSize) could be treated ! // specially at this point to just use an ergonomically set ! // MaxNewSize to set max_new_size. For cases with small ! // heaps such a policy often did not work because the MaxNewSize ! // was larger than the entire heap. The interpretation given ! // to ergonomically set flags is that the flags are set ! // by different collectors for their own special needs but ! // are not allowed to badly shape the heap. This allows the ! // different collectors to decide what's best for themselves ! // without having to factor in the overall heap shape. It ! // can be the case in the future that the collectors would ! // only make "wise" ergonomics choices and this policy could ! // just accept those choices. The choices currently made are ! // not always "wise". } else { max_new_size = scale_by_NewRatio_aligned(_max_heap_byte_size); // Bound the maximum size by NewSize below (since it historically // would have been NewSize and because the NewRatio calculation could // yield a size that is too small) and bound it by MaxNewSize above. --- 427,438 ---- // generations sizes. // Determine maximum size of gen0 size_t max_new_size = 0; ! if (!FLAG_IS_DEFAULT(MaxNewSize)) { ! max_new_size = MaxNewSize; } else { max_new_size = scale_by_NewRatio_aligned(_max_heap_byte_size); // Bound the maximum size by NewSize below (since it historically // would have been NewSize and because the NewRatio calculation could // yield a size that is too small) and bound it by MaxNewSize above.
*** 414,428 **** --- 497,518 ---- _min_gen0_size = MIN2(_min_gen0_size, _max_gen0_size); _initial_gen0_size = MAX2(MIN2(_initial_gen0_size, _max_gen0_size), _min_gen0_size); _min_gen0_size = MIN2(_min_gen0_size, _initial_gen0_size); } + // Write back to flag if necessary + if (MaxNewSize != _min_gen0_size) { + FLAG_SET_ERGO(uintx, MaxNewSize, _max_gen0_size); + } + if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("1: Minimum gen0 " SIZE_FORMAT " Initial gen0 " SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, _min_gen0_size, _initial_gen0_size, _max_gen0_size); } + + GenCollectorPolicy::assert_size_info(); } // Call this method during the sizing of the gen1 to make // adjustments to gen0 because of gen1 sizing policy. gen0 initially has // the most freedom in sizing because it is done before the
*** 439,457 **** if ((*gen1_size_ptr + *gen0_size_ptr) > heap_size) { if ((heap_size < (*gen0_size_ptr + min_gen1_size)) && (heap_size >= min_gen1_size + _min_alignment)) { // Adjust gen0 down to accommodate min_gen1_size ! *gen0_size_ptr = heap_size - min_gen1_size; ! *gen0_size_ptr = ! MAX2((uintx)align_size_down(*gen0_size_ptr, _min_alignment), _min_alignment); assert(*gen0_size_ptr > 0, "Min gen0 is too large"); result = true; } else { ! *gen1_size_ptr = heap_size - *gen0_size_ptr; ! *gen1_size_ptr = ! MAX2((uintx)align_size_down(*gen1_size_ptr, _min_alignment), _min_alignment); } } return result; } --- 529,543 ---- if ((*gen1_size_ptr + *gen0_size_ptr) > heap_size) { if ((heap_size < (*gen0_size_ptr + min_gen1_size)) && (heap_size >= min_gen1_size + _min_alignment)) { // Adjust gen0 down to accommodate min_gen1_size ! *gen0_size_ptr = restricted_align_down(heap_size - min_gen1_size, _min_alignment); assert(*gen0_size_ptr > 0, "Min gen0 is too large"); result = true; } else { ! *gen1_size_ptr = restricted_align_down(heap_size - *gen0_size_ptr, _min_alignment); } } return result; }
*** 468,500 **** // At this point the minimum, initial and maximum sizes // of the overall heap and of gen0 have been determined. // The maximum gen1 size can be determined from the maximum gen0 // and maximum heap size since no explicit flags exist // for setting the gen1 maximum. ! _max_gen1_size = _max_heap_byte_size - _max_gen0_size; ! _max_gen1_size = ! MAX2((uintx)align_size_down(_max_gen1_size, _min_alignment), _min_alignment); // If no explicit command line flag has been set for the // gen1 size, use what is left for gen1. ! if (FLAG_IS_DEFAULT(OldSize) || FLAG_IS_ERGO(OldSize)) { ! // The user has not specified any value or ergonomics ! // has chosen a value (which may or may not be consistent // with the overall heap size). In either case make // the minimum, maximum and initial sizes consistent // with the gen0 sizes and the overall heap sizes. ! assert(_min_heap_byte_size > _min_gen0_size, ! "gen0 has an unexpected minimum size"); ! _min_gen1_size = _min_heap_byte_size - _min_gen0_size; ! _min_gen1_size = MAX2((uintx)align_size_down(_min_gen1_size, _min_alignment), ! _min_alignment); ! _initial_gen1_size = _initial_heap_byte_size - _initial_gen0_size; ! _initial_gen1_size = MAX2((uintx)align_size_down(_initial_gen1_size, _min_alignment), ! _min_alignment); } else { // OldSize has been explicitly set on the command line. Use the // OldSize and then determine the consequences. ! _min_gen1_size = OldSize; _initial_gen1_size = OldSize; // If the user has explicitly set an OldSize that is inconsistent // with other command line flags, issue a warning. // The generation minimums and the overall heap minimum should --- 554,581 ---- // At this point the minimum, initial and maximum sizes // of the overall heap and of gen0 have been determined. // The maximum gen1 size can be determined from the maximum gen0 // and maximum heap size since no explicit flags exist // for setting the gen1 maximum. ! _max_gen1_size = MAX2(_max_heap_byte_size - _max_gen0_size, _min_alignment); ! // If no explicit command line flag has been set for the // gen1 size, use what is left for gen1. ! if (!FLAG_IS_CMDLINE(OldSize)) { ! // The user has not specified any value but the ergonomics ! // may have chosen a value (which may or may not be consistent // with the overall heap size). In either case make // the minimum, maximum and initial sizes consistent // with the gen0 sizes and the overall heap sizes. ! _min_gen1_size = MAX2(_min_heap_byte_size - _min_gen0_size, _min_alignment); ! _initial_gen1_size = MAX2(_initial_heap_byte_size - _initial_gen0_size, _min_alignment); ! // _max_gen1_size has already been made consistent above ! FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size); } else { // OldSize has been explicitly set on the command line. Use the // OldSize and then determine the consequences. ! _min_gen1_size = MIN2(OldSize, _min_heap_byte_size - _min_gen0_size); _initial_gen1_size = OldSize; // If the user has explicitly set an OldSize that is inconsistent // with other command line flags, issue a warning. // The generation minimums and the overall heap minimum should
*** 511,536 **** _max_heap_byte_size); } // If there is an inconsistency between the OldSize and the minimum and/or // initial size of gen0, since OldSize was explicitly set, OldSize wins. if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size, ! _min_heap_byte_size, OldSize)) { if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT " Initial gen0 " SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, _min_gen0_size, _initial_gen0_size, _max_gen0_size); } } // The same as above for the old gen initial size if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size, ! _initial_heap_byte_size, OldSize)) { if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("3: Minimum gen0 " SIZE_FORMAT " Initial gen0 " SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, _min_gen0_size, _initial_gen0_size, _max_gen0_size); } } } _min_gen1_size = MIN2(_min_gen1_size, _max_gen1_size); // Make sure that min gen1 <= initial gen1 <= max gen1 --- 592,619 ---- _max_heap_byte_size); } // If there is an inconsistency between the OldSize and the minimum and/or // initial size of gen0, since OldSize was explicitly set, OldSize wins. if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size, ! _min_heap_byte_size, _min_gen1_size)) { if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT " Initial gen0 " SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, _min_gen0_size, _initial_gen0_size, _max_gen0_size); } } // The same as above for the old gen initial size if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size, ! _initial_heap_byte_size, _initial_gen1_size)) { if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("3: Minimum gen0 " SIZE_FORMAT " Initial gen0 " SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, _min_gen0_size, _initial_gen0_size, _max_gen0_size); } } + // update OldSize + FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size); } _min_gen1_size = MIN2(_min_gen1_size, _max_gen1_size); // Make sure that min gen1 <= initial gen1 <= max gen1
*** 540,549 **** --- 623,634 ---- if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("Minimum gen1 " SIZE_FORMAT " Initial gen1 " SIZE_FORMAT " Maximum gen1 " SIZE_FORMAT, _min_gen1_size, _initial_gen1_size, _max_gen1_size); } + + TwoGenerationCollectorPolicy::assert_size_info(); } HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, bool is_tlab, bool* gc_overhead_limit_was_exceeded) {
src/share/vm/memory/collectorPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File