8230759: ZGC: Fix integer types
authorstefank
Wed, 11 Sep 2019 09:47:42 +0200
changeset 58237 944b58cbaf93
parent 58236 312126722609
child 58238 3386b9a8ef4d
8230759: ZGC: Fix integer types Reviewed-by: pliden
src/hotspot/share/gc/z/zAttachedArray.hpp
src/hotspot/share/gc/z/zAttachedArray.inline.hpp
src/hotspot/share/gc/z/zForwarding.cpp
src/hotspot/share/gc/z/zForwarding.hpp
src/hotspot/share/gc/z/zForwarding.inline.hpp
src/hotspot/share/gc/z/zNMethodData.cpp
src/hotspot/share/gc/z/zRelocate.cpp
src/hotspot/share/gc/z/zStat.cpp
src/hotspot/share/gc/z/zUncommitter.cpp
test/hotspot/gtest/gc/z/test_zForwarding.cpp
--- a/src/hotspot/share/gc/z/zAttachedArray.hpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zAttachedArray.hpp	Wed Sep 11 09:47:42 2019 +0200
@@ -29,7 +29,7 @@
 template <typename ObjectT, typename ArrayT>
 class ZAttachedArray {
 private:
-  const uint32_t _length;
+  const size_t _length;
 
   static size_t object_size();
 
@@ -39,7 +39,7 @@
 
   ZAttachedArray(size_t length);
 
-  uint32_t length() const;
+  size_t length() const;
   ArrayT* operator()(const ObjectT* obj) const;
 };
 
--- a/src/hotspot/share/gc/z/zAttachedArray.inline.hpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zAttachedArray.inline.hpp	Wed Sep 11 09:47:42 2019 +0200
@@ -51,7 +51,7 @@
     _length(length) {}
 
 template <typename ObjectT, typename ArrayT>
-inline uint32_t ZAttachedArray<ObjectT, ArrayT>::length() const {
+inline size_t ZAttachedArray<ObjectT, ArrayT>::length() const {
   return _length;
 }
 
--- a/src/hotspot/share/gc/z/zForwarding.cpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zForwarding.cpp	Wed Sep 11 09:47:42 2019 +0200
@@ -34,7 +34,7 @@
   // The table is sized to have a load factor of 50%, i.e. sized to have
   // double the number of entries actually inserted.
   assert(page->live_objects() > 0, "Invalid value");
-  const uint32_t nentries = ZUtils::round_up_power_of_2(page->live_objects() * 2);
+  const size_t nentries = ZUtils::round_up_power_of_2(page->live_objects() * 2);
   return ::new (AttachedArray::alloc(nentries)) ZForwarding(page, nentries);
 }
 
@@ -42,7 +42,7 @@
   AttachedArray::free(forwarding);
 }
 
-ZForwarding::ZForwarding(ZPage* page, uint32_t nentries) :
+ZForwarding::ZForwarding(ZPage* page, size_t nentries) :
     _virtual(page->virtual_memory()),
     _object_alignment_shift(page->object_alignment_shift()),
     _entries(nentries),
@@ -54,7 +54,7 @@
   guarantee(_refcount > 0, "Invalid refcount");
   guarantee(_page != NULL, "Invalid page");
 
