RFR: 8350118: Simplify the layout access VarHandle [v4]

Chen Liang liach at openjdk.org
Thu Feb 27 15:43:25 UTC 2025


> 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 with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 14 additional commits since the last revision:

 - Rollback lazy Segment adapter cache per vernee, fix header indent
 - Merge branch 'master' of https://github.com/openjdk/jdk into feature/ffm-vh-inline
 - Jorn vernee review
 - Review remarks, dates, some more simplifications
 - More cleanup
 - Merge branch 'master' of https://github.com/openjdk/jdk into feature/ffm-vh-inline
 - Make sure the form impl class is initialized
 - Reduce MT initialization work
 - MH linkToStatic stall
 - Merge branch 'master' of https://github.com/openjdk/jdk into feature/ffm-vh-inline
 - ... and 4 more: https://git.openjdk.org/jdk/compare/23dee8fd...d59ff23a

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/23720/files
  - new: https://git.openjdk.org/jdk/pull/23720/files/3d558a2d..d59ff23a

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=23720&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=23720&range=02-03

  Stats: 13038 lines in 332 files changed: 7301 ins; 4580 del; 1157 mod
  Patch: https://git.openjdk.org/jdk/pull/23720.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23720/head:pull/23720

PR: https://git.openjdk.org/jdk/pull/23720


More information about the build-dev mailing list