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	Wed Jan 15 01:41:51 2014
--- new/src/share/vm/memory/collectorPolicy.cpp	Wed Jan 15 01:41:51 2014

*** 43,53 **** --- 43,53 ---- #if INCLUDE_ALL_GCS #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" #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),
*** 186,204 **** --- 186,204 ---- // Parallel GC does its own alignment of the generations to avoid requiring a // large page (256M on some platforms) for the permanent generation. The // other collectors should also be updated to do their own alignment and then // this use of lcm() should be removed. if (UseLargePages && !UseParallelGC) { ! // in presence of large pages we have to make sure that our ! // In presence of large pages we have to make sure that our // alignment is large page aware alignment = lcm(os::large_page_size(), alignment); } return alignment; } - // GenCollectorPolicy methods. GenCollectorPolicy::GenCollectorPolicy() : _min_gen0_size(0), _initial_gen0_size(0), _max_gen0_size(0),
*** 376,389 **** --- 376,389 ---- _max_heap_byte_size = MaxHeapSize; FLAG_SET_ERGO(uintx, InitialHeapSize, calculated_heapsize); _initial_heap_byte_size = InitialHeapSize; } // adjust max heap size if necessary + // Adjust NewSize and OldSize or MaxHeapSize to match each other if (NewSize + OldSize > MaxHeapSize) { if (_max_heap_size_cmdline) { ! // somebody set a maximum heap size with the intention that we should not ! // Somebody has set a maximum heap size with the intention that we should not // exceed it. Adjust New/OldSize as necessary. uintx calculated_size = NewSize + OldSize; double shrink_factor = (double) MaxHeapSize / calculated_size; 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));
*** 440,452 **** --- 440,451 ---- // 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 // the generations minimum and initial must be the // same as its maximum. + // 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;
*** 464,475 **** --- 463,473 ---- 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. // 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); }
*** 484,503 **** --- 482,500 ---- _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. // 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) {
*** 539,549 **** --- 536,546 ---- } 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.
*** 551,566 **** --- 548,563 ---- 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 = 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
*** 568,585 **** --- 565,582 ---- _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 has been explicitly set on the command line. Use the // OldSize and then determine the consequences. _min_gen1_size = MIN2(OldSize, _min_heap_byte_size - _min_gen0_size); _initial_gen1_size = OldSize; // If the user has explicitly set an OldSize that is inconsistent // with other command line flags, issue a warning. ! // The generation minimums and the overall heap mimimum should ! // The generation minimums and the overall heap minimum 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);
*** 597,620 **** --- 594,617 ---- 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 + // The same as above for the old gen 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 + // 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); // Write back to flags if necessary if (NewSize != _initial_gen0_size) {
*** 651,664 **** --- 648,660 ---- // 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 ! HandleMark hm; // Discard any handles allocated in each iteration. // First allocation attempt is lock-free. Generation *gen0 = gch->get_gen(0); assert(gen0->supports_inline_contig_alloc(), "Otherwise, must do alloc within heap lock");
*** 667,677 **** --- 663,673 ---- if (result != NULL) { assert(gch->is_in_reserved(result), "result not in heap"); return result; } } ! unsigned int gc_count_before; // read inside the Heap_lock locked region ! unsigned int gc_count_before; // Read inside the Heap_lock locked region. { MutexLocker ml(Heap_lock); if (PrintGC && Verbose) { gclog_or_tty->print_cr("TwoGenerationCollectorPolicy::mem_allocate_work:" " attempting locked slow path allocation");
*** 686,708 **** --- 682,704 ---- return result; } if (GC_locker::is_active_and_needs_gc()) { if (is_tlab) { ! return NULL; // Caller will retry allocating individual object. } if (!gch->is_maximal_no_gc()) { ! // Try and expand heap to satisfy request. result = expand_heap_and_allocate(size, is_tlab); // result could be null if we are out of space + // Result could be null if we are out of space. if (result != NULL) { return result; } } if (gclocker_stalled_count > GCLockerRetryAllocationCount) { ! return NULL; // we didn't get to do a GC and we didn't get any memory ! return NULL; // We didn't get to do a GC and we didn't get any memory. } // If this thread is not in a jni critical section, we stall // the requestor until the critical section has cleared and // GC allowed. When the critical section clears, a GC is
*** 733,743 **** --- 729,739 ---- 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"); ! continue; // retry and/or stall as necessary ! continue; // Retry and/or stall as necessary. } // Allocation has failed and a collection // has been done. If the gc time limit was exceeded the // this time, return NULL so that an out-of-memory
*** 794,804 **** --- 790,800 ---- // GC locker is active; instead of a collection we will attempt // to expand the heap, if there's room for expansion. if (!gch->is_maximal_no_gc()) { result = expand_heap_and_allocate(size, is_tlab); } ! return result; // could be null if we are out of space ! return result; // Could be null if we are out of space. } else if (!gch->incremental_collection_will_fail(false /* don't consult_young */)) { // Do an incremental collection. gch->do_collection(false /* full */, false /* clear_all_soft_refs */, size /* size */,
*** 916,929 **** --- 912,923 ---- gc_count, full_gc_count, GCCause::_metadata_GC_threshold); VMThread::execute(&op); ! // If GC was locked out, try again. Check // before checking success because the prologue // could have succeeded and the GC still have // been locked out. ! // If GC was locked out, try again. Check before checking success because the + // prologue could have succeeded and the GC still have been locked out. if (op.gc_locked()) { continue; } if (op.prologue_succeeded()) {
*** 980,990 **** --- 974,984 ---- vm_exit_during_initialization("Unable to allocate gen spec"); } } void MarkSweepPolicy::initialize_gc_policy_counters() { // initialize the policy counters - 2 collectors, 3 generations + // Initialize the policy counters - 2 collectors, 3 generations. if (UseParNewGC) { _gc_policy_counters = new GCPolicyCounters("ParNew:MSC", 2, 3); } else { _gc_policy_counters = new GCPolicyCounters("Copy:MSC", 2, 3); }

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