src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

changeset 3809
1d478c993020
parent 3767
9d679effd28c
child 3812
bbc900c2482a
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon May 21 14:59:59 2012 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue May 29 10:18:02 2012 -0700
     1.3 @@ -952,9 +952,18 @@
     1.4          }
     1.5          should_try_gc = false;
     1.6        } else {
     1.7 -        // Read the GC count while still holding the Heap_lock.
     1.8 -        gc_count_before = total_collections();
     1.9 -        should_try_gc = true;
    1.10 +        // The GCLocker may not be active but the GCLocker initiated
    1.11 +        // GC may not yet have been performed (GCLocker::needs_gc()
    1.12 +        // returns true). In this case we do not try this GC and
    1.13 +        // wait until the GCLocker initiated GC is performed, and
    1.14 +        // then retry the allocation.
    1.15 +        if (GC_locker::needs_gc()) {
    1.16 +          should_try_gc = false;
    1.17 +        } else {
    1.18 +          // Read the GC count while still holding the Heap_lock.
    1.19 +          gc_count_before = total_collections();
    1.20 +          should_try_gc = true;
    1.21 +        }
    1.22        }
    1.23      }
    1.24  
    1.25 @@ -975,6 +984,9 @@
    1.26          return NULL;
    1.27        }
    1.28      } else {
    1.29 +      // The GCLocker is either active or the GCLocker initiated
    1.30 +      // GC has not yet been performed. Stall until it is and
    1.31 +      // then retry the allocation.
    1.32        GC_locker::stall_until_clear();
    1.33      }
    1.34  
    1.35 @@ -1054,9 +1066,18 @@
    1.36        if (GC_locker::is_active_and_needs_gc()) {
    1.37          should_try_gc = false;
    1.38        } else {
    1.39 -        // Read the GC count while still holding the Heap_lock.
    1.40 -        gc_count_before = total_collections();
    1.41 -        should_try_gc = true;
    1.42 +         // The GCLocker may not be active but the GCLocker initiated
    1.43 +        // GC may not yet have been performed (GCLocker::needs_gc()
    1.44 +        // returns true). In this case we do not try this GC and
    1.45 +        // wait until the GCLocker initiated GC is performed, and
    1.46 +        // then retry the allocation.
    1.47 +        if (GC_locker::needs_gc()) {
    1.48 +          should_try_gc = false;
    1.49 +        } else {
    1.50 +          // Read the GC count while still holding the Heap_lock.
    1.51 +          gc_count_before = total_collections();
    1.52 +          should_try_gc = true;
    1.53 +        }
    1.54        }
    1.55      }
    1.56  
    1.57 @@ -1081,6 +1102,9 @@
    1.58          return NULL;
    1.59        }
    1.60      } else {
    1.61 +      // The GCLocker is either active or the GCLocker initiated
    1.62 +      // GC has not yet been performed. Stall until it is and
    1.63 +      // then retry the allocation.
    1.64        GC_locker::stall_until_clear();
    1.65      }
    1.66  

mercurial