[foreign] RFR: add binder support for panama array carriers

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri May 25 20:13:25 UTC 2018


Thanks


On 25/05/18 19:58, Henry Jen wrote:
> Looks good, just curious, why static method in BoundedArray instead of default method on Array?
I have a vague feeling that these copy routines might come in handy for 
other purposes, so I've refactored it this way to maximise reusability. 
In other word, these are just helper methods, and other methods (such as 
Array::toArray, Scope::allocateArray) are expressed in terms of them.

Maurizio
>
> Cheers,
> Henry
>
>
>> On May 25, 2018, at 11:13 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>>
>> And this is another iteration which turns BoundedArray::copyTo/From into static methods
>>
>> http://cr.openjdk.java.net/~mcimadamore/panama/array_carrier-v3/
>>
>> Maurizio
>>
>>
>> On 25/05/18 18:35, Maurizio Cimadamore wrote:
>>> Slightly updated webrev which hoists the MH creation in BoundedArray::copyTo/From
>>>
>>> http://cr.openjdk.java.net/~mcimadamore/panama/array_carrier-v2/
>>>
>>> Maurizio
>>>
>>>
>>> On 25/05/18 18:26, Maurizio Cimadamore wrote:
>>>> Hi,
>>>> this patch removes binder support for Java array carriers and rewrires array support to use the Panama Array class.
>>>>
>>>> To allow interop from Java arrays and back the following API points have been added:
>>>>
>>>> Array<Integer> nativeArray = ...
>>>> int[] ia = nativeArray.toArray(int[]::new);
>>>>
>>>> And, the reverse operation is handled by Scope, by having a form of native array allocation which takes a Java array initializer:
>>>>
>>>> Array<Integer> newNativeArray = scope.allocateArray(NativeTypes.INT32, ia);
>>>>
>>>> This seems to work pretty well in terms of usability. Under the hood, the methods BoundedArray::copyFrom/To use MethodHandles to avoid boxing of elements.
>>>>
>>>> I've removed a lot of code that had to do, directly or indirectly, with Java array accessors generated by the binder.
>>>>
>>>> Webrev:
>>>>
>>>> http://cr.openjdk.java.net/~mcimadamore/panama/array_carrier/
>>>>
>>>> Cheers
>>>> Maurizio
>>>>
>>>>



More information about the panama-dev mailing list