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	Fri Oct 17 16:28:40 2014
--- new/src/share/vm/memory/collectorPolicy.cpp	Fri Oct 17 16:28:40 2014

*** 189,203 **** --- 189,204 ---- GenCollectorPolicy::GenCollectorPolicy() : _min_young_size(0), _initial_young_size(0), _max_young_size(0), _gen_alignment(0), _min_old_size(0), _initial_old_size(0), _max_old_size(0), ! _generations(NULL) ! _gen_alignment(0), + _young_gen_spec(NULL), + _old_gen_spec(NULL) {} size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) { return align_size_down_bounded(base_size / (NewRatio + 1), _gen_alignment); }
*** 600,610 **** --- 601,611 ---- // 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 *young = gch->get_gen(0); ! Generation *young = gch->young_gen(); assert(young->supports_inline_contig_alloc(), "Otherwise, must do alloc within heap lock"); if (young->should_allocate(size, is_tlab)) { result = young->par_allocate(size, is_tlab); if (result != NULL) {
*** 614,624 **** --- 615,625 ---- } 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:" ! gclog_or_tty->print_cr("GenCollectorPolicy::mem_allocate_work:" " attempting locked slow path allocation"); } // Note that only large objects get a shot at being // allocated in later generations. bool first_only = ! should_try_older_generation_allocation(size);
*** 704,727 **** --- 705,732 ---- } // Give a warning if we seem to be looping forever. if ((QueuedAllocationWarningCount > 0) && (try_count % QueuedAllocationWarningCount == 0)) { ! warning("TwoGenerationCollectorPolicy::mem_allocate_work retries %d times \n\t" ! warning("GenCollectorPolicy::mem_allocate_work retries %d times \n\t" " size=" SIZE_FORMAT " %s", try_count, size, is_tlab ? "(TLAB)" : ""); } } } HeapWord* GenCollectorPolicy::expand_heap_and_allocate(size_t size, bool is_tlab) { GenCollectedHeap *gch = GenCollectedHeap::heap(); HeapWord* result = NULL; for (int i = number_of_generations() - 1; i >= 0 && result == NULL; i--) { Generation *gen = gch->get_gen(i); if (gen->should_allocate(size, is_tlab)) { result = gen->expand_and_allocate(size, is_tlab); + Generation *old = gch->old_gen(); + if (old->should_allocate(size, is_tlab)) { + result = old->expand_and_allocate(size, is_tlab); + } + if (result == NULL) { + Generation *young = gch->young_gen(); + if (young->should_allocate(size, is_tlab)) { + result = young->expand_and_allocate(size, is_tlab); } } assert(result == NULL || gch->is_in_reserved(result), "result not in heap"); return result; }
*** 744,754 **** --- 749,759 ---- // Do an incremental collection. gch->do_collection(false /* full */, false /* clear_all_soft_refs */, size /* size */, is_tlab /* is_tlab */, ! number_of_generations() - 1 /* max_level */); ! Generation::Old /* max_gen */); } else { if (Verbose && PrintGCDetails) { gclog_or_tty->print(" :: Trying full because partial may fail :: "); } // Try a full collection; see delta for bug id 6266275
*** 757,767 **** --- 762,772 ---- // such allocation moved out of the safepoint path. gch->do_collection(true /* full */, false /* clear_all_soft_refs */, size /* size */, is_tlab /* is_tlab */, ! number_of_generations() - 1 /* max_level */); ! Generation::Old /* max_gen */); } result = gch->attempt_allocation(size, is_tlab, false /*first_only*/); if (result != NULL) {
*** 785,795 **** --- 790,800 ---- gch->do_collection(true /* full */, true /* clear_all_soft_refs */, size /* size */, is_tlab /* is_tlab */, ! number_of_generations() - 1 /* max_level */); ! Generation::Old /* max_gen */); } result = gch->attempt_allocation(size, is_tlab, false /* first_only */); if (result != NULL) { assert(gch->is_in_reserved(result), "result not in heap");
*** 890,900 **** --- 895,905 ---- // was a full collection because a partial collection (would // have) failed and is likely to fail again bool GenCollectorPolicy::should_try_older_generation_allocation( size_t word_size) const { GenCollectedHeap* gch = GenCollectedHeap::heap(); ! size_t young_capacity = gch->get_gen(0)->capacity_before_gc(); ! size_t young_capacity = gch->young_gen()->capacity_before_gc(); return (word_size > heap_word_size(young_capacity)) || GC_locker::is_active_and_needs_gc() || gch->incremental_collection_failed(); }
*** 907,930 **** --- 912,929 ---- _space_alignment = _gen_alignment = (uintx)Generation::GenGrain; _heap_alignment = compute_heap_alignment(); } void MarkSweepPolicy::initialize_generations() { _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL); if (_generations == NULL) { vm_exit_during_initialization("Unable to allocate gen spec"); } if (UseParNewGC) { ! _generations[0] = new GenerationSpec(Generation::ParNew, _initial_young_size, _max_young_size); ! _young_gen_spec = new GenerationSpec(Generation::ParNew, _initial_young_size, _max_young_size, _gen_alignment); } else { ! _generations[0] = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size); ! _young_gen_spec = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size, _gen_alignment); } ! _generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size); ! _old_gen_spec = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size, _gen_alignment); ! if (_generations[0] == NULL || _generations[1] == NULL) { ! if (_young_gen_spec == NULL || _old_gen_spec == NULL) { vm_exit_during_initialization("Unable to allocate gen spec"); } } void MarkSweepPolicy::initialize_gc_policy_counters() {

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