hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
changeset 26846 7d4376f8560e
parent 26841 d460d343d888
child 26848 03841b8f3633
equal deleted inserted replaced
26845:ae163b62b9ac 26846:7d4376f8560e
   908 }
   908 }
   909 
   909 
   910 class NoteStartOfMarkHRClosure: public HeapRegionClosure {
   910 class NoteStartOfMarkHRClosure: public HeapRegionClosure {
   911 public:
   911 public:
   912   bool doHeapRegion(HeapRegion* r) {
   912   bool doHeapRegion(HeapRegion* r) {
   913     if (!r->continuesHumongous()) {
   913     if (!r->is_continues_humongous()) {
   914       r->note_start_of_marking();
   914       r->note_start_of_marking();
   915     }
   915     }
   916     return false;
   916     return false;
   917   }
   917   }
   918 };
   918 };
  1396   // live object in it and sets its corresponding bit on the region
  1396   // live object in it and sets its corresponding bit on the region
  1397   // bitmap to 1. If the region is "starts humongous" it will also set
  1397   // bitmap to 1. If the region is "starts humongous" it will also set
  1398   // to 1 the bits on the region bitmap that correspond to its
  1398   // to 1 the bits on the region bitmap that correspond to its
  1399   // associated "continues humongous" regions.
  1399   // associated "continues humongous" regions.
  1400   void set_bit_for_region(HeapRegion* hr) {
  1400   void set_bit_for_region(HeapRegion* hr) {
  1401     assert(!hr->continuesHumongous(), "should have filtered those out");
  1401     assert(!hr->is_continues_humongous(), "should have filtered those out");
  1402 
  1402 
  1403     BitMap::idx_t index = (BitMap::idx_t) hr->hrm_index();
  1403     BitMap::idx_t index = (BitMap::idx_t) hr->hrm_index();
  1404     if (!hr->startsHumongous()) {
  1404     if (!hr->is_starts_humongous()) {
  1405       // Normal (non-humongous) case: just set the bit.
  1405       // Normal (non-humongous) case: just set the bit.
  1406       _region_bm->par_at_put(index, true);
  1406       _region_bm->par_at_put(index, true);
  1407     } else {
  1407     } else {
  1408       // Starts humongous case: calculate how many regions are part of
  1408       // Starts humongous case: calculate how many regions are part of
  1409       // this humongous region and then set the bit range.
  1409       // this humongous region and then set the bit range.
  1432     CMCountDataClosureBase(g1h, region_bm, card_bm),
  1432     CMCountDataClosureBase(g1h, region_bm, card_bm),
  1433     _bm(bm), _region_marked_bytes(0) { }
  1433     _bm(bm), _region_marked_bytes(0) { }
  1434 
  1434 
  1435   bool doHeapRegion(HeapRegion* hr) {
  1435   bool doHeapRegion(HeapRegion* hr) {
  1436 
  1436 
  1437     if (hr->continuesHumongous()) {
  1437     if (hr->is_continues_humongous()) {
  1438       // We will ignore these here and process them when their
  1438       // We will ignore these here and process them when their
  1439       // associated "starts humongous" region is processed (see
  1439       // associated "starts humongous" region is processed (see
  1440       // set_bit_for_heap_region()). Note that we cannot rely on their
  1440       // set_bit_for_heap_region()). Note that we cannot rely on their
  1441       // associated "starts humongous" region to have their bit set to
  1441       // associated "starts humongous" region to have their bit set to
  1442       // 1 since, due to the region chunking in the parallel region
  1442       // 1 since, due to the region chunking in the parallel region
  1554     _failures(0) { }
  1554     _failures(0) { }
  1555 
  1555 
  1556   int failures() const { return _failures; }
  1556   int failures() const { return _failures; }
  1557 
  1557 
  1558   bool doHeapRegion(HeapRegion* hr) {
  1558   bool doHeapRegion(HeapRegion* hr) {
  1559     if (hr->continuesHumongous()) {
  1559     if (hr->is_continues_humongous()) {
  1560       // We will ignore these here and process them when their
  1560       // We will ignore these here and process them when their
  1561       // associated "starts humongous" region is processed (see
  1561       // associated "starts humongous" region is processed (see
  1562       // set_bit_for_heap_region()). Note that we cannot rely on their
  1562       // set_bit_for_heap_region()). Note that we cannot rely on their
  1563       // associated "starts humongous" region to have their bit set to
  1563       // associated "starts humongous" region to have their bit set to
  1564       // 1 since, due to the region chunking in the parallel region
  1564       // 1 since, due to the region chunking in the parallel region
  1729                               BitMap* card_bm) :
  1729                               BitMap* card_bm) :
  1730     CMCountDataClosureBase(g1h, region_bm, card_bm) { }
  1730     CMCountDataClosureBase(g1h, region_bm, card_bm) { }
  1731 
  1731 
  1732   bool doHeapRegion(HeapRegion* hr) {
  1732   bool doHeapRegion(HeapRegion* hr) {
  1733 
  1733 
  1734     if (hr->continuesHumongous()) {
  1734     if (hr->is_continues_humongous()) {
  1735       // We will ignore these here and process them when their
  1735       // We will ignore these here and process them when their
  1736       // associated "starts humongous" region is processed (see
  1736       // associated "starts humongous" region is processed (see
  1737       // set_bit_for_heap_region()). Note that we cannot rely on their
  1737       // set_bit_for_heap_region()). Note that we cannot rely on their
  1738       // associated "starts humongous" region to have their bit set to
  1738       // associated "starts humongous" region to have their bit set to
  1739       // 1 since, due to the region chunking in the parallel region
  1739       // 1 since, due to the region chunking in the parallel region
  1859   size_t freed_bytes() { return _freed_bytes; }
  1859   size_t freed_bytes() { return _freed_bytes; }
  1860   const HeapRegionSetCount& old_regions_removed() { return _old_regions_removed; }
  1860   const HeapRegionSetCount& old_regions_removed() { return _old_regions_removed; }
  1861   const HeapRegionSetCount& humongous_regions_removed() { return _humongous_regions_removed; }
  1861   const HeapRegionSetCount& humongous_regions_removed() { return _humongous_regions_removed; }
  1862 
  1862 
  1863   bool doHeapRegion(HeapRegion *hr) {
  1863   bool doHeapRegion(HeapRegion *hr) {
  1864     if (hr->continuesHumongous()) {
  1864     if (hr->is_continues_humongous()) {
  1865       return false;
  1865       return false;
  1866     }
  1866     }
  1867     // We use a claim value of zero here because all regions
  1867     // We use a claim value of zero here because all regions
  1868     // were claimed with value 1 in the FinalCount task.
  1868     // were claimed with value 1 in the FinalCount task.
  1869     _g1->reset_gc_time_stamps(hr);
  1869     _g1->reset_gc_time_stamps(hr);
  1873     _max_live_bytes += hr->max_live_bytes();
  1873     _max_live_bytes += hr->max_live_bytes();
  1874 
  1874 
  1875     if (hr->used() > 0 && hr->max_live_bytes() == 0 && !hr->is_young()) {
  1875     if (hr->used() > 0 && hr->max_live_bytes() == 0 && !hr->is_young()) {
  1876       _freed_bytes += hr->used();
  1876       _freed_bytes += hr->used();
  1877       hr->set_containing_set(NULL);
  1877       hr->set_containing_set(NULL);
  1878       if (hr->isHumongous()) {
  1878       if (hr->is_humongous()) {
  1879         assert(hr->startsHumongous(), "we should only see starts humongous");
  1879         assert(hr->is_starts_humongous(), "we should only see starts humongous");
  1880         _humongous_regions_removed.increment(1u, hr->capacity());
  1880         _humongous_regions_removed.increment(1u, hr->capacity());
  1881         _g1->free_humongous_region(hr, _local_cleanup_list, true);
  1881         _g1->free_humongous_region(hr, _local_cleanup_list, true);
  1882       } else {
  1882       } else {
  1883         _old_regions_removed.increment(1u, hr->capacity());
  1883         _old_regions_removed.increment(1u, hr->capacity());
  1884         _g1->free_region(hr, _local_cleanup_list, true);
  1884         _g1->free_region(hr, _local_cleanup_list, true);
  3189     _g1h(g1h), _cm(g1h->concurrent_mark()),
  3189     _g1h(g1h), _cm(g1h->concurrent_mark()),
  3190     _ct_bs((CardTableModRefBS*) (g1h->barrier_set())),
  3190     _ct_bs((CardTableModRefBS*) (g1h->barrier_set())),
  3191     _cm_card_bm(cm_card_bm), _max_worker_id(max_worker_id) { }
  3191     _cm_card_bm(cm_card_bm), _max_worker_id(max_worker_id) { }
  3192 
  3192 
  3193   bool doHeapRegion(HeapRegion* hr) {
  3193   bool doHeapRegion(HeapRegion* hr) {
  3194     if (hr->continuesHumongous()) {
  3194     if (hr->is_continues_humongous()) {
  3195       // We will ignore these here and process them when their
  3195       // We will ignore these here and process them when their
  3196       // associated "starts humongous" region is processed.
  3196       // associated "starts humongous" region is processed.
  3197       // Note that we cannot rely on their associated
  3197       // Note that we cannot rely on their associated
  3198       // "starts humongous" region to have their bit set to 1
  3198       // "starts humongous" region to have their bit set to 1
  3199       // since, due to the region chunking in the parallel region
  3199       // since, due to the region chunking in the parallel region
  3561 }
  3561 }
  3562 
  3562 
  3563 void CMTask::setup_for_region(HeapRegion* hr) {
  3563 void CMTask::setup_for_region(HeapRegion* hr) {
  3564   assert(hr != NULL,
  3564   assert(hr != NULL,
  3565         "claim_region() should have filtered out NULL regions");
  3565         "claim_region() should have filtered out NULL regions");
  3566   assert(!hr->continuesHumongous(),
  3566   assert(!hr->is_continues_humongous(),
  3567         "claim_region() should have filtered out continues humongous regions");
  3567         "claim_region() should have filtered out continues humongous regions");
  3568 
  3568 
  3569   if (_cm->verbose_low()) {
  3569   if (_cm->verbose_low()) {
  3570     gclog_or_tty->print_cr("[%u] setting up for region "PTR_FORMAT,
  3570     gclog_or_tty->print_cr("[%u] setting up for region "PTR_FORMAT,
  3571                            _worker_id, p2i(hr));
  3571                            _worker_id, p2i(hr));
  4286                                "of region "HR_FORMAT,
  4286                                "of region "HR_FORMAT,
  4287                                _worker_id, p2i(_finger), p2i(_region_limit),
  4287                                _worker_id, p2i(_finger), p2i(_region_limit),
  4288                                HR_FORMAT_PARAMS(_curr_region));
  4288                                HR_FORMAT_PARAMS(_curr_region));
  4289       }
  4289       }
  4290 
  4290 
  4291       assert(!_curr_region->isHumongous() || mr.start() == _curr_region->bottom(),
  4291       assert(!_curr_region->is_humongous() || mr.start() == _curr_region->bottom(),
  4292              "humongous regions should go around loop once only");
  4292              "humongous regions should go around loop once only");
  4293 
  4293 
  4294       // Some special cases:
  4294       // Some special cases:
  4295       // If the memory region is empty, we can just give up the region.
  4295       // If the memory region is empty, we can just give up the region.
  4296       // If the current region is humongous then we only need to check
  4296       // If the current region is humongous then we only need to check
  4300       // that is left.
  4300       // that is left.
  4301       // If the iteration is successful, give up the region.
  4301       // If the iteration is successful, give up the region.
  4302       if (mr.is_empty()) {
  4302       if (mr.is_empty()) {
  4303         giveup_current_region();
  4303         giveup_current_region();
  4304         regular_clock_call();
  4304         regular_clock_call();
  4305       } else if (_curr_region->isHumongous() && mr.start() == _curr_region->bottom()) {
  4305       } else if (_curr_region->is_humongous() && mr.start() == _curr_region->bottom()) {
  4306         if (_nextMarkBitMap->isMarked(mr.start())) {
  4306         if (_nextMarkBitMap->isMarked(mr.start())) {
  4307           // The object is marked - apply the closure
  4307           // The object is marked - apply the closure
  4308           BitMap::idx_t offset = _nextMarkBitMap->heapWordToOffset(mr.start());
  4308           BitMap::idx_t offset = _nextMarkBitMap->heapWordToOffset(mr.start());
  4309           bitmap_closure.do_bit(offset);
  4309           bitmap_closure.do_bit(offset);
  4310         }
  4310         }
  4747   size_t next_live_bytes = r->next_live_bytes();
  4747   size_t next_live_bytes = r->next_live_bytes();
  4748   double gc_eff          = r->gc_efficiency();
  4748   double gc_eff          = r->gc_efficiency();
  4749   size_t remset_bytes    = r->rem_set()->mem_size();
  4749   size_t remset_bytes    = r->rem_set()->mem_size();
  4750   size_t strong_code_roots_bytes = r->rem_set()->strong_code_roots_mem_size();
  4750   size_t strong_code_roots_bytes = r->rem_set()->strong_code_roots_mem_size();
  4751 
  4751 
  4752   if (r->startsHumongous()) {
  4752   if (r->is_starts_humongous()) {
  4753     assert(_hum_used_bytes == 0 && _hum_capacity_bytes == 0 &&
  4753     assert(_hum_used_bytes == 0 && _hum_capacity_bytes == 0 &&
  4754            _hum_prev_live_bytes == 0 && _hum_next_live_bytes == 0,
  4754            _hum_prev_live_bytes == 0 && _hum_next_live_bytes == 0,
  4755            "they should have been zeroed after the last time we used them");
  4755            "they should have been zeroed after the last time we used them");
  4756     // Set up the _hum_* fields.
  4756     // Set up the _hum_* fields.
  4757     _hum_capacity_bytes  = capacity_bytes;
  4757     _hum_capacity_bytes  = capacity_bytes;
  4759     _hum_prev_live_bytes = prev_live_bytes;
  4759     _hum_prev_live_bytes = prev_live_bytes;
  4760     _hum_next_live_bytes = next_live_bytes;
  4760     _hum_next_live_bytes = next_live_bytes;
  4761     get_hum_bytes(&used_bytes, &capacity_bytes,
  4761     get_hum_bytes(&used_bytes, &capacity_bytes,
  4762                   &prev_live_bytes, &next_live_bytes);
  4762                   &prev_live_bytes, &next_live_bytes);
  4763     end = bottom + HeapRegion::GrainWords;
  4763     end = bottom + HeapRegion::GrainWords;
  4764   } else if (r->continuesHumongous()) {
  4764   } else if (r->is_continues_humongous()) {
  4765     get_hum_bytes(&used_bytes, &capacity_bytes,
  4765     get_hum_bytes(&used_bytes, &capacity_bytes,
  4766                   &prev_live_bytes, &next_live_bytes);
  4766                   &prev_live_bytes, &next_live_bytes);
  4767     assert(end == bottom + HeapRegion::GrainWords, "invariant");
  4767     assert(end == bottom + HeapRegion::GrainWords, "invariant");
  4768   }
  4768   }
  4769 
  4769