src/share/vm/memory/genCollectedHeap.cpp

changeset 9806
758c07667682
parent 9703
2fdf635bcf28
parent 9787
9f28a4cac6d9
child 9931
fd44df5e3bc3
     1.1 --- a/src/share/vm/memory/genCollectedHeap.cpp	Tue Feb 04 17:38:01 2020 +0800
     1.2 +++ b/src/share/vm/memory/genCollectedHeap.cpp	Tue Feb 04 18:13:14 2020 +0800
     1.3 @@ -796,8 +796,11 @@
     1.4  #else  // INCLUDE_ALL_GCS
     1.5      ShouldNotReachHere();
     1.6  #endif // INCLUDE_ALL_GCS
     1.7 -  } else if (cause == GCCause::_wb_young_gc) {
     1.8 -    // minor collection for WhiteBox API
     1.9 +  } else if ((cause == GCCause::_wb_young_gc) ||
    1.10 +             (cause == GCCause::_gc_locker)) {
    1.11 +    // minor collection for WhiteBox or GCLocker.
    1.12 +    // _gc_locker collections upgraded by GCLockerInvokesConcurrent
    1.13 +    // are handled above and never discarded.
    1.14      collect(cause, 0);
    1.15    } else {
    1.16  #ifdef ASSERT
    1.17 @@ -835,6 +838,11 @@
    1.18    // Read the GC count while holding the Heap_lock
    1.19    unsigned int gc_count_before      = total_collections();
    1.20    unsigned int full_gc_count_before = total_full_collections();
    1.21 +
    1.22 +  if (GC_locker::should_discard(cause, gc_count_before)) {
    1.23 +    return;
    1.24 +  }
    1.25 +
    1.26    {
    1.27      MutexUnlocker mu(Heap_lock);  // give up heap lock, execute gets it back
    1.28      VM_GenCollectFull op(gc_count_before, full_gc_count_before,
    1.29 @@ -887,24 +895,16 @@
    1.30  
    1.31  void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs,
    1.32                                            int max_level) {
    1.33 -  int local_max_level;
    1.34 -  if (!incremental_collection_will_fail(false /* don't consult_young */) &&
    1.35 -      gc_cause() == GCCause::_gc_locker) {
    1.36 -    local_max_level = 0;
    1.37 -  } else {
    1.38 -    local_max_level = max_level;
    1.39 -  }
    1.40  
    1.41    do_collection(true                 /* full */,
    1.42                  clear_all_soft_refs  /* clear_all_soft_refs */,
    1.43                  0                    /* size */,
    1.44                  false                /* is_tlab */,
    1.45 -                local_max_level      /* max_level */);
    1.46 +                max_level            /* max_level */);
    1.47    // Hack XXX FIX ME !!!
    1.48    // A scavenge may not have been attempted, or may have
    1.49    // been attempted and failed, because the old gen was too full
    1.50 -  if (local_max_level == 0 && gc_cause() == GCCause::_gc_locker &&
    1.51 -      incremental_collection_will_fail(false /* don't consult_young */)) {
    1.52 +  if (gc_cause() == GCCause::_gc_locker && incremental_collection_failed()) {
    1.53      if (PrintGCDetails) {
    1.54        gclog_or_tty->print_cr("GC locker: Trying a full collection "
    1.55                               "because scavenge failed");

mercurial