On Wed, 13 May 2026 13:00:52 GMT, Marc Chevalier <[email protected]> wrote:

> As suggested by Tobias, it seems that the loop
> https://github.com/openjdk/valhalla/blob/de6aff4ffe3344bfb886fa27385e432016bbbeef/src/hotspot/share/opto/graphKit.cpp#L2344-L2347
> is wrong, even with the index (`[0]`) fixed.
> 
> Indeed, `final_state` is the `SafePointNode` that tracks the JVM state, that 
> is the stack, slots... This kind of things. There is no good reason this 
> should replace the output of the existing call. Instead, we should replace 
> the projection of the old call with the output of the new call. The new call 
> can be found as being the input of `result`. Of course, `result` can be 
> something else than a projection from a call, typically a load, a constant... 
> But then, I don't think we can be in the case of an unloaded return type. 
> Testing seems to agree with that.
> 
> Another thing to take care of: `callprojs->resproj[i]` might be null, when 
> the projection isn't used. Indeed, `store_inline_type_fields_to_buf` has a 
> lot of `double` input, and so the `Half` part of these inputs are `top` (and 
> thus, not wired from the old call). On the other hand, the projection of the 
> new call must be there, but they should:
> https://github.com/openjdk/valhalla/blob/de6aff4ffe3344bfb886fa27385e432016bbbeef/src/hotspot/share/opto/graphKit.cpp#L2167-L2181
> 
> Thanks,
> Marc
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This pull request has now been integrated.

Changeset: 6b9eb7d6
Author:    Marc Chevalier <[email protected]>
URL:       
https://git.openjdk.org/valhalla/commit/6b9eb7d6a9548deef3dcb5bc4782b21cecfffe89
Stats:     91 lines in 2 files changed: 87 ins; 1 del; 3 mod

8384283: [lworld] Post-parse call devirtualization with unloaded return type 
fails

Reviewed-by: thartmann

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

PR: https://git.openjdk.org/valhalla/pull/2434

Reply via email to