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/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc
index c529410..e745c73 100644
--- a/compiler/optimizing/sharpening.cc
+++ b/compiler/optimizing/sharpening.cc
@@ -97,7 +97,9 @@
// class is initialized already or being initialized, and the call will not
// be invoked once the method is deoptimized.
- if (callee == codegen_->GetGraph()->GetArtMethod()) {
+ // We don't optimize for debuggable as it would prevent us from obsoleting the method in some
+ // situations.
+ if (callee == codegen_->GetGraph()->GetArtMethod() && !codegen_->GetGraph()->IsDebuggable()) {
// Recursive call.
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kRecursive;
code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallSelf;