hotspot/src/share/vm/memory/defNewGeneration.cpp
changeset 29684 a36d90acae41
parent 29200 5e480434bef4
child 29687 281ffb2398cd
equal deleted inserted replaced
29683:7675ca064fdc 29684:a36d90acae41
   224   _to_counters = new CSpaceCounters("s1", 2, _max_survivor_size, _to_space,
   224   _to_counters = new CSpaceCounters("s1", 2, _max_survivor_size, _to_space,
   225                                     _gen_counters);
   225                                     _gen_counters);
   226 
   226 
   227   compute_space_boundaries(0, SpaceDecorator::Clear, SpaceDecorator::Mangle);
   227   compute_space_boundaries(0, SpaceDecorator::Clear, SpaceDecorator::Mangle);
   228   update_counters();
   228   update_counters();
   229   _next_gen = NULL;
   229   _old_gen = NULL;
   230   _tenuring_threshold = MaxTenuringThreshold;
   230   _tenuring_threshold = MaxTenuringThreshold;
   231   _pretenure_size_threshold_words = PretenureSizeThreshold >> LogHeapWordSize;
   231   _pretenure_size_threshold_words = PretenureSizeThreshold >> LogHeapWordSize;
   232 
   232 
   233   _gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
   233   _gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
   234 }
   234 }
   381   int next_level = level() + 1;
   381   int next_level = level() + 1;
   382   GenCollectedHeap* gch = GenCollectedHeap::heap();
   382   GenCollectedHeap* gch = GenCollectedHeap::heap();
   383   assert(next_level < gch->_n_gens,
   383   assert(next_level < gch->_n_gens,
   384          "DefNewGeneration cannot be an oldest gen");
   384          "DefNewGeneration cannot be an oldest gen");
   385 
   385 
   386   Generation* next_gen = gch->get_gen(next_level);
   386   Generation* old_gen = gch->old_gen();
   387   size_t old_size = next_gen->capacity();
   387   size_t old_size = old_gen->capacity();
   388   size_t new_size_before = _virtual_space.committed_size();
   388   size_t new_size_before = _virtual_space.committed_size();
   389   size_t min_new_size = spec()->init_size();
   389   size_t min_new_size = spec()->init_size();
   390   size_t max_new_size = reserved().byte_size();
   390   size_t max_new_size = reserved().byte_size();
   391   assert(min_new_size <= new_size_before &&
   391   assert(min_new_size <= new_size_before &&
   392          new_size_before <= max_new_size,
   392          new_size_before <= max_new_size,
   566 
   566 
   567   _gc_timer->register_gc_start();
   567   _gc_timer->register_gc_start();
   568   DefNewTracer gc_tracer;
   568   DefNewTracer gc_tracer;
   569   gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
   569   gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
   570 
   570 
   571   _next_gen = gch->next_gen(this);
   571   _old_gen = gch->old_gen();
   572 
   572 
   573   // If the next generation is too full to accommodate promotion
   573   // If the next generation is too full to accommodate promotion
   574   // from this generation, pass on collection; let the next generation
   574   // from this generation, pass on collection; let the next generation
   575   // do it.
   575   // do it.
   576   if (!collection_attempt_is_safe()) {
   576   if (!collection_attempt_is_safe()) {
   686     swap_spaces();   // For uniformity wrt ParNewGeneration.
   686     swap_spaces();   // For uniformity wrt ParNewGeneration.
   687     from()->set_next_compaction_space(to());
   687     from()->set_next_compaction_space(to());
   688     gch->set_incremental_collection_failed();
   688     gch->set_incremental_collection_failed();
   689 
   689 
   690     // Inform the next generation that a promotion failure occurred.
   690     // Inform the next generation that a promotion failure occurred.
   691     _next_gen->promotion_failure_occurred();
   691     _old_gen->promotion_failure_occurred();
   692     gc_tracer.report_promotion_failed(_promotion_failed_info);
   692     gc_tracer.report_promotion_failed(_promotion_failed_info);
   693 
   693 
   694     // Reset the PromotionFailureALot counters.
   694     // Reset the PromotionFailureALot counters.
   695     NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();)
   695     NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();)
   696   }
   696   }
   791     obj = (oop) to()->allocate_aligned(s);
   791     obj = (oop) to()->allocate_aligned(s);
   792   }
   792   }
   793 
   793 
   794   // Otherwise try allocating obj tenured
   794   // Otherwise try allocating obj tenured
   795   if (obj == NULL) {
   795   if (obj == NULL) {
   796     obj = _next_gen->promote(old, s);
   796     obj = _old_gen->promote(old, s);
   797     if (obj == NULL) {
   797     if (obj == NULL) {
   798       handle_promotion_failure(old);
   798       handle_promotion_failure(old);
   799       return old;
   799       return old;
   800     }
   800     }
   801   } else {
   801   } else {
   896     if (Verbose && PrintGCDetails) {
   896     if (Verbose && PrintGCDetails) {
   897       gclog_or_tty->print(" :: to is not empty :: ");
   897       gclog_or_tty->print(" :: to is not empty :: ");
   898     }
   898     }
   899     return false;
   899     return false;
   900   }
   900   }
   901   if (_next_gen == NULL) {
   901   if (_old_gen == NULL) {
   902     GenCollectedHeap* gch = GenCollectedHeap::heap();
   902     GenCollectedHeap* gch = GenCollectedHeap::heap();
   903     _next_gen = gch->next_gen(this);
   903     _old_gen = gch->old_gen();
   904   }
   904   }
   905   return _next_gen->promotion_attempt_is_safe(used());
   905   return _old_gen->promotion_attempt_is_safe(used());
   906 }
   906 }
   907 
   907 
   908 void DefNewGeneration::gc_epilogue(bool full) {
   908 void DefNewGeneration::gc_epilogue(bool full) {
   909   DEBUG_ONLY(static bool seen_incremental_collection_failed = false;)
   909   DEBUG_ONLY(static bool seen_incremental_collection_failed = false;)
   910 
   910 
  1020 // Moved from inline file as they are not called inline
  1020 // Moved from inline file as they are not called inline
  1021 CompactibleSpace* DefNewGeneration::first_compaction_space() const {
  1021 CompactibleSpace* DefNewGeneration::first_compaction_space() const {
  1022   return eden();
  1022   return eden();
  1023 }
  1023 }
  1024 
  1024 
  1025 HeapWord* DefNewGeneration::allocate(size_t word_size,
  1025 HeapWord* DefNewGeneration::allocate(size_t word_size, bool is_tlab) {
  1026                                      bool is_tlab) {
       
  1027   // This is the slow-path allocation for the DefNewGeneration.
  1026   // This is the slow-path allocation for the DefNewGeneration.
  1028   // Most allocations are fast-path in compiled code.
  1027   // Most allocations are fast-path in compiled code.
  1029   // We try to allocate from the eden.  If that works, we are happy.
  1028   // We try to allocate from the eden.  If that works, we are happy.
  1030   // Note that since DefNewGeneration supports lock-free allocation, we
  1029   // Note that since DefNewGeneration supports lock-free allocation, we
  1031   // have to use it here, as well.
  1030   // have to use it here, as well.
  1032   HeapWord* result = eden()->par_allocate(word_size);
  1031   HeapWord* result = eden()->par_allocate(word_size);
  1033   if (result != NULL) {
  1032   if (result != NULL) {
  1034     if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
  1033     if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
  1035       _next_gen->sample_eden_chunk();
  1034       _old_gen->sample_eden_chunk();
  1036     }
  1035     }
  1037   } else {
  1036   } else {
  1038     // If the eden is full and the last collection bailed out, we are running
  1037     // If the eden is full and the last collection bailed out, we are running
  1039     // out of heap space, and we try to allocate the from-space, too.
  1038     // out of heap space, and we try to allocate the from-space, too.
  1040     // allocate_from_space can't be inlined because that would introduce a
  1039     // allocate_from_space can't be inlined because that would introduce a
  1045 }
  1044 }
  1046 
  1045 
  1047 HeapWord* DefNewGeneration::par_allocate(size_t word_size,
  1046 HeapWord* DefNewGeneration::par_allocate(size_t word_size,
  1048                                          bool is_tlab) {
  1047                                          bool is_tlab) {
  1049   HeapWord* res = eden()->par_allocate(word_size);
  1048   HeapWord* res = eden()->par_allocate(word_size);
  1050   if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
  1049   if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
  1051     _next_gen->sample_eden_chunk();
  1050     _old_gen->sample_eden_chunk();
  1052   }
  1051   }
  1053   return res;
  1052   return res;
  1054 }
  1053 }
  1055 
  1054 
  1056 size_t DefNewGeneration::tlab_capacity() const {
  1055 size_t DefNewGeneration::tlab_capacity() const {