RFR: 8372285: G1: Micro-optimize x86 barrier code

Aleksey Shipilev shade at openjdk.org
Fri Nov 21 09:13:45 UTC 2025


We know from [JDK-8372284](https://bugs.openjdk.org/browse/JDK-8372284) that G1 C2 stubs can take ~10% of total instructions. So minor optimizations in hand-written assembly pay off for code density. This PR does a little x86-specific polishing: `testptr` where possible, short forward branches where possible. I rewired some code to make it abundantly clear the branches in question are short. It also makes clear that lots of the affected methods are essentially fall-through.

The patch is deliberately on simpler side, so we can backport it to 25u, if need arises.

Additional testing:
 - [x] Linux x86_64 server fastdebug, `tier1`
 - [ ]  Linux x86_64 server fastdebug, `all`

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

Commit messages:
 - Also reflow generate_pre_barrier_slow_path, so it is obvious the branches are short
 - More touchups
 - Also optimize queue insertion
 - Touchups
 - WIP

Changes: https://git.openjdk.org/jdk/pull/28446/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28446&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8372285
  Stats: 71 lines in 1 file changed: 21 ins; 28 del; 22 mod
  Patch: https://git.openjdk.org/jdk/pull/28446.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28446/head:pull/28446

PR: https://git.openjdk.org/jdk/pull/28446


More information about the hotspot-dev mailing list