Print this page
rev 3463 : 7114678: G1: various small fixes, code cleanup, and refactoring
Summary: Various cleanups as a prelude to introducing iterators for HeapRegions.
Reviewed-by: johnc
Contributed-by: tonyp

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/heapRegion.cpp
          +++ new/src/share/vm/gc_implementation/g1/heapRegion.cpp
↓ open down ↓ 36 lines elided ↑ open up ↑
  37   37  int    HeapRegion::LogOfHRGrainWords = 0;
  38   38  size_t HeapRegion::GrainBytes        = 0;
  39   39  size_t HeapRegion::GrainWords        = 0;
  40   40  size_t HeapRegion::CardsPerRegion    = 0;
  41   41  
  42   42  HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
  43   43                                   HeapRegion* hr, OopClosure* cl,
  44   44                                   CardTableModRefBS::PrecisionStyle precision,
  45   45                                   FilterKind fk) :
  46   46    ContiguousSpaceDCTOC(hr, cl, precision, NULL),
  47      -  _hr(hr), _fk(fk), _g1(g1)
  48      -{ }
       47 +  _hr(hr), _fk(fk), _g1(g1) { }
  49   48  
  50   49  FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
  51   50                                                     OopClosure* oc) :
  52      -  _r_bottom(r->bottom()), _r_end(r->end()),
  53      -  _oc(oc), _out_of_region(0)
  54      -{}
       51 +  _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
  55   52  
  56   53  class VerifyLiveClosure: public OopClosure {
  57   54  private:
  58   55    G1CollectedHeap* _g1h;
  59   56    CardTableModRefBS* _bs;
  60   57    oop _containing_obj;
  61   58    bool _failures;
  62   59    int _n_failures;
  63   60    VerifyOption _vo;
  64   61  public:
↓ open down ↓ 440 lines elided ↑ open up ↑
 505  502    // region.
 506  503    this->initialize(mr, !is_zeroed, SpaceDecorator::Mangle);
 507  504    set_top(bottom());
 508  505    set_saved_mark();
 509  506  
 510  507    _rem_set =  new HeapRegionRemSet(sharedOffsetArray, this);
 511  508  
 512  509    assert(HeapRegionRemSet::num_par_rem_sets() > 0, "Invariant.");
 513  510  }
 514  511  
 515      -class NextCompactionHeapRegionClosure: public HeapRegionClosure {
 516      -  const HeapRegion* _target;
 517      -  bool _target_seen;
 518      -  HeapRegion* _last;
 519      -  CompactibleSpace* _res;
 520      -public:
 521      -  NextCompactionHeapRegionClosure(const HeapRegion* target) :
 522      -    _target(target), _target_seen(false), _res(NULL) {}
 523      -  bool doHeapRegion(HeapRegion* cur) {
 524      -    if (_target_seen) {
 525      -      if (!cur->isHumongous()) {
 526      -        _res = cur;
 527      -        return true;
 528      -      }
 529      -    } else if (cur == _target) {
 530      -      _target_seen = true;
 531      -    }
 532      -    return false;
 533      -  }
 534      -  CompactibleSpace* result() { return _res; }
 535      -};
 536      -
 537  512  CompactibleSpace* HeapRegion::next_compaction_space() const {
      513 +  // We're not using an iterator given that it will wrap around when
      514 +  // it reaches the last region and this is not what we want here.
 538  515    G1CollectedHeap* g1h = G1CollectedHeap::heap();
 539      -  // cast away const-ness
 540      -  HeapRegion* r = (HeapRegion*) this;
 541      -  NextCompactionHeapRegionClosure blk(r);
 542      -  g1h->heap_region_iterate_from(r, &blk);
 543      -  return blk.result();
      516 +  uint index = hrs_index() + 1;
      517 +  while (index < g1h->n_regions()) {
      518 +    HeapRegion* hr = g1h->region_at(index);
      519 +    if (!hr->isHumongous()) {
      520 +      return hr;
      521 +    }
      522 +    index += 1;
      523 +  }
      524 +  return NULL;
 544  525  }
 545  526  
 546  527  void HeapRegion::save_marks() {
 547  528    set_saved_mark();
 548  529  }
 549  530  
 550  531  void HeapRegion::oops_in_mr_iterate(MemRegion mr, OopClosure* cl) {
 551  532    HeapWord* p = mr.start();
 552  533    HeapWord* e = mr.end();
 553  534    oop obj;
↓ open down ↓ 452 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX