8232601: ZGC: Parameterize the ZGranuleMap table size
authorstefank
Mon, 28 Oct 2019 11:21:23 +0100
changeset 58809 44dc3d796110
parent 58808 9261ad32cba9
child 58810 3aba4a42d8ad
8232601: ZGC: Parameterize the ZGranuleMap table size Reviewed-by: pliden, eosterlund
src/hotspot/share/gc/z/zForwardingTable.cpp
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
--- a/src/hotspot/share/gc/z/zForwardingTable.cpp	Sun Oct 27 12:13:51 2019 +0000
+++ b/src/hotspot/share/gc/z/zForwardingTable.cpp	Mon Oct 28 11:21:23 2019 +0100
@@ -25,11 +25,12 @@
 #include "gc/z/zAddress.inline.hpp"
 #include "gc/z/zForwarding.inline.hpp"
 #include "gc/z/zForwardingTable.inline.hpp"
+#include "gc/z/zGlobals.hpp"
 #include "gc/z/zGranuleMap.inline.hpp"
 #include "utilities/debug.hpp"
 
 ZForwardingTable::ZForwardingTable() :
-    _map() {}
+    _map(ZAddressOffsetMax) {}
 
 void ZForwardingTable::insert(ZForwarding* forwarding) {
   const uintptr_t addr = ZAddress::good(forwarding->start());
--- a/src/hotspot/share/gc/z/zGranuleMap.hpp	Sun Oct 27 12:13:51 2019 +0000
+++ b/src/hotspot/share/gc/z/zGranuleMap.hpp	Mon Oct 28 11:21:23 2019 +0100
@@ -41,7 +41,7 @@
   size_t index_for_addr(uintptr_t addr) const;
 
 public:
-  ZGranuleMap();
+  ZGranuleMap(size_t max_offset);
   ~ZGranuleMap();
 
   T get(uintptr_t addr) const;
--- a/src/hotspot/share/gc/z/zGranuleMap.inline.hpp	Sun Oct 27 12:13:51 2019 +0000
+++ b/src/hotspot/share/gc/z/zGranuleMap.inline.hpp	Mon Oct 28 11:21:23 2019 +0100
@@ -28,11 +28,15 @@
 #include "gc/z/zGlobals.hpp"
 #include "gc/z/zGranuleMap.hpp"
 #include "memory/allocation.inline.hpp"
+#include "utilities/align.hpp"
+#include "utilities/debug.hpp"
 
 template <typename T>
-inline ZGranuleMap<T>::ZGranuleMap() :
-    _size(ZAddressOffsetMax >> ZGranuleSizeShift),
-    _map(MmapArrayAllocator<T>::allocate(_size, mtGC)) {}
+inline ZGranuleMap<T>::ZGranuleMap(size_t max_offset) :
+    _size(max_offset >> ZGranuleSizeShift),
+    _map(MmapArrayAllocator<T>::allocate(_size, mtGC)) {
+  assert(is_aligned(max_offset, ZGranuleSize), "Misaligned");
+}
 
 template <typename T>
 inline ZGranuleMap<T>::~ZGranuleMap() {
--- a/src/hotspot/share/gc/z/zHeapIterator.cpp	Sun Oct 27 12:13:51 2019 +0000
+++ b/src/hotspot/share/gc/z/zHeapIterator.cpp	Mon Oct 28 11:21:23 2019 +0100
@@ -126,7 +126,7 @@
 
 ZHeapIterator::ZHeapIterator() :
     _visit_stack(),
-    _visit_map() {}
+    _visit_map(ZAddressOffsetMax) {}
 
 ZHeapIterator::~ZHeapIterator() {
   ZVisitMapIterator iter(&_visit_map);
--- a/src/hotspot/share/gc/z/zPageTable.cpp	Sun Oct 27 12:13:51 2019 +0000
+++ b/src/hotspot/share/gc/z/zPageTable.cpp	Mon Oct 28 11:21:23 2019 +0100
@@ -23,6 +23,7 @@
 
 #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"
 #include "gc/z/zPageTable.inline.hpp"
@@ -30,7 +31,7 @@
 #include "utilities/debug.hpp"
 
 ZPageTable::ZPageTable() :
-    _map() {}
+    _map(ZAddressOffsetMax) {}
 
 void ZPageTable::insert(ZPage* page) {
   const uintptr_t addr = ZAddress::good(page->start());