CHA can devirtualize interface calls by strength reducing them to virtual calls when there's only a single direct implementor class present at runtime.
It relies on symbolic information present in bytecode and doesn't work when invocation goes through method handle linker (MethodHandle.linkToInterface()):
src/hotspot/share/opto/doCall.cpp:
if (call_does_dispatch && bytecode == Bytecodes::_invokeinterface) {
ciInstanceKlass* declared_interface =
caller->get_declared_method_holder_at_bci(bci)->as_instance_klass();
ciInstanceKlass* singleton = declared_interface->unique_implementor();
(Both C1 and C2 are affected.)
It relies on symbolic information present in bytecode and doesn't work when invocation goes through method handle linker (MethodHandle.linkToInterface()):
src/hotspot/share/opto/doCall.cpp:
if (call_does_dispatch && bytecode == Bytecodes::_invokeinterface) {
ciInstanceKlass* declared_interface =
caller->get_declared_method_holder_at_bci(bci)->as_instance_klass();
ciInstanceKlass* singleton = declared_interface->unique_implementor();
(Both C1 and C2 are affected.)
- relates to
-
JDK-8275830 C2: Receiver downcast is missing when inlining through method handle linkers
- Resolved
-
JDK-8297933 [REDO] Compiler should only use verified interface types for optimization
- Resolved
-
JDK-6312651 Compiler should only use verified interface types for optimization
- Closed
-
JDK-6986483 CHA: optimize calls through interfaces
- Resolved