RFR: 8373633: C2: Use interface receiver type to improve CHA decisions [v2]
Quan Anh Mai
qamai at openjdk.org
Thu Jan 29 12:25:25 UTC 2026
On Thu, 29 Jan 2026 11:39:56 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
>> src/hotspot/share/opto/type.cpp line 4593:
>>
>>> 4591: // For an interface instance reports one of most specific superinterfaces with a unique implementor.
>>> 4592: ciInstanceKlass* TypeInstPtr::has_unique_implementor(ciInstanceKlass* context_intf) const {
>>> 4593: if (is_interface() && context_intf->is_interface()) {
>>
>> I feel like you are making it unnecessarily complicated. `_interface` is the set of interfaces this `TypeInstPtr` must satisfy. As a result, a check like this would be sufficient (not real code):
>>
>> for (ciInstanceKlass* intf : _interfaces) {
>> ciInstanceKlass* candidate = intf->unique_implementor();
>> if (candidate != nullptr) {
>> return candidate;
>> }
>> }
>
> Even better, since these `_interfaces` are trusted, we don't need to emit a runtime check for the type.
Come to think of it, we can use `interface->unique_implementor()` similar to how we use `ik->unique_concrete_subklass()` in `TypeOopPtr::make_from_klass_common`, that is to tighten the `TypeOopPtr` at the time of creation.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28811#discussion_r2741378544
More information about the hotspot-compiler-dev
mailing list