diff --git a/src/hotspot/cpu/aarch64/javaFrameAnchor_aarch64.hpp b/src/hotspot/cpu/aarch64/javaFrameAnchor_aarch64.hpp index 8d125d3c0276a..838f2b6540617 100644 --- a/src/hotspot/cpu/aarch64/javaFrameAnchor_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/javaFrameAnchor_aarch64.hpp @@ -39,9 +39,11 @@ // 3 - restoring an old state (javaCalls) void clear(void) { + // No fencing required, the members are declared volatile so the compiler will not reorder and + // the profiler always reads from the same thread and should observe the state in program order. + // clearing _last_Java_sp must be first _last_Java_sp = nullptr; - OrderAccess::release(); _last_Java_fp = nullptr; _last_Java_pc = nullptr; } @@ -54,9 +56,10 @@ // To act like previous version (pd_cache_state) don't null _last_Java_sp // unless the value is changing // + // No fencing required, the members are declared volatile so the compiler will not reorder and + // the profiler always reads from the same thread and should observe the state in program order. if (_last_Java_sp != src->_last_Java_sp) { _last_Java_sp = nullptr; - OrderAccess::release(); } _last_Java_fp = src->_last_Java_fp; _last_Java_pc = src->_last_Java_pc; diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 2622bda1d0b82..7f74e44ceed7b 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -634,12 +634,13 @@ void MacroAssembler::set_last_Java_frame(Register last_java_sp, last_java_sp = esp; } - str(last_java_sp, Address(rthread, JavaThread::last_Java_sp_offset())); - // last_java_fp is optional if (last_java_fp->is_valid()) { str(last_java_fp, Address(rthread, JavaThread::last_Java_fp_offset())); } + + // Must be last so profiler will always see valid frame if has_last_frame() is true + str(last_java_sp, Address(rthread, JavaThread::last_Java_sp_offset())); } void MacroAssembler::set_last_Java_frame(Register last_java_sp,