8331734: Atomic MemorySegment VarHandle operations fails for element layouts

Reviewed-by: pminborg, psandoz
This commit is contained in:
Maurizio Cimadamore 2024-05-10 16:22:28 +00:00
parent 65abf24fde
commit 1c5f1501ac
3 changed files with 49 additions and 15 deletions

View file

@ -26,6 +26,7 @@
package jdk.internal.foreign;
import jdk.internal.vm.annotation.ForceInline;
import java.lang.foreign.AddressLayout;
import java.lang.foreign.GroupLayout;
import java.lang.foreign.MemoryLayout;
@ -204,10 +205,7 @@ public class LayoutPath {
String.format("Path does not select a value layout: %s", breadcrumbs()));
}
// If we have an enclosing layout, drop the alignment check for the accessed element,
// we check the root layout instead
ValueLayout accessedLayout = enclosing != null ? valueLayout.withByteAlignment(1) : valueLayout;
VarHandle handle = accessedLayout.varHandle();
VarHandle handle = valueLayout.varHandle();
handle = MethodHandles.collectCoordinates(handle, 1, offsetHandle());
// we only have to check the alignment of the root layout for the first dereference we do,