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

Jorn Vernee jvernee at openjdk.java.net
Tue Feb 15 15:37:43 UTC 2022


On Fri, 11 Feb 2022 19:05:19 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: 4c7b0da2
Author:    Jorn Vernee <jvernee at openjdk.org>
URL:       https://git.openjdk.java.net/panama-foreign/commit/4c7b0da2a31e1de6a93c6df93a730db056670c37
Stats:     420 lines in 5 files changed: 237 ins; 178 del; 5 mod

8281595: ASM-ify scope acquire/release for down call parameters
8281387: Some downcall shapes show unexpected allocations

Co-authored-by: Maurizio Cimadamore <mcimadamore at openjdk.org>
Reviewed-by: mcimadamore

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

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


More information about the panama-dev mailing list