src/hotspot/share/gc/g1/g1CollectedHeap.cpp
changeset 51494 1906adbef2dc
parent 51488 d14d24d076b7
child 51496 bf6b66fa8bdf
equal deleted inserted replaced
51493:6b5f3f5fd63c 51494:1906adbef2dc
   641         curr_region->set_open_archive();
   641         curr_region->set_open_archive();
   642       } else {
   642       } else {
   643         curr_region->set_closed_archive();
   643         curr_region->set_closed_archive();
   644       }
   644       }
   645       _hr_printer.alloc(curr_region);
   645       _hr_printer.alloc(curr_region);
   646       _old_set.add(curr_region);
   646       _archive_set.add(curr_region);
   647       HeapWord* top;
   647       HeapWord* top;
   648       HeapRegion* next_region;
   648       HeapRegion* next_region;
   649       if (curr_region != last_region) {
   649       if (curr_region != last_region) {
   650         top = curr_region->end();
   650         top = curr_region->end();
   651         next_region = _hrm.next_region_in_heap(curr_region);
   651         next_region = _hrm.next_region_in_heap(curr_region);
   798     HeapRegion* curr_region = start_region;
   798     HeapRegion* curr_region = start_region;
   799     while (curr_region != NULL) {
   799     while (curr_region != NULL) {
   800       guarantee(curr_region->is_archive(),
   800       guarantee(curr_region->is_archive(),
   801                 "Expected archive region at index %u", curr_region->hrm_index());
   801                 "Expected archive region at index %u", curr_region->hrm_index());
   802       uint curr_index = curr_region->hrm_index();
   802       uint curr_index = curr_region->hrm_index();
   803       _old_set.remove(curr_region);
   803       _archive_set.remove(curr_region);
   804       curr_region->set_free();
   804       curr_region->set_free();
   805       curr_region->set_top(curr_region->bottom());
   805       curr_region->set_top(curr_region->bottom());
   806       if (curr_region != last_region) {
   806       if (curr_region != last_region) {
   807         curr_region = _hrm.next_region_in_heap(curr_region);
   807         curr_region = _hrm.next_region_in_heap(curr_region);
   808       } else {
   808       } else {
  1415   _memory_manager("G1 Young Generation", "end of minor GC"),
  1415   _memory_manager("G1 Young Generation", "end of minor GC"),
  1416   _full_gc_memory_manager("G1 Old Generation", "end of major GC"),
  1416   _full_gc_memory_manager("G1 Old Generation", "end of major GC"),
  1417   _eden_pool(NULL),
  1417   _eden_pool(NULL),
  1418   _survivor_pool(NULL),
  1418   _survivor_pool(NULL),
  1419   _old_pool(NULL),
  1419   _old_pool(NULL),
  1420   _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()),
  1420   _old_set("Old Region Set", HeapRegionSetBase::ForOldRegions, new OldRegionSetMtSafeChecker()),
  1421   _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()),
  1421   _archive_set("Archive Region Set", HeapRegionSetBase::ForArchiveRegions, new ArchiveRegionSetMtSafeChecker()),
       
  1422   _humongous_set("Humongous Region Set", HeapRegionSetBase::ForHumongousRegions, new HumongousRegionSetMtSafeChecker()),
  1422   _bot(NULL),
  1423   _bot(NULL),
  1423   _listener(),
  1424   _listener(),
  1424   _hrm(),
  1425   _hrm(),
  1425   _allocator(NULL),
  1426   _allocator(NULL),
  1426   _verifier(NULL),
  1427   _verifier(NULL),
  4591 }
  4592 }
  4592 
  4593 
  4593 #endif // ASSERT
  4594 #endif // ASSERT
  4594 
  4595 
  4595 class TearDownRegionSetsClosure : public HeapRegionClosure {
  4596 class TearDownRegionSetsClosure : public HeapRegionClosure {
  4596 private:
       
  4597   HeapRegionSet *_old_set;
  4597   HeapRegionSet *_old_set;
  4598 
  4598 
  4599 public:
  4599 public:
  4600   TearDownRegionSetsClosure(HeapRegionSet* old_set) : _old_set(old_set) { }
  4600   TearDownRegionSetsClosure(HeapRegionSet* old_set) : _old_set(old_set) { }
  4601 
  4601 
  4604       _old_set->remove(r);
  4604       _old_set->remove(r);
  4605     } else if(r->is_young()) {
  4605     } else if(r->is_young()) {
  4606       r->uninstall_surv_rate_group();
  4606       r->uninstall_surv_rate_group();
  4607     } else {
  4607     } else {
  4608       // We ignore free regions, we'll empty the free list afterwards.
  4608       // We ignore free regions, we'll empty the free list afterwards.
  4609       // We ignore humongous regions, we're not tearing down the
  4609       // We ignore humongous and archive regions, we're not tearing down these
  4610       // humongous regions set.
  4610       // sets.
  4611       assert(r->is_free() || r->is_humongous(),
  4611       assert(r->is_archive() || r->is_free() || r->is_humongous(),
  4612              "it cannot be another type");
  4612              "it cannot be another type");
  4613     }
  4613     }
  4614     return false;
  4614     return false;
  4615   }
  4615   }
  4616 
  4616 
  4649   _summary_bytes_used = bytes;
  4649   _summary_bytes_used = bytes;
  4650 }
  4650 }
  4651 
  4651 
  4652 class RebuildRegionSetsClosure : public HeapRegionClosure {
  4652 class RebuildRegionSetsClosure : public HeapRegionClosure {
  4653 private:
  4653 private:
  4654   bool            _free_list_only;
  4654   bool _free_list_only;
  4655   HeapRegionSet*   _old_set;
  4655 
  4656   HeapRegionManager*   _hrm;
  4656   HeapRegionSet* _old_set;
  4657   size_t          _total_used;
  4657   HeapRegionManager* _hrm;
       
  4658 
       
  4659   size_t _total_used;
  4658 
  4660 
  4659 public:
  4661 public:
  4660   RebuildRegionSetsClosure(bool free_list_only,
  4662   RebuildRegionSetsClosure(bool free_list_only,
  4661                            HeapRegionSet* old_set, HeapRegionManager* hrm) :
  4663                            HeapRegionSet* old_set,
       
  4664                            HeapRegionManager* hrm) :
  4662     _free_list_only(free_list_only),
  4665     _free_list_only(free_list_only),
  4663     _old_set(old_set), _hrm(hrm), _total_used(0) {
  4666     _old_set(old_set), _hrm(hrm), _total_used(0) {
  4664     assert(_hrm->num_free_regions() == 0, "pre-condition");
  4667     assert(_hrm->num_free_regions() == 0, "pre-condition");
  4665     if (!free_list_only) {
  4668     if (!free_list_only) {
  4666       assert(_old_set->is_empty(), "pre-condition");
  4669       assert(_old_set->is_empty(), "pre-condition");
  4674       // Add free regions to the free list
  4677       // Add free regions to the free list
  4675       r->set_free();
  4678       r->set_free();
  4676       _hrm->insert_into_free_list(r);
  4679       _hrm->insert_into_free_list(r);
  4677     } else if (!_free_list_only) {
  4680     } else if (!_free_list_only) {
  4678 
  4681 
  4679       if (r->is_humongous()) {
  4682       if (r->is_archive() || r->is_humongous()) {
  4680         // We ignore humongous regions. We left the humongous set unchanged.
  4683         // We ignore archive and humongous regions. We left these sets unchanged.
  4681       } else {
  4684       } else {
  4682         assert(r->is_young() || r->is_free() || r->is_old(), "invariant");
  4685         assert(r->is_young() || r->is_free() || r->is_old(), "invariant");
  4683         // We now move all (non-humongous, non-old) regions to old gen, and register them as such.
  4686         // We now move all (non-humongous, non-old, non-archive) regions to old gen, and register them as such.
  4684         r->move_to_old();
  4687         r->move_to_old();
  4685         _old_set->add(r);
  4688         _old_set->add(r);
  4686       }
  4689       }
  4687       _total_used += r->used();
  4690       _total_used += r->used();
  4688     }
  4691     }
  4803                                              InCSetState dest) {
  4806                                              InCSetState dest) {
  4804   bool during_im = collector_state()->in_initial_mark_gc();
  4807   bool during_im = collector_state()->in_initial_mark_gc();
  4805   alloc_region->note_end_of_copying(during_im);
  4808   alloc_region->note_end_of_copying(during_im);
  4806   g1_policy()->record_bytes_copied_during_gc(allocated_bytes);
  4809   g1_policy()->record_bytes_copied_during_gc(allocated_bytes);
  4807   if (dest.is_old()) {
  4810   if (dest.is_old()) {
  4808     _old_set.add(alloc_region);
  4811     old_set_add(alloc_region);
  4809   }
  4812   }
  4810   _hr_printer.retire(alloc_region);
  4813   _hr_printer.retire(alloc_region);
  4811 }
  4814 }
  4812 
  4815 
  4813 HeapRegion* G1CollectedHeap::alloc_highest_free_region() {
  4816 HeapRegion* G1CollectedHeap::alloc_highest_free_region() {