src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp
changeset 58980 47c20fc6a517
parent 55429 d7da94e6c169
child 59248 e92153ed8bdc
equal deleted inserted replaced
58979:1edb08142cea 58980:47c20fc6a517
    26 #define SHARE_GC_G1_G1BLOCKOFFSETTABLE_INLINE_HPP
    26 #define SHARE_GC_G1_G1BLOCKOFFSETTABLE_INLINE_HPP
    27 
    27 
    28 #include "gc/g1/g1BlockOffsetTable.hpp"
    28 #include "gc/g1/g1BlockOffsetTable.hpp"
    29 #include "gc/g1/heapRegion.hpp"
    29 #include "gc/g1/heapRegion.hpp"
    30 #include "gc/shared/memset_with_concurrent_readers.hpp"
    30 #include "gc/shared/memset_with_concurrent_readers.hpp"
    31 #include "gc/shared/space.hpp"
       
    32 #include "runtime/atomic.hpp"
    31 #include "runtime/atomic.hpp"
    33 
    32 
    34 inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
    33 inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
    35   if (addr >= _space->bottom() && addr < _space->end()) {
    34   if (addr >= _hr->bottom() && addr < _hr->end()) {
    36     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
    35     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
    37     return forward_to_block_containing_addr(q, addr);
    36     return forward_to_block_containing_addr(q, addr);
    38   } else {
    37   } else {
    39     return NULL;
    38     return NULL;
    40   }
    39   }
    41 }
    40 }
    42 
    41 
    43 inline HeapWord* G1BlockOffsetTablePart::block_start_const(const void* addr) const {
    42 inline HeapWord* G1BlockOffsetTablePart::block_start_const(const void* addr) const {
    44   if (addr >= _space->bottom() && addr < _space->end()) {
    43   if (addr >= _hr->bottom() && addr < _hr->end()) {
    45     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
    44     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
    46     HeapWord* n = q + block_size(q);
    45     HeapWord* n = q + block_size(q);
    47     return forward_to_block_containing_addr_const(q, n, addr);
    46     return forward_to_block_containing_addr_const(q, n, addr);
    48   } else {
    47   } else {
    49     return NULL;
    48     return NULL;
   105          p2i(result), p2i(_reserved.start()), p2i(_reserved.end()));
   104          p2i(result), p2i(_reserved.start()), p2i(_reserved.end()));
   106   return result;
   105   return result;
   107 }
   106 }
   108 
   107 
   109 inline size_t G1BlockOffsetTablePart::block_size(const HeapWord* p) const {
   108 inline size_t G1BlockOffsetTablePart::block_size(const HeapWord* p) const {
   110   return _space->block_size(p);
   109   return _hr->block_size(p);
   111 }
   110 }
   112 
   111 
   113 inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr,
   112 inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr,
   114                                                                bool has_max_index,
   113                                                                bool has_max_index,
   115                                                                size_t max_index) const {
   114                                                                size_t max_index) const {
   116   assert(_object_can_span || _bot->offset_array(_bot->index_for(_space->bottom())) == 0,
   115   assert(_object_can_span || _bot->offset_array(_bot->index_for(_hr->bottom())) == 0,
   117          "Object crossed region boundary, found offset %u instead of 0",
   116          "Object crossed region boundary, found offset %u instead of 0",
   118          (uint) _bot->offset_array(_bot->index_for(_space->bottom())));
   117          (uint) _bot->offset_array(_bot->index_for(_hr->bottom())));
   119   size_t index = _bot->index_for(addr);
   118   size_t index = _bot->index_for(addr);
   120   // We must make sure that the offset table entry we use is valid.  If
   119   // We must make sure that the offset table entry we use is valid.  If
   121   // "addr" is past the end, start at the last known one and go forward.
   120   // "addr" is past the end, start at the last known one and go forward.
   122   if (has_max_index) {
   121   if (has_max_index) {
   123     index = MIN2(index, max_index);
   122     index = MIN2(index, max_index);
   138   return q;
   137   return q;
   139 }
   138 }
   140 
   139 
   141 inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
   140 inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
   142                                                                                 const void* addr) const {
   141                                                                                 const void* addr) const {
   143   if (addr >= _space->top()) return _space->top();
   142   if (addr >= _hr->top()) return _hr->top();
   144   while (n <= addr) {
   143   while (n <= addr) {
   145     q = n;
   144     q = n;
   146     oop obj = oop(q);
   145     oop obj = oop(q);
   147     if (obj->klass_or_null_acquire() == NULL) {
   146     if (obj->klass_or_null_acquire() == NULL) {
   148       return q;
   147       return q;