status of VM long loop optimizations - call for action

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Dec 16 17:10:53 UTC 2021


On 16/12/2021 16:57, Maurizio Cimadamore wrote:
> Such a signature should never cause an allocator to be called - it's 
> all primitives. 

Actually, looking closer, it seems like we're always wrapping with a 
context if the return is non-void:

https://github.com/openjdk/panama-foreign/blob/foreign-jextract/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/ProgrammableInvoker.java#L258

(jdk/jdk has some similar code)

This seems suboptimal. If return type is not a MemorySegment, we just 
pass is a dumb allocator:

https://github.com/openjdk/panama-foreign/blob/foreign-jextract/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java#L543

I think something is off there - we should probably leave the 
Bindind.Context as is - and late bind it when creating the downcall 
handle, either using Context::ofAllocator, or Context::DUMMY. That would 
then only allocate a context when truly needed.

But again - this is a different topic, we should probably move this 
discussion on a different thread.

Maurizio



More information about the panama-dev mailing list