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).

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

Commit messages:
 - Polish test
 - Trying something

Changes: https://git.openjdk.org/valhalla/pull/2434/files
  Webrev: https://webrevs.openjdk.org/?repo=valhalla&pr=2434&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8384283
  Stats: 92 lines in 2 files changed: 88 ins; 1 del; 3 mod
  Patch: https://git.openjdk.org/valhalla/pull/2434.diff
  Fetch: git fetch https://git.openjdk.org/valhalla.git pull/2434/head:pull/2434

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

Reply via email to