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	Thu Oct 31 16:44:06 2013
--- new/src/share/vm/memory/collectorPolicy.cpp	Thu Oct 31 16:44:06 2013

*** 57,82 **** --- 57,84 ---- _size_policy(NULL), _should_clear_all_soft_refs(false), _all_soft_refs_clear(false) {} + DEBUG_ONLY( 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"); } + }) + DEBUG_ONLY( 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_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,
*** 104,122 **** --- 106,124 ---- 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); ! uintx aligned_initial_heap_size = align_size_up(InitialHeapSize, _heap_alignment); ! uintx aligned_max_heap_size = align_size_up(MaxHeapSize, _heap_alignment); // Write back to flags if the values changed ! if (alignedInitialHeapSize != InitialHeapSize) { ! FLAG_SET_ERGO(uintx, InitialHeapSize, alignedInitialHeapSize); ! if (aligned_initial_heap_size != InitialHeapSize) { ! FLAG_SET_ERGO(uintx, InitialHeapSize, aligned_initial_heap_size); } ! if (alignedMaxHeapSize != MaxHeapSize) { ! FLAG_SET_ERGO(uintx, MaxHeapSize, alignedMaxHeapSize); ! if (aligned_max_heap_size != MaxHeapSize) { ! FLAG_SET_ERGO(uintx, MaxHeapSize, aligned_max_heap_size); } 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");
*** 133,153 **** --- 135,155 ---- _initial_heap_byte_size = InitialHeapSize; _max_heap_byte_size = MaxHeapSize; FLAG_SET_ERGO(uintx, MinHeapDeltaBytes, align_size_up(MinHeapDeltaBytes, _space_alignment)); CollectorPolicy::assert_flags(); + DEBUG_ONLY(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(); + DEBUG_ONLY(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);
*** 221,245 **** --- 223,250 ---- 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); } + DEBUG_ONLY( 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"); } + }) + DEBUG_ONLY( 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"); } + }) + DEBUG_ONLY( 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");
*** 247,267 **** --- 252,273 ---- 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"); } + }) + DEBUG_ONLY( 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_flags() { CollectorPolicy::initialize_flags(); assert(_gen_alignment != 0, "Generation alignment not set up properly");
*** 269,350 **** --- 275,356 ---- 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)); + assert(_heap_alignment % _gen_alignment == 0, + err_msg("heap_alignment: " SIZE_FORMAT " not aligned by gen_alignment: " SIZE_FORMAT, + _heap_alignment, _gen_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), ! uintx smallest_new_size = young_gen_size_lower_bound(); ! uintx smallest_heap_size = align_size_up(smallest_new_size + align_size_up(_space_alignment, _gen_alignment), _heap_alignment); ! if (MaxHeapSize < smallestHeapSize) { ! FLAG_SET_ERGO(uintx, MaxHeapSize, smallestHeapSize); ! if (MaxHeapSize < smallest_heap_size) { ! FLAG_SET_ERGO(uintx, MaxHeapSize, smallest_heap_size); _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 (_min_heap_byte_size < smallest_heap_size) { ! _min_heap_byte_size = smallest_heap_size; if (InitialHeapSize < _min_heap_byte_size) { ! FLAG_SET_ERGO(uintx, InitialHeapSize, smallestHeapSize); ! _initial_heap_byte_size = smallestHeapSize; ! FLAG_SET_ERGO(uintx, InitialHeapSize, smallest_heap_size); ! _initial_heap_byte_size = smallest_heap_size; } } // 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); ! smallest_new_size = MAX2(smallest_new_size, (uintx)align_size_down(NewSize, _gen_alignment)); ! if (smallest_new_size != NewSize) { ! FLAG_SET_ERGO(uintx, NewSize, smallest_new_size); } _initial_gen0_size = NewSize; if (!FLAG_IS_DEFAULT(MaxNewSize)) { ! uintx minNewSize = MAX2(_gen_alignment, _min_gen0_size); ! uintx min_new_size = MAX2(_gen_alignment, _min_gen0_size); if (MaxNewSize >= MaxHeapSize) { // Make sure there is room for an old generation ! uintx smallerMaxNewSize = MaxHeapSize - _gen_alignment; ! uintx smaller_max_new_size = 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); ! MaxNewSize/K, MaxHeapSize/K, smaller_max_new_size/K); } ! FLAG_SET_ERGO(uintx, MaxNewSize, smallerMaxNewSize); ! FLAG_SET_ERGO(uintx, MaxNewSize, smaller_max_new_size); 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 (MaxNewSize < min_new_size) { ! FLAG_SET_ERGO(uintx, MaxNewSize, min_new_size); } 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 and/or // a small (but not too small) MaxNewSize. ! if (FLAG_IS_CMDLINE(MaxNewSize)) { warning("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). " ! "A new max 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; ! FLAG_SET_ERGO(uintx, MaxNewSize, NewSize); ! _max_gen0_size = MaxNewSize; } if (SurvivorRatio < 1 || NewRatio < 1) { vm_exit_during_initialization("Invalid young gen ratio specified"); } GenCollectorPolicy::assert_flags(); + DEBUG_ONLY(GenCollectorPolicy::assert_flags();) } void TwoGenerationCollectorPolicy::initialize_flags() { GenCollectorPolicy::initialize_flags();
*** 371,382 **** --- 377,388 ---- 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)); ! uintx smaller_new_size = align_size_down((uintx)(NewSize * shrink_factor), _gen_alignment); ! FLAG_SET_ERGO(uintx, NewSize, MAX2(young_gen_size_lower_bound(), smaller_new_size)); _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
*** 387,397 **** --- 393,404 ---- _max_heap_byte_size = MaxHeapSize; } } always_do_update_barrier = UseConcMarkSweepGC; TwoGenerationCollectorPolicy::assert_flags(); + + DEBUG_ONLY(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
*** 495,505 **** --- 502,512 ---- 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(); + DEBUG_ONLY(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
*** 513,525 **** --- 520,532 ---- 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(); ! uintx smallest_new_size = young_gen_size_lower_bound(); if ((heap_size < (*gen0_size_ptr + min_gen1_size)) && ! (heap_size >= min_gen1_size + smallestNewSize)) { ! (heap_size >= min_gen1_size + smallest_new_size)) { // 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 {
*** 623,633 **** --- 630,640 ---- 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(); + DEBUG_ONLY(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