RFR: 8373633: C2: Use interface receiver type to improve CHA decisions [v2]

Quan Anh Mai qamai at openjdk.org
Thu Jan 29 11:43:35 UTC 2026


On Tue, 27 Jan 2026 22:18:33 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

>> Strength-reducing an interface call to a virtual call for interfaces with
>> unique implementors can use receiver type information to narrow the context.
>> 
>> C2 tracks interface types and receiver type information can be used to reveal
>> an interface with a unique implementor which can't be derived from the call
>> site itself.
>> 
>> Since C2 effectively accumulates a union interface type from multiple subtype checks, iterating over individual components of a type may reveal a candidate for a strength-reduction. The only prerequisite is that a candidate has to be a subtype of the declared interface.  
>> 
>> Testing: hs-tier1 - hs-tier5
>
> Vladimir Ivanov has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
> 
>  - addtional case
>  - Merge branch 'master' into cha.intf.recv
>  - Use receiver type to improve CHA decisions

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;
      }
    }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28811#discussion_r2741217681


More information about the hotspot-compiler-dev mailing list