8223308: ZGC: Remove ZGranuleMap::size()

Reviewed-by: stefank, eosterlund
This commit is contained in:
Per Lidén 2019-05-07 07:44:15 +02:00
parent c6a2274d1a
commit d5391d290d
2 changed files with 8 additions and 12 deletions

@ -35,10 +35,10 @@ class ZGranuleMap {
friend class ZGranuleMapIterator<T>;
private:
T* const _map;
const size_t _size;
T* const _map;
size_t index_for_addr(uintptr_t addr) const;
size_t size() const;
public:
ZGranuleMap();

@ -31,11 +31,12 @@
template <typename T>
inline ZGranuleMap<T>::ZGranuleMap() :
_map(MmapArrayAllocator<T>::allocate(size(), mtGC)) {}
_size(ZAddressOffsetMax >> ZGranuleSizeShift),
_map(MmapArrayAllocator<T>::allocate(_size, mtGC)) {}
template <typename T>
inline ZGranuleMap<T>::~ZGranuleMap() {
MmapArrayAllocator<T>::free(_map, size());
MmapArrayAllocator<T>::free(_map, _size);
}
template <typename T>
@ -43,16 +44,11 @@ inline size_t ZGranuleMap<T>::index_for_addr(uintptr_t addr) const {
assert(!ZAddress::is_null(addr), "Invalid address");
const size_t index = ZAddress::offset(addr) >> ZGranuleSizeShift;
assert(index < size(), "Invalid index");
assert(index < _size, "Invalid index");
return index;
}
template <typename T>
inline size_t ZGranuleMap<T>::size() const {
return ZAddressOffsetMax >> ZGranuleSizeShift;
}
template <typename T>
inline T ZGranuleMap<T>::get(uintptr_t addr) const {
const size_t index = index_for_addr(addr);
@ -83,7 +79,7 @@ inline ZGranuleMapIterator<T>::ZGranuleMapIterator(const ZGranuleMap<T>* map) :
template <typename T>
inline bool ZGranuleMapIterator<T>::next(T* value) {
if (_next < _map->size()) {
if (_next < _map->_size) {
*value = _map->_map[_next++];
return true;
}
@ -94,7 +90,7 @@ inline bool ZGranuleMapIterator<T>::next(T* value) {
template <typename T>
inline bool ZGranuleMapIterator<T>::next(T** value) {
if (_next < _map->size()) {
if (_next < _map->_size) {
*value = _map->_map + _next++;
return true;
}