Skip to content

Commit

Permalink
8330339: G1: Move some public methods to private in G1BlockOffsetTabl…
Browse files Browse the repository at this point in the history
…e APIs

Reviewed-by: ayang, iwalulya
  • Loading branch information
lgxbslgx committed Apr 22, 2024
1 parent 35b30c8 commit 70acade
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
24 changes: 24 additions & 0 deletions src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ G1BlockOffsetTable::G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* st
p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end()));
}

void G1BlockOffsetTable::set_offset_array_raw(uint8_t* addr, uint8_t offset) {
Atomic::store(addr, offset);
}

void G1BlockOffsetTable::set_offset_array(uint8_t* addr, uint8_t offset) {
check_address(addr, "Block offset table address out of range");
set_offset_array_raw(addr, offset);
}

void G1BlockOffsetTable::set_offset_array(uint8_t* addr, HeapWord* high, HeapWord* low) {
check_address(addr, "Block offset table address out of range");
assert(high >= low, "addresses out of order");
size_t offset = pointer_delta(high, low);
check_offset(offset, "offset too large");
set_offset_array(addr, (uint8_t)offset);
}

void G1BlockOffsetTable::set_offset_array(uint8_t* left, uint8_t* right, uint8_t offset) {
check_address(right, "Right block offset table address out of range");
assert(left <= right, "indexes out of order");
size_t num_cards = right - left + 1;
memset_with_concurrent_readers(left, offset, num_cards);
}

#ifdef ASSERT
void G1BlockOffsetTable::check_address(uint8_t* addr, const char* msg) const {
uint8_t* start_addr = const_cast<uint8_t*>(_offset_base + (uintptr_t(_reserved.start()) >> CardTable::card_shift()));
Expand Down
18 changes: 9 additions & 9 deletions src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {

inline void set_offset_array(uint8_t* left, uint8_t* right, uint8_t offset);

// Mapping from address to object start array entry
inline uint8_t* entry_for_addr(const void* const p) const;

// Mapping from object start array entry to address of first word
inline HeapWord* addr_for_entry(const uint8_t* const p) const;

void check_address(uint8_t* addr, const char* msg) const NOT_DEBUG_RETURN;

// Sets the entries corresponding to the cards starting at "start" and ending
Expand All @@ -74,6 +80,9 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {

void check_all_cards(uint8_t* left_card, uint8_t* right_card) const NOT_DEBUG_RETURN;

void verify_offset(uint8_t* card_index, uint8_t upper) const NOT_DEBUG_RETURN;
void verify_for_block(HeapWord* blk_start, HeapWord* blk_end) const NOT_DEBUG_RETURN;

static HeapWord* align_up_by_card_size(HeapWord* const addr) {
return align_up(addr, CardTable::card_size());
}
Expand All @@ -96,22 +105,13 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {
// in the heap parameter.
G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage);

// Mapping from address to object start array entry
uint8_t* entry_for_addr(const void* const p) const;

// Mapping from object start array entry to address of first word
HeapWord* addr_for_entry(const uint8_t* const p) const;

static bool is_crossing_card_boundary(HeapWord* const obj_start,
HeapWord* const obj_end) {
HeapWord* cur_card_boundary = align_up_by_card_size(obj_start);
// strictly greater-than
return obj_end > cur_card_boundary;
}

void verify_offset(uint8_t* card_index, uint8_t upper) const NOT_DEBUG_RETURN;
void verify_for_block(HeapWord* blk_start, HeapWord* blk_end) const NOT_DEBUG_RETURN;

// Returns the address of the start of the block reaching into the card containing
// "addr".
inline HeapWord* block_start_reaching_into_card(const void* addr) const;
Expand Down
24 changes: 0 additions & 24 deletions src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,6 @@ uint8_t G1BlockOffsetTable::offset_array(uint8_t* addr) const {
return Atomic::load(addr);
}

void G1BlockOffsetTable::set_offset_array_raw(uint8_t* addr, uint8_t offset) {
Atomic::store(addr, offset);
}

void G1BlockOffsetTable::set_offset_array(uint8_t* addr, uint8_t offset) {
check_address(addr, "Block offset table address out of range");
set_offset_array_raw(addr, offset);
}

void G1BlockOffsetTable::set_offset_array(uint8_t* addr, HeapWord* high, HeapWord* low) {
check_address(addr, "Block offset table address out of range");
assert(high >= low, "addresses out of order");
size_t offset = pointer_delta(high, low);
check_offset(offset, "offset too large");
set_offset_array(addr, (uint8_t)offset);
}

void G1BlockOffsetTable::set_offset_array(uint8_t* left, uint8_t* right, uint8_t offset) {
check_address(right, "Right block offset table address out of range");
assert(left <= right, "indexes out of order");
size_t num_cards = right - left + 1;
memset_with_concurrent_readers(left, offset, num_cards);
}

inline uint8_t* G1BlockOffsetTable::entry_for_addr(const void* const p) const {
assert(_reserved.contains(p),
"out of bounds access to block offset table");
Expand Down

1 comment on commit 70acade

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.