changeset 54735:a9f729b641a3

8223308: ZGC: Remove ZGranuleMap::size() Reviewed-by: stefank, eosterlund
author pliden
date Tue, 07 May 2019 07:44:15 +0200
parents e8f1b9fc82cc
children 1dc9bf9d016b
files src/hotspot/share/gc/z/zGranuleMap.hpp src/hotspot/share/gc/z/zGranuleMap.inline.hpp
diffstat 2 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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;
   }