Skip to content

Commit

Permalink
8227236: assert(singleton != __null && singleton != declared_interfac…
Browse files Browse the repository at this point in the history
…e) failed

Reviewed-by: dlong
  • Loading branch information
Vladimir Ivanov committed Sep 3, 2019
1 parent fd89fed commit 4dc79c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/hotspot/share/c1/c1_GraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/ci/ciInstanceKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ class ciInstanceKlass : public ciKlass {
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;

Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/opto/doCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4dc79c2

Please sign in to comment.