On Thu, 27 Feb 2025 16:00:47 GMT, Chen Liang <li...@openjdk.org> wrote:
>> Simplify the layout access var handles to be direct in some common cases. >> Also made `VarHandle::isAccessModeSupported` report if an access mode is >> supported for a VH. >> >> Reduces the instructions to execute this code in a simple main by 47%: >> >> long[] arr = new long[8]; >> var ms = MemorySegment.ofArray(arr); >> ms.setAtIndex(ValueLayout.JAVA_BYTE, 12, (byte) 3); >> >> >> Main overheads in FFM are identified to be: >> 1. Eager initialization of direct MethodHandle; can be CDS archived >> 2. MH combinator forms via LambdaFormEditor, not cached right now and always >> have large overhead >> >> Still need other measures to deal with common user patterns of >> `MethodHandles.insertCoordinates(vh, 1, 0L)` which currently is still very >> slow. >> >> Tests: 2 unrelated failures on tier 1-3 > > Chen Liang has updated the pull request incrementally with one additional > commit since the last revision: > > noStride -> constantOffset, optimize VH classes to have only 2 instead of 3 > classes for each type src/java.base/share/classes/java/lang/invoke/X-VarHandleSegmentView.java.template line 53: > 51: > 52: static final VarForm CONSTANT_OFFSET_FORM = new > VarForm(VarHandleSegmentAs$Type$s.class, MemorySegment.class, $type$.class, > long.class); > 53: static final VarForm TAKE_OFFSET_FORM = new > VarForm(VarHandleSegmentAs$Type$s.class, MemorySegment.class, $type$.class, > long.class, long.class); what does TAKE mean here? (the old names weren't great either, I realize). I think it would be better to decide, once and for all, how to refer to these things, and then use consistent naming throughout. I see we have discussed using "noStride" vs. "fixedOffset". Since the implementation now uses the term "constantOffset", let's just call the other "variableOffset" ? src/java.base/share/classes/java/lang/invoke/X-VarHandleSegmentView.java.template line 120: > 118: > 119: // This class must be accessed through non-aligned > VarHandleSegmentAs$Type$s > 120: final class VarHandleSegmentAs$Type$sAligned extends > VarHandleSegmentAs$Type$s { I kind of liked the nested classes -- why the change? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23720#discussion_r1975192481 PR Review Comment: https://git.openjdk.org/jdk/pull/23720#discussion_r1975193951