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

Roland Westrelin roland at openjdk.org
Wed Mar 27 16:49:22 UTC 2024


On Wed, 27 Mar 2024 16:39:32 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> src/hotspot/share/opto/graphKit.cpp line 3362:
>> 
>>> 3360:     // Generate the subtype check
>>> 3361:     Node* improved_superklass = superklass;
>>> 3362:     if (improved_klass_ptr_type != klass_ptr_type && improved_klass_ptr_type->singleton()) {
>> 
>> In what case can there be an `improved_klass_ptr_type` that's not a constant?
>
> I was surprised by that as well when I've run testing but `gen_checkcast()` is actually also called in `Parse::array_store_check()` which passes a `LoadKlassNode` which is not a constant:
> 
> https://github.com/openjdk/jdk/blob/05854fd704cba6ebd73007d9547a064891d49587/src/hotspot/share/opto/parseHelper.cpp#L233-L238
> 
> It states that it ignores the result and just calls it for the CFG effects - does not sound like a very clean solution.

I'm confused by this. Looking at `TypeInstKlassPtr::try_improve()` returns a constant only if it finds a unique subklass and that subklass is final. So it should not be uncommon to have an `improved_klass_ptr_type` that's not constant.

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

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


More information about the hotspot-compiler-dev mailing list