8357619: [JVMCI] Revisit phantom_ref parameter in JVMCINMethodData::get_nmethod_mirror

Reviewed-by: eosterlund, never
This commit is contained in:
Doug Simon 2025-06-03 06:20:29 +00:00
parent 497a1822ca
commit 6cfd4057dc
3 changed files with 8 additions and 12 deletions

View File

@ -2836,7 +2836,7 @@ C2V_VMENTRY_0(jlong, translate, (JNIEnv* env, jobject, jobject obj_handle, jbool
if (data != nullptr) {
// Only the mirror in the HotSpot heap is accessible
// through JVMCINMethodData
oop nmethod_mirror = data->get_nmethod_mirror(nm, /* phantom_ref */ true);
oop nmethod_mirror = data->get_nmethod_mirror(nm);
if (nmethod_mirror != nullptr) {
result = HotSpotJVMCI::wrap(nmethod_mirror);
}
@ -2868,7 +2868,7 @@ C2V_VMENTRY_0(jlong, translate, (JNIEnv* env, jobject, jobject obj_handle, jbool
if (data == nullptr) {
JVMCI_THROW_MSG_0(IllegalArgumentException, "Missing HotSpotNmethod data");
}
if (data->get_nmethod_mirror(nm, /* phantom_ref */ false) != nullptr) {
if (data->get_nmethod_mirror(nm) != nullptr) {
JVMCI_THROW_MSG_0(IllegalArgumentException, "Cannot overwrite existing HotSpotNmethod mirror for nmethod");
}
oop nmethod_mirror = HotSpotJVMCI::resolve(result);

View File

@ -776,15 +776,11 @@ void JVMCINMethodData::add_failed_speculation(nmethod* nm, jlong speculation) {
FailedSpeculation::add_failed_speculation(nm, _failed_speculations, data, length);
}
oop JVMCINMethodData::get_nmethod_mirror(nmethod* nm, bool phantom_ref) {
oop JVMCINMethodData::get_nmethod_mirror(nmethod* nm) {
if (_nmethod_mirror_index == -1) {
return nullptr;
}
if (phantom_ref) {
return nm->oop_at_phantom(_nmethod_mirror_index);
} else {
return nm->oop_at(_nmethod_mirror_index);
}
return nm->oop_at(_nmethod_mirror_index);
}
void JVMCINMethodData::set_nmethod_mirror(nmethod* nm, oop new_mirror) {
@ -802,7 +798,7 @@ void JVMCINMethodData::set_nmethod_mirror(nmethod* nm, oop new_mirror) {
}
void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm) {
oop nmethod_mirror = get_nmethod_mirror(nm, /* phantom_ref */ false);
oop nmethod_mirror = get_nmethod_mirror(nm);
if (nmethod_mirror == nullptr) {
return;
}
@ -2178,7 +2174,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
JVMCINMethodData* data = nm->jvmci_nmethod_data();
assert(data != nullptr, "must be");
if (install_default) {
assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm, /* phantom_ref */ false) == nullptr, "must be");
assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm) == nullptr, "must be");
if (entry_bci == InvocationEntryBci) {
// If there is an old version we're done with it
nmethod* old = method->code();
@ -2221,7 +2217,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
}
}
} else {
assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm, /* phantom_ref */ false) == HotSpotJVMCI::resolve(nmethod_mirror), "must be");
assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm) == HotSpotJVMCI::resolve(nmethod_mirror), "must be");
MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag);
if (!nm->make_in_use()) {
result = JVMCI::nmethod_reclaimed;

View File

@ -124,7 +124,7 @@ public:
void invalidate_nmethod_mirror(nmethod* nm);
// Gets the mirror from nm's oops table.
oop get_nmethod_mirror(nmethod* nm, bool phantom_ref);
oop get_nmethod_mirror(nmethod* nm);
// Sets the mirror in nm's oops table.
void set_nmethod_mirror(nmethod* nm, oop mirror);