8338471: Assert deleted methods not returned by CallInfo

Reviewed-by: shade, jwaters, dholmes
This commit is contained in:
Coleen Phillimore 2024-09-20 18:38:29 +00:00
parent 40fba14812
commit 5cffddc689
4 changed files with 10 additions and 7 deletions

View File

@ -83,6 +83,7 @@ void CompiledICData::initialize(CallInfo* call_info, Klass* receiver_klass) {
_speculated_klass = (uintptr_t)receiver_klass;
}
if (call_info->call_kind() == CallInfo::itable_call) {
assert(call_info->resolved_method() != nullptr, "virtual or interface method must be found");
_itable_defc_klass = call_info->resolved_method()->method_holder();
_itable_refc_klass = call_info->resolved_klass();
}
@ -238,6 +239,7 @@ void CompiledIC::set_to_megamorphic(CallInfo* call_info) {
return;
}
#ifdef ASSERT
assert(call_info->resolved_method() != nullptr, "virtual or interface method must be found");
int index = call_info->resolved_method()->itable_index();
assert(index == itable_index, "CallInfo pre-computes this");
InstanceKlass* k = call_info->resolved_method()->method_holder();
@ -254,6 +256,7 @@ void CompiledIC::set_to_megamorphic(CallInfo* call_info) {
}
}
assert(call_info->selected_method() != nullptr, "virtual or interface method must be found");
log_trace(inlinecache)("IC@" INTPTR_FORMAT ": to megamorphic %s entry: " INTPTR_FORMAT,
p2i(_call->instruction_address()), call_info->selected_method()->print_value_string(), p2i(entry));

View File

@ -87,7 +87,7 @@ void CallInfo::set_interface(Klass* resolved_klass,
// we should pick the vtable index from the resolved method.
// In that case, the caller must call set_virtual instead of set_interface.
assert(resolved_method->method_holder()->is_interface(), "");
assert(itable_index == resolved_method()->itable_index(), "");
assert(itable_index == resolved_method->itable_index(), "");
set_common(resolved_klass, resolved_method, selected_method, CallInfo::itable_call, itable_index, CHECK);
}
@ -1541,7 +1541,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
}
// resolve the method in the receiver class, unless it is private
if (!is_abstract_interpretation && !resolved_method()->is_private()) {
if (!is_abstract_interpretation && !resolved_method->is_private()) {
// do lookup based on receiver klass
// This search must match the linktime preparation search for itable initialization
// to correctly enforce loader constraints for interface method inheritance.
@ -1590,17 +1590,17 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result,
assert(is_abstract_interpretation || vtable_index == selected_method->vtable_index(), "sanity check");
result.set_virtual(resolved_klass, resolved_method, selected_method, vtable_index, CHECK);
} else if (resolved_method->has_itable_index()) {
int itable_index = resolved_method()->itable_index();
int itable_index = resolved_method->itable_index();
log_develop_trace(itables)(" -- itable index: %d", itable_index);
result.set_interface(resolved_klass, resolved_method, selected_method, itable_index, CHECK);
} else {
int index = resolved_method->vtable_index();
log_develop_trace(itables)(" -- non itable/vtable index: %d", index);
assert(index == Method::nonvirtual_vtable_index, "Oops hit another case!");
assert(resolved_method()->is_private() ||
(resolved_method()->is_final() && resolved_method->method_holder() == vmClasses::Object_klass()),
assert(resolved_method->is_private() ||
(resolved_method->is_final() && resolved_method->method_holder() == vmClasses::Object_klass()),
"Should only have non-virtual invokeinterface for private or final-Object methods!");
assert(resolved_method()->can_be_statically_bound(), "Should only have non-virtual invokeinterface for statically bound methods!");
assert(resolved_method->can_be_statically_bound(), "Should only have non-virtual invokeinterface for statically bound methods!");
// This sets up the nonvirtual form of "virtual" call (as needed for final and private methods)
result.set_virtual(resolved_klass, resolved_method, resolved_method, index, CHECK);
}

View File

@ -99,7 +99,6 @@ class CallInfo : public StackObj {
// Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method
void set_resolved_method_name(TRAPS);
BasicType result_type() const { return selected_method()->result_type(); }
CallKind call_kind() const { return _call_kind; }
int vtable_index() const {
// Even for interface calls the vtable index could be non-negative.

View File

@ -604,6 +604,7 @@ void ConstantPoolCache::adjust_method_entries(bool * trace_name_printed) {
if (old_method == nullptr || !old_method->is_old()) {
continue;
}
assert(!old_method->is_deleted(), "cannot delete these methods");
Method* new_method = old_method->get_new_method();
resolved_indy_entry_at(j)->adjust_method_entry(new_method);
log_adjust("indy", old_method, new_method, trace_name_printed);