RFR: 8354282: C2: more crashes in compiled code because of dependency on removed range check CastIIs [v8]

Quan Anh Mai qamai at openjdk.org
Tue Dec 2 17:48:44 UTC 2025


On Tue, 2 Dec 2025 16:48:55 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Suggestion:
>> 
>>     // Use case example: Range Check CastII
>>     // Floating: The Cast is only dependent on the single range check. If the range check was ever to be hoisted
>>     //           it would be safe to let the the Cast float to where the range check is hoisted up to.
>>     // Narrowing: The Cast narrows the type to a positive index. If the input to the Cast is narrower, we can safely
>>     //            remove the cast because the array access will be safe.
>
> Ok, I now read the PR from the top, and not just recent changes. If one were to start reading from the top, it would be clear without my suggestions here. But I think it could still be good to apply something about letting the Cast float to where we would hoist the RC.

Naming is hard, but it is worth pointing out in the comment that floating here refers to `depends_only_on_test`. In other words, a cast is considered floating if it is legal to change the control input of a cast from an `IfTrue` or `IfFalse` to an `IfTrue` and `IfFalse` that dominates the current control input, and the corresponding conditions of the `If`s are the same. In contrast, we cannot do that for a pinned cast, and if the control is folded away, the control input of the pinned cast is changed to the control predecessor of the folded node.

It is also worth noting that we have `Node::pinned` which means the node is pinned AT the control input while pinned here means that it is pinned UNDER the control input. Very confusing!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24575#discussion_r2582215477


More information about the hotspot-dev mailing list