8286704: G1: Call offset_of directly in subclasses of G1CardSetContainer

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Albert Mingkun Yang 2022-05-16 13:12:02 +00:00
parent 77dfbb4570
commit 22139c35c4
2 changed files with 15 additions and 21 deletions

View File

@ -188,12 +188,6 @@ private:
Atomic::release_store(_num_entries_addr, _local_num_entries);
}
};
template<typename Derived>
static size_t header_size_in_bytes_internal() {
return offset_of(Derived, _data);
}
public:
G1CardSetArray(uint const card_in_region, EntryCountType num_cards);
@ -206,7 +200,7 @@ public:
size_t num_entries() const { return _num_entries & EntryMask; }
static size_t header_size_in_bytes() { return header_size_in_bytes_internal<G1CardSetArray>(); }
static size_t header_size_in_bytes();
static size_t size_in_bytes(size_t num_cards) {
return header_size_in_bytes() + sizeof(EntryDataType) * num_cards;
@ -217,13 +211,6 @@ class G1CardSetBitMap : public G1CardSetContainer {
size_t _num_bits_set;
BitMap::bm_word_t _bits[1];
using ContainerPtr = G1CardSet::ContainerPtr;
template<typename Derived>
static size_t header_size_in_bytes_internal() {
return offset_of(Derived, _bits);
}
public:
G1CardSetBitMap(uint const card_in_region, uint const size_in_bits);
@ -244,7 +231,7 @@ public:
return static_cast<uint>(bm.get_next_one_offset(idx));
}
static size_t header_size_in_bytes() { return header_size_in_bytes_internal<G1CardSetBitMap>(); }
static size_t header_size_in_bytes();
static size_t size_in_bytes(size_t size_in_bits) { return header_size_in_bytes() + BitMap::calc_size_in_words(size_in_bits) * BytesPerWord; }
};
@ -258,11 +245,6 @@ private:
ContainerPtr _buckets[2];
// Do not add class member variables beyond this point
template<typename Derived>
static size_t header_size_in_bytes_internal() {
return offset_of(Derived, _buckets);
}
// Iterates over the given ContainerPtr with at index in this Howl card set,
// applying a CardOrRangeVisitor on it.
template <class CardOrRangeVisitor>
@ -297,7 +279,7 @@ public:
return round_up_power_of_2(num_cards);
}
static size_t header_size_in_bytes() { return header_size_in_bytes_internal<G1CardSetHowl>(); }
static size_t header_size_in_bytes();
static size_t size_in_bytes(size_t num_arrays) {
return header_size_in_bytes() + sizeof(ContainerPtr) * num_arrays;

View File

@ -221,6 +221,10 @@ void G1CardSetArray::iterate(CardVisitor& found) {
}
}
inline size_t G1CardSetArray::header_size_in_bytes() {
return offset_of(G1CardSetArray, _data);
}
inline G1CardSetBitMap::G1CardSetBitMap(uint card_in_region, uint size_in_bits) :
G1CardSetContainer(), _num_bits_set(1) {
assert(size_in_bits % (sizeof(_bits[0]) * BitsPerByte) == 0,
@ -252,6 +256,10 @@ inline void G1CardSetBitMap::iterate(CardVisitor& found, size_t size_in_bits, ui
}
}
inline size_t G1CardSetBitMap::header_size_in_bytes() {
return offset_of(G1CardSetBitMap, _bits);
}
inline G1CardSetHowl::G1CardSetHowl(EntryCountType card_in_region, G1CardSetConfiguration* config) :
G1CardSetContainer(),
_num_entries((config->max_cards_in_array() + 1)) /* Card Transfer will not increment _num_entries */ {
@ -352,4 +360,8 @@ inline G1CardSetHowl::EntryCountType G1CardSetHowl::num_buckets(size_t size_in_b
return (EntryCountType)num_arrays;
}
inline size_t G1CardSetHowl::header_size_in_bytes() {
return offset_of(G1CardSetHowl, _buckets);
}
#endif // SHARE_GC_G1_G1CARDSETCONTAINERS_INLINE_HPP