8285979: G1: G1SegmentedArraySegment::header_size() is incorrect since JDK-8283368

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Jie Fu 2022-05-02 22:41:06 +00:00
parent 50a4df87c8
commit fbcd874907
2 changed files with 4 additions and 4 deletions

View File

@ -32,9 +32,9 @@
G1SegmentedArraySegment::G1SegmentedArraySegment(uint slot_size, uint num_slots, G1SegmentedArraySegment* next, MEMFLAGS flag) : G1SegmentedArraySegment::G1SegmentedArraySegment(uint slot_size, uint num_slots, G1SegmentedArraySegment* next, MEMFLAGS flag) :
_slot_size(slot_size), _slot_size(slot_size),
_num_slots(num_slots), _num_slots(num_slots),
_mem_flag(flag),
_next(next), _next(next),
_next_allocate(0) { _next_allocate(0),
_mem_flag(flag) {
_bottom = ((char*) this) + header_size(); _bottom = ((char*) this) + header_size();
} }

View File

@ -36,17 +36,17 @@
class G1SegmentedArraySegment { class G1SegmentedArraySegment {
const uint _slot_size; const uint _slot_size;
const uint _num_slots; const uint _num_slots;
const MEMFLAGS _mem_flag;
G1SegmentedArraySegment* volatile _next; G1SegmentedArraySegment* volatile _next;
// Index into the next free slot to allocate into. Full if equal (or larger) // Index into the next free slot to allocate into. Full if equal (or larger)
// to _num_slots (can be larger because we atomically increment this value and // to _num_slots (can be larger because we atomically increment this value and
// check only afterwards if the allocation has been successful). // check only afterwards if the allocation has been successful).
uint volatile _next_allocate; uint volatile _next_allocate;
const MEMFLAGS _mem_flag;
char* _bottom; // Actual data. char* _bottom; // Actual data.
// Do not add class member variables beyond this point // Do not add class member variables beyond this point
static size_t header_size() { return align_up(offset_of(G1SegmentedArraySegment, _bottom), DEFAULT_CACHE_LINE_SIZE); } static size_t header_size() { return align_up(sizeof(G1SegmentedArraySegment), DEFAULT_CACHE_LINE_SIZE); }
static size_t payload_size(uint slot_size, uint num_slots) { static size_t payload_size(uint slot_size, uint num_slots) {
// The cast (size_t) is required to guard against overflow wrap around. // The cast (size_t) is required to guard against overflow wrap around.