[foreign-memaccess+abi] RFR: 8278151: Heap segments should handle alignment constraints in a deterministic fashion [v2]

Radoslaw Smogura duke at openjdk.java.net
Thu Dec 2 18:07:22 UTC 2021


On Thu, 2 Dec 2021 15:05:29 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Sorry, it was stupid question. Please ignore
>
> No problem - this is quite tricky. In general, `skipAlignmentMaskCheck` still does _something_ when accessing native segments (as the max align mask is zero there), but in general you are morally correct in observing that it's less useful than it used to be. My hope is that with the right VM fixes, we can get rid of `skipAlignmentMaskCheck` completely, and simplify all this.
> 
> For the records, the difference between unaligned and aligned access is as follows:
> 
> 
> Benchmark                                                Mode  Cnt  Score   Error  Units
> LoopOverNonConstant.segment_loop_instance                avgt   30  0.229 ? 0.002  ms/op
> LoopOverNonConstant.segment_loop_instance_aligned        avgt   30  0.335 ? 0.001  ms/op
> 
> 
> It's not terrible, but could of course be better.

Hmm...

I wonder a bit if this code can be optimized `if (((address | maxAlignMask) & alignmentMask) != 0) {`

Max `maxAlignMask`, can be 1,2,4 (if I see it correctly) so if `maxAlignMask` `alignmentMask` and will not be correct, than exception will be thrown regardless of address? I wonder if making static check could be more performant as VM move such check before loop, than we could only focus on `address & alignmentMask != 0`. Or something like this.

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

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


More information about the panama-dev mailing list