8232602: ZGC: Make ZGranuleMap ZAddress agnostic
authorstefank
Mon, 28 Oct 2019 11:23:28 +0100
changeset 58810 3aba4a42d8ad
parent 58809 44dc3d796110
child 58811 38f4701d6587
8232602: ZGC: Make ZGranuleMap ZAddress agnostic Reviewed-by: pliden, eosterlund
src/hotspot/share/gc/z/zForwardingTable.cpp
src/hotspot/share/gc/z/zForwardingTable.inline.hpp
src/hotspot/share/gc/z/zGranuleMap.hpp
src/hotspot/share/gc/z/zGranuleMap.inline.hpp
src/hotspot/share/gc/z/zHeapIterator.cpp
src/hotspot/share/gc/z/zPageTable.cpp
src/hotspot/share/gc/z/zPageTable.inline.hpp
--- a/src/hotspot/share/gc/z/zForwardingTable.cpp	Mon Oct 28 11:21:23 2019 +0100
+++ b/src/hotspot/share/gc/z/zForwardingTable.cpp	Mon Oct 28 11:23:28 2019 +0100
@@ -22,7 +22,6 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/z/zAddress.inline.hpp"
 #include "gc/z/zForwarding.inline.hpp"
 #include "gc/z/zForwardingTable.inline.hpp"
 #include "gc/z/zGlobals.hpp"
@@ -33,17 +32,17 @@
     _map(ZAddressOffsetMax) {}
 
 void ZForwardingTable::insert(ZForwarding* forwarding) {
-  const uintptr_t addr = ZAddress::good(forwarding->start());
+  const uintptr_t offset = forwarding->start();
   const size_t size = forwarding->size();
 
-  assert(get(addr) == NULL, "Invalid entry");
-  _map.put(addr, size, forwarding);
+  assert(_map.get(offset) == NULL, "Invalid entry");
+  _map.put(offset, size, forwarding);
 }
 
 void ZForwardingTable::remove(ZForwarding* forwarding) {
-  const uintptr_t addr = ZAddress::good(forwarding->start());
+  const uintptr_t offset = forwarding->start();
   const size_t size = forwarding->size();
 
-  assert(get(addr) == forwarding, "Invalid entry");
-  _map.put(addr, size, NULL);
+  assert(_map.get(offset) == forwarding, "Invalid entry");
+  _map.put(offset, size, NULL);
 }
--- a/src/hotspot/share/gc/z/zForwardingTable.inline.hpp	Mon Oct 28 11:21:23 2019 +0100
+++ b/src/hotspot/share/gc/z/zForwardingTable.inline.hpp	Mon Oct 28 11:23:28 2019 +0100
@@ -24,11 +24,13 @@
 #ifndef SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
 #define SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
 
+#include "gc/z/zAddress.inline.hpp"
 #include "gc/z/zForwardingTable.hpp"
 #include "gc/z/zGranuleMap.inline.hpp"
 
 inline ZForwarding* ZForwardingTable::get(uintptr_t addr) const {
-  return _map.get(addr);
+  assert(!ZAddress::is_null(addr), "Invalid address");
+  return _map.get(ZAddress::offset(addr));
 }
 
 #endif // SHARE_GC_Z_ZFORWARDINGTABLE_INLINE_HPP
--- a/src/hotspot/share/gc/z/zGranuleMap.hpp	Mon Oct 28 11:21:23 2019 +0100
+++ b/src/hotspot/share/gc/z/zGranuleMap.hpp	Mon Oct 28 11:23:28 2019 +0100
@@ -38,15 +38,15 @@
   const size_t _size;
   T* const     _map;
 
-  size_t index_for_addr(uintptr_t addr) const;
+  size_t index_for_offset(uintptr_t offset) const;
 
 public:
   ZGranuleMap(size_t max_offset);
   ~ZGranuleMap();
 
-  T get(uintptr_t addr) const;
-  void put(uintptr_t addr, T value);
-  void put(uintptr_t addr, size_t size, T value);
+  T get(uintptr_t offset) const;
+  void put(uintptr_t offset, T value);
+  void put(uintptr_t offset, size_t size, T value);
 };
 
 template <typename T>
--- a/src/hotspot/share/gc/z/zGranuleMap.inline.hpp	Mon Oct 28 11:21:23 2019 +0100
+++ b/src/hotspot/share/gc/z/zGranuleMap.inline.hpp	Mon Oct 28 11:23:28 2019 +0100
@@ -24,7 +24,6 @@
 #ifndef SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
 #define SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
 
-#include "gc/z/zAddress.inline.hpp"
 #include "gc/z/zGlobals.hpp"
 #include "gc/z/zGranuleMap.hpp"
 #include "memory/allocation.inline.hpp"
@@ -44,32 +43,30 @@
 }
 
 template <typename T>
