src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp

changeset 3957
a2f7274eb6ef
parent 3923
922993931b3d
child 3998
7383557659bd
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Tue Jul 17 12:24:05 2012 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu Jul 19 15:15:54 2012 -0700
     1.3 @@ -1528,35 +1528,13 @@
     1.4  
     1.5  class ParKnownGarbageHRClosure: public HeapRegionClosure {
     1.6    G1CollectedHeap* _g1h;
     1.7 -  CollectionSetChooser* _hrSorted;
     1.8 -  uint _marked_regions_added;
     1.9 -  size_t _reclaimable_bytes_added;
    1.10 -  uint _chunk_size;
    1.11 -  uint _cur_chunk_idx;
    1.12 -  uint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end)
    1.13 -
    1.14 -  void get_new_chunk() {
    1.15 -    _cur_chunk_idx = _hrSorted->claim_array_chunk(_chunk_size);
    1.16 -    _cur_chunk_end = _cur_chunk_idx + _chunk_size;
    1.17 -  }
    1.18 -  void add_region(HeapRegion* r) {
    1.19 -    if (_cur_chunk_idx == _cur_chunk_end) {
    1.20 -      get_new_chunk();
    1.21 -    }
    1.22 -    assert(_cur_chunk_idx < _cur_chunk_end, "postcondition");
    1.23 -    _hrSorted->set_region(_cur_chunk_idx, r);
    1.24 -    _marked_regions_added++;
    1.25 -    _reclaimable_bytes_added += r->reclaimable_bytes();
    1.26 -    _cur_chunk_idx++;
    1.27 -  }
    1.28 +  CSetChooserParUpdater _cset_updater;
    1.29  
    1.30  public:
    1.31    ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted,
    1.32                             uint chunk_size) :
    1.33 -      _g1h(G1CollectedHeap::heap()),
    1.34 -      _hrSorted(hrSorted), _chunk_size(chunk_size),
    1.35 -      _marked_regions_added(0), _reclaimable_bytes_added(0),
    1.36 -      _cur_chunk_idx(0), _cur_chunk_end(0) { }
    1.37 +    _g1h(G1CollectedHeap::heap()),
    1.38 +    _cset_updater(hrSorted, true /* parallel */, chunk_size) { }
    1.39  
    1.40    bool doHeapRegion(HeapRegion* r) {
    1.41      // Do we have any marking information for this region?
    1.42 @@ -1564,14 +1542,12 @@
    1.43        // We will skip any region that's currently used as an old GC
    1.44        // alloc region (we should not consider those for collection
    1.45        // before we fill them up).
    1.46 -      if (_hrSorted->should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
    1.47 -        add_region(r);
    1.48 +      if (_cset_updater.should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
    1.49 +        _cset_updater.add_region(r);
    1.50        }
    1.51      }
    1.52      return false;
    1.53    }
    1.54 -  uint marked_regions_added() { return _marked_regions_added; }
    1.55 -  size_t reclaimable_bytes_added() { return _reclaimable_bytes_added; }
    1.56  };
    1.57  
    1.58  class ParKnownGarbageTask: public AbstractGangTask {
    1.59 @@ -1591,10 +1567,6 @@
    1.60      _g1->heap_region_par_iterate_chunked(&parKnownGarbageCl, worker_id,
    1.61                                           _g1->workers()->active_workers(),
    1.62                                           HeapRegion::InitialClaimValue);
    1.63 -    uint regions_added = parKnownGarbageCl.marked_regions_added();
    1.64 -    size_t reclaimable_bytes_added =
    1.65 -                                   parKnownGarbageCl.reclaimable_bytes_added();
    1.66 -    _hrSorted->update_totals(regions_added, reclaimable_bytes_added);
    1.67    }
    1.68  };
    1.69  

mercurial