RFR: 8364141: Remove LockingMode related code from x86
Fredrik Bredberg
fbredberg at openjdk.org
Fri Aug 1 12:28:56 UTC 2025
On Fri, 1 Aug 2025 05:59:59 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
>> Since the integration of [JDK-8359437](https://bugs.openjdk.org/browse/JDK-8359437) the `LockingMode` flag can no longer be set by the user, instead it's declared as `const int LockingMode = LM_LIGHTWEIGHT;`. This means that we can now safely remove all `LockingMode` related code from all platforms.
>>
>> This PR removes `LockingMode` related code from the **x86** platform.
>>
>> When all the `LockingMode` code has been removed from all platforms, we can go on and remove it from shared (non-platform specific) files as well. And finally remove the `LockingMode` variable itself.
>>
>> Passes tier1-tier5 with no added problems.
>
> src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 227:
>
>> 225: void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Register rax_reg,
>> 226: Register t, Register thread) {
>> 227: assert(box == rbx, "Used for displaced header location");
>
> Where does this RBX requirement come from? Do not recall it being a thing for the lightweight implementation.
Good question! Long story short: `C2_MacroAssembler::fast_unlock` used to have this comment:
`// box: box address (displaced header location), killed. Must be EAX.
`
Looking at `cmpFastLock` in the `x86_64.ad` file I saw that the box was indeed hardwired to rax (e.g. `rax_RegP box`).
Since there was no special comment above `fast_lock_lightweight` I though that I should reuse the one from the deleted `fast_lock`. Then when looking in `cmpFastLockLightweight` I saw that box was hardwired to rbx. And ta-da, there you have the reason.
But now since you asked about it, I understand that the reason it say "Must be EAX" in `fast_lock`, was because it was used in a `cmpxchgptr`. But this was only used in the legacy locking mode, which is now deleted. So I will delete the comment and the assert().
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26552#discussion_r2247851859
More information about the hotspot-compiler-dev
mailing list