RFR: 8328480: C2: SubTypeCheckNode in checkcast should use the klass constant of a unique concrete sub class [v2]
Roland Westrelin
roland at openjdk.org
Thu Mar 28 16:27:32 UTC 2024
On Thu, 28 Mar 2024 16:14:03 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> src/hotspot/share/opto/graphKit.cpp line 3364:
>>
>>> 3362: if (improved_klass_ptr_type != klass_ptr_type) {
>>> 3363: if (improved_klass_ptr_type->singleton()) {
>>> 3364: improved_superklass = makecon(improved_klass_ptr_type);
>>
>> Do you really need to special case that one? Wouldn't the CastPP constant fold if `improved_klass_ptr_type` is a singleton?
>> 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.
>
>> 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.
Ok. Makes sense. Thanks for the explanation.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18515#discussion_r1543265259
More information about the hotspot-compiler-dev
mailing list