RFR: 8353176: C1: x86 patching stub always calls Thread::current()

Aleksey Shipilev shade at openjdk.org
Fri Mar 28 12:35:54 UTC 2025


On Fri, 28 Mar 2025 11:05:33 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> Noticed this while looking at compiled code density. In C1 PatchingStub code, we _always_ perform a runtime call to `Thread::current()`, even though we can rely on `r15_thread` to be available. This is because we are calling to `MacroAssembler::get_thread()`, which is always doing slowpath.
> 
> This kind of accident would be less likely / impossible once we cleanup uses of `MacroAssembler::get_thread()` with [JDK-8353174](https://bugs.openjdk.org/browse/JDK-8353174).
> 
> Additional testing:
>  - [x] Linux x86_64 server fastdebug, `tier1`
>  - [x] Linux x86_64 server fastdebug, `tier1` + `-XX:TieredStopAtLevel=1`
>  - [ ] Linux x86_64 server fastdebug, `all`
>  - [ ] Linux x86_64 server fastdebug, `all` + `-XX:TieredStopAtLevel=1`

Sample code density improvements:


$ for I in 1 2 3; do build/linux-x86_64-server-release/images/jdk/bin/java \ 
  -XX:TieredStopAtLevel=${I} -Xcomp -XX:+CITime \ 
  Hello 2>&1 | grep "nmethod code size"; done

# baseline
tier1:  463424 bytes
tier2:  499456 bytes
tier3: 1051016 bytes

# patched
tier1:  436632 bytes ; -6.1%
tier2:  472808 bytes ; -5.6%
tier3: 1024376 bytes ; -2.6%

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

PR Comment: https://git.openjdk.org/jdk/pull/24291#issuecomment-2761044476


More information about the hotspot-compiler-dev mailing list