src/share/vm/memory/defNewGeneration.cpp

changeset 2243
a7214d79fcf1
parent 2191
894b1d7c7e01
child 2244
c766bae6c14d
     1.1 --- a/src/share/vm/memory/defNewGeneration.cpp	Thu Oct 21 17:29:24 2010 -0700
     1.2 +++ b/src/share/vm/memory/defNewGeneration.cpp	Sat Oct 23 23:03:49 2010 -0700
     1.3 @@ -510,7 +510,7 @@
     1.4    // from this generation, pass on collection; let the next generation
     1.5    // do it.
     1.6    if (!collection_attempt_is_safe()) {
     1.7 -    gch->set_incremental_collection_will_fail();
     1.8 +    gch->set_incremental_collection_failed(); // Slight lie: we did not even attempt one
     1.9      return;
    1.10    }
    1.11    assert(to()->is_empty(), "Else not collection_attempt_is_safe");
    1.12 @@ -596,9 +596,8 @@
    1.13      if (PrintGC && !PrintGCDetails) {
    1.14        gch->print_heap_change(gch_prev_used);
    1.15      }
    1.16 +    assert(!gch->incremental_collection_failed(), "Should be clear");
    1.17    } else {
    1.18 -    assert(HandlePromotionFailure,
    1.19 -      "Should not be here unless promotion failure handling is on");
    1.20      assert(_promo_failure_scan_stack.is_empty(), "post condition");
    1.21      _promo_failure_scan_stack.clear(true); // Clear cached segments.
    1.22  
    1.23 @@ -613,7 +612,7 @@
    1.24      // and from-space.
    1.25      swap_spaces();   // For uniformity wrt ParNewGeneration.
    1.26      from()->set_next_compaction_space(to());
    1.27 -    gch->set_incremental_collection_will_fail();
    1.28 +    gch->set_incremental_collection_failed();
    1.29  
    1.30      // Inform the next generation that a promotion failure occurred.
    1.31      _next_gen->promotion_failure_occurred();
    1.32 @@ -700,12 +699,6 @@
    1.33    if (obj == NULL) {
    1.34      obj = _next_gen->promote(old, s);
    1.35      if (obj == NULL) {
    1.36 -      if (!HandlePromotionFailure) {
    1.37 -        // A failed promotion likely means the MaxLiveObjectEvacuationRatio flag
    1.38 -        // is incorrectly set. In any case, its seriously wrong to be here!
    1.39 -        vm_exit_out_of_memory(s*wordSize, "promotion");
    1.40 -      }
    1.41 -
    1.42        handle_promotion_failure(old);
    1.43        return old;
    1.44      }
    1.45 @@ -812,31 +805,7 @@
    1.46      assert(_next_gen != NULL,
    1.47             "This must be the youngest gen, and not the only gen");
    1.48    }
    1.49 -
    1.50 -  // Decide if there's enough room for a full promotion
    1.51 -  // When using extremely large edens, we effectively lose a
    1.52 -  // large amount of old space.  Use the "MaxLiveObjectEvacuationRatio"
    1.53 -  // flag to reduce the minimum evacuation space requirements. If
    1.54 -  // there is not enough space to evacuate eden during a scavenge,
    1.55 -  // the VM will immediately exit with an out of memory error.
    1.56 -  // This flag has not been tested
    1.57 -  // with collectors other than simple mark & sweep.
    1.58 -  //
    1.59 -  // Note that with the addition of promotion failure handling, the
    1.60 -  // VM will not immediately exit but will undo the young generation
    1.61 -  // collection.  The parameter is left here for compatibility.
    1.62 -  const double evacuation_ratio = MaxLiveObjectEvacuationRatio / 100.0;
    1.63 -
    1.64 -  // worst_case_evacuation is based on "used()".  For the case where this
    1.65 -  // method is called after a collection, this is still appropriate because
    1.66 -  // the case that needs to be detected is one in which a full collection
    1.67 -  // has been done and has overflowed into the young generation.  In that
    1.68 -  // case a minor collection will fail (the overflow of the full collection
    1.69 -  // means there is no space in the old generation for any promotion).
    1.70 -  size_t worst_case_evacuation = (size_t)(used() * evacuation_ratio);
    1.71 -
    1.72 -  return _next_gen->promotion_attempt_is_safe(worst_case_evacuation,
    1.73 -                                              HandlePromotionFailure);
    1.74 +  return _next_gen->promotion_attempt_is_safe(used());
    1.75  }
    1.76  
    1.77  void DefNewGeneration::gc_epilogue(bool full) {
    1.78 @@ -845,14 +814,17 @@
    1.79    // a minimum at the end of a collection.  If it is not, then
    1.80    // the heap is approaching full.
    1.81    GenCollectedHeap* gch = GenCollectedHeap::heap();
    1.82 -  clear_should_allocate_from_space();
    1.83 -  if (collection_attempt_is_safe()) {
    1.84 -    gch->clear_incremental_collection_will_fail();
    1.85 +  if (full) {
    1.86 +    assert(!GC_locker::is_active(), "We should not be executing here");
    1.87 +    if (!collection_attempt_is_safe()) {
    1.88 +      gch->set_incremental_collection_failed(); // Slight lie: a full gc left us in that state
    1.89 +      set_should_allocate_from_space(); // we seem to be running out of space
    1.90 +    } else {
    1.91 +      gch->clear_incremental_collection_failed(); // We just did a full collection
    1.92 +      clear_should_allocate_from_space(); // if set
    1.93 +    }
    1.94    } else {
    1.95 -    gch->set_incremental_collection_will_fail();
    1.96 -    if (full) { // we seem to be running out of space
    1.97 -      set_should_allocate_from_space();
    1.98 -    }
    1.99 +    assert(!gch->incremental_collection_failed(), "Error");
   1.100    }
   1.101  
   1.102    if (ZapUnusedHeapArea) {

mercurial