[code-reflection] Integrated: Make downcall method handles for ORT API functions static
Hannes Greule
hgreule at openjdk.org
Tue Feb 18 19:28:23 UTC 2025
On Tue, 18 Feb 2025 15:15:26 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This PR tweaks the method handles in `OnnxRuntime` to be static and final.
> The trick is to use a so called "virtual" downcall handle -- a downcall handle that takes its input address as an extra parameter.
> Then, we can just adapt such a method handle to fetch the target function address from the incoming `runtimeAddress` parameter.
> This way, all the method handles modelling functions in the ORT API can be made static, which unlocks better C2 optimizations.
>
> Clients of such method handles have to be tweaked to pass in the additional leading `runtimeAddress` parameter.
I don't know if there are downsides to those "virtual" downcall handles. Alternatively, would it make sense to use MutableCallSite? Afaik that should allow optimizations similar to static final fields but the actual targets could be resolved in the constructor still.
-------------
PR Comment: https://git.openjdk.org/babylon/pull/322#issuecomment-2666222388
More information about the babylon-dev
mailing list