changeset 52956:cd19c580ba9c

8214377: ZGC: Don't use memset to initialize array of ZForwardingTableEntry Reviewed-by: rkennke, eosterlund
author pliden
date Mon, 03 Dec 2018 14:52:49 +0100
parents 5d292d59fe40
children 8613f3fdbdae
files src/hotspot/share/gc/z/zForwardingTable.cpp src/hotspot/share/gc/z/zForwardingTableEntry.hpp
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/z/zForwardingTable.cpp	Mon Dec 03 14:52:49 2018 +0100
+++ b/src/hotspot/share/gc/z/zForwardingTable.cpp	Mon Dec 03 14:52:49 2018 +0100
@@ -38,11 +38,18 @@
   _size = ZUtils::round_up_power_of_2(live_objects * 2);
   _table = MallocArrayAllocator<ZForwardingTableEntry>::allocate(_size, mtGC);
 
-  // Clear table
-  memset(_table, ZForwardingTableEntry::empty(), _size * sizeof(ZForwardingTableEntry));
+  // Construct table entries
+  for (size_t i = 0; i < _size; i++) {
+    ::new (_table + i) ZForwardingTableEntry();
+  }
 }
 
 void ZForwardingTable::reset() {
+  // Destruct table entries
+  for (size_t i = 0; i < _size; i++) {
+    (_table + i)->~ZForwardingTableEntry();
+  }
+
   // Free table
   MallocArrayAllocator<ZForwardingTableEntry>::free(_table);
   _table = NULL;
--- a/src/hotspot/share/gc/z/zForwardingTableEntry.hpp	Mon Dec 03 14:52:49 2018 +0100
+++ b/src/hotspot/share/gc/z/zForwardingTableEntry.hpp	Mon Dec 03 14:52:49 2018 +0100
@@ -52,6 +52,10 @@
 
   uint64_t _entry;
 
+  static uintptr_t empty() {
+    return (uintptr_t)-1;
+  }
+
 public:
   ZForwardingTableEntry() :
       _entry(empty()) {}
@@ -60,10 +64,6 @@
       _entry(field_from_index::encode(from_index) |
              field_to_offset::encode(to_offset)) {}
 
-  static uintptr_t empty() {
-    return (uintptr_t)-1;
-  }
-
   bool is_empty() const {
     return _entry == empty();
   }