On Wed, 14 Jun 2023 23:38:01 GMT, Jorn Vernee <jver...@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

Reply via email to