-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;
+inline size_t ZGranuleMap<T>::index_for_offset(uintptr_t offset) const {
+  const size_t index = offset >> ZGranuleSizeShift;
   assert(index < _size, "Invalid index");
 
   return index;
 }
 
 template <typename T>
-inline T ZGranuleMap<T>::get(uintptr_t addr) const {
-  const size_t index = index_for_addr(addr);
+inline T ZGranuleMap<T>::get(uintptr_t offset) const {
+  const size_t index = index_for_offset(offset);
   return _map[index];
 }
 
 template <typename T>
-inline void ZGranuleMap<T>::put(uintptr_t addr, T value) {
-  const size_t index = index_for_addr(addr);
+inline void ZGranuleMap<T>::put(uintptr_t offset, T value) {
+  const size_t index = index_for_offset(offset);
   _map[index] = value;
 }
 
 template <typename T>
-inline void ZGranuleMap<T>::put(uintptr_t addr, size_t size, T value) {
+inline void ZGranuleMap<T>::put(uintptr_t offset, size_t size, T value) {
   assert(is_aligned(size, ZGranuleSize), "Misaligned");
 
-  const size_t start_index = index_for_addr(addr);
+  const size_t start_index = index_for_offset(offset);
   const size_t end_index = start_index + (size >> ZGranuleSizeShift);
   for (size_t index = start_index; index < end_index; index++) {
     _map[index] = value;
--- a/src/hotspot/share/gc/z/zHeapIterator.cpp	Mon Oct 28 11:21:23 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeapIterator.cpp	Mon Oct 28 11:23:28 2019 +0100
@@ -24,6 +24,7 @@
 #include "precompiled.hpp"
 #include "classfile/classLoaderData.hpp"
 #include "classfile/classLoaderDataGraph.hpp"
+#include "gc/z/zAddress.inline.hpp"
 #include "gc/z/zBarrier.inline.hpp"
 #include "gc/z/zGlobals.hpp"
 #include "gc/z/zGranuleMap.inline.hpp"
@@ -148,11 +149,11 @@
 }
 
 ZHeapIteratorBitMap* ZHeapIterator::object_map(oop obj) {
-  const uintptr_t addr = ZOop::to_address(obj);
-  ZHeapIteratorBitMap* map = _visit_map.get(addr);
+  const uintptr_t offset = ZAddress::offset(ZOop::to_address(obj));
+  ZHeapIteratorBitMap* map = _visit_map.get(offset);
   if (map == NULL) {
     map = new ZHeapIteratorBitMap(object_index_max());
-    _visit_map.put(addr, map);
+    _visit_map.put(offset, map);
   }
 
   return map;
--- a/src/hotspot/share/gc/z/zPageTable.cpp	Mon Oct 28 11:21:23 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageTable.cpp	Mon Oct 28 11:23:28 2019 +0100
@@ -22,7 +22,6 @@
  */
 
 #include "precompiled.hpp"
-#include "gc/z/zAddress.inline.hpp"
 #include "gc/z/zGlobals.hpp"
 #include "gc/z/zGranuleMap.inline.hpp"
 #include "gc/z/zPage.inline.hpp"
@@ -34,21 +33,21 @@
     _map(ZAddressOffsetMax) {}
 
 void ZPageTable::insert(ZPage* page) {
-  const uintptr_t addr = ZAddress::good(page->start());
+  const uintptr_t offset = page->start();
   const size_t size = page->size();
 
   // Make sure a newly created page is
   // visible before updating the page table.
   OrderAccess::storestore();
 
-  assert(get(addr) == NULL, "Invalid entry");
-  _map.put(addr, size, page);
+  assert(_map.get(offset) == NULL, "Invalid entry");
+  _map.put(offset, size, page);
 }
 
 void ZPageTable::remove(ZPage* page) {
-  const uintptr_t addr = ZAddress::good(page->start());
+  const uintptr_t offset = page->start();
   const size_t size = page->size();
 
-  assert(get(addr) == page, "Invalid entry");
-  _map.put(addr, size, NULL);
+  assert(_map.get(offset) == page, "Invalid entry");
+  _map.put(offset, size, NULL);
 }
--- a/src/hotspot/share/gc/z/zPageTable.inline.hpp	Mon Oct 28 11:21:23 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageTable.inline.hpp	Mon Oct 28 11:23:28 2019 +0100
@@ -29,7 +29,8 @@
 #include "gc/z/zPageTable.hpp"
 
 inline ZPage* ZPageTable::get(uintptr_t addr) const {
-  return _map.get(addr);
+  assert(!ZAddress::is_null(addr), "Invalid address");
+  return _map.get(ZAddress::offset(addr));
 }
 
 inline ZPageTableIterator::ZPageTableIterator(const ZPageTable* page_table) :