Flag::Error SurvivorRatioConstraintFunc(uintx value, bool verbose) { if (FLAG_IS_CMDLINE(SurvivorRatio) && (value > (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment()))) { CommandLineError::print(verbose, "SurvivorRatio (" UINTX_FORMAT ") must be " "less than or equal to ergonomic SurvivorRatio maximum (" SIZE_FORMAT ")\n", value, (MaxHeapSize / Universe::heap()->collector_policy()->space_alignment())); return Flag::VIOLATES_CONSTRAINT; } else { return Flag::SUCCESS; } }
Flag::Error MaxGCPauseMillisConstraintFunc(uintx value, bool verbose) { #if INCLUDE_ALL_GCS if (UseG1GC && FLAG_IS_CMDLINE(MaxGCPauseMillis) && (value >= GCPauseIntervalMillis)) { CommandLineError::print(verbose, "MaxGCPauseMillis (" UINTX_FORMAT ") must be " "less than GCPauseIntervalMillis (" UINTX_FORMAT ")\n", value, GCPauseIntervalMillis); return Flag::VIOLATES_CONSTRAINT; } #endif return Flag::SUCCESS; }
Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { if (!UseG1GC) return Flag::SUCCESS; // Default value of G1HeapRegionSize=0 means will be set ergonomically. if (FLAG_IS_CMDLINE(G1HeapRegionSize) && (value < HeapRegionBounds::min_size())) { CommandLineError::print(verbose, "G1HeapRegionSize (" SIZE_FORMAT ") must be " "greater than or equal to ergonomic heap region minimum size\n", value); return Flag::VIOLATES_CONSTRAINT; } else { return Flag::SUCCESS; } }
Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) { if (!UseG1GC) return Flag::SUCCESS; // Default value of G1RSetSparseRegionEntries=0 means will be set ergonomically. // Minimum value is 1. if (FLAG_IS_CMDLINE(G1RSetSparseRegionEntries) && (value < 1)) { CommandLineError::print(verbose, "G1RSetSparseRegionEntries (" INTX_FORMAT ") must be " "greater than or equal to 1\n", value); return Flag::VIOLATES_CONSTRAINT; } else { return Flag::SUCCESS; } }
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 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 // 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; DEBUG_ONLY(TwoGenerationCollectorPolicy::assert_flags();) }
Flag::Error TLABSizeConstraintFunc(size_t value, bool verbose) { // Skip for default value of zero which means set ergonomically. if (FLAG_IS_CMDLINE(TLABSize)) { if (value < MinTLABSize) { CommandLineError::print(verbose, "TLABSize (" SIZE_FORMAT ") must be " "greater than or equal to MinTLABSize (" SIZE_FORMAT ")\n", value, MinTLABSize); return Flag::VIOLATES_CONSTRAINT; } if (value > (ThreadLocalAllocBuffer::max_size() * HeapWordSize)) { CommandLineError::print(verbose, "TLABSize (" SIZE_FORMAT ") must be " "less than or equal to ergonomic TLAB maximum size (" SIZE_FORMAT ")\n", value, (ThreadLocalAllocBuffer::max_size() * HeapWordSize)); return Flag::VIOLATES_CONSTRAINT; } } return Flag::SUCCESS; }
Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) { #if INCLUDE_ALL_GCS if (UseG1GC) { if (FLAG_IS_CMDLINE(GCPauseIntervalMillis)) { if (value < 1) { CommandLineError::print(verbose, "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " "greater than or equal to 1\n", value); return Flag::VIOLATES_CONSTRAINT; } if (value <= MaxGCPauseMillis) { CommandLineError::print(verbose, "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " "greater than MaxGCPauseMillis (" UINTX_FORMAT ")\n", value, MaxGCPauseMillis); return Flag::VIOLATES_CONSTRAINT; } } } #endif return Flag::SUCCESS; }
// Values set on the command line win over any ergonomically // set command line parameters. // Ergonomic choice of parameters are done before this // method is called. Values for command line parameters such as NewSize // and MaxNewSize feed those ergonomic choices into this method. // This method makes the final generation sizings consistent with // themselves and with overall heap sizings. // 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. // Ergonomics plays here by previously calculating the desired // NewSize and MaxNewSize. max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize); } 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) { // The maximum and minimum heap sizes are the same so // the generations minimum and initial must be the // same as its maximum. _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_CMDLINE(NewSize)) { // If NewSize is set on the command line, we must use it as // the initial size and it also makes sense to use it as the // lower limit. _min_gen0_size = NewSize; desired_new_size = NewSize; max_new_size = MAX2(max_new_size, NewSize); } else if (FLAG_IS_ERGO(NewSize)) { // If NewSize is set ergonomically, we should use it as a lower // limit, but use NewRatio to calculate the initial size. _min_gen0_size = NewSize; desired_new_size = MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize); max_new_size = MAX2(max_new_size, NewSize); } else { // 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); desired_new_size = MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize); } assert(_min_gen0_size > 0, "Sanity check"); _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. _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 _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); } DEBUG_ONLY(GenCollectorPolicy::assert_size_info();) }
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)); 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 // Make sure the heap is large enough for two generations 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 < 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 < smallest_heap_size) { _min_heap_byte_size = smallest_heap_size; if (InitialHeapSize < _min_heap_byte_size) { 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 or unaligned value. smallest_new_size = MAX2(smallest_new_size, (uintx)align_size_down(NewSize, _gen_alignment)); if (smallest_new_size != NewSize) { // Do not use FLAG_SET_ERGO to update NewSize here, since this will override // if NewSize was set on the command line or not. This information is needed // later when setting the initial and minimum young generation size. NewSize = smallest_new_size; } _initial_gen0_size = NewSize; if (!FLAG_IS_DEFAULT(MaxNewSize)) { uintx min_new_size = MAX2(_gen_alignment, _min_gen0_size); if (MaxNewSize >= MaxHeapSize) { // Make sure there is room for an old generation 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, smaller_max_new_size/K); } 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 < 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, NewSize/K); } FLAG_SET_ERGO(uintx, MaxNewSize, NewSize); _max_gen0_size = MaxNewSize; } if (SurvivorRatio < 1 || NewRatio < 1) { vm_exit_during_initialization("Invalid young gen ratio specified"); } DEBUG_ONLY(GenCollectorPolicy::assert_flags();) }
size_t MetaspacePool::calculate_max_size() const { return FLAG_IS_CMDLINE(MaxMetaspaceSize) ? MaxMetaspaceSize : MemoryUsage::undefined_size(); }
void CodeCache::initialize_heaps() { bool non_nmethod_set = FLAG_IS_CMDLINE(NonNMethodCodeHeapSize); bool profiled_set = FLAG_IS_CMDLINE(ProfiledCodeHeapSize); bool non_profiled_set = FLAG_IS_CMDLINE(NonProfiledCodeHeapSize); size_t min_size = os::vm_page_size(); size_t cache_size = ReservedCodeCacheSize; size_t non_nmethod_size = NonNMethodCodeHeapSize; size_t profiled_size = ProfiledCodeHeapSize; size_t non_profiled_size = NonProfiledCodeHeapSize; // Check if total size set via command line flags exceeds the reserved size check_heap_sizes((non_nmethod_set ? non_nmethod_size : min_size), (profiled_set ? profiled_size : min_size), (non_profiled_set ? non_profiled_size : min_size), cache_size, non_nmethod_set && profiled_set && non_profiled_set); // Determine size of compiler buffers size_t code_buffers_size = 0; #ifdef COMPILER1 // C1 temporary code buffers (see Compiler::init_buffer_blob()) const int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); code_buffers_size += c1_count * Compiler::code_buffer_size(); #endif #ifdef COMPILER2 // C2 scratch buffers (see Compile::init_scratch_buffer_blob()) const int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); // Initial size of constant table (this may be increased if a compiled method needs more space) code_buffers_size += c2_count * C2Compiler::initial_code_buffer_size(); #endif // Increase default non_nmethod_size to account for compiler buffers if (!non_nmethod_set) { non_nmethod_size += code_buffers_size; } // Calculate default CodeHeap sizes if not set by user if (!non_nmethod_set && !profiled_set && !non_profiled_set) { // Check if we have enough space for the non-nmethod code heap if (cache_size > non_nmethod_size) { // Use the default value for non_nmethod_size and one half of the // remaining size for non-profiled and one half for profiled methods size_t remaining_size = cache_size - non_nmethod_size; profiled_size = remaining_size / 2; non_profiled_size = remaining_size - profiled_size; } else { // Use all space for the non-nmethod heap and set other heaps to minimal size non_nmethod_size = cache_size - 2 * min_size; profiled_size = min_size; non_profiled_size = min_size; } } else if (!non_nmethod_set || !profiled_set || !non_profiled_set) { // The user explicitly set some code heap sizes. Increase or decrease the (default) // sizes of the other code heaps accordingly. First adapt non-profiled and profiled // code heap sizes and then only change non-nmethod code heap size if still necessary. intx diff_size = cache_size - (non_nmethod_size + profiled_size + non_profiled_size); if (non_profiled_set) { if (!profiled_set) { // Adapt size of profiled code heap if (diff_size < 0 && ((intx)profiled_size + diff_size) <= 0) { // Not enough space available, set to minimum size diff_size += profiled_size - min_size; profiled_size = min_size; } else { profiled_size += diff_size; diff_size = 0; } } } else if (profiled_set) { // Adapt size of non-profiled code heap if (diff_size < 0 && ((intx)non_profiled_size + diff_size) <= 0) { // Not enough space available, set to minimum size diff_size += non_profiled_size - min_size; non_profiled_size = min_size; } else { non_profiled_size += diff_size; diff_size = 0; } } else if (non_nmethod_set) { // Distribute remaining size between profiled and non-profiled code heaps diff_size = cache_size - non_nmethod_size; profiled_size = diff_size / 2; non_profiled_size = diff_size - profiled_size; diff_size = 0; } if (diff_size != 0) { // Use non-nmethod code heap for remaining space requirements assert(!non_nmethod_set && ((intx)non_nmethod_size + diff_size) > 0, "sanity"); non_nmethod_size += diff_size; } } // We do not need the profiled CodeHeap, use all space for the non-profiled CodeHeap if(!heap_available(CodeBlobType::MethodProfiled)) { non_profiled_size += profiled_size; profiled_size = 0; } // We do not need the non-profiled CodeHeap, use all space for the non-nmethod CodeHeap if(!heap_available(CodeBlobType::MethodNonProfiled)) { non_nmethod_size += non_profiled_size; non_profiled_size = 0; } // Make sure we have enough space for VM internal code uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); if (non_nmethod_size < (min_code_cache_size + code_buffers_size)) { vm_exit_during_initialization(err_msg( "Not enough space in non-nmethod code heap to run VM: %zuK < %zuK", non_nmethod_size/K, (min_code_cache_size + code_buffers_size)/K)); } // Verify sizes and update flag values assert(non_profiled_size + profiled_size + non_nmethod_size == cache_size, "Invalid code heap sizes"); FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, non_nmethod_size); FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, profiled_size); FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, non_profiled_size); // Align CodeHeaps size_t alignment = heap_alignment(); non_nmethod_size = align_size_up(non_nmethod_size, alignment); profiled_size = align_size_down(profiled_size, alignment); // Reserve one continuous chunk of memory for CodeHeaps and split it into // parts for the individual heaps. The memory layout looks like this: // ---------- high ----------- // Non-profiled nmethods // Profiled nmethods // Non-nmethods // ---------- low ------------ ReservedCodeSpace rs = reserve_heap_memory(cache_size); ReservedSpace non_method_space = rs.first_part(non_nmethod_size); ReservedSpace rest = rs.last_part(non_nmethod_size); ReservedSpace profiled_space = rest.first_part(profiled_size); ReservedSpace non_profiled_space = rest.last_part(profiled_size); // Non-nmethods (stubs, adapters, ...) add_heap(non_method_space, "CodeHeap 'non-nmethods'", CodeBlobType::NonNMethod); // Tier 2 and tier 3 (profiled) methods add_heap(profiled_space, "CodeHeap 'profiled nmethods'", CodeBlobType::MethodProfiled); // Tier 1 and tier 4 (non-profiled) methods and native methods add_heap(non_profiled_space, "CodeHeap 'non-profiled nmethods'", CodeBlobType::MethodNonProfiled); }
// Values set on the command line win over any ergonomically // set command line parameters. // Ergonomic choice of parameters are done before this // method is called. Values for command line parameters such as NewSize // and MaxNewSize feed those ergonomic choices into this method. // This method makes the final generation sizings consistent with // themselves and with overall heap sizings. // 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)) { if (MaxNewSize < min_alignment()) { max_new_size = min_alignment(); } else 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. // Ergonomics plays here by previously calculating the desired // NewSize and MaxNewSize. max_new_size = MIN2(MAX2(max_new_size, (size_t)NewSize), (size_t)MaxNewSize); } assert(max_new_size > 0, "All paths should set max_new_size"); // Given the maximum gen0 size, determine the initial and // minimum sizes. 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); } 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 // to set the initial size. Although there is no reason // the minimum size and the initial size have to be the same, // the current implementation gets into trouble during the calculation // of the tenured generation sizes if they are different. // Note that this makes the initial size and the minimum size // generally small compared to the NewRatio calculation. _min_gen0_size = NewSize; desired_new_size = NewSize; max_new_size = MAX2(max_new_size, (size_t) NewSize); } else { // 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()), (size_t) NewSize); desired_new_size = MAX2(scale_by_NewRatio_aligned(initial_heap_byte_size()), (size_t) NewSize); } assert(_min_gen0_size > 0, "Sanity check"); set_initial_gen0_size(desired_new_size); set_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())); // 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)); } if (PrintGCDetails && Verbose) { gclog_or_tty->print_cr("Minimum gen0 " SIZE_FORMAT " Initial gen0 " SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, min_gen0_size(), initial_gen0_size(), max_gen0_size()); } }
// Minimum sizes of the generations may be different than // 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. void GenCollectorPolicy::initialize_size_info() { CollectorPolicy::initialize_size_info(); _initial_young_size = NewSize; _max_young_size = MaxNewSize; _initial_old_size = OldSize; // Determine maximum size of the young generation. if (FLAG_IS_DEFAULT(MaxNewSize)) { _max_young_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. _max_young_size = MIN2(MAX2(_max_young_size, _initial_young_size), MaxNewSize); } // Given the maximum young size, determine the initial and // minimum young sizes. if (_max_heap_byte_size == _initial_heap_byte_size) { // The maximum and initial heap sizes are the same so the generation's // initial size must be the same as it maximum size. Use NewSize as the // size if set on command line. _max_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : _max_young_size; _initial_young_size = _max_young_size; // Also update the minimum size if min == initial == max. if (_max_heap_byte_size == _min_heap_byte_size) { _min_young_size = _max_young_size; } } else { if (FLAG_IS_CMDLINE(NewSize)) { // If NewSize is set on the command line, we should use it as // the initial size, but make sure it is within the heap bounds. _initial_young_size = MIN2(_max_young_size, bound_minus_alignment(NewSize, _initial_heap_byte_size)); _min_young_size = bound_minus_alignment(_initial_young_size, _min_heap_byte_size); } else { // For the case where NewSize is not set on the command line, use // NewRatio to size the initial generation size. Use the current // NewSize as the floor, because if NewRatio is overly large, the resulting // size can be too small. _initial_young_size = MIN2(_max_young_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize)); } } log_trace(gc, heap)("1: Minimum young " SIZE_FORMAT " Initial young " SIZE_FORMAT " Maximum young " SIZE_FORMAT, _min_young_size, _initial_young_size, _max_young_size); // At this point the minimum, initial and maximum sizes // of the overall heap and of the young generation have been determined. // The maximum old size can be determined from the maximum young // and maximum heap size since no explicit flags exist // for setting the old generation maximum. _max_old_size = MAX2(_max_heap_byte_size - _max_young_size, _gen_alignment); // If no explicit command line flag has been set for the // old generation size, use what is left. 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 young sizes and the overall heap sizes. _min_old_size = _gen_alignment; _initial_old_size = MIN2(_max_old_size, MAX2(_initial_heap_byte_size - _initial_young_size, _min_old_size)); // _max_old_size has already been made consistent above. } else { // OldSize has been explicitly set on the command line. Use it // for the initial size but make sure the minimum allow a young // generation to fit as well. // 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 // be within one generation alignment. if (_initial_old_size > _max_old_size) { log_warning(gc, ergo)("Inconsistency between maximum heap size and maximum " "generation sizes: using maximum heap = " SIZE_FORMAT ", -XX:OldSize flag is being ignored", _max_heap_byte_size); _initial_old_size = _max_old_size; } _min_old_size = MIN2(_initial_old_size, _min_heap_byte_size - _min_young_size); } // The initial generation sizes should match the initial heap size, // if not issue a warning and resize the generations. This behavior // differs from JDK8 where the generation sizes have higher priority // than the initial heap size. if ((_initial_old_size + _initial_young_size) != _initial_heap_byte_size) { log_warning(gc, ergo)("Inconsistency between generation sizes and heap size, resizing " "the generations to fit the heap."); size_t desired_young_size = _initial_heap_byte_size - _initial_old_size; if (_initial_heap_byte_size < _initial_old_size) { // Old want all memory, use minimum for young and rest for old _initial_young_size = _min_young_size; _initial_old_size = _initial_heap_byte_size - _min_young_size; } else if (desired_young_size > _max_young_size) { // Need to increase both young and old generation _initial_young_size = _max_young_size; _initial_old_size = _initial_heap_byte_size - _max_young_size; } else if (desired_young_size < _min_young_size) { // Need to decrease both young and old generation _initial_young_size = _min_young_size; _initial_old_size = _initial_heap_byte_size - _min_young_size; } else { // The young generation boundaries allow us to only update the // young generation. _initial_young_size = desired_young_size; } log_trace(gc, heap)("2: Minimum young " SIZE_FORMAT " Initial young " SIZE_FORMAT " Maximum young " SIZE_FORMAT, _min_young_size, _initial_young_size, _max_young_size); } // Write back to flags if necessary. if (NewSize != _initial_young_size) { FLAG_SET_ERGO(size_t, NewSize, _initial_young_size); } if (MaxNewSize != _max_young_size) { FLAG_SET_ERGO(size_t, MaxNewSize, _max_young_size); } if (OldSize != _initial_old_size) { FLAG_SET_ERGO(size_t, OldSize, _initial_old_size); } log_trace(gc, heap)("Minimum old " SIZE_FORMAT " Initial old " SIZE_FORMAT " Maximum old " SIZE_FORMAT, _min_old_size, _initial_old_size, _max_old_size); DEBUG_ONLY(GenCollectorPolicy::assert_size_info();) }
void TwoGenerationCollectorPolicy::initialize_size_info() { 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 // 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) { 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); } // 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)) { 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)) { 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); } } } // Enforce the maximum gen1 size. _min_gen1_size = MIN2(_min_gen1_size, _max_gen1_size); // 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, _initial_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); } DEBUG_ONLY(TwoGenerationCollectorPolicy::assert_size_info();) }
void CodeCache::initialize_heaps() { // Determine size of compiler buffers size_t code_buffers_size = 0; #ifdef COMPILER1 // C1 temporary code buffers (see Compiler::init_buffer_blob()) const int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); code_buffers_size += c1_count * Compiler::code_buffer_size(); #endif #ifdef COMPILER2 // C2 scratch buffers (see Compile::init_scratch_buffer_blob()) const int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); // Initial size of constant table (this may be increased if a compiled method needs more space) code_buffers_size += c2_count * C2Compiler::initial_code_buffer_size(); #endif // Calculate default CodeHeap sizes if not set by user if (!FLAG_IS_CMDLINE(NonNMethodCodeHeapSize) && !FLAG_IS_CMDLINE(ProfiledCodeHeapSize) && !FLAG_IS_CMDLINE(NonProfiledCodeHeapSize)) { // Increase default NonNMethodCodeHeapSize to account for compiler buffers FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, NonNMethodCodeHeapSize + code_buffers_size); // Check if we have enough space for the non-nmethod code heap if (ReservedCodeCacheSize > NonNMethodCodeHeapSize) { // Use the default value for NonNMethodCodeHeapSize and one half of the // remaining size for non-profiled methods and one half for profiled methods size_t remaining_size = ReservedCodeCacheSize - NonNMethodCodeHeapSize; size_t profiled_size = remaining_size / 2; size_t non_profiled_size = remaining_size - profiled_size; FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, profiled_size); FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, non_profiled_size); } else { // Use all space for the non-nmethod heap and set other heaps to minimal size FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, ReservedCodeCacheSize - os::vm_page_size() * 2); FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, os::vm_page_size()); FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, os::vm_page_size()); } } // We do not need the profiled CodeHeap, use all space for the non-profiled CodeHeap if(!heap_available(CodeBlobType::MethodProfiled)) { FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, NonProfiledCodeHeapSize + ProfiledCodeHeapSize); FLAG_SET_ERGO(uintx, ProfiledCodeHeapSize, 0); } // We do not need the non-profiled CodeHeap, use all space for the non-nmethod CodeHeap if(!heap_available(CodeBlobType::MethodNonProfiled)) { FLAG_SET_ERGO(uintx, NonNMethodCodeHeapSize, NonNMethodCodeHeapSize + NonProfiledCodeHeapSize); FLAG_SET_ERGO(uintx, NonProfiledCodeHeapSize, 0); } // Make sure we have enough space for VM internal code uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); if (NonNMethodCodeHeapSize < (min_code_cache_size + code_buffers_size)) { vm_exit_during_initialization("Not enough space in non-nmethod code heap to run VM."); } guarantee(NonProfiledCodeHeapSize + ProfiledCodeHeapSize + NonNMethodCodeHeapSize <= ReservedCodeCacheSize, "Size check"); // Align CodeHeaps size_t alignment = heap_alignment(); size_t non_method_size = align_size_up(NonNMethodCodeHeapSize, alignment); size_t profiled_size = align_size_down(ProfiledCodeHeapSize, alignment); // Reserve one continuous chunk of memory for CodeHeaps and split it into // parts for the individual heaps. The memory layout looks like this: // ---------- high ----------- // Non-profiled nmethods // Profiled nmethods // Non-nmethods // ---------- low ------------ ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize); ReservedSpace non_method_space = rs.first_part(non_method_size); ReservedSpace rest = rs.last_part(non_method_size); ReservedSpace profiled_space = rest.first_part(profiled_size); ReservedSpace non_profiled_space = rest.last_part(profiled_size); // Non-nmethods (stubs, adapters, ...) add_heap(non_method_space, "CodeHeap 'non-nmethods'", CodeBlobType::NonNMethod); // Tier 2 and tier 3 (profiled) methods add_heap(profiled_space, "CodeHeap 'profiled nmethods'", CodeBlobType::MethodProfiled); // Tier 1 and tier 4 (non-profiled) methods and native methods add_heap(non_profiled_space, "CodeHeap 'non-profiled nmethods'", CodeBlobType::MethodNonProfiled); }
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 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 (aligned_initial_heap_size != InitialHeapSize) { FLAG_SET_ERGO(uintx, InitialHeapSize, aligned_initial_heap_size); } 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"); } 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)); DEBUG_ONLY(CollectorPolicy::assert_flags();) }
void GenCollectorPolicy::initialize_flags() { CollectorPolicy::initialize_flags(); assert(_gen_alignment != 0, "Generation alignment not set up properly"); assert(_heap_alignment >= _gen_alignment, "heap_alignment: " SIZE_FORMAT " less than gen_alignment: " SIZE_FORMAT, _heap_alignment, _gen_alignment); assert(_gen_alignment % _space_alignment == 0, "gen_alignment: " SIZE_FORMAT " not aligned by space_alignment: " SIZE_FORMAT, _gen_alignment, _space_alignment); assert(_heap_alignment % _gen_alignment == 0, "heap_alignment: " SIZE_FORMAT " not aligned by gen_alignment: " SIZE_FORMAT, _heap_alignment, _gen_alignment); // All generational heaps have a young gen; handle those flags here // Make sure the heap is large enough for two generations size_t smallest_new_size = young_gen_size_lower_bound(); size_t smallest_heap_size = align_size_up(smallest_new_size + old_gen_size_lower_bound(), _heap_alignment); if (MaxHeapSize < smallest_heap_size) { FLAG_SET_ERGO(size_t, 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 < smallest_heap_size) { _min_heap_byte_size = smallest_heap_size; if (InitialHeapSize < _min_heap_byte_size) { FLAG_SET_ERGO(size_t, InitialHeapSize, smallest_heap_size); _initial_heap_byte_size = smallest_heap_size; } } // Make sure NewSize allows an old generation to fit even if set on the command line if (FLAG_IS_CMDLINE(NewSize) && NewSize >= _initial_heap_byte_size) { log_warning(gc, ergo)("NewSize was set larger than initial heap size, will use initial heap size."); FLAG_SET_ERGO(size_t, NewSize, bound_minus_alignment(NewSize, _initial_heap_byte_size)); } // Now take the actual NewSize into account. We will silently increase NewSize // if the user specified a smaller or unaligned value. size_t bounded_new_size = bound_minus_alignment(NewSize, MaxHeapSize); bounded_new_size = MAX2(smallest_new_size, (size_t)align_size_down(bounded_new_size, _gen_alignment)); if (bounded_new_size != NewSize) { FLAG_SET_ERGO(size_t, NewSize, bounded_new_size); } _min_young_size = smallest_new_size; _initial_young_size = NewSize; if (!FLAG_IS_DEFAULT(MaxNewSize)) { if (MaxNewSize >= MaxHeapSize) { // Make sure there is room for an old generation size_t smaller_max_new_size = MaxHeapSize - _gen_alignment; if (FLAG_IS_CMDLINE(MaxNewSize)) { log_warning(gc, ergo)("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, smaller_max_new_size/K); } FLAG_SET_ERGO(size_t, MaxNewSize, smaller_max_new_size); if (NewSize > MaxNewSize) { FLAG_SET_ERGO(size_t, NewSize, MaxNewSize); _initial_young_size = NewSize; } } else if (MaxNewSize < _initial_young_size) { FLAG_SET_ERGO(size_t, MaxNewSize, _initial_young_size); } else if (!is_size_aligned(MaxNewSize, _gen_alignment)) { FLAG_SET_ERGO(size_t, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment)); } _max_young_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)) { log_warning(gc, ergo)("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, NewSize/K); } FLAG_SET_ERGO(size_t, MaxNewSize, NewSize); _max_young_size = MaxNewSize; } if (SurvivorRatio < 1 || NewRatio < 1) { vm_exit_during_initialization("Invalid young gen ratio specified"); } if (OldSize < old_gen_size_lower_bound()) { FLAG_SET_ERGO(size_t, OldSize, old_gen_size_lower_bound()); } if (!is_size_aligned(OldSize, _gen_alignment)) { FLAG_SET_ERGO(size_t, 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(size_t, MaxHeapSize, calculated_heapsize); _max_heap_byte_size = MaxHeapSize; FLAG_SET_ERGO(size_t, InitialHeapSize, calculated_heapsize); _initial_heap_byte_size = InitialHeapSize; } // Adjust NewSize and OldSize or MaxHeapSize to match each other if (NewSize + OldSize > MaxHeapSize) { if (FLAG_IS_CMDLINE(MaxHeapSize)) { // Somebody has set a maximum heap size with the intention that we should not // exceed it. Adjust New/OldSize as necessary. size_t calculated_size = NewSize + OldSize; double shrink_factor = (double) MaxHeapSize / calculated_size; size_t smaller_new_size = align_size_down((size_t)(NewSize * shrink_factor), _gen_alignment); FLAG_SET_ERGO(size_t, NewSize, MAX2(young_gen_size_lower_bound(), smaller_new_size)); _initial_young_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(size_t, OldSize, MaxHeapSize - NewSize); } else { FLAG_SET_ERGO(size_t, MaxHeapSize, align_size_up(NewSize + OldSize, _heap_alignment)); _max_heap_byte_size = MaxHeapSize; } } // Update NewSize, if possible, to avoid sizing the young gen too small when only // OldSize is set on the command line. if (FLAG_IS_CMDLINE(OldSize) && !FLAG_IS_CMDLINE(NewSize)) { if (OldSize < _initial_heap_byte_size) { size_t new_size = _initial_heap_byte_size - OldSize; // Need to compare against the flag value for max since _max_young_size // might not have been set yet. if (new_size >= _min_young_size && new_size <= MaxNewSize) { FLAG_SET_ERGO(size_t, NewSize, new_size); _initial_young_size = NewSize; } } } always_do_update_barrier = UseConcMarkSweepGC; DEBUG_ONLY(GenCollectorPolicy::assert_flags();) }