--- old/src/share/vm/memory/collectorPolicy.cpp 2014-10-17 16:28:40.000000000 +0200 +++ new/src/share/vm/memory/collectorPolicy.cpp 2014-10-17 16:28:40.000000000 +0200 @@ -191,11 +191,12 @@ _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) { @@ -602,7 +603,7 @@ 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)) { @@ -616,8 +617,8 @@ { MutexLocker ml(Heap_lock); if (PrintGC && Verbose) { - gclog_or_tty->print_cr("TwoGenerationCollectorPolicy::mem_allocate_work:" - " attempting locked slow path allocation"); + 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. @@ -706,7 +707,7 @@ // 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)" : ""); } } @@ -716,10 +717,14 @@ 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"); @@ -746,7 +751,7 @@ 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 :: "); @@ -759,7 +764,7 @@ 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*/); @@ -787,7 +792,7 @@ 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 */); @@ -892,7 +897,7 @@ 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(); @@ -909,20 +914,14 @@ } 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"); } }