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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Jun 17 15:48:04 UTC 2021


This patch includes some of the changes from Lee to support a set of static functions to allow bulk copy from Java arrays to segments (and viceversa) in a more succint fashion (so that the user doesn't have to create a temporary heap segment to do the copy).

I've added a new public method to `MemorySegment` which performs an *element-wise* bulk copy; it takes a source segment and a couple of element layouts: the source element layout and the destination element layout. The two layouts must have same size, but can have different alignments (which will be checked against the corresponding segments) and byte orders. If the byte order differs, a bulk copy with swap will be performed. As such, this method generalizes the previous `copyFrom` - as follows:


copyFrom(srcSegment) -> copyFrom(JAVA_BYTE, srcSegment, JAVA_BYTE)

I've added support for argument type profiling for MemoryCopy static methods to avoid type pollution in cases where same metod is called with different memory segment types.

I've done a pass over the javadoc, and make it more consistent with the rest of the API. I've also reworked the test a bit to use the data provider functionality of TestNG, since all the test cases were similar, except for the carrier type.

There are other cosmetic changes as well, compared to original code from Lee, such as naming of static fields which is now capitalized. Everything else is the same.

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

Commit messages:
 - Further streamline test, and use a data provider
 - Streamline test
 - Add jtreg test header to TestMemoryCopy
 - Merge branch 'foreign-memaccess+abi' into copyMemory+8264594
 - Merge branch 'foreign-memaccess+abi' into copyMemory+8264594
 - * Indent test file
 - Add support for argument type profiling for MemoryCopy statics
 - * Fix javadoc in MemorySegment::copyFrom
 - * Streamline implementation of swappy copy methods
 - Fix whitespaces
 - ... and 4 more: https://git.openjdk.java.net/panama-foreign/compare/0d9d64da...2c6fa450

Changes: https://git.openjdk.java.net/panama-foreign/pull/555/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=555&range=00
  Stats: 1212 lines in 8 files changed: 1132 ins; 24 del; 56 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/555.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/555/head:pull/555

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


More information about the panama-dev mailing list