--- a/src/hotspot/share/gc/z/zGranuleMap.hpp Mon May 06 21:31:36 2019 -0700
+++ b/src/hotspot/share/gc/z/zGranuleMap.hpp Tue May 07 07:44:15 2019 +0200
@@ -35,10 +35,10 @@
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();
--- a/src/hotspot/share/gc/z/zGranuleMap.inline.hpp Mon May 06 21:31:36 2019 -0700
+++ b/src/hotspot/share/gc/z/zGranuleMap.inline.hpp Tue May 07 07:44:15 2019 +0200
@@ -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,17 +44,12 @@
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);
return _map[index];
@@ -83,7 +79,7 @@
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 @@
template <typename T>
inline bool ZGranuleMapIterator<T>::next(T** value) {
- if (_next < _map->size()) {
+ if (_next < _map->_size) {
*value = _map->_map + _next++;
return true;
}