[foreign-memaccess+abi] RFR: 8268743: Require a better way for copying data between MemorySegments and on-heap arrays
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Mon Jun 21 14:41:08 UTC 2021
On Tue, 15 Jun 2021 11:56:26 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> After some investigation, it seems that escape analysis is defeated in cases where a new heap segment is created fresh just before performing a bulk copy.
>
> This is caused by the fact that, on segment creation, we perform this test:
>
>
> static int defaultAccessModes(long size) {
> return (enableSmallSegments && size < Integer.MAX_VALUE) ?
> SMALL : 0;
> }
>
>
> To make sure that segments whose size fits in an `int` do not incur in penalties associated with lack of optimizations over long loop bound check optimizations.
>
> Unfortunately, this logic is control flow logic, and control flow disables escape analysis optimizations.
>
> For segment wrappers around byte arrays we can workaround by removing the check (all byte segments are small by definition, since there's a 1-1 mapping between logical elements and physical bytes). For other segment kinds we cannot do much.
>
> While it would be possible, in principle, to resort to more complex bound checks for heap segments, we believe the way forward is to eliminate the need for "small" segments, which will be possible once the PR below is completed:
>
> https://github.com/openjdk/jdk/pull/2045
Closing as it does not address the original problem.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/560
More information about the panama-dev
mailing list