RFR: 8328480: C2: SubTypeCheckNode in checkcast should use the klass constant of a unique concrete sub class [v2]

Christian Hagedorn chagedorn at openjdk.org
Thu Mar 28 16:16:33 UTC 2024


On Thu, 28 Mar 2024 15:14:01 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> Do you really need to special case that one? Wouldn't the CastPP constant fold if improved_klass_ptr_type is a singleton?

For `Y <: abstract X`, when `superklass` is a precise constant `X` and `improved_klass_ptr_type` is a precise constant `Y`, then `CastPP(nullptr, superklass, improved_klass_ptr_type)` will be replaced by `top` and assigned to `improved_superklass` which is probably not what we want. That's why I special cased the singleton case. This could happen, for example, with:

obj = (X)o; // superklass = ConP #precise X, improved_klass_ptr_type = precise Y


> Also there is the question of whether a CastPP or a CheckCastPP should be used here and if it matters. They don't differ that much anymore so I suppose CastPP is ok.

Okay, sound good.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18515#discussion_r1543245301


More information about the hotspot-compiler-dev mailing list