On Wed, 26 Feb 2025 20:13:42 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:
> 
>   Jorn vernee review

I put that 3 lines of code in a `public static void main` and measured the 
number of instructions executed using bytestacks. Unfortunately we don't have 
any automation, and this test is partial that we should probably add more 
things to the measurement (such as general foreign function cost, and cost of 
other kinds of foreign memory access).

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

PR Comment: https://git.openjdk.org/jdk/pull/23720#issuecomment-2686250061

Reply via email to