diff --git a/src/hotspot/share/c1/c1_GraphBuilder.cpp b/src/hotspot/share/c1/c1_GraphBuilder.cpp index 02be6f8d49e..0179923bc30 100644 --- a/src/hotspot/share/c1/c1_GraphBuilder.cpp +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp @@ -2121,7 +2121,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { } if (cha_monomorphic_target != nullptr) { - assert(!target->can_be_statically_bound() || target->equals(cha_monomorphic_target), ""); + assert(!target->can_be_statically_bound() || target == cha_monomorphic_target, ""); assert(!cha_monomorphic_target->is_abstract(), ""); if (!cha_monomorphic_target->can_be_statically_bound(actual_recv)) { // If we inlined because CHA revealed only a single target method, diff --git a/src/hotspot/share/ci/ciMethod.cpp b/src/hotspot/share/ci/ciMethod.cpp index a74a812c6a2..80277b91d22 100644 --- a/src/hotspot/share/ci/ciMethod.cpp +++ b/src/hotspot/share/ci/ciMethod.cpp @@ -742,6 +742,13 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, if (target() == nullptr) { return nullptr; } + + // Redefinition support. + if (this->is_old() || root_m->is_old() || target->is_old()) { + guarantee(CURRENT_THREAD_ENV->jvmti_state_changed(), "old method not detected"); + return nullptr; + } + if (target() == root_m->get_Method()) { return root_m; } @@ -781,22 +788,6 @@ bool ciMethod::can_omit_stack_trace() const { return _can_omit_stack_trace; } -// ------------------------------------------------------------------ -// ciMethod::equals -// -// Returns true if the methods are the same, taking redefined methods -// into account. -bool ciMethod::equals(const ciMethod* m) const { - if (this == m) return true; - VM_ENTRY_MARK; - Method* m1 = this->get_Method(); - Method* m2 = m->get_Method(); - if (m1->is_old()) m1 = m1->get_new_method(); - if (m2->is_old()) m2 = m2->get_new_method(); - return m1 == m2; -} - - // ------------------------------------------------------------------ // ciMethod::resolve_invoke // @@ -835,6 +826,12 @@ ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, boo ciMethod* result = this; if (m != get_Method()) { + // Redefinition support. + if (this->is_old() || m->is_old()) { + guarantee(CURRENT_THREAD_ENV->jvmti_state_changed(), "old method not detected"); + return nullptr; + } + result = CURRENT_THREAD_ENV->get_method(m); } @@ -1495,3 +1492,10 @@ bool ciMethod::is_consistent_info(ciMethod* declared_method, ciMethod* resolved_ } // ------------------------------------------------------------------ +// ciMethod::is_old +// +// Return true for redefined methods +bool ciMethod::is_old() const { + ASSERT_IN_VM; + return get_Method()->is_old(); +} diff --git a/src/hotspot/share/ci/ciMethod.hpp b/src/hotspot/share/ci/ciMethod.hpp index cc524930192..eecd9427585 100644 --- a/src/hotspot/share/ci/ciMethod.hpp +++ b/src/hotspot/share/ci/ciMethod.hpp @@ -360,13 +360,12 @@ class ciMethod : public ciMetadata { bool is_vector_method() const; bool is_object_initializer() const; bool is_scoped() const; + bool is_old() const; bool can_be_statically_bound(ciInstanceKlass* context) const; bool can_omit_stack_trace() const; - bool equals(const ciMethod* m) const; - // Replay data methods static void dump_name_as_ascii(outputStream* st, Method* method); void dump_name_as_ascii(outputStream* st);