Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on graalvm/sulong#157
This is a sketch of how I think we could support the Ruby C API using interop. When we used Truffle C, we had several intrinsic nodes, so Ruby functionality implemented in Truffle C. I guess we want to avoid that? Otherwise we'll have to define an API that Sulong provides to register those intrinsics. If we can do it with just normal interop that's probably better.
We have a header that describes the Ruby C API.
We then have a library that implements that in terms of the interop functions that Sulong can provide. That library is compiled into a
.su
and shipped with JRuby+Truffle, and loaded whenever the first C extension is loaded.Most of the C API is implemented by
INVOKE
ing methods that are implemented by JRuby+Truffle, in aTruffle::CExt
module, that is exported by default asruby_cext
.There are a lot of open questions here.
If the return type of interop functions like
READ
arevoid*
, to read it do I do*((int*) READ
, or(int) READ
? What do I do with variadic arguments to pass them on a second time?RSTRING_PTR
needs to provide what appears to be achar*
but actually allows me to intercept read and write operations, and that needs to work with pointer arithmetic. We solved all these with Truffle C, so they're all do-able.