[foreign-memaccess+abi] RFR: 8270376: Finalize API for memory copy [v3]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Jul 15 09:45:49 UTC 2021


On Wed, 14 Jul 2021 11:24:46 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> This patch ties up some loose ends with the MemoryCopy API, and it also prepares the ground for some other related refactorings in this area.
>> 
>> The meat of this patch is represented by the various changes in MemoryCopy, where all methods were renamed to simply `copy`, and the length parameter (now called `elementCount`) is always moved to the end.
>> 
>> I've also simplified naming of parameters, as I think distinguishing between `index` and `offset` is enough (e.g. an array has an index, a segment has an offset).
>> 
>> You will see that, at the very end of the class, three more copy methods have been added, which deal fully in terms of segments. I have also moved the complex layout-based memory segment copy operation (which does the swap) as a static method in this class, as I believe the static form makes the method more regular and usable.
>> 
>> I've made some changes to our uses of `copyFrom` in the linker, to use the new methods in `MemoryCopy` when the copy operation was performing slicing in the source/target segment, which I think makes the code more readable. Of course these changes are completely optional and could be omitted as well.
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix whitespaces

> Hi,
> I made a quick test with Lucene, see branch: [apache/lucene at main...uschindler:draft/jdk-foreign-mmap-8270376](https://github.com/apache/lucene/compare/main...uschindler:draft/jdk-foreign-mmap-8270376), example implementation for reading bytes: https://github.com/uschindler/lucene/blob/b4e76e6963c94f65a3c4348d485e66d2c5802b25/lucene/core/src/java/org/apache/lucene/store/MemorySegmentIndexInput.java#L149-L160
> 
> Lucene tests pass and performance seems OK. I did not test the `Object` syscopy-like aproach.

Thanks for verifying that performance did not regress with the new implementation scheme!

-------------

PR: https://git.openjdk.java.net/panama-foreign/pull/568


More information about the panama-dev mailing list