RFR: 8351748: Add class init barrier to AOT-cached Method/Var Handles
Ioi Lam
iklam at openjdk.org
Mon Mar 24 06:45:14 UTC 2025
On Thu, 13 Mar 2025 16:51:36 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>>> IMO a safer alternative is to unconditionally keep all clinit barriers during assembly phase (irrespective of whether relevant class is initialized or not).
>>
>> Could you elaborate how this can be done?
>
>> Could you elaborate how this can be done?
>
> For `MethodHandle`s `DirectMethodHandle.shouldBeInitialized(Class)` determines whether a barrier is needed or not. It can be tweaked to behave conservatively during assembly phase and report `true` irrespective of whether the target class is initialized or not. (And it can take AOT-inited classes into account as well.)
>
> (`VarHandle`s use `Unsafe.shouldBeInitialized(Class)` directly.)
Thanks @iwanowww @liach for the review
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24004#issuecomment-2747045729
More information about the hotspot-runtime-dev
mailing list