Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/hotspot/cpu/aarch64/javaFrameAnchor_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
// 3 - restoring an old state (javaCalls)

void clear(void) {
// clearing _last_Java_sp must be first
// Must clear sp first and place a store-store barrier (dmb ISHST) immediately after,
// to ensure ACGT does not observe a corrupted frame.
_last_Java_sp = nullptr;
OrderAccess::release();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need a compiler fence here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not, if this is the same thread as readers. I don't know what it's for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OrderAccess::release() is more than a compiler barrier on AArch64. I am guessing this was copied from x86 or one of the others where that same function is a compiler barrier? Should I move compiler_barrier from the random source files its in, into globalDefinitions, and use that?

_last_Java_fp = nullptr;
Expand All @@ -54,14 +55,21 @@
// To act like previous version (pd_cache_state) don't null _last_Java_sp
// unless the value is changing
//
if (_last_Java_sp != src->_last_Java_sp) {
bool different_sp = _last_Java_sp != src->_last_Java_sp;
if (different_sp) {
// Must clear sp first and place a store-store barrier (dmb ISHST) immediately after,
// to ensure ACGT does not observe a corrupted frame.
_last_Java_sp = nullptr;
OrderAccess::release();
}
_last_Java_fp = src->_last_Java_fp;
_last_Java_pc = src->_last_Java_pc;
// Must be last so profiler will always see valid frame if has_last_frame() is true
_last_Java_sp = src->_last_Java_sp;
if (different_sp) {
// Must set sp last and place a store-store barrier (dmb ISHST) immediately before,
// to ensure ACGT does not observe a corrupted frame.
OrderAccess::release();
_last_Java_sp = src->_last_Java_sp;
}
}

bool walkable(void) { return _last_Java_sp != nullptr && _last_Java_pc != nullptr; }
Expand Down
11 changes: 8 additions & 3 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,10 @@ void MacroAssembler::pop_cont_fastpath(Register java_thread) {
}

void MacroAssembler::reset_last_Java_frame(bool clear_fp) {
// we must set sp to zero to clear frame
// Must clear sp first and place a store-store barrier (dmb ISHST) immediately after,
// to ensure ACGT does not observe a corrupted frame.
str(zr, Address(rthread, JavaThread::last_Java_sp_offset()));
membar(Assembler::StoreStore);

// must clear fp, so that compiled frames are not confused; it is
// possible that we need it only for debugging
Expand Down Expand Up @@ -634,12 +636,15 @@ 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 set sp last and place a store-store barrier (dmb ISHST) immediately before,
// to ensure ACGT does not observe a corrupted frame.
membar(Assembler::StoreStore);
str(last_java_sp, Address(rthread, JavaThread::last_Java_sp_offset()));
}

void MacroAssembler::set_last_Java_frame(Register last_java_sp,
Expand Down