comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 6254:a2f7274eb6ef

7114678: G1: various small fixes, code cleanup, and refactoring Summary: Various cleanups as a prelude to introducing iterators for HeapRegions. Reviewed-by: johnc, brutisso
author tonyp
date Thu, 19 Jul 2012 15:15:54 -0700
parents 8a2e5a6a19a4
children 957c266d8bc5 7383557659bd
comparison
equal deleted inserted replaced
6253:db823a892a55 6254:a2f7274eb6ef
42 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1, 42 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
43 HeapRegion* hr, OopClosure* cl, 43 HeapRegion* hr, OopClosure* cl,
44 CardTableModRefBS::PrecisionStyle precision, 44 CardTableModRefBS::PrecisionStyle precision,
45 FilterKind fk) : 45 FilterKind fk) :
46 ContiguousSpaceDCTOC(hr, cl, precision, NULL), 46 ContiguousSpaceDCTOC(hr, cl, precision, NULL),
47 _hr(hr), _fk(fk), _g1(g1) 47 _hr(hr), _fk(fk), _g1(g1) { }
48 { }
49 48
50 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, 49 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
51 OopClosure* oc) : 50 OopClosure* oc) :
52 _r_bottom(r->bottom()), _r_end(r->end()), 51 _r_bottom(r->bottom()), _r_end(r->end()), _oc(oc) { }
53 _oc(oc), _out_of_region(0)
54 {}
55 52
56 class VerifyLiveClosure: public OopClosure { 53 class VerifyLiveClosure: public OopClosure {
57 private: 54 private:
58 G1CollectedHeap* _g1h; 55 G1CollectedHeap* _g1h;
59 CardTableModRefBS* _bs; 56 CardTableModRefBS* _bs;
510 _rem_set = new HeapRegionRemSet(sharedOffsetArray, this); 507 _rem_set = new HeapRegionRemSet(sharedOffsetArray, this);
511 508
512 assert(HeapRegionRemSet::num_par_rem_sets() > 0, "Invariant."); 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 CompactibleSpace* HeapRegion::next_compaction_space() const { 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 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 515 G1CollectedHeap* g1h = G1CollectedHeap::heap();
539 // cast away const-ness 516 uint index = hrs_index() + 1;
540 HeapRegion* r = (HeapRegion*) this; 517 while (index < g1h->n_regions()) {
541 NextCompactionHeapRegionClosure blk(r); 518 HeapRegion* hr = g1h->region_at(index);
542 g1h->heap_region_iterate_from(r, &blk); 519 if (!hr->isHumongous()) {
543 return blk.result(); 520 return hr;
521 }
522 index += 1;
523 }
524 return NULL;
544 } 525 }
545 526
546 void HeapRegion::save_marks() { 527 void HeapRegion::save_marks() {
547 set_saved_mark(); 528 set_saved_mark();
548 } 529 }