[foreign-preview] RFR: 8281595: ASM-ify scope acquire/release for down call parameters

Jorn Vernee jvernee at openjdk.java.net
Fri Feb 11 19:15:01 UTC 2022


Hi,

This patch rewrites the scope acquire/release logic that we do for downcalls inside ASM, in the generated specialized binding class. This also drops the fallback path we had for more than 5 scopes. The new code now always checks to see if every scope is unique. (I think that should be okay, but please let me know if otherwise).

I've also added a benchmark by Maurizio to this patch, which was showing a failure to scalar replace some scoped arguments with the old MH logic (reason discussed in [JDK-8281387](https://bugs.openjdk.java.net/browse/JDK-8281387)). With the new ASM-based logic, there is no sign of allocations (other than some noise):


Benchmark                                                     Mode  Cnt   Score    Error   Units
PointerInvoke.panama_call_as_address                          avgt   30  13.181 ±  0.320   ns/op
PointerInvoke.panama_call_as_address:·gc.alloc.rate           avgt   30   0.043 ±  0.049  MB/sec
PointerInvoke.panama_call_as_address:·gc.alloc.rate.norm      avgt   30   0.001 ±  0.001    B/op
PointerInvoke.panama_call_as_address:·gc.count                avgt   30     ≈ 0           counts
PointerInvoke.panama_call_as_long                             avgt   30  12.943 ±  0.287   ns/op
PointerInvoke.panama_call_as_long:·gc.alloc.rate              avgt   30   0.065 ±  0.054  MB/sec
PointerInvoke.panama_call_as_long:·gc.alloc.rate.norm         avgt   30   0.002 ±  0.001    B/op
PointerInvoke.panama_call_as_long:·gc.count                   avgt   30     ≈ 0           counts
PointerInvoke.panama_call_as_new_segment                      avgt   30  14.309 ±  0.177   ns/op
PointerInvoke.panama_call_as_new_segment:·gc.alloc.rate       avgt   30   0.173 ±  0.144  MB/sec
PointerInvoke.panama_call_as_new_segment:·gc.alloc.rate.norm  avgt   30   0.005 ±  0.004    B/op
PointerInvoke.panama_call_as_new_segment:·gc.count            avgt   30     ≈ 0           counts
PointerInvoke.panama_call_as_segment                          avgt   30  13.273 ±  0.191   ns/op
PointerInvoke.panama_call_as_segment:·gc.alloc.rate           avgt   30  ≈ 10??           MB/sec
PointerInvoke.panama_call_as_segment:·gc.alloc.rate.norm      avgt   30  ≈ 10??             B/op
PointerInvoke.panama_call_as_segment:·gc.count                avgt   30     ≈ 0           counts


Thanks,
Jorn

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

Commit messages:
 - Fix copyright year
 - Add PointerInvoke benchmark
 - ASM-ify downcall scope acquire/release

Changes: https://git.openjdk.java.net/panama-foreign/pull/640/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=640&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8281595
  Stats: 420 lines in 5 files changed: 237 ins; 178 del; 5 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/640.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/640/head:pull/640

PR: https://git.openjdk.java.net/panama-foreign/pull/640


More information about the panama-dev mailing list