JDK-8290688 : Optimize x86_64 nmethod entry barriers
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • CPU: x86
  • Submitted: 2022-07-20
  • Updated: 2022-07-28
  • Resolved: 2022-07-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20 b08Fixed
Related Reports
Blocks :  
Description
The current nmethod entry barrier is good, but it could be a bit better. In particular, this enhancement targets the following ideas.

1. The alignment of the cmp instruction is 8 bytes. However, we only patch 4 bytes and the instruction length is always 8 bytes. So if we align the start of the instruction to 4 bytes only, that is enough to ensure that the immediate part of the instruction is 4 byte aligned, which is all we need (cf. http://cr.openjdk.java.net/~jrose/jvm/hotspot-cmc.html).

2. Today the fast path (conditionally) jumps over a call to a stub. It is not uncommon for the branch not taken path being better optimized, making it favourable to move the call to a stub out-of-line. This has the additional benefit of not polluting the instruction caches at the nmethod entry with instructions not used in the fast path. A bit messy but we can do it for C2.

3. For C1 and native wrappers, I don't think they are hot enough to warrant the stub machinery. But at least the jump that jumps over the cold stuff, can be shortened. I can get behind that.

Before addressing this, turning nmethod entry barriers on with G1 (e.g. by enabling loom) leads to a regression in DaCapo tradesoap-large. With this enhancement, the regression goes away, so that the cost of nmethod entry barriers is not visible.
Comments
Changeset: b28f9dab Author: Erik Ă–sterlund <eosterlund@openjdk.org> Date: 2022-07-22 14:42:42 +0000 URL: https://git.openjdk.org/jdk/commit/b28f9dab80bf5d4de89942585c1ed7bb121d9cbd
22-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9569 Date: 2022-07-20 11:51:08 +0000
20-07-2022