Binder prototype (aka. javaffi)
Mikael Vidstedt
mikael.vidstedt at oracle.com
Thu Dec 24 20:15:57 UTC 2015
All,
This year Santa brings a prototype implementation of the binder!
For some time now I and Henry have been working on a prototype of the
binder, gluing together jextract (aka. "the groveler") with Vladimir's
linkToNative functionality. The TL;DR of this is that with this
prototype code we can now run the canonical test cases like getpid,
printf (varargs) and qsort (callbacks), as well other complex function
types.
Some disclaimers to set the mood:
The functionality in this prototype is in no way complete, nor is it
stable. The implementation work has been focused exclusively on the sysv
x64 ABI, meaning linux, osx and solaris only. Also, while the prototype
does support enough types and function prototypes to hopefully make it
interesting to look at and play around with, it is by no means providing
complete support for all type marshaling, especially not for callbacks.
If you actually run it you will also find that it can crash the VM
relatively easily, so don't start putting this in production quite yet. :)
All that said, one of the most interesting test cases we have working is
using the prototype binder for jextract itself - for binding the
libclang API. The API includes functions with struct-by-value arguments
and callbacks, so having it working is a good proof point that we've
moved beyond the typical "simple" canonical examples. Not to mention the
fact that it's fun to have a real world use case to work on.
I was hoping to have this in shape to push to the panama forest this
week, but I'll need a few more days to get everything in place.
Meanwhile, please have a look at the webrevs below and let me/us know
what you think. Of specific interest may be the files in the jdk webrev
under src/demo/share/panama/Panama. These "demos" outline roughly how
this may be used, though spelling and exact syntax *will* change.
Webrev (top dir):
http://cr.openjdk.java.net/~mikael/webrevs/panama/javaffi-20151224/webrev.00/top/webrev/
Webrev (jdk):
http://cr.openjdk.java.net/~mikael/webrevs/panama/javaffi-20151224/webrev.00/jdk/webrev/
Webrev (hotspot):
http://cr.openjdk.java.net/~mikael/webrevs/panama/javaffi-20151224/webrev.00/hotspot/webrev/
Happy holidays!
Cheers,
Mikael
More information about the panama-dev
mailing list