< prev index next >
src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp
Print this page
rev 51891 : 8225716: G1 GC: Undefined behaviour in G1BlockOffsetTablePart::block_at_or_preceding
Reviewed-by: kbarrett, tschatzl
*** 27,36 ****
--- 27,37 ----
#include "gc/g1/g1BlockOffsetTable.hpp"
#include "gc/g1/heapRegion.hpp"
#include "gc/shared/memset_with_concurrent_readers.hpp"
#include "gc/shared/space.hpp"
+ #include "runtime/atomic.hpp"
inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
if (addr >= _space->bottom() && addr < _space->end()) {
HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
return forward_to_block_containing_addr(q, addr);
*** 49,64 ****
}
}
u_char G1BlockOffsetTable::offset_array(size_t index) const {
check_index(index, "index out of range");
! return _offset_array[index];
}
void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {
check_index(index, "index out of range");
! set_offset_array_raw(index, offset);
}
void G1BlockOffsetTable::set_offset_array(size_t index, HeapWord* high, HeapWord* low) {
check_index(index, "index out of range");
assert(high >= low, "addresses out of order");
--- 50,65 ----
}
}
u_char G1BlockOffsetTable::offset_array(size_t index) const {
check_index(index, "index out of range");
! return Atomic::load(&_offset_array[index]);
}
void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {
check_index(index, "index out of range");
! Atomic::store(offset, &_offset_array[index]);
}
void G1BlockOffsetTable::set_offset_array(size_t index, HeapWord* high, HeapWord* low) {
check_index(index, "index out of range");
assert(high >= low, "addresses out of order");
*** 69,79 ****
void G1BlockOffsetTable::set_offset_array(size_t left, size_t right, u_char offset) {
check_index(right, "right index out of range");
assert(left <= right, "indexes out of order");
size_t num_cards = right - left + 1;
! memset_with_concurrent_readers(&_offset_array[left], offset, num_cards);
}
// Variant of index_for that does not check the index for validity.
inline size_t G1BlockOffsetTable::index_for_raw(const void* p) const {
return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> BOTConstants::LogN;
--- 70,81 ----
void G1BlockOffsetTable::set_offset_array(size_t left, size_t right, u_char offset) {
check_index(right, "right index out of range");
assert(left <= right, "indexes out of order");
size_t num_cards = right - left + 1;
! memset_with_concurrent_readers
! (const_cast<u_char*> (&_offset_array[left]), offset, num_cards);
}
// Variant of index_for that does not check the index for validity.
inline size_t G1BlockOffsetTable::index_for_raw(const void* p) const {
return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> BOTConstants::LogN;
< prev index next >