RFR: 8267807: C2: Downcast receiver to target holder during inlining
Vladimir Ivanov
vlivanov at openjdk.java.net
Thu May 27 10:43:09 UTC 2021
On Thu, 27 May 2021 08:24:18 GMT, Roland Westrelin <roland at openjdk.org> wrote:
>> Virtual method calls involve an implicit subtype check against callee holder.
>> But if receiver type is too broad, it has to be narrowed before parsing the callee method.
>> Otherwise, it may cause problems during parsing and currently it simply blocks inlining.
>>
>> Proposed fix implements the narrowing step and re-enables inlining.
>>
>> Testing:
>> - [x] hs-tier1 - hs-tier9
>
> src/hotspot/share/opto/doCall.cpp line 1138:
>
>> 1136: bool is_interface_holder = cha_monomorphic_target->holder()->is_interface();
>> 1137: if (has_receiver && !is_interface_holder) {
>> 1138: if (!cha_monomorphic_target->holder()->is_subtype_of(receiver_type->klass())) {
>
> Given we can't trust interface types, shouldn't we test for receiver_type not an interface here?
Though it doesn't happen in practice now, we can trust interface types on the receiver object because virtual/interface method invocation implies proper type check of the receiver.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4212
More information about the hotspot-compiler-dev
mailing list