hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
changeset 2741 34e2a243d69a
parent 2345 3098a48a7240
child 2881 74a1337e4acc
equal deleted inserted replaced
2738:7a72e5ed1d10 2741:34e2a243d69a
   526          (!res->isHumongous() &&
   526          (!res->isHumongous() &&
   527           (!zero_filled ||
   527           (!zero_filled ||
   528            res->zero_fill_state() == HeapRegion::Allocated)),
   528            res->zero_fill_state() == HeapRegion::Allocated)),
   529          "Non-young alloc Regions must be zero filled (and non-H)");
   529          "Non-young alloc Regions must be zero filled (and non-H)");
   530 
   530 
   531   if (G1TraceRegions) {
   531   if (G1PrintRegions) {
   532     if (res != NULL) {
   532     if (res != NULL) {
   533       gclog_or_tty->print_cr("new alloc region %d:["PTR_FORMAT", "PTR_FORMAT"], "
   533       gclog_or_tty->print_cr("new alloc region %d:["PTR_FORMAT", "PTR_FORMAT"], "
   534                              "top "PTR_FORMAT,
   534                              "top "PTR_FORMAT,
   535                              res->hrs_index(), res->bottom(), res->end(), res->top());
   535                              res->hrs_index(), res->bottom(), res->end(), res->top());
   536     }
   536     }
  2280   if (TraceGen0Time || TraceGen1Time) {
  2280   if (TraceGen0Time || TraceGen1Time) {
  2281     // The "G1CollectorPolicy" is keeping track of these stats, so delegate
  2281     // The "G1CollectorPolicy" is keeping track of these stats, so delegate
  2282     // to that.
  2282     // to that.
  2283     g1_policy()->print_tracing_info();
  2283     g1_policy()->print_tracing_info();
  2284   }
  2284   }
  2285   if (SummarizeG1RSStats) {
  2285   if (G1SummarizeRSetStats) {
  2286     g1_rem_set()->print_summary_info();
  2286     g1_rem_set()->print_summary_info();
  2287   }
  2287   }
  2288   if (SummarizeG1ConcMark) {
  2288   if (G1SummarizeConcurrentMark) {
  2289     concurrent_mark()->print_summary_info();
  2289     concurrent_mark()->print_summary_info();
  2290   }
  2290   }
  2291   if (SummarizeG1ZFStats) {
  2291   if (G1SummarizeZFStats) {
  2292     ConcurrentZFThread::print_summary_info();
  2292     ConcurrentZFThread::print_summary_info();
  2293   }
  2293   }
  2294   g1_policy()->print_yg_surv_rate_info();
  2294   g1_policy()->print_yg_surv_rate_info();
  2295 
  2295 
  2296   GCOverheadReporter::printGCOverhead();
  2296   GCOverheadReporter::printGCOverhead();
  3253   preserve_mark_if_necessary(old, m);
  3253   preserve_mark_if_necessary(old, m);
  3254 
  3254 
  3255   HeapRegion* r = heap_region_containing(old);
  3255   HeapRegion* r = heap_region_containing(old);
  3256   if (!r->evacuation_failed()) {
  3256   if (!r->evacuation_failed()) {
  3257     r->set_evacuation_failed(true);
  3257     r->set_evacuation_failed(true);
  3258     if (G1TraceRegions) {
  3258     if (G1PrintRegions) {
  3259       gclog_or_tty->print("evacuation failed in heap region "PTR_FORMAT" "
  3259       gclog_or_tty->print("evacuation failed in heap region "PTR_FORMAT" "
  3260                           "["PTR_FORMAT","PTR_FORMAT")\n",
  3260                           "["PTR_FORMAT","PTR_FORMAT")\n",
  3261                           r, r->bottom(), r->end());
  3261                           r, r->bottom(), r->end());
  3262     }
  3262     }
  3263   }
  3263   }
  3464   static size_t bitmap_word_covers_words() {
  3464   static size_t bitmap_word_covers_words() {
  3465     return BitsPerWord << shifter();
  3465     return BitsPerWord << shifter();
  3466   }
  3466   }
  3467 
  3467 
  3468   static size_t gclab_word_size() {
  3468   static size_t gclab_word_size() {
  3469     return ParallelGCG1AllocBufferSize / HeapWordSize;
  3469     return G1ParallelGCAllocBufferSize / HeapWordSize;
  3470   }
  3470   }
  3471 
  3471 
  3472   static size_t bitmap_size_in_bits() {
  3472   static size_t bitmap_size_in_bits() {
  3473     size_t bits_in_bitmap = gclab_word_size() >> shifter();
  3473     size_t bits_in_bitmap = gclab_word_size() >> shifter();
  3474     // We are going to ensure that the beginning of a word in this
  3474     // We are going to ensure that the beginning of a word in this
  3614   bool        _during_marking;
  3614   bool        _during_marking;
  3615   GCLabBitMap _bitmap;
  3615   GCLabBitMap _bitmap;
  3616 
  3616 
  3617 public:
  3617 public:
  3618   G1ParGCAllocBuffer() :
  3618   G1ParGCAllocBuffer() :
  3619     ParGCAllocBuffer(ParallelGCG1AllocBufferSize / HeapWordSize),
  3619     ParGCAllocBuffer(G1ParallelGCAllocBufferSize / HeapWordSize),
  3620     _during_marking(G1CollectedHeap::heap()->mark_in_progress()),
  3620     _during_marking(G1CollectedHeap::heap()->mark_in_progress()),
  3621     _bitmap(G1CollectedHeap::heap()->reserved_region().start()),
  3621     _bitmap(G1CollectedHeap::heap()->reserved_region().start()),
  3622     _retired(false)
  3622     _retired(false)
  3623   { }
  3623   { }
  3624 
  3624 
  3810 
  3810 
  3811   HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) {
  3811   HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) {
  3812 
  3812 
  3813     HeapWord* obj = NULL;
  3813     HeapWord* obj = NULL;
  3814     if (word_sz * 100 <
  3814     if (word_sz * 100 <
  3815         (size_t)(ParallelGCG1AllocBufferSize / HeapWordSize) *
  3815         (size_t)(G1ParallelGCAllocBufferSize / HeapWordSize) *
  3816                                                   ParallelGCBufferWastePct) {
  3816                                                   ParallelGCBufferWastePct) {
  3817       G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
  3817       G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
  3818       add_to_alloc_buffer_waste(alloc_buf->words_remaining());
  3818       add_to_alloc_buffer_waste(alloc_buf->words_remaining());
  3819       alloc_buf->retire(false, false);
  3819       alloc_buf->retire(false, false);
  3820 
  3820 
  3821       HeapWord* buf =
  3821       HeapWord* buf =
  3822         _g1h->par_allocate_during_gc(purpose, ParallelGCG1AllocBufferSize / HeapWordSize);
  3822         _g1h->par_allocate_during_gc(purpose, G1ParallelGCAllocBufferSize / HeapWordSize);
  3823       if (buf == NULL) return NULL; // Let caller handle allocation failure.
  3823       if (buf == NULL) return NULL; // Let caller handle allocation failure.
  3824       // Otherwise.
  3824       // Otherwise.
  3825       alloc_buf->set_buf(buf);
  3825       alloc_buf->set_buf(buf);
  3826 
  3826 
  3827       obj = alloc_buf->allocate(word_sz);
  3827       obj = alloc_buf->allocate(word_sz);
  4329       double elapsed_ms = (os::elapsedTime()-start)*1000.0;
  4329       double elapsed_ms = (os::elapsedTime()-start)*1000.0;
  4330       double term_ms = pss.term_time()*1000.0;
  4330       double term_ms = pss.term_time()*1000.0;
  4331       _g1h->g1_policy()->record_obj_copy_time(i, elapsed_ms-term_ms);
  4331       _g1h->g1_policy()->record_obj_copy_time(i, elapsed_ms-term_ms);
  4332       _g1h->g1_policy()->record_termination_time(i, term_ms);
  4332       _g1h->g1_policy()->record_termination_time(i, term_ms);
  4333     }
  4333     }
  4334     if (G1UseSurvivorSpace) {
  4334     if (G1UseSurvivorSpaces) {
  4335       _g1h->g1_policy()->record_thread_age_table(pss.age_table());
  4335       _g1h->g1_policy()->record_thread_age_table(pss.age_table());
  4336     }
  4336     }
  4337     _g1h->update_surviving_young_words(pss.surviving_young_words()+1);
  4337     _g1h->update_surviving_young_words(pss.surviving_young_words()+1);
  4338 
  4338 
  4339     // Clean up any par-expanded rem sets.
  4339     // Clean up any par-expanded rem sets.
  4433   double mark_stack_scan_ms = (os::elapsedTime() - ext_roots_end) * 1000.0;
  4433   double mark_stack_scan_ms = (os::elapsedTime() - ext_roots_end) * 1000.0;
  4434   g1_policy()->record_mark_stack_scan_time(worker_i, mark_stack_scan_ms);
  4434   g1_policy()->record_mark_stack_scan_time(worker_i, mark_stack_scan_ms);
  4435 
  4435 
  4436   // XXX What should this be doing in the parallel case?
  4436   // XXX What should this be doing in the parallel case?
  4437   g1_policy()->record_collection_pause_end_CH_strong_roots();
  4437   g1_policy()->record_collection_pause_end_CH_strong_roots();
  4438   if (G1VerifyRemSet) {
       
  4439     // :::: FIXME ::::
       
  4440     // The stupid remembered set doesn't know how to filter out dead
       
  4441     // objects, which the smart one does, and so when it is created
       
  4442     // and then compared the number of entries in each differs and
       
  4443     // the verification code fails.
       
  4444     guarantee(false, "verification code is broken, see note");
       
  4445 
       
  4446     // Let's make sure that the current rem set agrees with the stupidest
       
  4447     // one possible!
       
  4448     bool refs_enabled = ref_processor()->discovery_enabled();
       
  4449     if (refs_enabled) ref_processor()->disable_discovery();
       
  4450     StupidG1RemSet stupid(this);
       
  4451     count_closure.n = 0;
       
  4452     stupid.oops_into_collection_set_do(&count_closure, worker_i);
       
  4453     int stupid_n = count_closure.n;
       
  4454     count_closure.n = 0;
       
  4455     g1_rem_set()->oops_into_collection_set_do(&count_closure, worker_i);
       
  4456     guarantee(count_closure.n == stupid_n, "Old and new rem sets differ.");
       
  4457     gclog_or_tty->print_cr("\nFound %d pointers in heap RS.", count_closure.n);
       
  4458     if (refs_enabled) ref_processor()->enable_discovery();
       
  4459   }
       
  4460   if (scan_so != NULL) {
  4438   if (scan_so != NULL) {
  4461     scan_scan_only_set(scan_so, worker_i);
  4439     scan_scan_only_set(scan_so, worker_i);
  4462   }
  4440   }
  4463   // Now scan the complement of the collection set.
  4441   // Now scan the complement of the collection set.
  4464   if (scan_rs != NULL) {
  4442   if (scan_rs != NULL) {