On Fri, 3 Jul 2026 22:43:58 GMT, Dean Long <[email protected]> wrote:

>> Roland Westrelin has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Tobias' comments
>
> src/hotspot/share/c1/c1_Canonicalizer.cpp line 648:
> 
>> 646:       // Interface casts can't be statically optimized away since 
>> verifier doesn't
>> 647:       // enforce interface types in bytecode.
>> 648:       if (!is_interface && klass->is_subtype_of(x->klass())) {
> 
> Do we still need to check for obj->is_null_free() here?

Historically, these conditions were needed when `CheckCast` still accepted a 
`null_free` argument for Q-descriptor casts which required the cast to throw on 
null:
https://github.com/openjdk/valhalla/blob/2742ec77d2accaaa05ec9f1fa63f1f03ab52a0db/src/hotspot/share/c1/c1_Instruction.hpp#L1511-L1513

[JDK-8325660](https://bugs.openjdk.org/browse/JDK-8325660) removed that state, 
i.e.`x->is_null_free()` is now always `false`. The `|| obj->is_null_free()` 
condition was there to avoid the null check if the casted `obj` can't be null. 
It's also not needed anymore.

> src/hotspot/share/c1/c1_Canonicalizer.cpp line 655:
> 
>> 653:     }
>> 654:     // checkcast of null returns null for non null-free klasses
>> 655:     if (!x->is_null_free() && obj->is_null_obj()) {
> 
> Suggestion:
> 
>     if (obj->is_null_obj()) {
> 
> Isn't !x->is_null_free() always true here?

Yes, good catch. This should be removed.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2624#discussion_r3527371345
PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2624#discussion_r3527374040

Reply via email to