Skip to content

Commit

Permalink
8294947: Use 64bit atomics in patch_verified_entry on x86_64
Browse files Browse the repository at this point in the history
Backport-of: d0fae43e89a73e9d73b074fa12276c43ba629278
  • Loading branch information
GoeLin committed Jan 4, 2023
1 parent 3a019fd commit 0ce1205
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/hotspot/cpu/x86/nativeInst_x86.cpp
Expand Up @@ -510,12 +510,27 @@ void NativeJump::check_verified_entry_alignment(address entry, address verified_
//
void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) {
// complete jump instruction (to be inserted) is in code_buffer;
#ifdef _LP64
union {
jlong cb_long;
unsigned char code_buffer[8];
} u;

u.cb_long = *(jlong *)verified_entry;

intptr_t disp = (intptr_t)dest - ((intptr_t)verified_entry + 1 + 4);
guarantee(disp == (intptr_t)(int32_t)disp, "must be 32-bit offset");

u.code_buffer[0] = instruction_code;
*(int32_t*)(u.code_buffer + 1) = (int32_t)disp;

Atomic::store((jlong *) verified_entry, u.cb_long);
ICache::invalidate_range(verified_entry, 8);

#else
unsigned char code_buffer[5];
code_buffer[0] = instruction_code;
intptr_t disp = (intptr_t)dest - ((intptr_t)verified_entry + 1 + 4);
#ifdef AMD64
guarantee(disp == (intptr_t)(int32_t)disp, "must be 32-bit offset");
#endif // AMD64
*(int32_t*)(code_buffer + 1) = (int32_t)disp;

check_verified_entry_alignment(entry, verified_entry);
Expand Down Expand Up @@ -546,6 +561,7 @@ void NativeJump::patch_verified_entry(address entry, address verified_entry, add
*(int32_t*)verified_entry = *(int32_t *)code_buffer;
// Invalidate. Opteron requires a flush after every write.
n_jump->wrote(0);
#endif // _LP64

}

Expand Down

1 comment on commit 0ce1205

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.