[foreign-memaccess+abi] RFR: Revert SegmentAllocator API changes

Per Minborg pminborg at openjdk.org
Fri Aug 18 06:54:47 UTC 2023


On Thu, 17 Aug 2023 17:01:44 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch reverts the changes to the `implSpec` of the various default methods in `SegmentAllocator`.
> We have realized that the changes there are irrelevant. What matters in order to get to optimal peak performance is that `SegmentAllocator::copyArrayWithSwapIfNeeded` is force-inlined.
> 
> The segment allocator test is also reverted to its former self.

src/java.base/share/classes/java/lang/foreign/SegmentAllocator.java line 332:

> 330:         int size = Array.getLength(Objects.requireNonNull(array));
> 331:         MemorySegment segment = allocateNoInit(Objects.requireNonNull(elementLayout), size);
> 332:         if (size > 0) {

Do we need this check? Is it not so that a vast majority of provided arrays would have a size > 0 and in the rare occasion there is a zero-length array, it will still work without this check?

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

PR Review Comment: https://git.openjdk.org/panama-foreign/pull/868#discussion_r1298073792


More information about the panama-dev mailing list