8327250: assert(!method->is_old()) failed: Should not be installing old methods

Reviewed-by: eosterlund, sspitsyn
This commit is contained in:
Coleen Phillimore 2024-04-11 13:17:48 +00:00
parent ecc603ca9b
commit 63684cd183
3 changed files with 30 additions and 9 deletions

View File

@ -864,13 +864,12 @@ void InterpreterRuntime::resolve_invoke(JavaThread* current, Bytecodes::Code byt
return; return;
} }
if (JvmtiExport::can_hotswap_or_post_breakpoint() && info.resolved_method()->is_old()) { resolved_method = methodHandle(current, info.resolved_method());
resolved_method = methodHandle(current, info.resolved_method()->get_new_method());
} else {
resolved_method = methodHandle(current, info.resolved_method());
}
} // end JvmtiHideSingleStepping } // end JvmtiHideSingleStepping
// Don't allow safepoints until the method is cached.
NoSafepointVerifier nsv;
// check if link resolution caused cpCache to be updated // check if link resolution caused cpCache to be updated
if (cache->resolved_method_entry_at(method_index)->is_resolved(bytecode)) return; if (cache->resolved_method_entry_at(method_index)->is_resolved(bytecode)) return;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,6 +50,7 @@
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "oops/resolvedIndyEntry.hpp" #include "oops/resolvedIndyEntry.hpp"
#include "oops/symbolHandle.hpp" #include "oops/symbolHandle.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp" #include "prims/methodHandles.hpp"
#include "runtime/fieldDescriptor.inline.hpp" #include "runtime/fieldDescriptor.inline.hpp"
#include "runtime/frame.inline.hpp" #include "runtime/frame.inline.hpp"
@ -112,6 +113,27 @@ void CallInfo::set_handle(Klass* resolved_klass,
_resolved_appendix = resolved_appendix; _resolved_appendix = resolved_appendix;
} }
// Redefinition safepoint may have updated the method. Make sure the new version of the method is returned.
// Callers are responsible for not safepointing and storing this method somewhere safe where redefinition
// can replace it if runs again. Safe places are constant pool cache and code cache metadata.
// The old method is safe in CallInfo since its a methodHandle (it won't get deleted), and accessed with these
// accessors.
Method* CallInfo::resolved_method() const {
if (JvmtiExport::can_hotswap_or_post_breakpoint() && _resolved_method->is_old()) {
return _resolved_method->get_new_method();
} else {
return _resolved_method();
}
}
Method* CallInfo::selected_method() const {
if (JvmtiExport::can_hotswap_or_post_breakpoint() && _selected_method->is_old()) {
return _selected_method->get_new_method();
} else {
return _selected_method();
}
}
void CallInfo::set_common(Klass* resolved_klass, void CallInfo::set_common(Klass* resolved_klass,
const methodHandle& resolved_method, const methodHandle& resolved_method,
const methodHandle& selected_method, const methodHandle& selected_method,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -92,8 +92,8 @@ class CallInfo : public StackObj {
CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS); CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS);
Klass* resolved_klass() const { return _resolved_klass; } Klass* resolved_klass() const { return _resolved_klass; }
Method* resolved_method() const { return _resolved_method(); } Method* resolved_method() const;
Method* selected_method() const { return _selected_method(); } Method* selected_method() const;
Handle resolved_appendix() const { return _resolved_appendix; } Handle resolved_appendix() const { return _resolved_appendix; }
Handle resolved_method_name() const { return _resolved_method_name; } Handle resolved_method_name() const { return _resolved_method_name; }
// Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method // Materialize a java.lang.invoke.ResolvedMethodName for this resolved_method