From ddd071617e7bc25c496973b231d02ced438d1344 Mon Sep 17 00:00:00 2001 From: Damon Fenacci Date: Fri, 27 Oct 2023 12:56:03 +0000 Subject: [PATCH] 8317661: [REDO] store/load order not preserved when handling memory pool due to weakly ordered memory architecture of aarch64 Reviewed-by: dholmes, aph --- src/hotspot/share/code/codeCache.cpp | 2 ++ src/hotspot/share/services/memoryPool.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 99539ed80cc..3af55c00567 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -573,6 +573,8 @@ CodeBlob* CodeCache::allocate(int size, CodeBlobType code_blob_type, bool handle CompileBroker::handle_full_code_cache(orig_code_blob_type); } return nullptr; + } else { + OrderAccess::release(); // ensure heap expansion is visible to an asynchronous observer (e.g. CodeHeapPool::get_memory_usage()) } if (PrintCodeCacheExtension) { ResourceMark rm; diff --git a/src/hotspot/share/services/memoryPool.cpp b/src/hotspot/share/services/memoryPool.cpp index 15210835478..d5b8f93d929 100644 --- a/src/hotspot/share/services/memoryPool.cpp +++ b/src/hotspot/share/services/memoryPool.cpp @@ -179,6 +179,7 @@ CodeHeapPool::CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_us MemoryUsage CodeHeapPool::get_memory_usage() { size_t used = used_in_bytes(); + OrderAccess::acquire(); // ensure possible cache expansion in CodeCache::allocate is seen size_t committed = _codeHeap->capacity(); size_t maxSize = (available_for_allocation() ? max_size() : 0);