8335217: Fix memory ordering in ClassLoaderData::ChunkedHandleList

Reviewed-by: dholmes, stefank, eosterlund
This commit is contained in:
Zhengyu Gu 2024-06-29 20:40:51 +00:00
parent bb18498d71
commit d9bcf06145

View File

@ -202,9 +202,9 @@ OopHandle ClassLoaderData::ChunkedHandleList::add(oop o) {
int ClassLoaderData::ChunkedHandleList::count() const {
int count = 0;
Chunk* chunk = _head;
Chunk* chunk = Atomic::load_acquire(&_head);
while (chunk != nullptr) {
count += chunk->_size;
count += Atomic::load(&chunk->_size);
chunk = chunk->_next;
}
return count;
@ -258,9 +258,9 @@ bool ClassLoaderData::ChunkedHandleList::contains(oop p) {
#ifndef PRODUCT
bool ClassLoaderData::ChunkedHandleList::owner_of(oop* oop_handle) {
Chunk* chunk = _head;
Chunk* chunk = Atomic::load_acquire(&_head);
while (chunk != nullptr) {
if (&(chunk->_data[0]) <= oop_handle && oop_handle < &(chunk->_data[chunk->_size])) {
if (&(chunk->_data[0]) <= oop_handle && oop_handle < &(chunk->_data[Atomic::load(&chunk->_size)])) {
return true;
}
chunk = chunk->_next;