Skip to content

Conversation

graalvmbot
Copy link

@graalvmbot graalvmbot commented Sep 24, 2025

See https://bugs.openjdk.org/browse/JDK-8364670 for a detailed description.
This PR adapts JVMCI such that it binds (or attaches) certain Java methods at the call site.
Binding a method at the call site means we save the Method* extracted from the code stream in the relocation information.
By binding a method at the call site we want to override the usual call site resolution when the target of the call instruction is patched.
The current implementation does the computation if a method needs to be bound at the call site in jvmciCodeInstaller.cpp.

A method needs to be bound if:

  • The method in the debug info of the call is not a method handle while it is in bytecode. This will allow Graal to replace a method handle with the resolved method.
  • The reexecute bit is set. Graal can use this for the Truffle safepoint.

Hotspot already provides us with functionality to replace a method handle with the resolved method in sharedRuntime.cpp. We only need to bind the method to trigger this functionality.

To handle the case that the reexecute bit is set we need to introduce our own logic in sharedRuntime.cpp. We use the reexecute bit to indicate that the call is side-effect free and that the call resolution should not use the symbol information to extract the method. This is necessary as the bci may not point to an invoke bytecode. This will allow Graal to directly call the Truffle safepoint without having to go through a stub, see link We are allowed to use the reexecute bit as it is always set to false when we invoke a Java method. This is necessary as Hotspot expects the bci to point to the invoke bytecode.

@graalvmbot graalvmbot merged commit c3da348 into jdk25 Sep 24, 2025
55 of 61 checks passed
@graalvmbot graalvmbot deleted the mh/GR-68488/Method-Binding branch September 24, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant