Beispiel #1
0
inline HeapRegion* HeapRegionSeq::addr_to_region(HeapWord* addr) const {
  if (addr != NULL && addr < heap_end()) {
    assert(addr >= heap_bottom(),
          err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT, addr, heap_bottom()));
    return addr_to_region_unsafe(addr);
  }
  return NULL;
}
void HeapRegionSeq::verify_optional() {
  guarantee(length() <= _allocated_length,
            err_msg("invariant: _length: %u _allocated_length: %u",
                    length(), _allocated_length));
  guarantee(_allocated_length <= max_length(),
            err_msg("invariant: _allocated_length: %u _max_length: %u",
                    _allocated_length, max_length()));
  guarantee(_next_search_index <= length(),
            err_msg("invariant: _next_search_index: %u _length: %u",
                    _next_search_index, length()));

  HeapWord* prev_end = heap_bottom();
  for (uint i = 0; i < _allocated_length; i += 1) {
    HeapRegion* hr = _regions.get_by_index(i);
    guarantee(hr != NULL, err_msg("invariant: i: %u", i));
    guarantee(hr->bottom() == prev_end,
              err_msg("invariant i: %u "HR_FORMAT" prev_end: "PTR_FORMAT,
                      i, HR_FORMAT_PARAMS(hr), p2i(prev_end)));
    guarantee(hr->hrs_index() == i,
              err_msg("invariant: i: %u hrs_index(): %u", i, hr->hrs_index()));
    if (i < length()) {
      // Asserts will fire if i is >= _length
      HeapWord* addr = hr->bottom();
      guarantee(addr_to_region(addr) == hr, "sanity");
      guarantee(addr_to_region_unsafe(addr) == hr, "sanity");
    } else {
      guarantee(hr->is_empty(), "sanity");
      guarantee(!hr->isHumongous(), "sanity");
      // using assert instead of guarantee here since containing_set()
      // is only available in non-product builds.
      assert(hr->containing_set() == NULL, "sanity");
    }
    if (hr->startsHumongous()) {
      prev_end = hr->orig_end();
    } else {
      prev_end = hr->end();
    }
  }
  for (uint i = _allocated_length; i < max_length(); i += 1) {
    guarantee(_regions.get_by_index(i) == NULL, err_msg("invariant i: %u", i));
  }
}