From 5404b4eafc2eb3291cecf99f98728946388f5d16 Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Mon, 15 Apr 2024 08:07:49 +0000 Subject: [PATCH] 8330105: SharedRuntime::resolve* should respect interpreter-only mode Reviewed-by: never, dlong, dnsimon --- src/hotspot/share/runtime/sharedRuntime.cpp | 51 +++++++-------------- src/hotspot/share/runtime/sharedRuntime.hpp | 1 + 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index a4ee1a31734..2b06859c96d 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -1396,8 +1396,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_ic_miss(JavaThread* current->set_vm_result_2(callee_method()); JRT_BLOCK_END // return compiled code entry point after potential safepoints - assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); - return callee_method->verified_code_entry(); + return get_resolved_entry(current, callee_method); JRT_END @@ -1450,8 +1449,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method(JavaThread* current) current->set_vm_result_2(callee_method()); JRT_BLOCK_END // return compiled code entry point after potential safepoints - assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); - return callee_method->verified_code_entry(); + return get_resolved_entry(current, callee_method); JRT_END // Handle abstract method call @@ -1488,6 +1486,17 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_abstract(JavaThread* return res; JRT_END +// return verified_code_entry if interp_only_mode is not set for the current thread; +// otherwise return c2i entry. +address SharedRuntime::get_resolved_entry(JavaThread* current, methodHandle callee_method) { + if (current->is_interp_only_mode()) { + // In interp_only_mode we need to go to the interpreted entry + // The c2i won't patch in this mode -- see fixup_callers_callsite + return callee_method->get_c2i_entry(); + } + assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); + return callee_method->verified_code_entry(); +} // resolve a static call and patch code JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread* current )) @@ -1496,37 +1505,11 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread* curren JRT_BLOCK callee_method = SharedRuntime::resolve_helper(false, false, CHECK_NULL); current->set_vm_result_2(callee_method()); - - if (current->is_interp_only_mode()) { - RegisterMap reg_map(current, - RegisterMap::UpdateMap::skip, - RegisterMap::ProcessFrames::include, - RegisterMap::WalkContinuation::skip); - frame stub_frame = current->last_frame(); - assert(stub_frame.is_runtime_frame(), "must be a runtimeStub"); - frame caller = stub_frame.sender(®_map); - enter_special = caller.cb() != nullptr && caller.cb()->is_nmethod() - && caller.cb()->as_nmethod()->method()->is_continuation_enter_intrinsic(); - } JRT_BLOCK_END - - if (current->is_interp_only_mode() && enter_special) { - // enterSpecial is compiled and calls this method to resolve the call to Continuation::enter - // but in interp_only_mode we need to go to the interpreted entry - // The c2i won't patch in this mode -- see fixup_callers_callsite - // - // This should probably be done in all cases, not just enterSpecial (see JDK-8218403), - // but that's part of a larger fix, and the situation is worse for enterSpecial, as it has no - // interpreted version. - return callee_method->get_c2i_entry(); - } - // return compiled code entry point after potential safepoints - assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); - return callee_method->verified_code_entry(); + return get_resolved_entry(current, callee_method); JRT_END - // resolve virtual call and update inline cache to monomorphic JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread* current)) methodHandle callee_method; @@ -1535,8 +1518,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread* curre current->set_vm_result_2(callee_method()); JRT_BLOCK_END // return compiled code entry point after potential safepoints - assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); - return callee_method->verified_code_entry(); + return get_resolved_entry(current, callee_method); JRT_END @@ -1549,8 +1531,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_opt_virtual_call_C(JavaThread* c current->set_vm_result_2(callee_method()); JRT_BLOCK_END // return compiled code entry point after potential safepoints - assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); - return callee_method->verified_code_entry(); + return get_resolved_entry(current, callee_method); JRT_END methodHandle SharedRuntime::handle_ic_miss_helper(TRAPS) { diff --git a/src/hotspot/share/runtime/sharedRuntime.hpp b/src/hotspot/share/runtime/sharedRuntime.hpp index c8a10006764..d477929768f 100644 --- a/src/hotspot/share/runtime/sharedRuntime.hpp +++ b/src/hotspot/share/runtime/sharedRuntime.hpp @@ -496,6 +496,7 @@ class SharedRuntime: AllStatic { static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current); // Resolving of calls + static address get_resolved_entry (JavaThread* current, methodHandle callee_method); static address resolve_static_call_C (JavaThread* current); static address resolve_virtual_call_C (JavaThread* current); static address resolve_opt_virtual_call_C(JavaThread* current);