Mercurial > hg > truffle
diff src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 4829:9509c20bba28
6976060: G1: humongous object allocations should initiate marking cycles when necessary
Reviewed-by: tonyp, johnc
author | brutisso |
---|---|
date | Mon, 16 Jan 2012 22:10:05 +0100 |
parents | 2ace1c4ee8da |
children | 7ca7be5a6a0b |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Jan 16 11:21:21 2012 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Jan 16 22:10:05 2012 +0100 @@ -1045,17 +1045,24 @@ // regions, we'll first try to do the allocation without doing a // collection hoping that there's enough space in the heap. result = humongous_obj_allocate(word_size); - if (result != NULL) { - return result; + + if (result == NULL) { + if (GC_locker::is_active_and_needs_gc()) { + should_try_gc = false; + } else { + // Read the GC count while still holding the Heap_lock. + gc_count_before = SharedHeap::heap()->total_collections(); + should_try_gc = true; + } } - - if (GC_locker::is_active_and_needs_gc()) { - should_try_gc = false; - } else { - // Read the GC count while still holding the Heap_lock. - gc_count_before = SharedHeap::heap()->total_collections(); - should_try_gc = true; + } + + if (result != NULL) { + if (g1_policy()->need_to_start_conc_mark("concurrent humongous allocation")) { + // We need to release the Heap_lock before we try to call collect + collect(GCCause::_g1_humongous_allocation); } + return result; } if (should_try_gc) { @@ -1111,7 +1118,11 @@ return _mutator_alloc_region.attempt_allocation_locked(word_size, false /* bot_updates */); } else { - return humongous_obj_allocate(word_size); + HeapWord* result = humongous_obj_allocate(word_size); + if (result != NULL && g1_policy()->need_to_start_conc_mark("STW humongous allocation")) { + g1_policy()->set_initiate_conc_mark_if_possible(); + } + return result; } ShouldNotReachHere(); @@ -2295,7 +2306,8 @@ bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { return ((cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) || - (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent)); + (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent) || + cause == GCCause::_g1_humongous_allocation); } #ifndef PRODUCT