RFR: 8310053: VarHandle and slice handle derived from layout are lacking alignment check [v4]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Jun 15 00:26:11 UTC 2023


On Wed, 14 Jun 2023 23:38:01 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Add missing alignment checks for the alignment constraint of the root layout of a VarHandle created through `MemoryLayout::varHandle` and a MethodHandle `MemoryLayout::sliceHandle`.
>> 
>> Testing: `jdk_foreign` test suite
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Drop alignment checks from accessed elements
>   Use expectThrows

I'm wondering... for dereference path elements, we already perform a root layout check as part of the memory segment expansion - e.g. we use the target layout to resize the segment (and perform an alignment check). So in that case there would still be duplicate alignment checks.

In such cases, we need to make sure that either (a) only the first var handle in the dereference chain gets the proper alignment adaptation on the input segment or that (b) they all do, but then we omit the alignment checks that are generated as part of calling VH::get on the address layout (but that might be harder to do, as that logic is shared). I think (a) is probably simplest - just have a boolean in the path which says whether a path is nested into some other path using a dereference and, if so, omit the alignment adaptation?

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

PR Comment: https://git.openjdk.org/jdk/pull/14475#issuecomment-1592156216


More information about the core-libs-dev mailing list