[foreign-preview] RFR: 8286306: Upcall wrapper class sharing
    Jorn Vernee 
    jvernee at openjdk.java.net
       
    Fri May  6 14:58:09 UTC 2022
    
    
  
This patch adds upcall wrapper class sharing.
I recently realized that these classes can be shared if they have the same input FunctionDescriptor, but a different target method handle.
This is implemented by generating a wrapper class that takes the target method handles as a leading argument. The target method handle is then inserted into the parameter list using `MethodHandles::insertArguments` to create the final method handle that is returned by the specializer. After MH customization kicks in, the target will be a constant again (so shouldn't affect peak performance).
Doing this doesn't effect peak performance, as verified through the Upcalls benchmark, but does significantly improve linking performance.
Before:
    Benchmark              Mode  Cnt   Score   Error  Units
    LinkUpcall.link_blank  avgt   30  69.323 � 2.522  us/op
After:
    Benchmark              Mode  Cnt   Score   Error  Units
    LinkUpcall.link_blank  avgt   30  11.787 � 0.744  us/op
-------------
Commit messages:
 - Small code simplification
 - Add link benchmark
 - Upcall Wrapper class sharing
Changes: https://git.openjdk.java.net/panama-foreign/pull/679/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=679&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8286306
  Stats: 102 lines in 3 files changed: 94 ins; 0 del; 8 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/679.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/679/head:pull/679
PR: https://git.openjdk.java.net/panama-foreign/pull/679
    
    
More information about the panama-dev
mailing list