comparison 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
comparison
equal deleted inserted replaced
4828:851b58c26def 4829:9509c20bba28
1043 1043
1044 // Given that humongous objects are not allocated in young 1044 // Given that humongous objects are not allocated in young
1045 // regions, we'll first try to do the allocation without doing a 1045 // regions, we'll first try to do the allocation without doing a
1046 // collection hoping that there's enough space in the heap. 1046 // collection hoping that there's enough space in the heap.
1047 result = humongous_obj_allocate(word_size); 1047 result = humongous_obj_allocate(word_size);
1048 if (result != NULL) { 1048
1049 return result; 1049 if (result == NULL) {
1050 if (GC_locker::is_active_and_needs_gc()) {
1051 should_try_gc = false;
1052 } else {
1053 // Read the GC count while still holding the Heap_lock.
1054 gc_count_before = SharedHeap::heap()->total_collections();
1055 should_try_gc = true;
1056 }
1050 } 1057 }
1051 1058 }
1052 if (GC_locker::is_active_and_needs_gc()) { 1059
1053 should_try_gc = false; 1060 if (result != NULL) {
1054 } else { 1061 if (g1_policy()->need_to_start_conc_mark("concurrent humongous allocation")) {
1055 // Read the GC count while still holding the Heap_lock. 1062 // We need to release the Heap_lock before we try to call collect
1056 gc_count_before = SharedHeap::heap()->total_collections(); 1063 collect(GCCause::_g1_humongous_allocation);
1057 should_try_gc = true;
1058 } 1064 }
1065 return result;
1059 } 1066 }
1060 1067
1061 if (should_try_gc) { 1068 if (should_try_gc) {
1062 // If we failed to allocate the humongous object, we should try to 1069 // If we failed to allocate the humongous object, we should try to
1063 // do a collection pause (if we're allowed) in case it reclaims 1070 // do a collection pause (if we're allowed) in case it reclaims
1109 1116
1110 if (!isHumongous(word_size)) { 1117 if (!isHumongous(word_size)) {
1111 return _mutator_alloc_region.attempt_allocation_locked(word_size, 1118 return _mutator_alloc_region.attempt_allocation_locked(word_size,
1112 false /* bot_updates */); 1119 false /* bot_updates */);
1113 } else { 1120 } else {
1114 return humongous_obj_allocate(word_size); 1121 HeapWord* result = humongous_obj_allocate(word_size);
1122 if (result != NULL && g1_policy()->need_to_start_conc_mark("STW humongous allocation")) {
1123 g1_policy()->set_initiate_conc_mark_if_possible();
1124 }
1125 return result;
1115 } 1126 }
1116 1127
1117 ShouldNotReachHere(); 1128 ShouldNotReachHere();
1118 } 1129 }
1119 1130
2293 } 2304 }
2294 2305
2295 bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { 2306 bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
2296 return 2307 return
2297 ((cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) || 2308 ((cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) ||
2298 (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent)); 2309 (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent) ||
2310 cause == GCCause::_g1_humongous_allocation);
2299 } 2311 }
2300 2312
2301 #ifndef PRODUCT 2313 #ifndef PRODUCT
2302 void G1CollectedHeap::allocate_dummy_regions() { 2314 void G1CollectedHeap::allocate_dummy_regions() {
2303 // Let's fill up most of the region 2315 // Let's fill up most of the region