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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Aug 5 10:44:16 UTC 2021


> 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 with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision:

 - Fix javadoc
 - Address review comments
 - Merge branch 'foreign-memaccess+abi' into memorycopy_finalize
 - Update test/jdk/java/foreign/TestCopyFrom.java
   
   Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
 - Make `copyFrom` a default method
 - Drop memory copy primitive using Object, but keep internal centralized implementation
   Move MemorySegment copy methods as static methods in MemorySegment
 - Fix whitespaces
 - Consolidate copy to/from array methods to reuse same underlying implementation.
 - Fix jaavdoc warning
 - Remove comments from StdLibTest
 - ... and 2 more: https://git.openjdk.java.net/panama-foreign/compare/ca84f911...342d1c82

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

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/568/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/568/files/49e3cfbd..342d1c82

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=568&range=05
 - incr: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=568&range=04-05

  Stats: 16570 lines in 655 files changed: 9824 ins; 3052 del; 3694 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/568.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/568/head:pull/568

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


More information about the panama-dev mailing list