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

Yudi Zheng yzheng at openjdk.org
Mon Apr 15 16:15:01 UTC 2024


On Mon, 15 Apr 2024 14:24:29 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:

>> JavaThread::set_interp_only_mode may be called while a thread is blocked waiting for a JIT compilation to complete. When interpreter-only mode is set, we should dispatch to interpreter instead of the returned compiled code.
>
> This is the same initial fix I proposed for JDK-8302351 but which I later changed when stumbling upon some exception cases where we cannot just return the c2i adapter entry: method handle intrinsics and enterSpecial/doYield methods.
> For method handle intrinsics, _linkToNative doesn't have an interpreter version so the c2i will lead to a i2c and we will crash because we cannot cascade those. For the other method handle intrinsics, although there is an interpreter version, I found another issue where generate_method_handle_interpreter_entry() can throw an exception before we create the interpreter frame, which will lead to crashes when walking the stack.
> Regarding enterSpecial/doYield, those also lack an interpreter version as _linkToNative(although enterSpecial has a hack here), but they are not really an issue today because we cannot switch to interpreter only mode while resolving those methods.

@pchilano  how about we return c2i only if callee is not a method handle intrinsic?

diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp
index 2b06859c96d..74d361a2b57 100644
--- a/src/hotspot/share/runtime/sharedRuntime.cpp
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp
@@ -1489,7 +1489,7 @@ 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()) {
+  if (current->is_interp_only_mode()  && !callee_method->is_method_handle_intrinsic()) {
     // 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();

Btw how did you stress test this? https://github.com/openjdk/jdk/pull/14108#issuecomment-1574091628

-------------

PR Comment: https://git.openjdk.org/jdk/pull/18741#issuecomment-2057229315


More information about the hotspot-dev mailing list