-  uint32_t live_objects = 0;
+  size_t live_objects = 0;
 
   for (ZForwardingCursor i = 0; i < _entries.length(); i++) {
     const ZForwardingEntry entry = at(&i);
--- a/src/hotspot/share/gc/z/zForwarding.hpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zForwarding.hpp	Wed Sep 11 09:47:42 2019 +0200
@@ -30,7 +30,7 @@
 
 class ZPage;
 
-typedef uint32_t ZForwardingCursor;
+typedef size_t ZForwardingCursor;
 
 class ZForwarding {
   friend class VMStructs;
@@ -54,7 +54,7 @@
   ZForwardingEntry first(uintptr_t from_index, ZForwardingCursor* cursor) const;
   ZForwardingEntry next(ZForwardingCursor* cursor) const;
 
-  ZForwarding(ZPage* page, uint32_t nentries);
+  ZForwarding(ZPage* page, size_t nentries);
 
 public:
   static ZForwarding* create(ZPage* page);
--- a/src/hotspot/share/gc/z/zForwarding.inline.hpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zForwarding.inline.hpp	Wed Sep 11 09:47:42 2019 +0200
@@ -99,14 +99,14 @@
 }
 
 inline ZForwardingEntry ZForwarding::first(uintptr_t from_index, ZForwardingCursor* cursor) const {
-  const uint32_t mask = _entries.length() - 1;
-  const uint32_t hash = ZHash::uint32_to_uint32((uint32_t)from_index);
+  const size_t mask = _entries.length() - 1;
+  const size_t hash = ZHash::uint32_to_uint32((uint32_t)from_index);
   *cursor = hash & mask;
   return at(cursor);
 }
 
 inline ZForwardingEntry ZForwarding::next(ZForwardingCursor* cursor) const {
-  const uint32_t mask = _entries.length() - 1;
+  const size_t mask = _entries.length() - 1;
   *cursor = (*cursor + 1) & mask;
   return at(cursor);
 }
--- a/src/hotspot/share/gc/z/zNMethodData.cpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zNMethodData.cpp	Wed Sep 11 09:47:42 2019 +0200
@@ -45,7 +45,7 @@
     _has_non_immediates(has_non_immediates) {
   // Save all immediate oops
   for (size_t i = 0; i < immediates_count(); i++) {
-    immediates_begin()[i] = immediates.at(i);
+    immediates_begin()[i] = immediates.at(int(i));
   }
 }
 
--- a/src/hotspot/share/gc/z/zRelocate.cpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zRelocate.cpp	Wed Sep 11 09:47:42 2019 +0200
@@ -126,7 +126,7 @@
   // Relocation contention
   ZStatInc(ZCounterRelocationContention);
   log_trace(gc)("Relocation contention, thread: " PTR_FORMAT " (%s), forwarding: " PTR_FORMAT
-                ", entry: " UINT32_FORMAT ", oop: " PTR_FORMAT ", size: " SIZE_FORMAT,
+                ", entry: " SIZE_FORMAT ", oop: " PTR_FORMAT ", size: " SIZE_FORMAT,
                 ZThread::id(), ZThread::name(), p2i(forwarding), cursor, from_good, size);
 
   // Try undo allocation
--- a/src/hotspot/share/gc/z/zStat.cpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zStat.cpp	Wed Sep 11 09:47:42 2019 +0200
@@ -354,7 +354,7 @@
 
 void ZStatValue::initialize() {
   // Finalize and align CPU offset
-  _cpu_offset = align_up(_cpu_offset, ZCacheLineSize);
+  _cpu_offset = align_up(_cpu_offset, (uint32_t)ZCacheLineSize);
 
   // Allocation aligned memory
   const size_t size = _cpu_offset * ZCPU::count();
--- a/src/hotspot/share/gc/z/zUncommitter.cpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/src/hotspot/share/gc/z/zUncommitter.cpp	Wed Sep 11 09:47:42 2019 +0200
@@ -36,7 +36,7 @@
 
 bool ZUncommitter::idle(uint64_t timeout) {
   // Idle for at least one second
-  const uint64_t expires = os::elapsedTime() + MAX2(timeout, 1ul);
+  const uint64_t expires = os::elapsedTime() + MAX2<uint64_t>(timeout, 1);
 
   for (;;) {
     // We might wake up spuriously from wait, so always recalculate
--- a/test/hotspot/gtest/gc/z/test_zForwarding.cpp	Tue Sep 10 17:07:02 2019 +0200
+++ b/test/hotspot/gtest/gc/z/test_zForwarding.cpp	Wed Sep 11 09:47:42 2019 +0200
@@ -40,19 +40,19 @@
 public:
   // Helper functions
 
-  static bool is_power_of_2(uint32_t value) {
+  static bool is_power_of_2(size_t value) {
     return ::is_power_of_2((intptr_t)value);
   }
 
   class SequenceToFromIndex : AllStatic {
   public:
-    static uintptr_t even(uint32_t sequence_number) {
+    static uintptr_t even(size_t sequence_number) {
       return sequence_number * 2;
     }
-    static uintptr_t odd(uint32_t sequence_number) {
+    static uintptr_t odd(size_t sequence_number) {
       return even(sequence_number) + 1;
     }
-    static uintptr_t one_to_one(uint32_t sequence_number) {
+    static uintptr_t one_to_one(size_t sequence_number) {
       return sequence_number;
     }
   };
@@ -64,10 +64,10 @@
   }
 
   static void find_empty(ZForwarding* forwarding) {
-    uint32_t size = forwarding->_entries.length();
-    uint32_t entries_to_check = size * 2;
+    size_t size = forwarding->_entries.length();
+    size_t entries_to_check = size * 2;
 
-    for (uint32_t i = 0; i < entries_to_check; i++) {
+    for (size_t i = 0; i < entries_to_check; i++) {
       uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
 
       EXPECT_FALSE(forwarding->find(from_index).populated()) << CAPTURE2(from_index, size);
@@ -75,11 +75,11 @@
   }
 
   static void find_full(ZForwarding* forwarding) {
-    uint32_t size = forwarding->_entries.length();
-    uint32_t entries_to_populate = size;
+    size_t size = forwarding->_entries.length();
+    size_t entries_to_populate = size;
 
     // Populate
-    for (uint32_t i = 0; i < entries_to_populate; i++) {
+    for (size_t i = 0; i < entries_to_populate; i++) {
       uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
 
       ZForwardingCursor cursor;
@@ -90,7 +90,7 @@
     }
 
     // Verify
-    for (uint32_t i = 0; i < entries_to_populate; i++) {
+    for (size_t i = 0; i < entries_to_populate; i++) {
       uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
 
       ZForwardingEntry entry = forwarding->find(from_index);
@@ -102,11 +102,11 @@
   }
 
   static void find_every_other(ZForwarding* forwarding) {
-    uint32_t size = forwarding->_entries.length();
-    uint32_t entries_to_populate = size / 2;
+    size_t size = forwarding->_entries.length();
+    size_t entries_to_populate = size / 2;
 
     // Populate even from indices
-    for (uint32_t i = 0; i < entries_to_populate; i++) {
+    for (size_t i = 0; i < entries_to_populate; i++) {
       uintptr_t from_index = SequenceToFromIndex::even(i);
 
       ZForwardingCursor cursor;
@@ -117,7 +117,7 @@
     }
 
     // Verify populated even indices
-    for (uint32_t i = 0; i < entries_to_populate; i++) {
+    for (size_t i = 0; i < entries_to_populate; i++) {
       uintptr_t from_index = SequenceToFromIndex::even(i);
 
       ZForwardingCursor cursor;
@@ -132,7 +132,7 @@
     //
     // This check could be done on a larger range of sequence numbers,
     // but currently entries_to_populate is used.
-    for (uint32_t i = 0; i < entries_to_populate; i++) {
+    for (size_t i = 0; i < entries_to_populate; i++) {
       uintptr_t from_index = SequenceToFromIndex::odd(i);
 
       ZForwardingEntry entry = forwarding->find(from_index);
@@ -158,7 +158,7 @@
     page.mark_object(ZAddress::marked(object), dummy, dummy);
 
     const uint32_t live_objects = size;
-    const uint32_t live_bytes = live_objects * object_size;
+    const size_t live_bytes = live_objects * object_size;
     page.inc_live_atomic(live_objects, live_bytes);
 
     // Setup forwarding