mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8214377: ZGC: Don't use memset to initialize array of ZForwardingTableEntry
Reviewed-by: rkennke, eosterlund
This commit is contained in:
parent
8fc0c2f645
commit
fff6e05c96
2 changed files with 13 additions and 6 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue