8225716: G1 GC: Undefined behaviour in G1BlockOffsetTablePart::block_at_or_preceding
Reviewed-by: kbarrett, tschatzl
This commit is contained in:
parent
fe66fd327f
commit
41ca20f5b5
@ -391,8 +391,6 @@ G1BlockOffsetTablePart::print_on(outputStream* out) {
|
|||||||
#endif // !PRODUCT
|
#endif // !PRODUCT
|
||||||
|
|
||||||
HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() {
|
HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() {
|
||||||
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array),
|
|
||||||
"just checking");
|
|
||||||
_next_offset_index = _bot->index_for_raw(_space->bottom());
|
_next_offset_index = _bot->index_for_raw(_space->bottom());
|
||||||
_next_offset_index++;
|
_next_offset_index++;
|
||||||
_next_offset_threshold =
|
_next_offset_threshold =
|
||||||
@ -401,8 +399,6 @@ HeapWord* G1BlockOffsetTablePart::initialize_threshold_raw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void G1BlockOffsetTablePart::zero_bottom_entry_raw() {
|
void G1BlockOffsetTablePart::zero_bottom_entry_raw() {
|
||||||
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array),
|
|
||||||
"just checking");
|
|
||||||
size_t bottom_index = _bot->index_for_raw(_space->bottom());
|
size_t bottom_index = _bot->index_for_raw(_space->bottom());
|
||||||
assert(_bot->address_for_index_raw(bottom_index) == _space->bottom(),
|
assert(_bot->address_for_index_raw(bottom_index) == _space->bottom(),
|
||||||
"Precondition of call");
|
"Precondition of call");
|
||||||
@ -410,8 +406,6 @@ void G1BlockOffsetTablePart::zero_bottom_entry_raw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* G1BlockOffsetTablePart::initialize_threshold() {
|
HeapWord* G1BlockOffsetTablePart::initialize_threshold() {
|
||||||
assert(!G1CollectedHeap::heap()->is_in_reserved(_bot->_offset_array),
|
|
||||||
"just checking");
|
|
||||||
_next_offset_index = _bot->index_for(_space->bottom());
|
_next_offset_index = _bot->index_for(_space->bottom());
|
||||||
_next_offset_index++;
|
_next_offset_index++;
|
||||||
_next_offset_threshold =
|
_next_offset_threshold =
|
||||||
|
@ -52,7 +52,7 @@ private:
|
|||||||
|
|
||||||
// Array for keeping offsets for retrieving object start fast given an
|
// Array for keeping offsets for retrieving object start fast given an
|
||||||
// address.
|
// address.
|
||||||
u_char* _offset_array; // byte array keeping backwards offsets
|
volatile u_char* _offset_array; // byte array keeping backwards offsets
|
||||||
|
|
||||||
void check_offset(size_t offset, const char* msg) const {
|
void check_offset(size_t offset, const char* msg) const {
|
||||||
assert(offset <= BOTConstants::N_words,
|
assert(offset <= BOTConstants::N_words,
|
||||||
@ -64,10 +64,7 @@ private:
|
|||||||
// For performance these have to devolve to array accesses in product builds.
|
// For performance these have to devolve to array accesses in product builds.
|
||||||
inline u_char offset_array(size_t index) const;
|
inline u_char offset_array(size_t index) const;
|
||||||
|
|
||||||
void set_offset_array_raw(size_t index, u_char offset) {
|
inline void set_offset_array_raw(size_t index, u_char offset);
|
||||||
_offset_array[index] = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void set_offset_array(size_t index, u_char offset);
|
inline void set_offset_array(size_t index, u_char offset);
|
||||||
|
|
||||||
inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
|
inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "gc/g1/heapRegion.hpp"
|
#include "gc/g1/heapRegion.hpp"
|
||||||
#include "gc/shared/memset_with_concurrent_readers.hpp"
|
#include "gc/shared/memset_with_concurrent_readers.hpp"
|
||||||
#include "gc/shared/space.hpp"
|
#include "gc/shared/space.hpp"
|
||||||
|
#include "runtime/atomic.hpp"
|
||||||
|
|
||||||
inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
|
inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) {
|
||||||
if (addr >= _space->bottom() && addr < _space->end()) {
|
if (addr >= _space->bottom() && addr < _space->end()) {
|
||||||
@ -51,7 +52,11 @@ inline HeapWord* G1BlockOffsetTablePart::block_start_const(const void* addr) con
|
|||||||
|
|
||||||
u_char G1BlockOffsetTable::offset_array(size_t index) const {
|
u_char G1BlockOffsetTable::offset_array(size_t index) const {
|
||||||
check_index(index, "index out of range");
|
check_index(index, "index out of range");
|
||||||
return _offset_array[index];
|
return Atomic::load(&_offset_array[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void G1BlockOffsetTable::set_offset_array_raw(size_t index, u_char offset) {
|
||||||
|
Atomic::store(offset, &_offset_array[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {
|
void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {
|
||||||
@ -71,7 +76,8 @@ void G1BlockOffsetTable::set_offset_array(size_t left, size_t right, u_char offs
|
|||||||
check_index(right, "right index out of range");
|
check_index(right, "right index out of range");
|
||||||
assert(left <= right, "indexes out of order");
|
assert(left <= right, "indexes out of order");
|
||||||
size_t num_cards = right - left + 1;
|
size_t num_cards = right - left + 1;
|
||||||
memset_with_concurrent_readers(&_offset_array[left], offset, num_cards);
|
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.
|
// Variant of index_for that does not check the index for validity.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user