8214377: ZGC: Don't use memset to initialize array of ZForwardingTableEntry

Reviewed-by: rkennke, eosterlund
This commit is contained in:
Per Lidén 2018-12-03 14:52:49 +01:00
parent 8fc0c2f645
commit fff6e05c96
2 changed files with 13 additions and 6 deletions

View File

@ -38,11 +38,18 @@ void ZForwardingTable::setup(size_t live_objects) {
_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;

View File

@ -52,6 +52,10 @@ private:
uint64_t _entry;
static uintptr_t empty() {
return (uintptr_t)-1;
}
public:
ZForwardingTableEntry() :
_entry(empty()) {}
@ -60,10 +64,6 @@ public:
_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();
}