src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp
changeset 55438 0692b67f5462
parent 53244 9807daeb47c4
child 58980 47c20fc6a517
equal deleted inserted replaced
55437:360f8769d3dc 55438:0692b67f5462
    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"
    31 #include "gc/shared/space.hpp"
       
    32 #include "runtime/atomic.hpp"
    32 
    33 
    33 inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
    34 inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
    34   if (addr >= _space->bottom() && addr < _space->end()) {
    35   if (addr >= _space->bottom() && addr < _space->end()) {
    35     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
    36     HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
    36     return forward_to_block_containing_addr(q, addr);
    37     return forward_to_block_containing_addr(q, addr);
    49   }
    50   }
    50 }
    51 }
    51 
    52 
    52 u_char G1BlockOffsetTable::offset_array(size_t index) const {
    53 u_char G1BlockOffsetTable::offset_array(size_t index) const {
    53   check_index(index, "index out of range");
    54   check_index(index, "index out of range");
    54   return _offset_array[index];
    55   return Atomic::load(&_offset_array[index]);
       
    56 }
       
    57 
       
    58 void G1BlockOffsetTable::set_offset_array_raw(size_t index, u_char offset) {
       
    59   Atomic::store(offset, &_offset_array[index]);
    55 }
    60 }
    56 
    61 
    57 void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {
    62 void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {
    58   check_index(index, "index out of range");
    63   check_index(index, "index out of range");
    59   set_offset_array_raw(index, offset);
    64   set_offset_array_raw(index, offset);
    69 
    74 
    70 void G1BlockOffsetTable::set_offset_array(size_t left, size_t right, u_char offset) {
    75 void G1BlockOffsetTable::set_offset_array(size_t left, size_t right, u_char offset) {
    71   check_index(right, "right index out of range");
    76   check_index(right, "right index out of range");
    72   assert(left <= right, "indexes out of order");
    77   assert(left <= right, "indexes out of order");
    73   size_t num_cards = right - left + 1;
    78   size_t num_cards = right - left + 1;
    74   memset_with_concurrent_readers(&_offset_array[left], offset, num_cards);
    79   memset_with_concurrent_readers
       
    80     (const_cast<u_char*> (&_offset_array[left]), offset, num_cards);
    75 }
    81 }
    76 
    82 
    77 // Variant of index_for that does not check the index for validity.
    83 // Variant of index_for that does not check the index for validity.
    78 inline size_t G1BlockOffsetTable::index_for_raw(const void* p) const {
    84 inline size_t G1BlockOffsetTable::index_for_raw(const void* p) const {
    79   return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> BOTConstants::LogN;
    85   return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> BOTConstants::LogN;