[foreign-jextract] RFR: 8249810: Jextract should generate parameter types with Addressable type

Henry Jen henryjen at openjdk.java.net
Wed Jul 22 03:47:17 UTC 2020


On Tue, 21 Jul 2020 23:23:26 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> It is true at ABI level, the method handle can only handle MemoryAddress. But there is nothing preventing something
>> like ConstantHelper to adapt the ABI-level MH to take Addressable as you do here.
>> What I am suggesting is simply saying you don't need add sigtype, simply take the incoming method type and adapt
>> MemoryAddress into Addressable.address().
>
>> What I am suggesting is simply saying you don't need add sigtype, simply take the incoming method type and adapt
>> MemoryAddress into Addressable.address().
> 
> Not sure I get it. I think this same builder code is reused both for downcalls and upcalls; but we don't want to do the
> transformation for upcalls. So at the very least we'd need to pass a boolean to turn the transformation on/off. If we
> go down this path, then I guess TypeTranslator could be reverted back to what it was - is that what you are
> suggesting?  Or, perhaps you are proposing to inject some adapters into the method handle returned by constant helper
> (or, perhaps, more simply, in RuntimeHelper). That is also doable, but I guess I'm not 100% sure of what is there to be
> gained by doing so; I suspect that scanning the signature, look for all MemoryAddress parameter and inject an adapter
> in the right position is not much simpler than what we're doing here? Performance-wise I also don't see any benefit.

OK, I don't think this function is used for upcall, perhaps I am wrong.

What I am suggesting is that we don't need to change this function signature, but instead
Class<?> pType = type.parameterType(i);
if (pType == MemoryAddress.class) {
    pType = Addressable.class;
    pExprs.add(pName + ".address()");
} else {
    pExprs.add(pName);
}
sb.append(delim + pType.getName() + " " + pName);

Then we can revert changes in OutputFactory to get sigtype.
As I look at this change, the sigtype seems to alway be adapted into Addressable, am I miss something?

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

PR: https://git.openjdk.java.net/panama-foreign/pull/257


More information about the panama-dev mailing list