Fix creating self-recursive obsolete methods.
We were using recursive loading of the current art method which was
making us miss obsolete methods in some cases.
We could also end up checking the wrong method when walking the stack.
We also add tests for recursive obsolete methods in general.
Bug: 34815470
Test: mma -j40 test-art-host
Test: ART_TEST_JIT=true mma -j40 test-art-host
Change-Id: I522fd4cac4e3f9d35d03b128bad6d6971cfe6c4a
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 45611a9..f5151b5 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -1141,8 +1141,17 @@
return nullptr;
}
if (kIsDebugBuild && method != nullptr) {
- DCHECK_EQ(it->second, method)
- << ArtMethod::PrettyMethod(method) << " " << ArtMethod::PrettyMethod(it->second) << " "
+ // When we are walking the stack to redefine classes and creating obsolete methods it is
+ // possible that we might have updated the method_code_map by making this method obsolete in a
+ // previous frame. Therefore we should just check that the non-obsolete version of this method
+ // is the one we expect. We change to the non-obsolete versions in the error message since the
+ // obsolete version of the method might not be fully initialized yet. This situation can only
+ // occur when we are in the process of allocating and setting up obsolete methods. Otherwise
+ // method and it->second should be identical. (See runtime/openjdkjvmti/ti_redefine.cc for more
+ // information.)
+ DCHECK_EQ(it->second->GetNonObsoleteMethod(), method->GetNonObsoleteMethod())
+ << ArtMethod::PrettyMethod(method->GetNonObsoleteMethod()) << " "
+ << ArtMethod::PrettyMethod(it->second->GetNonObsoleteMethod()) << " "
<< std::hex << pc;
}
return method_header;
diff --git a/runtime/stack.cc b/runtime/stack.cc
index f9efc0b..5ad00a4 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -625,7 +625,7 @@
} else {
DCHECK(cur_quick_frame_ != nullptr);
CHECK(!IsInInlinedFrame()) << "We do not support setting inlined method's ArtMethod!";
- *cur_quick_frame_ = method;
+ *cur_quick_frame_ = method;
}
}