MethodHandle for indirect/vtable call?
John Rose
john.r.rose at oracle.com
Fri Dec 11 23:26:44 UTC 2020
On Dec 11, 2020, at 7:38 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>
> That said, I believe that there might be implications on the intrinsics machinery in what you're asking - if I'm not wrong, the intrinsic machinery does really expect all the ingredient of a call (including the target address) to be _constant_ - otherwise it can imagine it could be hard to emit generic assembly for that(how is the address communicated to the assembly stub) ?
When I did an earlier version of this (internal project “Blackbird”
ca. 2005) the FP-calling version of each signature was a very simple
variation on the fixed-address-calling version. I expect the same
to be true today. The various system ABIs (generally speaking)
use the same register assignments for both FP-based and fixed
address calls. It follows that if the FP is passed in “appendix”
position (i.e., after all the other arguments) then there is no
data motion required in either arguments or return values,
and you simply run a tail-call through the trailing FP value.
This is how (non-native) method handle calls work today,
so the VM is familiar with this trick already.
> So, yes, this is an issue - and I think one that will be addressed (not in Java 16 though) - there's an open question as to how much fast we can make the general MH you describe - it might be possible that the linker API will have two flavors of "downcallHandle”.
At some very low level, corresponding to invokeBasic,
for every native MH of the form (T,U,…,M)R there will
also be a native MH of the form (T,U,…,N,M’)R where
N is an appropriate type (perhaps long) for passing a
variable native function pointer. The argument M is
whatever internal steering information the native
call engine requires, so there are (in some sense)
two appendices here. Perhaps M’ is a variation
on M which “expects” the extra function pointer
argument N.
At some intermediate level, with some simple
argument permutation, there will likely be a
MH of the form (N’,T,U,…,M)R, where N’ is
some possibly up-leveled version of N.
— John
More information about the panama-dev
mailing list