[jdk18] Integrated: 8279930: Synthetic cast causes generation of store barriers when using heap segments

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Jan 14 11:19:36 UTC 2022


On Wed, 12 Jan 2022 15:48:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> When looking at larger benchmarks, I noted a discrepancy between the performance of off-heap segments and on-heap segments. Looking at the assembly for the `MemorySegment::asSlice` method I could see some additional barriers in the off-heap case, but could not initially make sense of them. Vlad pointed me at G1 (in fact no such barrier was emitted when using a different GC, such as the serial GC, or ZGC), and later Erik narrowed the problem down to a failure in a C2 optimization to remove barriers around initializing stores. This problem was caused by a synthetic cast added by javac to a value (the base object) that initialized the newly created memory segment slice. Because of that case, C2 missed the store as an "initializing" one, and inserted additional barriers. This patch should make performance of on-heap segments a lot more reliable, especially when slicing is involved.

This pull request has now been integrated.

Changeset: c6b02755
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.java.net/jdk18/commit/c6b027559c6e055b1475ada4001ef483b1a12d24
Stats:     292 lines in 3 files changed: 263 ins; 0 del; 29 mod

8279930: Synthetic cast causes generation of store barriers when using heap segments

Reviewed-by: psandoz

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

PR: https://git.openjdk.java.net/jdk18/pull/97


More information about the core-libs-dev mailing list