RFR: 8372285: G1: Micro-optimize x86 barrier code
Aleksey Shipilev
shade at openjdk.org
Fri Nov 21 09:13:46 UTC 2025
On Fri, 21 Nov 2025 09:06:54 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> 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`
Sample experiments show this saves ~1.6% of code:
$ for I in `seq 1 3`; do build/linux-x86_64-server-release/images/jdk/bin/java -Xcomp -XX:+CITime 2>&1 | grep "nmethod code"; done
# Before
nmethod code size : 5764304 bytes
nmethod code size : 5764336 bytes
nmethod code size : 5764480 bytes
# After (-1.6%)
nmethod code size : 5670136 bytes
nmethod code size : 5670136 bytes
nmethod code size : 5670168 bytes
$ for I in `seq 1 3`; do build/linux-x86_64-server-release/images/jdk/bin/java -Xcomp -XX:+CITime Hello.java 2>&1 | grep "nmethod code"; done
# Before
nmethod code size : 25394184 bytes
nmethod code size : 25394552 bytes
nmethod code size : 25393968 bytes
# After (-1.6%)
nmethod code size : 24988544 bytes
nmethod code size : 24991696 bytes
nmethod code size : 24991040 bytes
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28446#issuecomment-3562073445
More information about the hotspot-dev
mailing list