OpenJDK / jdk / jdk
changeset 55825:278795ad438a
8228631: Fix inconsistent OopStorage::Block owner usage
Summary: Only use Block's owner member for address validation.
Reviewed-by: tschatzl, pliden
author | kbarrett |
---|---|
date | Fri, 26 Jul 2019 20:15:13 -0400 |
parents | bfe9696bf57f |
children | 02cffb476ab0 |
files | src/hotspot/share/gc/shared/oopStorage.cpp src/hotspot/share/gc/shared/oopStorage.inline.hpp |
diffstat | 2 files changed, 6 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hotspot/share/gc/shared/oopStorage.cpp Fri Jul 26 13:32:59 2019 -0700 +++ b/src/hotspot/share/gc/shared/oopStorage.cpp Fri Jul 26 20:15:13 2019 -0400 @@ -208,7 +208,7 @@ OopStorage::Block::Block(const OopStorage* owner, void* memory) : _data(), _allocated_bitmask(0), - _owner(owner), + _owner_address(reinterpret_cast<intptr_t>(owner)), _memory(memory), _active_index(0), _allocation_list_entry(), @@ -228,7 +228,7 @@ // Clear fields used by block_for_ptr and entry validation, which // might help catch bugs. Volatile to prevent dead-store elimination. const_cast<uintx volatile&>(_allocated_bitmask) = 0; - const_cast<OopStorage* volatile&>(_owner) = NULL; + const_cast<intptr_t volatile&>(_owner_address) = 0; } size_t OopStorage::Block::allocation_size() { @@ -356,9 +356,7 @@ intptr_t owner_addr = reinterpret_cast<intptr_t>(owner); for (unsigned i = 0; i < section_count; ++i, section += section_size) { Block* candidate = reinterpret_cast<Block*>(section); - intptr_t* candidate_owner_addr - = reinterpret_cast<intptr_t*>(&candidate->_owner); - if (SafeFetchN(candidate_owner_addr, 0) == owner_addr) { + if (SafeFetchN(&candidate->_owner_address, 0) == owner_addr) { return candidate; } } @@ -609,7 +607,7 @@ if ((releasing == old_allocated) || is_full_bitmask(old_allocated)) { // Log transitions. Both transitions are possible in a single update. if (log_is_enabled(Debug, oopstorage, blocks)) { - log_release_transitions(releasing, old_allocated, _owner, this); + log_release_transitions(releasing, old_allocated, owner, this); } // Attempt to claim responsibility for adding this block to the deferred // list, by setting the link to non-NULL by self-looping. If this fails, @@ -634,7 +632,7 @@ owner->record_needs_cleanup(); } log_debug(oopstorage, blocks)("%s: deferred update " PTR_FORMAT, - _owner->name(), p2i(this)); + owner->name(), p2i(this)); } } // Release hold on empty block deletion.
--- a/src/hotspot/share/gc/shared/oopStorage.inline.hpp Fri Jul 26 13:32:59 2019 -0700 +++ b/src/hotspot/share/gc/shared/oopStorage.inline.hpp Fri Jul 26 20:15:13 2019 -0400 @@ -137,7 +137,7 @@ static const unsigned _data_pos = 0; // Position of _data. volatile uintx _allocated_bitmask; // One bit per _data element. - const OopStorage* _owner; + intptr_t _owner_address; void* _memory; // Unaligned storage containing block. size_t _active_index; AllocationListEntry _allocation_list_entry;