[foreign] RFR: misc binder improvements

Henry Jen henry.jen at oracle.com
Fri Jun 22 06:34:08 UTC 2018


Overall seems good to me, 

- In NativeInvoker:211, Pointer<?> r = scope.allocate(returnLayoutType);
It was allocateStruct which align up 8, not sure if it’s intentional, but you did add an allocate method with align requirement, which I suppose is to be used here? If not, what’s that method for? Also, I would recommend rename that method to make it clear the second argument is alignment, so that won’t be confused with allocateArray, which was named allocate before. Naturally I will think the second argument is element count, just like calloc() is with a count.

- LayoutTypeImpl:87 Address.ofLayout(64, layout)
I understand this is same code as before, but I think this should use SystemABI.layoutFor(CType.Pointer).

Cheers,
Henry


> On Jun 21, 2018, at 9:55 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> Hi,
> I took care of some suboptimal things in the binder, to make it as fast as possible (w/o going too deep into premature optimization territory). Among the improved patterns:
> 
> * Reference class is rewritten so that all MH are now static
> 
> * related to above: turned LayoutType into an interface (so that carrier(), pointertype() elementtype() are not exposed to public API, but can be accessed internally)
> 
> * Avoid Scope.allocateStruct in NativeInvoker, as that causes layout parsing
> 
> * pre-cache all static info about a call (e.g. all LayoutTypes), again Util.makeType can cause layout parsing so we don't want to do that in the middle of a native call
> 
> * as before, but from the UpcallHandler path (this meant a new class UpcallHandlerFactory is added that caches all static info)
> 
> These improvements bring the panama generated code almost in parity with JNI code when running the clang-ffi test.
> 
> Webrev:
> http://cr.openjdk.java.net/~mcimadamore/panama/binder-opts/
> 
> Maurizio
> 
> 



More information about the panama-dev mailing list