Skip to content

Commit db4842c

Browse files
committedMar 19, 2024
8328364: Remove redundant fields in 'BOTConstants'
Reviewed-by: ayang, tschatzl
1 parent c01095c commit db4842c

16 files changed

+72
-126
lines changed
 

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

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -49,9 +49,9 @@ G1BlockOffsetTable::G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* st
4949

5050
#ifdef ASSERT
5151
void G1BlockOffsetTable::check_index(size_t index, const char* msg) const {
52-
assert((index) < (_reserved.word_size() >> BOTConstants::log_card_size_in_words()),
52+
assert((index) < (_reserved.word_size() >> CardTable::card_shift_in_words()),
5353
"%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT,
54-
msg, (index), (_reserved.word_size() >> BOTConstants::log_card_size_in_words()));
54+
msg, (index), (_reserved.word_size() >> CardTable::card_shift_in_words()));
5555
assert(G1CollectedHeap::heap()->is_in(address_for_index_raw(index)),
5656
"Index " SIZE_FORMAT " corresponding to " PTR_FORMAT
5757
" (%u) is not in committed area.",
@@ -107,7 +107,7 @@ G1BlockOffsetTablePart::G1BlockOffsetTablePart(G1BlockOffsetTable* array, HeapRe
107107
void G1BlockOffsetTablePart::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) {
108108
assert(start_card <= end_card, "precondition");
109109
assert(start_card > _bot->index_for(_hr->bottom()), "Cannot be first card");
110-
assert(_bot->offset_array(start_card-1) < BOTConstants::card_size_in_words(),
110+
assert(_bot->offset_array(start_card-1) < CardTable::card_size_in_words(),
111111
"Offset card has an unexpected value");
112112
size_t start_card_for_region = start_card;
113113
u_char offset = max_jubyte;
@@ -116,7 +116,7 @@ void G1BlockOffsetTablePart::set_remainder_to_point_to_start_incl(size_t start_c
116116
// so that the reach ends in this region and not at the start
117117
// of the next.
118118
size_t reach = start_card - 1 + (BOTConstants::power_to_cards_back(i+1) - 1);
119-
offset = BOTConstants::card_size_in_words() + i;
119+
offset = CardTable::card_size_in_words() + i;
120120
if (reach >= end_card) {
121121
_bot->set_offset_array(start_card_for_region, end_card, offset);
122122
start_card_for_region = reach + 1;
@@ -138,16 +138,16 @@ void G1BlockOffsetTablePart::check_all_cards(size_t start_card, size_t end_card)
138138
if (end_card < start_card) {
139139
return;
140140
}
141-
guarantee(_bot->offset_array(start_card) == BOTConstants::card_size_in_words(), "Wrong value in second card");
141+
guarantee(_bot->offset_array(start_card) == CardTable::card_size_in_words(), "Wrong value in second card");
142142
for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
143143
u_char entry = _bot->offset_array(c);
144144
if (c - start_card > BOTConstants::power_to_cards_back(1)) {
145-
guarantee(entry > BOTConstants::card_size_in_words(),
145+
guarantee(entry > CardTable::card_size_in_words(),
146146
"Should be in logarithmic region - "
147147
"entry: %u, "
148148
"_array->offset_array(c): %u, "
149149
"N_words: %u",
150-
(uint)entry, (uint)_bot->offset_array(c), BOTConstants::card_size_in_words());
150+
(uint)entry, (uint)_bot->offset_array(c), CardTable::card_size_in_words());
151151
}
152152
size_t backskip = BOTConstants::entry_to_cards_back(entry);
153153
size_t landing_card = c - backskip;
@@ -160,10 +160,10 @@ void G1BlockOffsetTablePart::check_all_cards(size_t start_card, size_t end_card)
160160
} else {
161161
guarantee(landing_card == start_card - 1, "Tautology");
162162
// Note that N_words is the maximum offset value
163-
guarantee(_bot->offset_array(landing_card) < BOTConstants::card_size_in_words(),
163+
guarantee(_bot->offset_array(landing_card) < CardTable::card_size_in_words(),
164164
"landing card offset: %u, "
165165
"N_words: %u",
166-
(uint)_bot->offset_array(landing_card), (uint)BOTConstants::card_size_in_words());
166+
(uint)_bot->offset_array(landing_card), (uint)CardTable::card_size_in_words());
167167
}
168168
}
169169
}
@@ -188,13 +188,13 @@ void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
188188
"phantom block");
189189
assert(blk_end > cur_card_boundary, "should be past cur_card_boundary");
190190
assert(blk_start <= cur_card_boundary, "blk_start should be at or before cur_card_boundary");
191-
assert(pointer_delta(cur_card_boundary, blk_start) < BOTConstants::card_size_in_words(),
192-
"offset should be < BOTConstants::card_size_in_words()");
191+
assert(pointer_delta(cur_card_boundary, blk_start) < CardTable::card_size_in_words(),
192+
"offset should be < CardTable::card_size_in_words()");
193193
assert(G1CollectedHeap::heap()->is_in_reserved(blk_start),
194194
"reference must be into the heap");
195195
assert(G1CollectedHeap::heap()->is_in_reserved(blk_end - 1),
196196
"limit must be within the heap");
197-
assert(cur_card_boundary == _bot->_reserved.start() + index*BOTConstants::card_size_in_words(),
197+
assert(cur_card_boundary == _bot->_reserved.start() + index * CardTable::card_size_in_words(),
198198
"index must agree with cur_card_boundary");
199199

200200
// Mark the card that holds the offset into the block.
@@ -213,15 +213,15 @@ void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
213213
#ifdef ASSERT
214214
// Calculate new_card_boundary this way because end_index
215215
// may be the last valid index in the covered region.
216-
HeapWord* new_card_boundary = _bot->address_for_index(end_index) + BOTConstants::card_size_in_words();
216+
HeapWord* new_card_boundary = _bot->address_for_index(end_index) + CardTable::card_size_in_words();
217217
assert(new_card_boundary >= blk_end, "postcondition");
218218

219219
// The offset can be 0 if the block starts on a boundary. That
220220
// is checked by an assertion above.
221221
size_t start_index = _bot->index_for(blk_start);
222222
HeapWord* boundary = _bot->address_for_index(start_index);
223223
assert((_bot->offset_array(index) == 0 && blk_start == boundary) ||
224-
(_bot->offset_array(index) > 0 && _bot->offset_array(index) < BOTConstants::card_size_in_words()),
224+
(_bot->offset_array(index) > 0 && _bot->offset_array(index) < CardTable::card_size_in_words()),
225225
"offset array should have been set - "
226226
"index offset: %u, "
227227
"blk_start: " PTR_FORMAT ", "
@@ -231,12 +231,12 @@ void G1BlockOffsetTablePart::update_for_block_work(HeapWord* blk_start,
231231
for (size_t j = index + 1; j <= end_index; j++) {
232232
assert(_bot->offset_array(j) > 0 &&
233233
_bot->offset_array(j) <=
234-
(u_char) (BOTConstants::card_size_in_words()+BOTConstants::N_powers-1),
234+
(u_char) (CardTable::card_size_in_words() + BOTConstants::N_powers - 1),
235235
"offset array should have been set - "
236236
"%u not > 0 OR %u not <= %u",
237237
(uint) _bot->offset_array(j),
238238
(uint) _bot->offset_array(j),
239-
(uint) (BOTConstants::card_size_in_words() + BOTConstants::N_powers - 1));
239+
(uint) (CardTable::card_size_in_words() + BOTConstants::N_powers - 1));
240240
}
241241
#endif
242242
}
@@ -248,7 +248,7 @@ void G1BlockOffsetTablePart::verify() const {
248248

249249
for (size_t current_card = start_card; current_card < end_card; current_card++) {
250250
u_char entry = _bot->offset_array(current_card);
251-
if (entry < BOTConstants::card_size_in_words()) {
251+
if (entry < CardTable::card_size_in_words()) {
252252
// The entry should point to an object before the current card. Verify that
253253
// it is possible to walk from that object in to the current card by just
254254
// iterating over the objects following it.

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

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
2727

2828
#include "gc/g1/g1RegionToSpaceMapper.hpp"
2929
#include "gc/shared/blockOffsetTable.hpp"
30+
#include "gc/shared/cardTable.hpp"
3031
#include "memory/memRegion.hpp"
3132
#include "memory/virtualspace.hpp"
3233
#include "utilities/globalDefinitions.hpp"
@@ -55,9 +56,9 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {
5556
volatile u_char* _offset_array; // byte array keeping backwards offsets
5657

5758
void check_offset(size_t offset, const char* msg) const {
58-
assert(offset < BOTConstants::card_size_in_words(),
59+
assert(offset < CardTable::card_size_in_words(),
5960
"%s - offset: " SIZE_FORMAT ", N_words: %u",
60-
msg, offset, BOTConstants::card_size_in_words());
61+
msg, offset, CardTable::card_size_in_words());
6162
}
6263

6364
// Bounds checking accessors:
@@ -78,13 +79,13 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {
7879
// Return the number of slots needed for an offset array
7980
// that covers mem_region_words words.
8081
static size_t compute_size(size_t mem_region_words) {
81-
size_t number_of_slots = (mem_region_words / BOTConstants::card_size_in_words());
82+
size_t number_of_slots = (mem_region_words / CardTable::card_size_in_words());
8283
return ReservedSpace::allocation_align_size_up(number_of_slots);
8384
}
8485

8586
// Returns how many bytes of the heap a single byte of the BOT corresponds to.
8687
static size_t heap_map_factor() {
87-
return BOTConstants::card_size();
88+
return CardTable::card_size();
8889
}
8990

9091
// Initialize the Block Offset Table to cover the memory region passed
@@ -100,7 +101,7 @@ class G1BlockOffsetTable: public CHeapObj<mtGC> {
100101
inline HeapWord* address_for_index(size_t index) const;
101102
// Variant of address_for_index that does not check the index for validity.
102103
inline HeapWord* address_for_index_raw(size_t index) const {
103-
return _reserved.start() + (index << BOTConstants::log_card_size_in_words());
104+
return _reserved.start() + (index << CardTable::card_shift_in_words());
104105
}
105106
};
106107

@@ -124,7 +125,7 @@ class G1BlockOffsetTablePart {
124125
void check_all_cards(size_t left_card, size_t right_card) const NOT_DEBUG_RETURN;
125126

126127
static HeapWord* align_up_by_card_size(HeapWord* const addr) {
127-
return align_up(addr, BOTConstants::card_size());
128+
return align_up(addr, CardTable::card_size());
128129
}
129130

130131
void update_for_block(HeapWord* blk_start, size_t size) {

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,8 @@
2626
#define SHARE_GC_G1_G1BLOCKOFFSETTABLE_INLINE_HPP
2727

2828
#include "gc/g1/g1BlockOffsetTable.hpp"
29-
3029
#include "gc/g1/g1HeapRegion.hpp"
30+
#include "gc/shared/cardTable.hpp"
3131
#include "gc/shared/memset_with_concurrent_readers.hpp"
3232
#include "runtime/atomic.hpp"
3333
#include "oops/oop.inline.hpp"
@@ -47,14 +47,14 @@ inline HeapWord* G1BlockOffsetTablePart::block_start_reaching_into_card(const vo
4747
size_t index = _bot->index_for(addr);
4848

4949
u_char offset = _bot->offset_array(index);
50-
while (offset >= BOTConstants::card_size_in_words()) {
50+
while (offset >= CardTable::card_size_in_words()) {
5151
// The excess of the offset from N_words indicates a power of Base
5252
// to go back by.
5353
size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
5454
index -= n_cards_back;
5555
offset = _bot->offset_array(index);
5656
}
57-
assert(offset < BOTConstants::card_size_in_words(), "offset too large");
57+
assert(offset < CardTable::card_size_in_words(), "offset too large");
5858

5959
HeapWord* q = _bot->address_for_index(index);
6060
return q - offset;
@@ -92,7 +92,7 @@ void G1BlockOffsetTable::set_offset_array(size_t left, size_t right, u_char offs
9292

9393
// Variant of index_for that does not check the index for validity.
9494
inline size_t G1BlockOffsetTable::index_for_raw(const void* p) const {
95-
return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> BOTConstants::log_card_size();
95+
return pointer_delta((char*)p, _reserved.start(), sizeof(char)) >> CardTable::card_shift();
9696
}
9797

9898
inline size_t G1BlockOffsetTable::index_for(const void* p) const {

‎src/hotspot/share/gc/g1/g1RemSet.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -531,7 +531,7 @@ class G1ScanHRForRegionClosure : public HeapRegionClosure {
531531
return;
532532
}
533533

534-
HeapWord* scan_end = MIN2(card_start + (num_cards << BOTConstants::log_card_size_in_words()), top);
534+
HeapWord* scan_end = MIN2(card_start + (num_cards << CardTable::card_shift_in_words()), top);
535535
if (_scanned_to >= scan_end) {
536536
return;
537537
}

‎src/hotspot/share/gc/parallel/objectStartArray.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@ static size_t num_bytes_required(MemRegion mr) {
3434
assert(CardTable::is_card_aligned(mr.start()), "precondition");
3535
assert(CardTable::is_card_aligned(mr.end()), "precondition");
3636

37-
return mr.word_size() / BOTConstants::card_size_in_words();
37+
return mr.word_size() / CardTable::card_size_in_words();
3838
}
3939

4040
void ObjectStartArray::initialize(MemRegion reserved_region) {
@@ -58,7 +58,7 @@ void ObjectStartArray::initialize(MemRegion reserved_region) {
5858

5959
assert(_virtual_space.low_boundary() != nullptr, "set from the backing_store");
6060

61-
_offset_base = (uint8_t*)(_virtual_space.low_boundary() - (uintptr_t(reserved_region.start()) >> BOTConstants::log_card_size()));
61+
_offset_base = (uint8_t*)(_virtual_space.low_boundary() - (uintptr_t(reserved_region.start()) >> CardTable::card_shift()));
6262
}
6363

6464
void ObjectStartArray::set_covered_region(MemRegion mr) {
@@ -111,7 +111,7 @@ void ObjectStartArray::update_for_block_work(HeapWord* blk_start,
111111
// -1 so that the reach ends in this region and not at the start
112112
// of the next.
113113
uint8_t* reach = offset_entry + BOTConstants::power_to_cards_back(i + 1) - 1;
114-
uint8_t value = checked_cast<uint8_t>(BOTConstants::card_size_in_words() + i);
114+
uint8_t value = checked_cast<uint8_t>(CardTable::card_size_in_words() + i);
115115

116116
fill_range(start_entry_for_region, MIN2(reach, end_entry), value);
117117
start_entry_for_region = reach + 1;
@@ -132,7 +132,7 @@ void ObjectStartArray::verify_for_block(HeapWord* blk_start, HeapWord* blk_end)
132132
const uint8_t* const start_entry = entry_for_addr(align_up_by_card_size(blk_start));
133133
const uint8_t* const end_entry = entry_for_addr(blk_end - 1);
134134
// Check entries in [start_entry, end_entry]
135-
assert(*start_entry < BOTConstants::card_size_in_words(), "offset entry");
135+
assert(*start_entry < CardTable::card_size_in_words(), "offset entry");
136136

137137
for (const uint8_t* i = start_entry + 1; i <= end_entry; ++i) {
138138
const uint8_t prev = *(i-1);

‎src/hotspot/share/gc/parallel/objectStartArray.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
2727

2828
#include "gc/parallel/psVirtualspace.hpp"
2929
#include "gc/shared/blockOffsetTable.hpp"
30+
#include "gc/shared/cardTable.hpp"
3031
#include "memory/allocation.hpp"
3132
#include "memory/memRegion.hpp"
3233
#include "oops/oop.hpp"
@@ -50,21 +51,21 @@ class ObjectStartArray : public CHeapObj<mtGC> {
5051
uint8_t* entry_for_addr(const void* const p) const {
5152
assert(_covered_region.contains(p),
5253
"out of bounds access to object start array");
53-
uint8_t* result = &_offset_base[uintptr_t(p) >> BOTConstants::log_card_size()];
54+
uint8_t* result = &_offset_base[uintptr_t(p) >> CardTable::card_shift()];
5455
return result;
5556
}
5657

5758
// Mapping from object start array entry to address of first word
5859
HeapWord* addr_for_entry(const uint8_t* const p) const {
5960
size_t delta = pointer_delta(p, _offset_base, sizeof(uint8_t));
60-
HeapWord* result = (HeapWord*) (delta << BOTConstants::log_card_size());
61+
HeapWord* result = (HeapWord*) (delta << CardTable::card_shift());
6162
assert(_covered_region.contains(result),
6263
"out of bounds accessor from card marking array");
6364
return result;
6465
}
6566

6667
static HeapWord* align_up_by_card_size(HeapWord* const addr) {
67-
return align_up(addr, BOTConstants::card_size());
68+
return align_up(addr, CardTable::card_size());
6869
}
6970

7071
void update_for_block_work(HeapWord* blk_start, HeapWord* blk_end);

‎src/hotspot/share/gc/parallel/objectStartArray.inline.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@ HeapWord* ObjectStartArray::block_start_reaching_into_card(HeapWord* const addr)
5050
while (true) {
5151
offset = *entry;
5252

53-
if (offset < BOTConstants::card_size_in_words()) {
53+
if (offset < CardTable::card_size_in_words()) {
5454
break;
5555
}
5656

‎src/hotspot/share/gc/parallel/psOldGen.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -127,7 +127,7 @@ size_t PSOldGen::num_iterable_blocks() const {
127127

128128
void PSOldGen::object_iterate_block(ObjectClosure* cl, size_t block_index) {
129129
size_t block_word_size = IterateBlockSize / HeapWordSize;
130-
assert((block_word_size % BOTConstants::card_size_in_words()) == 0,
130+
assert((block_word_size % CardTable::card_size_in_words()) == 0,
131131
"To ensure fast object_start calls");
132132

133133
MutableSpace *space = object_space();

‎src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -129,7 +129,7 @@ void SerialBlockOffsetTable::update_for_block_work(HeapWord* blk_start,
129129
// -1 so that the reach ends in this region and not at the start
130130
// of the next.
131131
size_t reach = offset_card + BOTConstants::power_to_cards_back(i + 1) - 1;
132-
uint8_t value = checked_cast<uint8_t>(BOTConstants::card_size_in_words() + i);
132+
uint8_t value = checked_cast<uint8_t>(CardTable::card_size_in_words() + i);
133133

134134
_array->set_offset_array(start_card_for_region, MIN2(reach, end_card), value);
135135
start_card_for_region = reach + 1;
@@ -151,7 +151,7 @@ HeapWord* SerialBlockOffsetTable::block_start_reaching_into_card(const void* add
151151
while (true) {
152152
offset = _array->offset_array(index);
153153

154-
if (offset < BOTConstants::card_size_in_words()) {
154+
if (offset < CardTable::card_size_in_words()) {
155155
break;
156156
}
157157

@@ -171,7 +171,7 @@ void SerialBlockOffsetTable::verify_for_block(HeapWord* blk_start, HeapWord* blk
171171
const size_t start_card = _array->index_for(align_up_by_card_size(blk_start));
172172
const size_t end_card = _array->index_for(blk_end - 1);
173173
// Check cards in [start_card, end_card]
174-
assert(_array->offset_array(start_card) < BOTConstants::card_size_in_words(), "offset card");
174+
assert(_array->offset_array(start_card) < CardTable::card_size_in_words(), "offset card");
175175

176176
for (size_t i = start_card + 1; i <= end_card; ++i) {
177177
const uint8_t prev = _array->offset_array(i-1);

‎src/hotspot/share/gc/serial/serialBlockOffsetTable.hpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -61,9 +61,9 @@ class SerialBlockOffsetSharedArray: public CHeapObj<mtGC> {
6161
// Return the number of slots needed for an offset array
6262
// that covers mem_region_words words.
6363
static size_t compute_size(size_t mem_region_words) {
64-
assert(mem_region_words % BOTConstants::card_size_in_words() == 0, "precondition");
64+
assert(mem_region_words % CardTable::card_size_in_words() == 0, "precondition");
6565

66-
size_t number_of_slots = mem_region_words / BOTConstants::card_size_in_words();
66+
size_t number_of_slots = mem_region_words / CardTable::card_size_in_words();
6767
return ReservedSpace::allocation_align_size_up(number_of_slots);
6868
}
6969

@@ -91,7 +91,7 @@ class SerialBlockOffsetSharedArray: public CHeapObj<mtGC> {
9191
void set_offset_array(size_t index, HeapWord* high, HeapWord* low) {
9292
assert(index < _vs.committed_size(), "index out of range");
9393
assert(high >= low, "addresses out of order");
94-
assert(pointer_delta(high, low) < BOTConstants::card_size_in_words(), "offset too large");
94+
assert(pointer_delta(high, low) < CardTable::card_size_in_words(), "offset too large");
9595
_offset_array[index] = checked_cast<uint8_t>(pointer_delta(high, low));
9696
}
9797

@@ -117,17 +117,15 @@ class SerialBlockOffsetTable {
117117
void update_for_block_work(HeapWord* blk_start, HeapWord* blk_end);
118118

119119
static HeapWord* align_up_by_card_size(HeapWord* const addr) {
120-
return align_up(addr, BOTConstants::card_size());
120+
return align_up(addr, CardTable::card_size());
121121
}
122122

123123
void verify_for_block(HeapWord* blk_start, HeapWord* blk_end) const;
124124

125125
public:
126126
// Initialize the table to cover the given space.
127127
// The contents of the initial table are undefined.
128-
SerialBlockOffsetTable(SerialBlockOffsetSharedArray* array) : _array(array) {
129-
assert(BOTConstants::card_size() == CardTable::card_size(), "sanity");
130-
}
128+
SerialBlockOffsetTable(SerialBlockOffsetSharedArray* array) : _array(array) {}
131129

132130
static bool is_crossing_card_boundary(HeapWord* const obj_start,
133131
HeapWord* const obj_end) {

‎src/hotspot/share/gc/serial/serialBlockOffsetTable.inline.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,14 +33,14 @@ inline size_t SerialBlockOffsetSharedArray::index_for(const void* p) const {
3333
pc < (char*)_reserved.end(),
3434
"p not in range.");
3535
size_t delta = pointer_delta(pc, _reserved.start(), sizeof(char));
36-
size_t result = delta >> BOTConstants::log_card_size();
36+
size_t result = delta >> CardTable::card_shift();
3737
assert(result < _vs.committed_size(), "bad index from address");
3838
return result;
3939
}
4040

4141
inline HeapWord* SerialBlockOffsetSharedArray::address_for_index(size_t index) const {
4242
assert(index < _vs.committed_size(), "bad index");
43-
HeapWord* result = _reserved.start() + (index << BOTConstants::log_card_size_in_words());
43+
HeapWord* result = _reserved.start() + (index << CardTable::card_shift_in_words());
4444
assert(result >= _reserved.start() && result < _reserved.end(),
4545
"bad address from index");
4646
return result;

‎src/hotspot/share/gc/shared/blockOffsetTable.cpp

-39
This file was deleted.

‎src/hotspot/share/gc/shared/blockOffsetTable.hpp

+4-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,44 +25,25 @@
2525
#ifndef SHARE_GC_SHARED_BLOCKOFFSETTABLE_HPP
2626
#define SHARE_GC_SHARED_BLOCKOFFSETTABLE_HPP
2727

28+
#include "gc/shared/cardTable.hpp"
2829
#include "memory/allStatic.hpp"
2930
#include "utilities/globalDefinitions.hpp"
3031

3132
class BOTConstants : public AllStatic {
32-
static uint _log_card_size;
33-
static uint _log_card_size_in_words;
34-
static uint _card_size;
35-
static uint _card_size_in_words;
36-
3733
public:
3834
// entries "e" of at least N_words mean "go back by Base^(e-N_words)."
3935
// All entries are less than "N_words + N_powers".
4036
static const uint LogBase = 4;
4137
static const uint Base = (1 << LogBase);
4238
static const uint N_powers = 14;
4339

44-
// Initialize bot size based on card size
45-
static void initialize_bot_size(uint card_shift);
46-
4740
static size_t power_to_cards_back(uint i) {
4841
return (size_t)1 << (LogBase * i);
4942
}
5043

5144
static size_t entry_to_cards_back(u_char entry) {
52-
assert(entry >= _card_size_in_words, "Precondition");
53-
return power_to_cards_back(entry - _card_size_in_words);
54-
}
55-
static uint log_card_size() {
56-
return _log_card_size;
57-
}
58-
static uint log_card_size_in_words() {
59-
return _log_card_size_in_words;
60-
}
61-
static uint card_size() {
62-
return _card_size;
63-
}
64-
static uint card_size_in_words() {
65-
return _card_size_in_words;
45+
assert(entry >= CardTable::card_size_in_words(), "Precondition");
46+
return power_to_cards_back(entry - CardTable::card_size_in_words());
6647
}
6748
};
6849

‎src/hotspot/share/gc/shared/cardTable.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#endif
4141

4242
uint CardTable::_card_shift = 0;
43+
uint CardTable::_card_shift_in_words = 0;
4344
uint CardTable::_card_size = 0;
4445
uint CardTable::_card_size_in_words = 0;
4546

@@ -50,9 +51,7 @@ void CardTable::initialize_card_size() {
5051
_card_size = GCCardSizeInBytes;
5152
_card_shift = log2i_exact(_card_size);
5253
_card_size_in_words = _card_size / sizeof(HeapWord);
53-
54-
// Set blockOffsetTable size based on card table entry size
55-
BOTConstants::initialize_bot_size(_card_shift);
54+
_card_shift_in_words = _card_shift - LogHeapWordSize;
5655

5756
log_info_p(gc, init)("CardTable entry size: " UINT32_FORMAT, _card_size);
5857
}

‎src/hotspot/share/gc/shared/cardTable.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class CardTable: public CHeapObj<mtGC> {
7373

7474
// CardTable entry size
7575
static uint _card_shift;
76+
static uint _card_shift_in_words;
7677
static uint _card_size;
7778
static uint _card_size_in_words;
7879

@@ -182,6 +183,10 @@ class CardTable: public CHeapObj<mtGC> {
182183
return _card_shift;
183184
}
184185

186+
static uint card_shift_in_words() {
187+
return _card_shift_in_words;
188+
}
189+
185190
static uint card_size() {
186191
return _card_size;
187192
}

‎test/hotspot/gtest/gc/g1/test_freeRegionList.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ TEST_VM(FreeRegionList, length) {
5656
bot_rs.size(),
5757
os::vm_page_size(),
5858
HeapRegion::GrainBytes,
59-
BOTConstants::card_size(),
59+
CardTable::card_size(),
6060
mtGC);
6161
G1BlockOffsetTable bot(heap, bot_storage);
6262
bot_storage->commit_regions(0, num_regions_in_test);

0 commit comments

Comments
 (0)
Please sign in to comment.