--- old/src/share/vm/memory/collectorPolicy.cpp 2014-10-17 15:27:15.000000000 +0200 +++ new/src/share/vm/memory/collectorPolicy.cpp 2014-10-17 15:27:15.000000000 +0200 @@ -602,7 +602,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 +616,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 +706,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 +716,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"); @@ -892,7 +896,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();