Skip to content

Commit 5cbdb27

Browse files
committed
Hi all, please review this minor touch-up of the G1BiasedArray classes, removing some unused methods and improving method visibility a bit. Testing: gha Thanks, Thomas
1 parent ae7ae84 commit 5cbdb27

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,4 @@ void G1BiasedMappedArrayBase::verify_biased_index(idx_t biased_index) const {
5757
biased_index, bias(), length());
5858
}
5959

60-
void G1BiasedMappedArrayBase::verify_biased_index_inclusive_end(idx_t biased_index) const {
61-
guarantee(_biased_base != nullptr, "Array not initialized");
62-
guarantee(biased_index >= bias() && biased_index <= (bias() + length()),
63-
"Biased index out of inclusive bounds, index: %zu bias: %zu length: %zu",
64-
biased_index, bias(), length());
65-
}
66-
6760
#endif

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

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,6 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> {
3838

3939
void* _alloc_base; // the address the unpadded array has been allocated to
4040

41-
public:
42-
typedef size_t idx_t;
43-
44-
protected:
45-
address _base; // the real base address
46-
size_t _length; // the length of the array
47-
address _biased_base; // base address biased by "bias" elements
48-
size_t _bias; // the bias, i.e. the offset biased_base is located to the right in elements
49-
uint _shift_by; // the amount of bits to shift right when mapping to an index of the array.
50-
51-
protected:
52-
G1BiasedMappedArrayBase();
53-
5441
// Allocate a new array, generic version.
5542
address create_new_base_array(size_t length, size_t elem_size);
5643

@@ -67,6 +54,18 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> {
6754
_shift_by = shift_by;
6855
}
6956

57+
public:
58+
typedef size_t idx_t;
59+
60+
protected:
61+
address _base; // the real base address
62+
size_t _length; // the length of the array
63+
address _biased_base; // base address biased by "bias" elements
64+
size_t _bias; // the bias, i.e. the offset biased_base is located to the right in elements
65+
uint _shift_by; // the amount of bits to shift right when mapping to an index of the array.
66+
67+
G1BiasedMappedArrayBase();
68+
7069
// Allocate and initialize this array to cover the heap addresses in the range
7170
// of [bottom, end).
7271
void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) {
@@ -90,7 +89,6 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> {
9089

9190
void verify_index(idx_t index) const PRODUCT_RETURN;
9291
void verify_biased_index(idx_t biased_index) const PRODUCT_RETURN;
93-
void verify_biased_index_inclusive_end(idx_t biased_index) const PRODUCT_RETURN;
9492

9593
public:
9694
virtual ~G1BiasedMappedArrayBase();
@@ -103,10 +101,15 @@ class G1BiasedMappedArrayBase : public CHeapObj<mtGC> {
103101
// heap into this array.
104102
template<class T>
105103
class G1BiasedMappedArray : public G1BiasedMappedArrayBase {
104+
105+
T* base() const { return (T*)G1BiasedMappedArrayBase::_base; }
106+
107+
// The raw biased base pointer.
108+
T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; }
109+
106110
public:
107111
typedef G1BiasedMappedArrayBase::idx_t idx_t;
108112

109-
T* base() const { return (T*)G1BiasedMappedArrayBase::_base; }
110113
// Return the element of the given array at the given index. Assume
111114
// the index is valid. This is a convenience method that does sanity
112115
// checking on the index.
@@ -123,9 +126,6 @@ class G1BiasedMappedArray : public G1BiasedMappedArrayBase {
123126
this->base()[index] = value;
124127
}
125128

126-
// The raw biased base pointer.
127-
T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; }
128-
129129
// Return the element of the given array that covers the given word in the
130130
// heap. Assumes the index is valid.
131131
T get_by_address(HeapWord* value) const {
@@ -166,15 +166,6 @@ class G1BiasedMappedArray : public G1BiasedMappedArrayBase {
166166
}
167167
}
168168

169-
protected:
170-
// Returns the address of the element the given address maps to
171-
T* address_mapped_to(HeapWord* address) {
172-
idx_t biased_index = ((uintptr_t)address) >> this->shift_by();
173-
this->verify_biased_index_inclusive_end(biased_index);
174-
return biased_base() + biased_index;
175-
}
176-
177-
public:
178169
// Return the smallest address (inclusive) in the heap that this array covers.
179170
HeapWord* bottom_address_mapped() const {
180171
return (HeapWord*) ((uintptr_t)this->bias() << this->shift_by());
@@ -194,6 +185,7 @@ class G1BiasedMappedArray : public G1BiasedMappedArrayBase {
194185
set_by_index(i, value);
195186
}
196187
}
188+
197189
public:
198190
G1BiasedMappedArray() {}
199191

0 commit comments

Comments
 (0)