src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp

changeset 7051
1f1d373cd044
parent 6992
2c6ef90f030a
child 7256
0fcaab91d485
     1.1 --- a/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp	Tue Aug 19 10:50:27 2014 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp	Thu Aug 21 11:47:10 2014 +0200
     1.3 @@ -47,14 +47,69 @@
     1.4    }
     1.5  }
     1.6  
     1.7 +#define check_index(index, msg)                                                \
     1.8 +  assert((index) < (_reserved.word_size() >> LogN_words),                      \
     1.9 +         err_msg("%s - index: "SIZE_FORMAT", _vs.committed_size: "SIZE_FORMAT, \
    1.10 +                 msg, (index), (_reserved.word_size() >> LogN_words)));        \
    1.11 +  assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)),   \
    1.12 +         err_msg("Index "SIZE_FORMAT" corresponding to "PTR_FORMAT             \
    1.13 +                 " (%u) is not in committed area.",                            \
    1.14 +                 (index),                                                      \
    1.15 +                 p2i(address_for_index_raw(index)),                            \
    1.16 +                 G1CollectedHeap::heap()->addr_to_region(address_for_index_raw(index))));
    1.17 +
    1.18 +u_char G1BlockOffsetSharedArray::offset_array(size_t index) const {
    1.19 +  check_index(index, "index out of range");
    1.20 +  return _offset_array[index];
    1.21 +}
    1.22 +
    1.23 +void G1BlockOffsetSharedArray::set_offset_array(size_t index, u_char offset) {
    1.24 +  check_index(index, "index out of range");
    1.25 +  set_offset_array_raw(index, offset);
    1.26 +}
    1.27 +
    1.28 +void G1BlockOffsetSharedArray::set_offset_array(size_t index, HeapWord* high, HeapWord* low) {
    1.29 +  check_index(index, "index out of range");
    1.30 +  assert(high >= low, "addresses out of order");
    1.31 +  size_t offset = pointer_delta(high, low);
    1.32 +  check_offset(offset, "offset too large");
    1.33 +  set_offset_array(index, (u_char)offset);
    1.34 +}
    1.35 +
    1.36 +void G1BlockOffsetSharedArray::set_offset_array(size_t left, size_t right, u_char offset) {
    1.37 +  check_index(right, "right index out of range");
    1.38 +  assert(left <= right, "indexes out of order");
    1.39 +  size_t num_cards = right - left + 1;
    1.40 +  if (UseMemSetInBOT) {
    1.41 +    memset(&_offset_array[left], offset, num_cards);
    1.42 +  } else {
    1.43 +    size_t i = left;
    1.44 +    const size_t end = i + num_cards;
    1.45 +    for (; i < end; i++) {
    1.46 +      _offset_array[i] = offset;
    1.47 +    }
    1.48 +  }
    1.49 +}
    1.50 +
    1.51 +void G1BlockOffsetSharedArray::check_offset_array(size_t index, HeapWord* high, HeapWord* low) const {
    1.52 +  check_index(index, "index out of range");
    1.53 +  assert(high >= low, "addresses out of order");
    1.54 +  check_offset(pointer_delta(high, low), "offset too large");
    1.55 +  assert(_offset_array[index] == pointer_delta(high, low), "Wrong offset");
    1.56 +}
    1.57 +
    1.58 +// Variant of index_for that does not check the index for validity.
    1.59 +inline size_t G1BlockOffsetSharedArray::index_for_raw(const void* p) const {
    1.60 +  return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> LogN;
    1.61 +}
    1.62 +
    1.63  inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const {
    1.64    char* pc = (char*)p;
    1.65    assert(pc >= (char*)_reserved.start() &&
    1.66           pc <  (char*)_reserved.end(),
    1.67           err_msg("p (" PTR_FORMAT ") not in reserved [" PTR_FORMAT ", " PTR_FORMAT ")",
    1.68                   p2i(p), p2i(_reserved.start()), p2i(_reserved.end())));
    1.69 -  size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char));
    1.70 -  size_t result = delta >> LogN;
    1.71 +  size_t result = index_for_raw(p);
    1.72    check_index(result, "bad index from address");
    1.73    return result;
    1.74  }
    1.75 @@ -62,7 +117,7 @@
    1.76  inline HeapWord*
    1.77  G1BlockOffsetSharedArray::address_for_index(size_t index) const {
    1.78    check_index(index, "index out of range");
    1.79 -  HeapWord* result = _reserved.start() + (index << LogN_words);
    1.80 +  HeapWord* result = address_for_index_raw(index);
    1.81    assert(result >= _reserved.start() && result < _reserved.end(),
    1.82           err_msg("bad address from index result " PTR_FORMAT
    1.83                   " _reserved.start() " PTR_FORMAT " _reserved.end() "
    1.84 @@ -71,6 +126,8 @@
    1.85    return result;
    1.86  }
    1.87  
    1.88 +#undef check_index
    1.89 +
    1.90  inline size_t
    1.91  G1BlockOffsetArray::block_size(const HeapWord* p) const {
    1.92    return gsp()->block_size(p);

mercurial