8227236: assert(singleton != __null && singleton != declared_interface) failed

Reviewed-by: dlong
This commit is contained in:
Vladimir Ivanov 2019-09-03 17:45:02 +03:00
parent fd89fedccf
commit 4dc79c2e05
3 changed files with 14 additions and 7 deletions

View File

@ -1957,12 +1957,11 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
// 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()) {

View File

@ -248,6 +248,12 @@ public:
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;

View File

@ -310,10 +310,12 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool
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);