8330105: SharedRuntime::resolve* should respect interpreter-only mode

Reviewed-by: never, dlong, dnsimon
This commit is contained in:
Yudi Zheng 2024-04-15 08:07:49 +00:00 committed by Doug Simon
parent d22d560871
commit 5404b4eafc
2 changed files with 17 additions and 35 deletions

View File

@ -1396,8 +1396,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_ic_miss(JavaThread*
current->set_vm_result_2(callee_method()); current->set_vm_result_2(callee_method());
JRT_BLOCK_END JRT_BLOCK_END
// return compiled code entry point after potential safepoints // return compiled code entry point after potential safepoints
assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); return get_resolved_entry(current, callee_method);
return callee_method->verified_code_entry();
JRT_END JRT_END
@ -1450,8 +1449,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method(JavaThread* current)
current->set_vm_result_2(callee_method()); current->set_vm_result_2(callee_method());
JRT_BLOCK_END JRT_BLOCK_END
// return compiled code entry point after potential safepoints // return compiled code entry point after potential safepoints
assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); return get_resolved_entry(current, callee_method);
return callee_method->verified_code_entry();
JRT_END JRT_END
// Handle abstract method call // Handle abstract method call
@ -1488,6 +1486,17 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_abstract(JavaThread*
return res; return res;
JRT_END 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 // resolve a static call and patch code
JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_static_call_C(JavaThread* current )) 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 JRT_BLOCK
callee_method = SharedRuntime::resolve_helper(false, false, CHECK_NULL); callee_method = SharedRuntime::resolve_helper(false, false, CHECK_NULL);
current->set_vm_result_2(callee_method()); 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(&reg_map);
enter_special = caller.cb() != nullptr && caller.cb()->is_nmethod()
&& caller.cb()->as_nmethod()->method()->is_continuation_enter_intrinsic();
}
JRT_BLOCK_END 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 // return compiled code entry point after potential safepoints
assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); return get_resolved_entry(current, callee_method);
return callee_method->verified_code_entry();
JRT_END JRT_END
// resolve virtual call and update inline cache to monomorphic // resolve virtual call and update inline cache to monomorphic
JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread* current)) JRT_BLOCK_ENTRY(address, SharedRuntime::resolve_virtual_call_C(JavaThread* current))
methodHandle callee_method; 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()); current->set_vm_result_2(callee_method());
JRT_BLOCK_END JRT_BLOCK_END
// return compiled code entry point after potential safepoints // return compiled code entry point after potential safepoints
assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); return get_resolved_entry(current, callee_method);
return callee_method->verified_code_entry();
JRT_END 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()); current->set_vm_result_2(callee_method());
JRT_BLOCK_END JRT_BLOCK_END
// return compiled code entry point after potential safepoints // return compiled code entry point after potential safepoints
assert(callee_method->verified_code_entry() != nullptr, " Jump to zero!"); return get_resolved_entry(current, callee_method);
return callee_method->verified_code_entry();
JRT_END JRT_END
methodHandle SharedRuntime::handle_ic_miss_helper(TRAPS) { methodHandle SharedRuntime::handle_ic_miss_helper(TRAPS) {

View File

@ -496,6 +496,7 @@ class SharedRuntime: AllStatic {
static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current); static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
// Resolving of calls // Resolving of calls
static address get_resolved_entry (JavaThread* current, methodHandle callee_method);
static address resolve_static_call_C (JavaThread* current); static address resolve_static_call_C (JavaThread* current);
static address resolve_virtual_call_C (JavaThread* current); static address resolve_virtual_call_C (JavaThread* current);
static address resolve_opt_virtual_call_C(JavaThread* current); static address resolve_opt_virtual_call_C(JavaThread* current);