src/share/vm/memory/collectorPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/memory/collectorPolicy.cpp	Mon Sep 30 21:36:12 2013
--- new/src/share/vm/memory/collectorPolicy.cpp	Mon Sep 30 21:36:12 2013

*** 51,131 **** --- 51,131 ---- 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(), ! 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, ! _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())); ! _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())) { ! if (!is_size_aligned(MaxMetaspaceSize, _max_alignment)) { FLAG_SET_ERGO(uintx, MaxMetaspaceSize, ! restricted_align_down(MaxMetaspaceSize, max_alignment())); ! restricted_align_down(MaxMetaspaceSize, _max_alignment)); } if (MetaspaceSize > MaxMetaspaceSize) { FLAG_SET_ERGO(uintx, MetaspaceSize, MaxMetaspaceSize); } ! if (!is_size_aligned(MetaspaceSize, min_alignment())) { ! if (!is_size_aligned(MetaspaceSize, _min_alignment)) { FLAG_SET_ERGO(uintx, MetaspaceSize, ! restricted_align_down(MetaspaceSize, min_alignment())); ! restricted_align_down(MetaspaceSize, _min_alignment)); } assert(MetaspaceSize <= MaxMetaspaceSize, "Must be"); ! MinMetaspaceExpansion = restricted_align_down(MinMetaspaceExpansion, min_alignment()); ! MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, min_alignment()); ! MinMetaspaceExpansion = restricted_align_down(MinMetaspaceExpansion, _min_alignment); ! MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, _min_alignment); ! MinHeapDeltaBytes = align_size_up(MinHeapDeltaBytes, min_alignment()); ! MinHeapDeltaBytes = align_size_up(MinHeapDeltaBytes, _min_alignment); ! assert(MetaspaceSize % min_alignment() == 0, "metapace alignment"); ! assert(MaxMetaspaceSize % max_alignment() == 0, "maximum metaspace alignment"); ! 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 ! set_min_heap_byte_size(align_size_up(Arguments::min_heap_size(), min_alignment())); ! set_initial_heap_byte_size(align_size_up(InitialHeapSize, min_alignment())); ! set_max_heap_byte_size(align_size_up(MaxHeapSize, max_alignment())); ! _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) { ! if (_initial_heap_byte_size < M) { vm_exit_during_initialization("Too small initial heap"); } // Check heap parameter properties ! if (min_heap_byte_size() < M) { ! if (_min_heap_byte_size < M) { vm_exit_during_initialization("Too small minimum heap"); } ! if (initial_heap_byte_size() <= NewSize) { ! 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()) { ! 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()) { ! 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()) { ! 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()); ! _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;
*** 133,151 **** --- 133,144 ---- return result; } GenRemSet* CollectorPolicy::create_rem_set(MemRegion whole_heap, int max_covered_regions) { switch (rem_set_name()) { case GenRemSet::CardTable: { CardTableRS* res = new CardTableRS(whole_heap, max_covered_regions); return res; } default: guarantee(false, "unrecognized GenRemSet::Name"); return NULL; } + assert(rem_set_name() == GenRemSet::CardTable, "unrecognized GenRemSet::Name"); + return new CardTableRS(whole_heap, max_covered_regions); } void CollectorPolicy::cleared_all_soft_refs() { // If near gc overhear limit, continue to clear SoftRefs. SoftRefs may // have been cleared in the last collection but if the gc overhear
*** 183,201 **** --- 176,194 ---- // 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(); ! 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(); ! size_t alignment = _min_alignment; size_t max_minus = maximum_size - alignment; return desired_size < max_minus ? desired_size : max_minus; }
*** 210,311 **** --- 203,304 ---- GCTimeRatio); } void GenCollectorPolicy::initialize_flags() { // All sizes must be multiples of the generation granularity. ! set_min_alignment((uintx) Generation::GenGrain); ! set_max_alignment(compute_max_alignment()); ! _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()); ! 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"); ! assert(NewSize % _min_alignment == 0, "eden space alignment"); ! assert(MaxNewSize % _min_alignment == 0, "survivor space alignment"); ! if (NewSize < 3*min_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 heap ratio specified"); ! vm_exit_during_initialization("Invalid young gen ratio specified"); } } void TwoGenerationCollectorPolicy::initialize_flags() { GenCollectorPolicy::initialize_flags(); ! OldSize = align_size_down(OldSize, min_alignment()); ! 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()); ! calculated_heapsize = align_size_up(calculated_heapsize, _max_alignment); MaxHeapSize = calculated_heapsize; InitialHeapSize = calculated_heapsize; } ! MaxHeapSize = align_size_up(MaxHeapSize, max_alignment()); ! 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()); ! 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(). ! // _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()); ! 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()); ! 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(). ! // _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()); ! 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"); ! 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
*** 316,346 **** --- 309,339 ---- // 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. ! // _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 < _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()); ! 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); ! MaxNewSize/K, _max_heap_byte_size/K, max_new_size/K); } else { ! max_new_size = align_size_down(MaxNewSize, min_alignment()); ! 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
*** 354,364 **** --- 347,357 ---- // 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()); ! 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. // Ergonomics plays here by previously calculating the desired // NewSize and MaxNewSize.
*** 367,383 **** --- 360,376 ---- assert(max_new_size > 0, "All paths should set max_new_size"); // Given the maximum gen0 size, determine the initial and // minimum gen0 sizes. ! if (max_heap_byte_size() == min_heap_byte_size()) { ! if (_max_heap_byte_size == _min_heap_byte_size) { // The maximum and minimum heap sizes are the same so // the generations minimum and initial must be the // same as its maximum. ! set_min_gen0_size(max_new_size); ! set_initial_gen0_size(max_new_size); ! set_max_gen0_size(max_new_size); ! _min_gen0_size = max_new_size; ! _initial_gen0_size = max_new_size; ! _max_gen0_size = max_new_size; } else { size_t desired_new_size = 0; if (!FLAG_IS_DEFAULT(NewSize)) { // If NewSize is set ergonomically (for example by cms), it // would make sense to use it. If it is used, also use it
*** 394,440 **** --- 387,427 ---- // For the case where NewSize is the default, use NewRatio // to size the minimum and initial generation sizes. // Use the default NewSize as the floor for these values. If // NewRatio is overly large, the resulting sizes can be too // small. ! _min_gen0_size = MAX2(scale_by_NewRatio_aligned(min_heap_byte_size()), NewSize); ! _min_gen0_size = MAX2(scale_by_NewRatio_aligned(_min_heap_byte_size), NewSize); desired_new_size = ! MAX2(scale_by_NewRatio_aligned(initial_heap_byte_size()), NewSize); ! MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize); } assert(_min_gen0_size > 0, "Sanity check"); ! set_initial_gen0_size(desired_new_size); ! set_max_gen0_size(max_new_size); ! _initial_gen0_size = desired_new_size; ! _max_gen0_size = max_new_size; // At this point the desirable initial and minimum sizes have been // determined without regard to the maximum sizes. // Bound the sizes by the corresponding overall heap sizes. set_min_gen0_size( ! bound_minus_alignment(_min_gen0_size, min_heap_byte_size())); set_initial_gen0_size( bound_minus_alignment(_initial_gen0_size, initial_heap_byte_size())); set_max_gen0_size( bound_minus_alignment(_max_gen0_size, max_heap_byte_size())); + _min_gen0_size = bound_minus_alignment(_min_gen0_size, _min_heap_byte_size); ! _initial_gen0_size = bound_minus_alignment(_initial_gen0_size, _initial_heap_byte_size); + _max_gen0_size = bound_minus_alignment(_max_gen0_size, _max_heap_byte_size); // At this point all three sizes have been checked against the // maximum sizes but have not been checked for consistency // among the three. // Final check min <= initial <= max ! set_min_gen0_size(MIN2(_min_gen0_size, _max_gen0_size)); set_initial_gen0_size( ! MAX2(MIN2(_initial_gen0_size, _max_gen0_size), _min_gen0_size)); set_min_gen0_size(MIN2(_min_gen0_size, _initial_gen0_size)); ! _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); } 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()); ! _min_gen0_size, _initial_gen0_size, _max_gen0_size); } } // Call this method during the sizing of the gen1 to make // adjustments to gen0 because of gen1 sizing policy. gen0 initially has
*** 450,479 **** --- 437,464 ---- 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())) { ! (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()); ! 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()); ! MAX2((uintx)align_size_down(*gen1_size_ptr, _min_alignment), _min_alignment); } } return result; } // Minimum sizes of the generations may be different than ! // the initial sizes. An inconsistently is permitted here ! // the initial sizes. An inconsistency is permitted here // in the total size that can be specified explicitly by // command line specification of OldSize and NewSize and // also a command line specification of -Xms. Issue a warning // but allow the values to pass.
*** 481,568 **** --- 466,548 ---- GenCollectorPolicy::initialize_size_info(); // 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 ! // 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 = _max_heap_byte_size - _max_gen0_size; _max_gen1_size = ! MAX2((uintx)align_size_down(_max_gen1_size, min_alignment()), min_alignment()); ! 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, ! assert(_min_heap_byte_size > _min_gen0_size, "gen0 has an unexpected minimum size"); ! set_min_gen1_size(min_heap_byte_size() - min_gen0_size()); set_min_gen1_size( MAX2((uintx)align_size_down(_min_gen1_size, min_alignment()), ! min_alignment())); set_initial_gen1_size(initial_heap_byte_size() - initial_gen0_size()); set_initial_gen1_size( MAX2((uintx)align_size_down(_initial_gen1_size, min_alignment()), min_alignment())); ! _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 has been explicitly set on the command line. Use the // OldSize and then determine the consequences. ! set_min_gen1_size(OldSize); ! set_initial_gen1_size(OldSize); ! _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 ! // The generation minimums and the overall heap minimum should // be within one heap alignment. ! if ((_min_gen1_size + _min_gen0_size + min_alignment()) < min_heap_byte_size()) { ! 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()); ! _min_heap_byte_size); } ! if ((OldSize > _max_gen1_size)) { warning("Inconsistency between maximum heap size and maximum " "generation sizes: using maximum heap = " SIZE_FORMAT " -XX:OldSize flag is being ignored", ! max_heap_byte_size()); ! _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)) { ! _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()); ! _min_gen0_size, _initial_gen0_size, _max_gen0_size); } } ! // Initial 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)) { ! _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_gen0_size, _initial_gen0_size, _max_gen0_size); } } } // Enforce the maximum gen1 size. set_min_gen1_size(MIN2(_min_gen1_size, _max_gen1_size)); // Check that min gen1 <= initial gen1 <= max gen1 set_initial_gen1_size(MAX2(_initial_gen1_size, _min_gen1_size)); set_initial_gen1_size(MIN2(_initial_gen1_size, _max_gen1_size)); + _min_gen1_size = MIN2(_min_gen1_size, _max_gen1_size); + + // Make sure 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); 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()); ! _min_gen1_size, _initial_gen1_size, _max_gen1_size); } } HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, bool is_tlab,
*** 577,588 **** --- 557,567 ---- // limit is being exceeded as checked below. *gc_overhead_limit_was_exceeded = false; HeapWord* result = NULL; ! // Loop until the allocation is satisified, // or unsatisfied after GC. ! // Loop until the allocation is satisfied, or unsatisfied after GC. for (int try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) { HandleMark hm; // discard any handles allocated in each iteration // First allocation attempt is lock-free. Generation *gen0 = gch->get_gen(0);
*** 653,665 **** --- 632,642 ---- // Read the gc count while the heap lock is held. gc_count_before = Universe::heap()->total_collections(); } ! VM_GenCollectForAllocation op(size, is_tlab, gc_count_before); is_tlab, gc_count_before); VMThread::execute(&op); if (op.prologue_succeeded()) { result = op.result(); if (op.gc_locked()) { assert(result == NULL, "must be NULL if gc_locked() is true");
*** 890,911 **** --- 867,890 ---- 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"); + } if (UseParNewGC) { _generations[0] = new GenerationSpec(Generation::ParNew, _initial_gen0_size, _max_gen0_size); } else { _generations[0] = new GenerationSpec(Generation::DefNew, _initial_gen0_size, _max_gen0_size); } _generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_gen1_size, _max_gen1_size); ! if (_generations[0] == NULL || _generations[1] == NULL) { vm_exit_during_initialization("Unable to allocate gen spec"); + } } void MarkSweepPolicy::initialize_gc_policy_counters() { // initialize the policy counters - 2 collectors, 3 generations if (UseParNewGC) {

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