Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix memory ordering and add comment
  • Loading branch information
zhengyu123 committed Apr 8, 2026
commit 44fb8799bc7848226fb1761c053787412a12a720
1 change: 1 addition & 0 deletions ddprof-lib/src/main/cpp/hotspot/jitCodeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ void JNICALL JitCodeCache::DynamicCodeGenerated(jvmtiEnv *jvmti, const char *nam
CodeHeap::setInterpreterStart(address);
} else if (strcmp(name, "call_stub") == 0) {
_call_stub_begin.store(address, std::memory_order_relaxed);
// This fence ensures that _call_stub_begin is visible before _call_stub_end, so that isCallStub() works correctly
std::atomic_thread_fence(std::memory_order_release);
_call_stub_end.store((const char *)address + length, std::memory_order_relaxed);
}
Expand Down
2 changes: 1 addition & 1 deletion ddprof-lib/src/main/cpp/hotspot/jitCodeCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class JitCodeCache {
const void *address, jint length);

static inline bool isCallStub(const void *address) {
return _call_stub_end.load(std::memory_order_relaxed) != nullptr &&
return _call_stub_end.load(std::memory_order_acquire) != nullptr &&
address >= _call_stub_begin.load(std::memory_order_relaxed) &&
address < _call_stub_end.load(std::memory_order_relaxed);
Comment thread
zhengyu123 marked this conversation as resolved.
Outdated
}
Expand Down