On Thu, 29 Jan 2026 21:24:05 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>> 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.
>
> What makes it more complicated is the requirement to return a subtype of declared interface. `_interfaces` contain a closure of a set of interfaces. A dependency on an unrelated interface (in the context of the call site) is not enough to ensure correctness of interface->virtual strength reduction.
Can you use `ciInstanceKlass::unique_implementor` during the creation of the `TypeInstPtr`, will this work?
diff --git a/src/hotspot/share/opto/type.cpp b/src/hotspot/share/opto/type.cpp
index eb825b81a93..7e395fca743 100644
--- a/src/hotspot/share/opto/type.cpp
+++ b/src/hotspot/share/opto/type.cpp
@@ -3702,6 +3702,13 @@ const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass* klass, bool klass_
deps->assert_abstract_with_unique_concrete_subtype(ik, sub);
klass = ik = sub;
klass_is_exact = sub->is_final();
+ } else if (ik->is_interface() && interface_handling == trust_interfaces) {
+ sub = ik->unique_implementor();
+ if (sub != nullptr) {
+ deps->assert_unique_implementor(ik, sub);
+ klass = ik = sub;
+ klass_is_exact = sub->is_final();
+ }
}
}
if (!klass_is_exact && try_for_exact && deps != nullptr &&
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28811#discussion_r2744306281