< prev index next >

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

Print this page




  64   check_offset(offset, "offset too large");
  65   set_offset_array(index, (u_char)offset);
  66 }
  67 
  68 void G1BlockOffsetSharedArray::set_offset_array(size_t left, size_t right, u_char offset) {
  69   check_index(right, "right index out of range");
  70   assert(left <= right, "indexes out of order");
  71   size_t num_cards = right - left + 1;
  72   memset_with_concurrent_readers(&_offset_array[left], offset, num_cards);
  73 }
  74 
  75 // Variant of index_for that does not check the index for validity.
  76 inline size_t G1BlockOffsetSharedArray::index_for_raw(const void* p) const {
  77   return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> LogN;
  78 }
  79 
  80 inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const {
  81   char* pc = (char*)p;
  82   assert(pc >= (char*)_reserved.start() &&
  83          pc <  (char*)_reserved.end(),
  84          err_msg("p (" PTR_FORMAT ") not in reserved [" PTR_FORMAT ", " PTR_FORMAT ")",
  85                  p2i(p), p2i(_reserved.start()), p2i(_reserved.end())));
  86   size_t result = index_for_raw(p);
  87   check_index(result, "bad index from address");
  88   return result;
  89 }
  90 
  91 inline HeapWord*
  92 G1BlockOffsetSharedArray::address_for_index(size_t index) const {
  93   check_index(index, "index out of range");
  94   HeapWord* result = address_for_index_raw(index);
  95   assert(result >= _reserved.start() && result < _reserved.end(),
  96          err_msg("bad address from index result " PTR_FORMAT
  97                  " _reserved.start() " PTR_FORMAT " _reserved.end() "
  98                  PTR_FORMAT,
  99                  p2i(result), p2i(_reserved.start()), p2i(_reserved.end())));
 100   return result;
 101 }
 102 
 103 inline size_t
 104 G1BlockOffsetArray::block_size(const HeapWord* p) const {
 105   return gsp()->block_size(p);
 106 }
 107 
 108 inline HeapWord*
 109 G1BlockOffsetArray::block_at_or_preceding(const void* addr,
 110                                           bool has_max_index,
 111                                           size_t max_index) const {
 112   assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
 113   size_t index = _array->index_for(addr);
 114   // We must make sure that the offset table entry we use is valid.  If
 115   // "addr" is past the end, start at the last known one and go forward.
 116   if (has_max_index) {
 117     index = MIN2(index, max_index);
 118   }
 119   HeapWord* q = _array->address_for_index(index);




  64   check_offset(offset, "offset too large");
  65   set_offset_array(index, (u_char)offset);
  66 }
  67 
  68 void G1BlockOffsetSharedArray::set_offset_array(size_t left, size_t right, u_char offset) {
  69   check_index(right, "right index out of range");
  70   assert(left <= right, "indexes out of order");
  71   size_t num_cards = right - left + 1;
  72   memset_with_concurrent_readers(&_offset_array[left], offset, num_cards);
  73 }
  74 
  75 // Variant of index_for that does not check the index for validity.
  76 inline size_t G1BlockOffsetSharedArray::index_for_raw(const void* p) const {
  77   return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> LogN;
  78 }
  79 
  80 inline size_t G1BlockOffsetSharedArray::index_for(const void* p) const {
  81   char* pc = (char*)p;
  82   assert(pc >= (char*)_reserved.start() &&
  83          pc <  (char*)_reserved.end(),
  84          "p (" PTR_FORMAT ") not in reserved [" PTR_FORMAT ", " PTR_FORMAT ")",
  85          p2i(p), p2i(_reserved.start()), p2i(_reserved.end()));
  86   size_t result = index_for_raw(p);
  87   check_index(result, "bad index from address");
  88   return result;
  89 }
  90 
  91 inline HeapWord*
  92 G1BlockOffsetSharedArray::address_for_index(size_t index) const {
  93   check_index(index, "index out of range");
  94   HeapWord* result = address_for_index_raw(index);
  95   assert(result >= _reserved.start() && result < _reserved.end(),
  96          "bad address from index result " PTR_FORMAT
  97          " _reserved.start() " PTR_FORMAT " _reserved.end() " PTR_FORMAT,
  98          p2i(result), p2i(_reserved.start()), p2i(_reserved.end()));

  99   return result;
 100 }
 101 
 102 inline size_t
 103 G1BlockOffsetArray::block_size(const HeapWord* p) const {
 104   return gsp()->block_size(p);
 105 }
 106 
 107 inline HeapWord*
 108 G1BlockOffsetArray::block_at_or_preceding(const void* addr,
 109                                           bool has_max_index,
 110                                           size_t max_index) const {
 111   assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
 112   size_t index = _array->index_for(addr);
 113   // We must make sure that the offset table entry we use is valid.  If
 114   // "addr" is past the end, start at the last known one and go forward.
 115   if (has_max_index) {
 116     index = MIN2(index, max_index);
 117   }
 118   HeapWord* q = _array->address_for_index(index);


< prev index next >