Skip to content

Commit 7051296

Browse files
committed
8257993: vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine/TestDescription.java crash intermittently
Reviewed-by: mdoerr Backport-of: 0a3e446
1 parent 6747c78 commit 7051296

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/hotspot/share/interpreter/interpreterRuntime.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -854,24 +854,17 @@ void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code byte
854854
CallInfo info;
855855
constantPoolHandle pool(thread, last_frame.method()->constants());
856856

857+
methodHandle resolved_method;
858+
857859
{
858860
JvmtiHideSingleStepping jhss(thread);
859861
LinkResolver::resolve_invoke(info, receiver, pool,
860862
last_frame.get_index_u2_cpcache(bytecode), bytecode,
861863
CHECK);
862-
if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
863-
int retry_count = 0;
864-
while (info.resolved_method()->is_old()) {
865-
// It is very unlikely that method is redefined more than 100 times
866-
// in the middle of resolve. If it is looping here more than 100 times
867-
// means then there could be a bug here.
868-
guarantee((retry_count++ < 100),
869-
"Could not resolve to latest version of redefined method");
870-
// method is redefined in the middle of resolve so re-try.
871-
LinkResolver::resolve_invoke(info, receiver, pool,
872-
last_frame.get_index_u2_cpcache(bytecode), bytecode,
873-
CHECK);
874-
}
864+
if (JvmtiExport::can_hotswap_or_post_breakpoint() && info.resolved_method()->is_old()) {
865+
resolved_method = methodHandle(thread, info.resolved_method()->get_new_method());
866+
} else {
867+
resolved_method = info.resolved_method();
875868
}
876869
} // end JvmtiHideSingleStepping
877870

@@ -881,22 +874,20 @@ void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code byte
881874

882875
#ifdef ASSERT
883876
if (bytecode == Bytecodes::_invokeinterface) {
884-
if (info.resolved_method()->method_holder() ==
885-
SystemDictionary::Object_klass()) {
877+
if (resolved_method->method_holder() == SystemDictionary::Object_klass()) {
886878
// NOTE: THIS IS A FIX FOR A CORNER CASE in the JVM spec
887879
// (see also CallInfo::set_interface for details)
888880
assert(info.call_kind() == CallInfo::vtable_call ||
889881
info.call_kind() == CallInfo::direct_call, "");
890-
methodHandle rm = info.resolved_method();
891-
assert(rm->is_final() || info.has_vtable_index(),
882+
assert(resolved_method->is_final() || info.has_vtable_index(),
892883
"should have been set already");
893-
} else if (!info.resolved_method()->has_itable_index()) {
884+
} else if (!resolved_method->has_itable_index()) {
894885
// Resolved something like CharSequence.toString. Use vtable not itable.
895886
assert(info.call_kind() != CallInfo::itable_call, "");
896887
} else {
897888
// Setup itable entry
898889
assert(info.call_kind() == CallInfo::itable_call, "");
899-
int index = info.resolved_method()->itable_index();
890+
int index = resolved_method->itable_index();
900891
assert(info.itable_index() == index, "");
901892
}
902893
} else if (bytecode == Bytecodes::_invokespecial) {
@@ -916,20 +907,20 @@ void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code byte
916907
case CallInfo::direct_call:
917908
cp_cache_entry->set_direct_call(
918909
bytecode,
919-
info.resolved_method(),
910+
resolved_method,
920911
sender->is_interface());
921912
break;
922913
case CallInfo::vtable_call:
923914
cp_cache_entry->set_vtable_call(
924915
bytecode,
925-
info.resolved_method(),
916+
resolved_method,
926917
info.vtable_index());
927918
break;
928919
case CallInfo::itable_call:
929920
cp_cache_entry->set_itable_call(
930921
bytecode,
931922
info.resolved_klass(),
932-
info.resolved_method(),
923+
resolved_method,
933924
info.itable_index());
934925
break;
935926
default: ShouldNotReachHere();

src/hotspot/share/oops/method.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,15 @@ class Method : public Metadata {
984984
// Deallocation function for redefine classes or if an error occurs
985985
void deallocate_contents(ClassLoaderData* loader_data);
986986

987+
Method* get_new_method() const {
988+
InstanceKlass* holder = method_holder();
989+
Method* new_method = holder->method_with_idnum(orig_method_idnum());
990+
991+
assert(new_method != NULL, "method_with_idnum() should not be null");
992+
assert(this != new_method, "sanity check");
993+
return new_method;
994+
}
995+
987996
// Printing
988997
#ifndef PRODUCT
989998
void print_on(outputStream* st) const;

0 commit comments

Comments
 (0)