diff --git a/src/hotspot/cpu/riscv/javaFrameAnchor_riscv.hpp b/src/hotspot/cpu/riscv/javaFrameAnchor_riscv.hpp index f276d51b169..f4fbc6fb564 100644 --- a/src/hotspot/cpu/riscv/javaFrameAnchor_riscv.hpp +++ b/src/hotspot/cpu/riscv/javaFrameAnchor_riscv.hpp @@ -39,25 +39,23 @@ // 3 - restoring an old state (javaCalls) void clear(void) { + // No hardware barriers are necessary. All members are volatile and the profiler + // is run from a signal handler and the only observer is the thread its running on. + // clearing _last_Java_sp must be first _last_Java_sp = nullptr; - OrderAccess::release(); _last_Java_fp = nullptr; _last_Java_pc = nullptr; } void copy(JavaFrameAnchor* src) { - // In order to make sure the transition state is valid for "this" + // No hardware barriers are necessary. All members are volatile and the profiler + // is run from a signal handler and the only observer is the thread its running on. + // We must clear _last_Java_sp before copying the rest of the new data - // - // Hack Alert: Temporary bugfix for 4717480/4721647 - // To act like previous version (pd_cache_state) don't null _last_Java_sp - // unless the value is changing - // assert(src != nullptr, "Src should not be null."); 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/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index e398d353ac0..9e0c81b004f 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -244,12 +244,14 @@ void MacroAssembler::set_last_Java_frame(Register last_java_sp, last_java_sp = esp; } - sd(last_java_sp, Address(xthread, JavaThread::last_Java_sp_offset())); - // last_java_fp is optional if (last_java_fp->is_valid()) { sd(last_java_fp, Address(xthread, JavaThread::last_Java_fp_offset())); } + + // We must set sp last. + sd(last_java_sp, Address(xthread, JavaThread::last_Java_sp_offset())); + } void MacroAssembler::set_last_Java_frame(Register last_java_sp,