OpenJDK / jdk / jdk
changeset 56162:bf3fb5465543
8227236: assert(singleton != __null && singleton != declared_interface) failed
Reviewed-by: dlong
author | vlivanov |
---|---|
date | Tue, 03 Sep 2019 17:45:02 +0300 |
parents | d8f22418ca99 |
children | 849acc346a1d |
files | src/hotspot/share/c1/c1_GraphBuilder.cpp src/hotspot/share/ci/ciInstanceKlass.hpp src/hotspot/share/opto/doCall.cpp |
diffstat | 3 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hotspot/share/c1/c1_GraphBuilder.cpp Tue Sep 03 13:55:41 2019 -0400 +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp Tue Sep 03 17:45:02 2019 +0300 @@ -1957,12 +1957,11 @@ // number of implementors for decl_interface is 0 or 1. If // it's 0 then no class implements decl_interface and there's // no point in inlining. - ciInstanceKlass* singleton = NULL; ciInstanceKlass* declared_interface = callee_holder; - if (declared_interface->nof_implementors() == 1 && - (!target->is_default_method() || target->is_overpass()) /* CHA doesn't support default methods yet. */) { - singleton = declared_interface->implementor(); - assert(singleton != NULL && singleton != declared_interface, ""); + ciInstanceKlass* singleton = declared_interface->unique_implementor(); + if (singleton != NULL && + (!target->is_default_method() || target->is_overpass()) /* CHA doesn't support default methods yet. */ ) { + assert(singleton != declared_interface, "not a unique implementor"); cha_monomorphic_target = target->find_monomorphic_target(calling_klass, declared_interface, singleton); if (cha_monomorphic_target != NULL) { if (cha_monomorphic_target->holder() != compilation()->env()->Object_klass()) {
--- a/src/hotspot/share/ci/ciInstanceKlass.hpp Tue Sep 03 13:55:41 2019 -0400 +++ b/src/hotspot/share/ci/ciInstanceKlass.hpp Tue Sep 03 17:45:02 2019 +0300 @@ -248,6 +248,12 @@ bool is_leaf_type(); ciInstanceKlass* implementor(); + ciInstanceKlass* unique_implementor() { + assert(is_loaded(), "must be loaded"); + ciInstanceKlass* impl = implementor(); + return (impl != this ? impl : NULL); + } + // Is the defining class loader of this class the default loader? bool uses_default_loader() const;
--- a/src/hotspot/share/opto/doCall.cpp Tue Sep 03 13:55:41 2019 -0400 +++ b/src/hotspot/share/opto/doCall.cpp Tue Sep 03 17:45:02 2019 +0300 @@ -310,10 +310,12 @@ 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(); - if (declared_interface->nof_implementors() == 1 && + if (singleton != NULL && (!callee->is_default_method() || callee->is_overpass()) /* CHA doesn't support default methods yet */) { - ciInstanceKlass* singleton = declared_interface->implementor(); + assert(singleton != declared_interface, "not a unique implementor"); + ciMethod* cha_monomorphic_target = callee->find_monomorphic_target(caller->holder(), declared_interface, singleton);