On Fri, 29 May 2026 16:44:57 GMT, Patricio Chilano Mateo 
<[email protected]> wrote:

> For calls where value type arguments are passed in scalarized form, the c2 
> compiler adds the `Method*` to the relocation metadata 
> [[1]](https://github.com/openjdk/valhalla/blob/4c23f0ed5d6a89cd1e7ab8550b367bca296a9f30/src/hotspot/share/opto/graphKit.cpp#L2059),
>  so it can later be recovered in `SharedRuntime::resolve_xxx_call_C` as 
> `attached_method` instead of resolving normally through the constant pool 
> (but only if the callee holder is an inline klass 
> [[2]](https://github.com/openjdk/valhalla/blob/4c23f0ed5d6a89cd1e7ab8550b367bca296a9f30/src/hotspot/share/runtime/sharedRuntime.cpp#L1297)).
> 
> When resolving static calls, before the thread returns back to Java either 
> the holder class should be already initialized or the thread should be the 
> one currently initializing it. But the `LinkResolver` path we take for the 
> `attached_method` case doesn’t try to initialize the holder klass, i.e. there 
> is an assumption that it’s already initialized. Since c2 doesn’t generate an 
> uncommon trap in the caller if the callee holder class is being initialized, 
> a thread can reach the static resolution case of a method from an inline 
> klass as described above while the class is still being initialized, leading 
> to the reported assert failure.
> 
> The attached method is needed when the receiver may be scalarized as no 
> receiver oop might be available to resolve against. Since that doesn’t apply 
> to static calls the proposed fix is to also ignore the attached method in 
> those cases.
> 
> I added a reproducer test that crashes with the same assert failure without 
> this fix. Also tested the patch in mach5 tier1-3 and valhalla-comp-stress.
> 
> Thanks,
> Patricio
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Looks good to me too. Thanks for fixing!

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

Marked as reviewed by thartmann (Committer).

PR Review: 
https://git.openjdk.org/valhalla/pull/2490#pullrequestreview-4398669256

Reply via email to