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

changeset 5773
a19bea467577
parent 5074
b0d20fa374b4
child 6198
55fb97c4c58d
     1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp	Tue Sep 24 10:14:02 2013 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp	Wed Sep 25 13:25:24 2013 +0200
     1.3 @@ -71,27 +71,16 @@
     1.4  
     1.5  // Public
     1.6  
     1.7 -void HeapRegionSeq::initialize(HeapWord* bottom, HeapWord* end,
     1.8 -                               uint max_length) {
     1.9 +void HeapRegionSeq::initialize(HeapWord* bottom, HeapWord* end) {
    1.10    assert((uintptr_t) bottom % HeapRegion::GrainBytes == 0,
    1.11           "bottom should be heap region aligned");
    1.12    assert((uintptr_t) end % HeapRegion::GrainBytes == 0,
    1.13           "end should be heap region aligned");
    1.14  
    1.15 -  _length = 0;
    1.16 -  _heap_bottom = bottom;
    1.17 -  _heap_end = end;
    1.18 -  _region_shift = HeapRegion::LogOfHRGrainBytes;
    1.19    _next_search_index = 0;
    1.20    _allocated_length = 0;
    1.21 -  _max_length = max_length;
    1.22  
    1.23 -  _regions = NEW_C_HEAP_ARRAY(HeapRegion*, max_length, mtGC);
    1.24 -  memset(_regions, 0, (size_t) max_length * sizeof(HeapRegion*));
    1.25 -  _regions_biased = _regions - ((uintx) bottom >> _region_shift);
    1.26 -
    1.27 -  assert(&_regions[0] == &_regions_biased[addr_to_index_biased(bottom)],
    1.28 -         "bottom should be included in the region with index 0");
    1.29 +  _regions.initialize(bottom, end, HeapRegion::GrainBytes);
    1.30  }
    1.31  
    1.32  MemRegion HeapRegionSeq::expand_by(HeapWord* old_end,
    1.33 @@ -101,15 +90,15 @@
    1.34    G1CollectedHeap* g1h = G1CollectedHeap::heap();
    1.35  
    1.36    HeapWord* next_bottom = old_end;
    1.37 -  assert(_heap_bottom <= next_bottom, "invariant");
    1.38 +  assert(heap_bottom() <= next_bottom, "invariant");
    1.39    while (next_bottom < new_end) {
    1.40 -    assert(next_bottom < _heap_end, "invariant");
    1.41 +    assert(next_bottom < heap_end(), "invariant");
    1.42      uint index = length();
    1.43  
    1.44 -    assert(index < _max_length, "otherwise we cannot expand further");
    1.45 +    assert(index < max_length(), "otherwise we cannot expand further");
    1.46      if (index == 0) {
    1.47        // We have not allocated any regions so far
    1.48 -      assert(next_bottom == _heap_bottom, "invariant");
    1.49 +      assert(next_bottom == heap_bottom(), "invariant");
    1.50      } else {
    1.51        // next_bottom should match the end of the last/previous region
    1.52        assert(next_bottom == at(index - 1)->end(), "invariant");
    1.53 @@ -122,8 +111,8 @@
    1.54          // allocation failed, we bail out and return what we have done so far
    1.55          return MemRegion(old_end, next_bottom);
    1.56        }
    1.57 -      assert(_regions[index] == NULL, "invariant");
    1.58 -      _regions[index] = new_hr;
    1.59 +      assert(_regions.get_by_index(index) == NULL, "invariant");
    1.60 +      _regions.set_by_index(index, new_hr);
    1.61        increment_allocated_length();
    1.62      }
    1.63      // Have to increment the length first, otherwise we will get an
    1.64 @@ -228,26 +217,26 @@
    1.65  
    1.66  #ifndef PRODUCT
    1.67  void HeapRegionSeq::verify_optional() {
    1.68 -  guarantee(_length <= _allocated_length,
    1.69 +  guarantee(length() <= _allocated_length,
    1.70              err_msg("invariant: _length: %u _allocated_length: %u",
    1.71 -                    _length, _allocated_length));
    1.72 -  guarantee(_allocated_length <= _max_length,
    1.73 +                    length(), _allocated_length));
    1.74 +  guarantee(_allocated_length <= max_length(),
    1.75              err_msg("invariant: _allocated_length: %u _max_length: %u",
    1.76 -                    _allocated_length, _max_length));
    1.77 -  guarantee(_next_search_index <= _length,
    1.78 +                    _allocated_length, max_length()));
    1.79 +  guarantee(_next_search_index <= length(),
    1.80              err_msg("invariant: _next_search_index: %u _length: %u",
    1.81 -                    _next_search_index, _length));
    1.82 +                    _next_search_index, length()));
    1.83  
    1.84 -  HeapWord* prev_end = _heap_bottom;
    1.85 +  HeapWord* prev_end = heap_bottom();
    1.86    for (uint i = 0; i < _allocated_length; i += 1) {
    1.87 -    HeapRegion* hr = _regions[i];
    1.88 +    HeapRegion* hr = _regions.get_by_index(i);
    1.89      guarantee(hr != NULL, err_msg("invariant: i: %u", i));
    1.90      guarantee(hr->bottom() == prev_end,
    1.91                err_msg("invariant i: %u "HR_FORMAT" prev_end: "PTR_FORMAT,
    1.92                        i, HR_FORMAT_PARAMS(hr), prev_end));
    1.93      guarantee(hr->hrs_index() == i,
    1.94                err_msg("invariant: i: %u hrs_index(): %u", i, hr->hrs_index()));
    1.95 -    if (i < _length) {
    1.96 +    if (i < length()) {
    1.97        // Asserts will fire if i is >= _length
    1.98        HeapWord* addr = hr->bottom();
    1.99        guarantee(addr_to_region(addr) == hr, "sanity");
   1.100 @@ -265,8 +254,8 @@
   1.101        prev_end = hr->end();
   1.102      }
   1.103    }
   1.104 -  for (uint i = _allocated_length; i < _max_length; i += 1) {
   1.105 -    guarantee(_regions[i] == NULL, err_msg("invariant i: %u", i));
   1.106 +  for (uint i = _allocated_length; i < max_length(); i += 1) {
   1.107 +    guarantee(_regions.get_by_index(i) == NULL, err_msg("invariant i: %u", i));
   1.108    }
   1.109  }
   1.110  #endif // PRODUCT

mercurial