Skip to content

Commit 4fa77a2

Browse files
committed
8329096: G1: Change the type of G1BlockOffsetTable::_offset_base to uint8_t*
Reviewed-by: ayang, tschatzl
1 parent 3eb1d05 commit 4fa77a2

File tree

3 files changed

+49
-50
lines changed

3 files changed

+49
-50
lines changed

src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ G1BlockOffsetTable::G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* st
4040

4141
MemRegion bot_reserved = storage->reserved();
4242

43-
_offset_base = ((u_char*)bot_reserved.start() - (uintptr_t(_reserved.start()) >> CardTable::card_shift()));
43+
_offset_base = ((uint8_t*)bot_reserved.start() - (uintptr_t(_reserved.start()) >> CardTable::card_shift()));
4444

4545
log_trace(gc, bot)("G1BlockOffsetTable::G1BlockOffsetTable: ");
4646
log_trace(gc, bot)(" rs.base(): " PTR_FORMAT " rs.size(): " SIZE_FORMAT " rs end(): " PTR_FORMAT,
4747
p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end()));
4848
}
4949

5050
#ifdef ASSERT
51-
void G1BlockOffsetTable::check_address(u_char* addr, const char* msg) const {
52-
u_char* start_addr = const_cast<u_char *>(_offset_base + (uintptr_t(_reserved.start()) >> CardTable::card_shift()));
53-
u_char* end_addr = const_cast<u_char *>(_offset_base + (uintptr_t(_reserved.end()) >> CardTable::card_shift()));
51+
void G1BlockOffsetTable::check_address(uint8_t* addr, const char* msg) const {
52+
uint8_t* start_addr = const_cast<uint8_t*>(_offset_base + (uintptr_t(_reserved.start()) >> CardTable::card_shift()));
53+
uint8_t* end_addr = const_cast<uint8_t*>(_offset_base + (uintptr_t(_reserved.end()) >> CardTable::card_shift()));
5454
assert(addr >= start_addr && addr <= end_addr,
5555
"%s - offset address: " PTR_FORMAT ", start address: " PTR_FORMAT ", end address: " PTR_FORMAT,
5656
msg, (p2i(addr)), (p2i(start_addr)), (p2i(end_addr)));
@@ -102,18 +102,18 @@ G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, HeapRe
102102
// Move back N (e.g., 8) entries and repeat with the
103103
// value of the new entry
104104
//
105-
void G1BlockOffsetTablePart::set_remainder_to_point_to_start_incl(u_char* start_card, u_char* end_card) {
105+
void G1BlockOffsetTablePart::set_remainder_to_point_to_start_incl(uint8_t* start_card, uint8_t* end_card) {
106106
assert(start_card <= end_card, "precondition");
107107
assert(start_card > _bot->entry_for_addr(_hr->bottom()), "Cannot be first card");
108108
assert(_bot->offset_array(start_card-1) < CardTable::card_size_in_words(),
109109
"Offset card has an unexpected value");
110-
u_char* start_card_for_region = start_card;
111-
u_char offset = max_jubyte;
110+
uint8_t* start_card_for_region = start_card;
111+
uint8_t offset = UINT8_MAX;
112112
for (uint i = 0; i < BOTConstants::N_powers; i++) {
113113
// -1 so that the card with the actual offset is counted. Another -1
114114
// so that the reach ends in this region and not at the start
115115
// of the next.
116-
u_char* reach = start_card - 1 + (BOTConstants::power_to_cards_back(i+1) - 1);
116+
uint8_t* reach = start_card - 1 + (BOTConstants::power_to_cards_back(i+1) - 1);
117117
offset = CardTable::card_size_in_words() + i;
118118
if (reach >= end_card) {
119119
_bot->set_offset_array(start_card_for_region, end_card, offset);
@@ -131,13 +131,13 @@ void G1BlockOffsetTablePart::set_remainder_to_point_to_start_incl(u_char* start_
131131
// The card-interval [start_card, end_card] is a closed interval; this
132132
// is an expensive check -- use with care and only under protection of
133133
// suitable flag.
134-
void G1BlockOffsetTablePart::check_all_cards(u_char* start_card, u_char* end_card) const {
134+
void G1BlockOffsetTablePart::check_all_cards(uint8_t* start_card, uint8_t* end_card) const {
135135
if (end_card < start_card) {
136136
return;
137137
}
138138
guarantee(_bot->offset_array(start_card) == CardTable::card_size_in_words(), "Wrong value in second card");
139-
for (u_char* c = start_card + 1; c <= end_card; c++ /* yeah! */) {
140-
u_char entry = _bot->offset_array(c);
139+
for (uint8_t* c = start_card + 1; c <= end_card; c++ /* yeah! */) {
140+
uint8_t entry = _bot->offset_array(c);
141141
if ((unsigned)(c - start_card) > BOTConstants::power_to_cards_back(1)) {
142142
guarantee(entry > CardTable::card_size_in_words(),
143143
"Should be in logarithmic region - "
@@ -147,7 +147,7 @@ void G1BlockOffsetTablePart::check_all_cards(u_char* start_card, u_char* end_car
147147
(uint)entry, (uint)_bot->offset_array(c), CardTable::card_size_in_words());
148148
}
149149
size_t backskip = BOTConstants::entry_to_cards_back(entry);
150-
u_char* landing_card = c - backskip;
150+
uint8_t* landing_card = c - backskip;
151151
guarantee(landing_card >= (start_card - 1), "Inv");
152152
if (landing_card >= start_card) {
153153
guarantee(_bot->offset_array(landing_card) <= entry,
@@ -179,7 +179,7 @@ void G1BlockOffsetTablePart::check_all_cards(u_char* start_card, u_char* end_car
179179
void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
180180
HeapWord* blk_end) {
181181
HeapWord* const cur_card_boundary = align_up_by_card_size(blk_start);
182-
u_char* const offset_card = _bot->entry_for_addr(cur_card_boundary);
182+
uint8_t* const offset_card = _bot->entry_for_addr(cur_card_boundary);
183183

184184
assert(blk_start != nullptr && blk_end > blk_start,
185185
"phantom block");
@@ -200,7 +200,7 @@ void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
200200
// We need to now mark the subsequent cards that this block spans.
201201

202202
// Index of card on which the block ends.
203-
u_char* end_card = _bot->entry_for_addr(blk_end - 1);
203+
uint8_t* end_card = _bot->entry_for_addr(blk_end - 1);
204204

205205
// Are there more cards left to be updated?
206206
if (offset_card + 1 <= end_card) {
@@ -215,7 +215,7 @@ void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
215215

216216
// The offset can be 0 if the block starts on a boundary. That
217217
// is checked by an assertion above.
218-
u_char* previous_card = _bot->entry_for_addr(blk_start);
218+
uint8_t* previous_card = _bot->entry_for_addr(blk_start);
219219
HeapWord* boundary = _bot->addr_for_entry(previous_card);
220220
assert((_bot->offset_array(offset_card) == 0 && blk_start == boundary) ||
221221
(_bot->offset_array(offset_card) > 0 && _bot->offset_array(offset_card) < CardTable::card_size_in_words()),
@@ -225,10 +225,10 @@ void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
225225
"boundary: " PTR_FORMAT,
226226
(uint)_bot->offset_array(offset_card),
227227
p2i(blk_start), p2i(boundary));
228-
for (u_char* j = offset_card + 1; j <= end_card; j++) {
228+
for (uint8_t* j = offset_card + 1; j <= end_card; j++) {
229229
assert(_bot->offset_array(j) > 0 &&
230230
_bot->offset_array(j) <=
231-
(u_char) (CardTable::card_size_in_words() + BOTConstants::N_powers - 1),
231+
(uint8_t) (CardTable::card_size_in_words() + BOTConstants::N_powers - 1),
232232
"offset array should have been set - "
233233
"%u not > 0 OR %u not <= %u",
234234
(uint) _bot->offset_array(j),
@@ -240,11 +240,11 @@ void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
240240

241241
void G1BlockOffsetTablePart::verify() const {
242242
assert(_hr->bottom() < _hr->top(), "Only non-empty regions should be verified.");
243-
u_char* start_card = _bot->entry_for_addr(_hr->bottom());
244-
u_char* end_card = _bot->entry_for_addr(_hr->top() - 1);
243+
uint8_t* start_card = _bot->entry_for_addr(_hr->bottom());
244+
uint8_t* end_card = _bot->entry_for_addr(_hr->top() - 1);
245245

246-
for (u_char* current_card = start_card; current_card < end_card; current_card++) {
247-
u_char entry = _bot->offset_array(current_card);
246+
for (uint8_t* current_card = start_card; current_card < end_card; current_card++) {
247+
uint8_t entry = _bot->offset_array(current_card);
248248
if (entry < CardTable::card_size_in_words()) {
249249
// The entry should point to an object before the current card. Verify that
250250
// it is possible to walk from that object in to the current card by just
@@ -281,12 +281,12 @@ void G1BlockOffsetTablePart::verify() const {
281281

282282
#ifndef PRODUCT
283283
void G1BlockOffsetTablePart::print_on(outputStream* out) {
284-
u_char* from_card = _bot->entry_for_addr(_hr->bottom());
285-
u_char* to_card = _bot->entry_for_addr(_hr->end());
284+
uint8_t* from_card = _bot->entry_for_addr(_hr->bottom());
285+
uint8_t* to_card = _bot->entry_for_addr(_hr->end());
286286
out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") "
287287
"cards [" SIZE_FORMAT "," SIZE_FORMAT ")",
288288
p2i(_hr->bottom()), p2i(_hr->end()), p2i(from_card), p2i(to_card));
289-
for (u_char* i = from_card; i < to_card; ++i) {
289+
for (uint8_t* i = from_card; i < to_card; ++i) {
290290
out->print_cr(" entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u",
291291
p2i(i), p2i(_bot->addr_for_entry(i)),
292292
(uint) _bot->offset_array(i));

src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {
5252
MemRegion _reserved;
5353

5454
// Biased array-start of BOT array for fast BOT entry translation
55-
volatile u_char* _offset_base;
55+
volatile uint8_t* _offset_base;
5656

5757
void check_offset(size_t offset, const char* msg) const {
5858
assert(offset < CardTable::card_size_in_words(),
@@ -62,16 +62,16 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {
6262

6363
// Bounds checking accessors:
6464
// For performance these have to devolve to array accesses in product builds.
65-
inline u_char offset_array(u_char* addr) const;
65+
inline uint8_t offset_array(uint8_t* addr) const;
6666

67-
inline void set_offset_array_raw(u_char* addr, u_char offset);
68-
inline void set_offset_array(u_char* addr, u_char offset);
67+
inline void set_offset_array_raw(uint8_t* addr, uint8_t offset);
68+
inline void set_offset_array(uint8_t* addr, uint8_t offset);
6969

70-
inline void set_offset_array(u_char* addr, HeapWord* high, HeapWord* low);
70+
inline void set_offset_array(uint8_t* addr, HeapWord* high, HeapWord* low);
7171

72-
inline void set_offset_array(u_char* left, u_char* right, u_char offset);
72+
inline void set_offset_array(uint8_t* left, uint8_t* right, uint8_t offset);
7373

74-
void check_address(u_char* addr, const char* msg) const NOT_DEBUG_RETURN;
74+
void check_address(uint8_t* addr, const char* msg) const NOT_DEBUG_RETURN;
7575

7676
public:
7777

@@ -92,10 +92,10 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {
9292
G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage);
9393

9494
// Mapping from address to object start array entry
95-
u_char* entry_for_addr(const void* const p) const;
95+
uint8_t* entry_for_addr(const void* const p) const;
9696

9797
// Mapping from object start array entry to address of first word
98-
HeapWord* addr_for_entry(const u_char* const p) const;
98+
HeapWord* addr_for_entry(const uint8_t* const p) const;
9999
};
100100

101101
class G1BlockOffsetTablePart {
@@ -110,12 +110,12 @@ class G1BlockOffsetTablePart {
110110

111111
// Sets the entries corresponding to the cards starting at "start" and ending
112112
// at "end" to point back to the card before "start"; [start, end]
113-
void set_remainder_to_point_to_start_incl(u_char* start, u_char* end);
113+
void set_remainder_to_point_to_start_incl(uint8_t* start, uint8_t* end);
114114

115115
// Update BOT entries corresponding to the mem range [blk_start, blk_end).
116116
void update_for_block_work(HeapWord* blk_start, HeapWord* blk_end);
117117

118-
void check_all_cards(u_char* left_card, u_char* right_card) const NOT_DEBUG_RETURN;
118+
void check_all_cards(uint8_t* left_card, uint8_t* right_card) const NOT_DEBUG_RETURN;
119119

120120
static HeapWord* align_up_by_card_size(HeapWord* const addr) {
121121
return align_up(addr, CardTable::card_size());

src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ inline HeapWord* G1BlockOffsetTablePart::block_start_reaching_into_card(const vo
3838
#ifdef ASSERT
3939
if (!_hr->is_continues_humongous()) {
4040
// For non-ContinuesHumongous regions, the first obj always starts from bottom.
41-
u_char offset = _bot->offset_array(_bot->entry_for_addr(_hr->bottom()));
41+
uint8_t offset = _bot->offset_array(_bot->entry_for_addr(_hr->bottom()));
4242
assert(offset == 0, "Found offset %u instead of 0 for region %u %s",
4343
offset, _hr->hrm_index(), _hr->get_short_type_str());
4444
}
4545
#endif
4646

47-
u_char* entry = _bot->entry_for_addr(addr);
48-
u_char offset = _bot->offset_array(entry);
47+
uint8_t* entry = _bot->entry_for_addr(addr);
48+
uint8_t offset = _bot->offset_array(entry);
4949
while (offset >= CardTable::card_size_in_words()) {
5050
// The excess of the offset from N_words indicates a power of Base
5151
// to go back by.
@@ -58,45 +58,44 @@ inline HeapWord* G1BlockOffsetTablePart::block_start_reaching_into_card(const vo
5858
return q - offset;
5959
}
6060

61-
u_char G1BlockOffsetTable::offset_array(u_char* addr) const {
61+
uint8_t G1BlockOffsetTable::offset_array(uint8_t* addr) const {
6262
check_address(addr, "Block offset table address out of range");
6363
return Atomic::load(addr);
6464
}
6565

66-
void G1BlockOffsetTable::set_offset_array_raw(u_char* addr, u_char offset) {
66+
void G1BlockOffsetTable::set_offset_array_raw(uint8_t* addr, uint8_t offset) {
6767
Atomic::store(addr, offset);
6868
}
6969

70-
void G1BlockOffsetTable::set_offset_array(u_char* addr, u_char offset) {
70+
void G1BlockOffsetTable::set_offset_array(uint8_t* addr, uint8_t offset) {
7171
check_address(addr, "Block offset table address out of range");
7272
set_offset_array_raw(addr, offset);
7373
}
7474

75-
void G1BlockOffsetTable::set_offset_array(u_char* addr, HeapWord* high, HeapWord* low) {
75+
void G1BlockOffsetTable::set_offset_array(uint8_t* addr, HeapWord* high, HeapWord* low) {
7676
check_address(addr, "Block offset table address out of range");
7777
assert(high >= low, "addresses out of order");
7878
size_t offset = pointer_delta(high, low);
7979
check_offset(offset, "offset too large");
80-
set_offset_array(addr, (u_char)offset);
80+
set_offset_array(addr, (uint8_t)offset);
8181
}
8282

83-
void G1BlockOffsetTable::set_offset_array(u_char* left, u_char* right, u_char offset) {
83+
void G1BlockOffsetTable::set_offset_array(uint8_t* left, uint8_t* right, uint8_t offset) {
8484
check_address(right, "Right block offset table address out of range");
8585
assert(left <= right, "indexes out of order");
8686
size_t num_cards = right - left + 1;
87-
memset_with_concurrent_readers
88-
(const_cast<u_char*> (left), offset, num_cards);
87+
memset_with_concurrent_readers(left, offset, num_cards);
8988
}
9089

91-
inline u_char* G1BlockOffsetTable::entry_for_addr(const void* const p) const {
90+
inline uint8_t* G1BlockOffsetTable::entry_for_addr(const void* const p) const {
9291
assert(_reserved.contains(p),
9392
"out of bounds access to block offset table");
94-
u_char* result = const_cast<u_char *>(&_offset_base[uintptr_t(p) >> CardTable::card_shift()]);
93+
uint8_t* result = const_cast<uint8_t*>(&_offset_base[uintptr_t(p) >> CardTable::card_shift()]);
9594
return result;
9695
}
9796

98-
inline HeapWord* G1BlockOffsetTable::addr_for_entry(const u_char* const p) const {
99-
size_t delta = pointer_delta(p, _offset_base, sizeof(u_char));
97+
inline HeapWord* G1BlockOffsetTable::addr_for_entry(const uint8_t* const p) const {
98+
size_t delta = pointer_delta(p, _offset_base, sizeof(uint8_t));
10099
HeapWord* result = (HeapWord*) (delta << CardTable::card_shift());
101100
assert(_reserved.contains(result),
102101
"out of bounds accessor from block offset table");

0 commit comments

Comments
 (0)