[foreign-memaccess+abi] RFR: Add support for high-level functions to copy to and from Java arrays

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Jun 21 15:25:11 UTC 2021


On Mon, 21 Jun 2021 15:14:04 GMT, Uwe Schindler <uschindler at openjdk.org> wrote:

> Hi,
> when testing this with Lucene, Irecognized the following:
> 
> ```
> org.apache.lucene.store.TestMultiMMap > test suite's output saved to /home/thetaphi/benchmark/lucene_candidate/lucene/core/build/test-results/test/outputs/OUTPUT-org.apache.lucene.store.TestMultiMMap.txt, copied below:
>    >     java.lang.IllegalArgumentException: Source segment incompatible with alignment constraints
>    >         at __randomizedtesting.SeedInfo.seed([90A99875BABA30A6:B162CD10DB95DFC]:0)
>    >         at jdk.incubator.foreign/jdk.internal.foreign.AbstractMemorySegmentImpl.copyFrom(AbstractMemorySegmentImpl.java:158)
>    >         at jdk.incubator.foreign/jdk.incubator.foreign.MemoryCopy.copyToArray(MemoryCopy.java:493)
>    >         at org.apache.lucene.store.MemorySegmentIndexInput.readLongs(MemorySegmentIndexInput.java:204)
> ```
> 
> So it is impossible to copy stuff if the source segment is not at an aligned position. Unfortunately, with data inside a memory mapped file it may often happen that data is not properly aligned, but you still need to copy them (including swapping).

This is an issue in the layouts used by the MemoryCopy class. I meant to drop all alignment constraints from them when doing another pass on the code, but it seems like I forgot.

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

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


More information about the panama-dev mailing list