src/share/vm/memory/defNewGeneration.cpp

changeset 2336
6cd6d394f280
parent 2314
f95d63e2154a
child 2380
74ee0db180fa
     1.1 --- a/src/share/vm/memory/defNewGeneration.cpp	Tue Dec 07 16:44:34 2010 -0800
     1.2 +++ b/src/share/vm/memory/defNewGeneration.cpp	Tue Dec 07 21:55:53 2010 -0800
     1.3 @@ -483,16 +483,17 @@
     1.4  // so we try to allocate the from-space, too.
     1.5  HeapWord* DefNewGeneration::allocate_from_space(size_t size) {
     1.6    HeapWord* result = NULL;
     1.7 -  if (PrintGC && Verbose) {
     1.8 +  if (Verbose && PrintGCDetails) {
     1.9      gclog_or_tty->print("DefNewGeneration::allocate_from_space(%u):"
    1.10 -                  "  will_fail: %s"
    1.11 -                  "  heap_lock: %s"
    1.12 -                  "  free: " SIZE_FORMAT,
    1.13 -                  size,
    1.14 -               GenCollectedHeap::heap()->incremental_collection_will_fail() ? "true" : "false",
    1.15 -               Heap_lock->is_locked() ? "locked" : "unlocked",
    1.16 -               from()->free());
    1.17 -    }
    1.18 +                        "  will_fail: %s"
    1.19 +                        "  heap_lock: %s"
    1.20 +                        "  free: " SIZE_FORMAT,
    1.21 +                        size,
    1.22 +                        GenCollectedHeap::heap()->incremental_collection_will_fail(false /* don't consult_young */) ?
    1.23 +                          "true" : "false",
    1.24 +                        Heap_lock->is_locked() ? "locked" : "unlocked",
    1.25 +                        from()->free());
    1.26 +  }
    1.27    if (should_allocate_from_space() || GC_locker::is_active_and_needs_gc()) {
    1.28      if (Heap_lock->owned_by_self() ||
    1.29          (SafepointSynchronize::is_at_safepoint() &&
    1.30 @@ -534,6 +535,9 @@
    1.31    // from this generation, pass on collection; let the next generation
    1.32    // do it.
    1.33    if (!collection_attempt_is_safe()) {
    1.34 +    if (Verbose && PrintGCDetails) {
    1.35 +      gclog_or_tty->print(" :: Collection attempt not safe :: ");
    1.36 +    }
    1.37      gch->set_incremental_collection_failed(); // Slight lie: we did not even attempt one
    1.38      return;
    1.39    }
    1.40 @@ -821,6 +825,9 @@
    1.41  
    1.42  bool DefNewGeneration::collection_attempt_is_safe() {
    1.43    if (!to()->is_empty()) {
    1.44 +    if (Verbose && PrintGCDetails) {
    1.45 +      gclog_or_tty->print(" :: to is not empty :: ");
    1.46 +    }
    1.47      return false;
    1.48    }
    1.49    if (_next_gen == NULL) {
    1.50 @@ -843,10 +850,18 @@
    1.51    GenCollectedHeap* gch = GenCollectedHeap::heap();
    1.52    if (full) {
    1.53      DEBUG_ONLY(seen_incremental_collection_failed = false;)
    1.54 -    if (!collection_attempt_is_safe()) {
    1.55 +    if (!collection_attempt_is_safe() && !_eden_space->is_empty()) {
    1.56 +      if (Verbose && PrintGCDetails) {
    1.57 +        gclog_or_tty->print("DefNewEpilogue: cause(%s), full, not safe, set_failed, set_alloc_from, clear_seen",
    1.58 +                            GCCause::to_string(gch->gc_cause()));
    1.59 +      }
    1.60        gch->set_incremental_collection_failed(); // Slight lie: a full gc left us in that state
    1.61        set_should_allocate_from_space(); // we seem to be running out of space
    1.62      } else {
    1.63 +      if (Verbose && PrintGCDetails) {
    1.64 +        gclog_or_tty->print("DefNewEpilogue: cause(%s), full, safe, clear_failed, clear_alloc_from, clear_seen",
    1.65 +                            GCCause::to_string(gch->gc_cause()));
    1.66 +      }
    1.67        gch->clear_incremental_collection_failed(); // We just did a full collection
    1.68        clear_should_allocate_from_space(); // if set
    1.69      }
    1.70 @@ -860,11 +875,20 @@
    1.71      // a full collection in between.
    1.72      if (!seen_incremental_collection_failed &&
    1.73          gch->incremental_collection_failed()) {
    1.74 +      if (Verbose && PrintGCDetails) {
    1.75 +        gclog_or_tty->print("DefNewEpilogue: cause(%s), not full, not_seen_failed, failed, set_seen_failed",
    1.76 +                            GCCause::to_string(gch->gc_cause()));
    1.77 +      }
    1.78        seen_incremental_collection_failed = true;
    1.79      } else if (seen_incremental_collection_failed) {
    1.80 -      assert(gch->gc_cause() == GCCause::_scavenge_alot || !gch->incremental_collection_failed(),
    1.81 +      if (Verbose && PrintGCDetails) {
    1.82 +        gclog_or_tty->print("DefNewEpilogue: cause(%s), not full, seen_failed, will_clear_seen_failed",
    1.83 +                            GCCause::to_string(gch->gc_cause()));
    1.84 +      }
    1.85 +      assert(gch->gc_cause() == GCCause::_scavenge_alot ||
    1.86 +             (gch->gc_cause() == GCCause::_java_lang_system_gc && UseConcMarkSweepGC && ExplicitGCInvokesConcurrent) ||
    1.87 +             !gch->incremental_collection_failed(),
    1.88               "Twice in a row");
    1.89 -
    1.90        seen_incremental_collection_failed = false;
    1.91      }
    1.92  #endif // ASSERT

mercurial