RFR: 8349479: C2: when a Type node becomes dead, make CFG path that uses it unreachable [v2]

Roland Westrelin roland at openjdk.org
Fri Mar 21 16:39:15 UTC 2025


On Fri, 21 Mar 2025 08:40:04 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>     * Should we keep the HaltNodes in the graph? The question here is if we assume that:
>       
>       * these HaltNodes should never be taken, because the data nodes have proven that the path is impossible? Then we could actually just constant fold the if before the HaltNode.
>       * these HaltNodes may be taken, because maybe there is a bug and only that led to the constant folding of the data node. Hitting a HaltNode would be a proof of a bug, and so we should keep them. It is better to crash the program than to continue in an inconsistent state down the wrong branch. Deopt would have been desirable, but restoring the state is probably near impossible.

I think we want to leave the `Halt` nodes in the final code. Investigating crashes when compile code executes is somewhat trickier than crashes when compiling and that's a drawback of this patch. If the `Halt` nodes are removed then, in case of a bug where a path that's expected unreachable is taken, execution could proceed and fail only much later. That would lead to much harder and mysterious bugs. 

Also it's not guaranteed that there's a an `If` right before the `Cast` or that that `If` is actually the condition guarding the `Cast`.

Thanks for the comments.

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

PR Comment: https://git.openjdk.org/jdk/pull/23468#issuecomment-2743895442


More information about the hotspot-compiler-dev mailing list