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

        

*** 45,102 **** #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" #endif // INCLUDE_ALL_GCS // CollectorPolicy methods. 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"); } - - MinHeapDeltaBytes = align_size_up(MinHeapDeltaBytes, _min_alignment); - } - - 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); --- 45,158 ---- #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp" #endif // INCLUDE_ALL_GCS // CollectorPolicy methods. + CollectorPolicy::CollectorPolicy() : + _space_alignment(0), + _heap_alignment(0), + _initial_heap_byte_size(InitialHeapSize), + _max_heap_byte_size(MaxHeapSize), + _min_heap_byte_size(Arguments::min_heap_size()), + _max_heap_size_cmdline(false), + _size_policy(NULL), + _should_clear_all_soft_refs(false), + _all_soft_refs_clear(false) + {} + + void CollectorPolicy::assert_flags() { + assert(InitialHeapSize <= MaxHeapSize, "Ergonomics decided on incompatible initial and maximum heap sizes"); + assert(InitialHeapSize % _heap_alignment == 0, "InitialHeapSize alignment"); + assert(MaxHeapSize % _heap_alignment == 0, "MaxHeapSize alignment"); + } + + void CollectorPolicy::assert_size_info() { + assert(InitialHeapSize == _initial_heap_byte_size, "Discrepancy between InitialHeapSize flag and local storage"); + assert(MaxHeapSize == _max_heap_byte_size, "Discrepancy between MaxHeapSize flag and local storage"); + 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 % _heap_alignment == 0, "min_heap_byte_size alignment"); + assert(_initial_heap_byte_size % _heap_alignment == 0, "initial_heap_byte_size alignment"); + assert(_max_heap_byte_size % _heap_alignment == 0, "max_heap_byte_size alignment"); + } + + void CollectorPolicy::initialize_alignments() { + _space_alignment = (uintx) Generation::GenGrain; + _heap_alignment = compute_heap_alignment(); + } + void CollectorPolicy::initialize_flags() { ! assert(_space_alignment != 0, "Space alignment not set up properly"); ! assert(_heap_alignment != 0, "Heap alignment not set up properly"); ! assert(_heap_alignment >= _space_alignment, ! err_msg("heap_alignment: " SIZE_FORMAT " less than space_alignment: " SIZE_FORMAT, ! _heap_alignment, _space_alignment)); ! assert(_heap_alignment % _space_alignment == 0, ! err_msg("heap_alignment: " SIZE_FORMAT " not aligned by space_alignment: " SIZE_FORMAT, ! _heap_alignment, _space_alignment)); ! if (FLAG_IS_CMDLINE(MaxHeapSize)) { ! if (FLAG_IS_CMDLINE(InitialHeapSize) && InitialHeapSize > MaxHeapSize) { ! vm_exit_during_initialization("Initial heap size set to a larger value than the maximum heap size"); ! } ! if (_min_heap_byte_size != 0 && MaxHeapSize < _min_heap_byte_size) { ! vm_exit_during_initialization("Incompatible minimum and maximum heap sizes specified"); ! } ! _max_heap_size_cmdline = true; } // Check heap parameter properties ! if (InitialHeapSize < M) { vm_exit_during_initialization("Too small initial heap"); } if (_min_heap_byte_size < M) { vm_exit_during_initialization("Too small minimum heap"); } ! ! // User inputs from -Xmx and -Xms must be aligned ! _min_heap_byte_size = align_size_up(_min_heap_byte_size, _heap_alignment); ! uintx alignedInitialHeapSize = align_size_up(InitialHeapSize, _heap_alignment); ! uintx alignedMaxHeapSize = align_size_up(MaxHeapSize, _heap_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 (FLAG_IS_CMDLINE(InitialHeapSize) && _min_heap_byte_size != 0 && ! InitialHeapSize < _min_heap_byte_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 < _min_heap_byte_size) { ! _min_heap_byte_size = InitialHeapSize; ! } } + _initial_heap_byte_size = InitialHeapSize; + _max_heap_byte_size = MaxHeapSize; + + FLAG_SET_ERGO(uintx, MinHeapDeltaBytes, align_size_up(MinHeapDeltaBytes, _space_alignment)); + + CollectorPolicy::assert_flags(); + } + + void CollectorPolicy::initialize_size_info() { 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);
*** 116,126 **** _should_clear_all_soft_refs = size_policy()->gc_overhead_limit_near(); } _all_soft_refs_clear = true; } ! size_t CollectorPolicy::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. --- 172,182 ---- _should_clear_all_soft_refs = size_policy()->gc_overhead_limit_near(); } _all_soft_refs_clear = true; } ! size_t CollectorPolicy::compute_heap_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.
*** 144,160 **** } // GenCollectorPolicy methods. size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) { ! return align_size_down_bounded(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; ! size_t max_minus = maximum_size - alignment; return desired_size < max_minus ? desired_size : max_minus; } void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size, --- 200,215 ---- } // GenCollectorPolicy methods. size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) { ! return align_size_down_bounded(base_size / (NewRatio + 1), _gen_alignment); } size_t GenCollectorPolicy::bound_minus_alignment(size_t desired_size, size_t maximum_size) { ! size_t max_minus = maximum_size - _gen_alignment; return desired_size < max_minus ? desired_size : max_minus; } void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size,
*** 166,270 **** 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 --- 221,407 ---- init_survivor_size, max_gc_pause_sec, GCTimeRatio); } ! size_t GenCollectorPolicy::young_gen_size_lower_bound() { ! // The young generation must be aligned and have room for eden + two survivors ! return align_size_up(3 * _space_alignment, _gen_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 % _gen_alignment == 0, "NewSize alignment"); ! assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize % _gen_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 % _gen_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(NewSize == _initial_gen0_size, "Discrepancy between NewSize flag and local storage"); ! assert(MaxNewSize == _max_gen0_size, "Discrepancy between MaxNewSize flag and local storage"); ! 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 % _gen_alignment == 0, "_min_gen0_size alignment"); ! assert(_initial_gen0_size % _gen_alignment == 0, "_initial_gen0_size alignment"); ! assert(_max_gen0_size % _gen_alignment == 0, "_max_gen0_size alignment"); ! } ! ! void TwoGenerationCollectorPolicy::assert_size_info() { ! GenCollectorPolicy::assert_size_info(); ! assert(OldSize == _initial_gen1_size, "Discrepancy between OldSize flag and local storage"); ! 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 % _gen_alignment == 0, "_max_gen1_size alignment"); ! assert(_initial_gen1_size % _gen_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_alignments() { ! CollectorPolicy::initialize_alignments(); ! _gen_alignment = default_gen_alignment(); ! } + void GenCollectorPolicy::initialize_flags() { CollectorPolicy::initialize_flags(); ! assert(_gen_alignment != 0, "Generation alignment not set up properly"); ! assert(_heap_alignment >= _gen_alignment, ! err_msg("heap_alignment: " SIZE_FORMAT " less than gen_alignment: " SIZE_FORMAT, ! _heap_alignment, _gen_alignment)); ! assert(_gen_alignment % _space_alignment == 0, ! err_msg("gen_alignment: " SIZE_FORMAT " not aligned by space_alignment: " SIZE_FORMAT, ! _gen_alignment, _space_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("Initial young gen size set larger than the maximum young gen size"); ! } ! ! // Make sure the heap is large enough for two generations ! uintx smallestNewSize = young_gen_size_lower_bound(); ! uintx smallestHeapSize = align_size_up(smallestNewSize + align_size_up(_space_alignment, _gen_alignment), ! _heap_alignment); ! if (MaxHeapSize < smallestHeapSize) { ! FLAG_SET_ERGO(uintx, MaxHeapSize, smallestHeapSize); ! _max_heap_byte_size = MaxHeapSize; ! } ! // If needed, synchronize _min_heap_byte size and _initial_heap_byte_size ! if (_min_heap_byte_size < smallestHeapSize) { ! _min_heap_byte_size = smallestHeapSize; ! if (InitialHeapSize < _min_heap_byte_size) { ! FLAG_SET_ERGO(uintx, InitialHeapSize, smallestHeapSize); ! _initial_heap_byte_size = smallestHeapSize; ! } ! } ! // Now take the actual NewSize into account. We will silently increase NewSize ! // if the user specified a smaller value. ! smallestNewSize = MAX2(smallestNewSize, (uintx)align_size_down(NewSize, _gen_alignment)); ! if (smallestNewSize != NewSize) { ! FLAG_SET_ERGO(uintx, NewSize, smallestNewSize); ! } ! _initial_gen0_size = NewSize; ! ! if (!FLAG_IS_DEFAULT(MaxNewSize)) { ! uintx minNewSize = MAX2(_gen_alignment, _min_gen0_size); ! ! if (MaxNewSize >= MaxHeapSize) { ! // Make sure there is room for an old generation ! uintx smallerMaxNewSize = MaxHeapSize - _gen_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); ! _initial_gen0_size = NewSize; ! } ! } else if (MaxNewSize < minNewSize) { ! FLAG_SET_ERGO(uintx, MaxNewSize, minNewSize); ! } else if (!is_size_aligned(MaxNewSize, _gen_alignment)) { ! FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment)); ! } ! _max_gen0_size = MaxNewSize; } ! 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); ! _initial_gen0_size = NewSize; } 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, _gen_alignment)) { ! FLAG_SET_ERGO(uintx, OldSize, align_size_down(OldSize, _gen_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, _heap_alignment); ! FLAG_SET_ERGO(uintx, MaxHeapSize, calculated_heapsize); ! _max_heap_byte_size = MaxHeapSize; ! FLAG_SET_ERGO(uintx, InitialHeapSize, calculated_heapsize); ! _initial_heap_byte_size = InitialHeapSize; } // adjust max heap size if necessary if (NewSize + OldSize > MaxHeapSize) { ! if (_max_heap_size_cmdline) { // 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; ! uintx smallerNewSize = align_size_down((uintx)(NewSize * shrink_factor), _gen_alignment); ! FLAG_SET_ERGO(uintx, NewSize, MAX2(young_gen_size_lower_bound(), smallerNewSize)); ! _initial_gen0_size = NewSize; // OldSize is already aligned because above we aligned MaxHeapSize to ! // _heap_alignment, and we just made sure that NewSize is aligned to ! // _gen_alignment. In initialize_flags() we verified that _heap_alignment ! // is a multiple of _gen_alignment. ! FLAG_SET_ERGO(uintx, OldSize, MaxHeapSize - NewSize); } else { ! FLAG_SET_ERGO(uintx, MaxHeapSize, align_size_up(NewSize + OldSize, _heap_alignment)); ! _max_heap_byte_size = MaxHeapSize; } } 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
*** 275,321 **** // In the absence of explicitly set command line flags, policies // such as the use of NewRatio are used to size the generation. void GenCollectorPolicy::initialize_size_info() { CollectorPolicy::initialize_size_info(); ! // _min_alignment is used for alignment within a generation. // There is additional alignment done down stream for some // collectors that sometimes causes unwanted rounding up of // 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. --- 412,431 ---- // In the absence of explicitly set command line flags, policies // such as the use of NewRatio are used to size the generation. void GenCollectorPolicy::initialize_size_info() { CollectorPolicy::initialize_size_info(); ! // _space_alignment is used for alignment within a generation. // There is additional alignment done down stream for some // collectors that sometimes causes unwanted rounding up of // 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.
*** 380,394 **** --- 490,515 ---- _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 flags if necessary + if (NewSize != _initial_gen0_size) { + FLAG_SET_ERGO(uintx, NewSize, _initial_gen0_size); + } + + if (MaxNewSize != _max_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
*** 402,419 **** const size_t heap_size, const size_t min_gen1_size) { bool result = false; 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 = align_size_down_bounded(heap_size - min_gen1_size, _min_alignment); assert(*gen0_size_ptr > 0, "Min gen0 is too large"); result = true; } else { ! *gen1_size_ptr = align_size_down_bounded(heap_size - *gen0_size_ptr, _min_alignment); } } return result; } --- 523,541 ---- const size_t heap_size, const size_t min_gen1_size) { bool result = false; if ((*gen1_size_ptr + *gen0_size_ptr) > heap_size) { + uintx smallestNewSize = young_gen_size_lower_bound(); if ((heap_size < (*gen0_size_ptr + min_gen1_size)) && ! (heap_size >= min_gen1_size + smallestNewSize)) { // Adjust gen0 down to accommodate min_gen1_size ! *gen0_size_ptr = align_size_down_bounded(heap_size - min_gen1_size, _gen_alignment); assert(*gen0_size_ptr > 0, "Min gen0 is too large"); result = true; } else { ! *gen1_size_ptr = align_size_down_bounded(heap_size - *gen0_size_ptr, _gen_alignment); } } return result; }
*** 430,469 **** // 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 exits // 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 { // It's 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 mimimum should ! // be within one heap alignment. ! if ((_min_gen1_size + _min_gen0_size + _min_alignment) < _min_heap_byte_size) { warning("Inconsistency between minimum heap size and minimum " "generation sizes: using minimum heap = " SIZE_FORMAT, _min_heap_byte_size); } if (OldSize > _max_gen1_size) { --- 552,586 ---- // 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 exits // for setting the gen1 maximum. ! _max_gen1_size = MAX2(_max_heap_byte_size - _max_gen0_size, _gen_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, _gen_alignment); ! _initial_gen1_size = MAX2(_initial_heap_byte_size - _initial_gen0_size, _gen_alignment); ! // _max_gen1_size has already been made consistent above ! FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size); } else { // It's 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 mimimum should ! // be within one generation alignment. ! if ((_min_gen1_size + _min_gen0_size + _gen_alignment) < _min_heap_byte_size) { warning("Inconsistency between minimum heap size and minimum " "generation sizes: using minimum heap = " SIZE_FORMAT, _min_heap_byte_size); } if (OldSize > _max_gen1_size) {
*** 473,492 **** _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); } } // 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); } --- 590,609 ---- _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); } } // 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); }
*** 497,511 **** --- 614,643 ---- // Check that min gen1 <= initial gen1 <= max gen1 _initial_gen1_size = MAX2(_initial_gen1_size, _min_gen1_size); _initial_gen1_size = MIN2(_initial_gen1_size, _max_gen1_size); + // Write back to flags if necessary + if (NewSize != _initial_gen0_size) { + FLAG_SET_ERGO(uintx, NewSize, _max_gen0_size); + } + + if (MaxNewSize != _max_gen0_size) { + FLAG_SET_ERGO(uintx, MaxNewSize, _max_gen0_size); + } + + if (OldSize != _initial_gen1_size) { + FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size); + } + 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) {
*** 824,837 **** // // MarkSweepPolicy methods // - MarkSweepPolicy::MarkSweepPolicy() { - initialize_all(); - } - void MarkSweepPolicy::initialize_generations() { _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); if (_generations == NULL) { vm_exit_during_initialization("Unable to allocate gen spec"); } --- 956,965 ----
src/share/vm/memory/collectorPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File