ART: Do not access-check type on instanceof peephole
When attempting the instanceof+branch peephole, do not retrieve
the cast type with an access check to avoid a posted failure. That
failure does not happen, it belongs with the instanceof.
Bug: 121245951
Test: m test-art-host
Change-Id: I87e2228bff9f3374e7141e600f24554846ecac32
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 8d9176a..a1f9a2a 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -2699,8 +2699,11 @@
// type is assignable to the original then allow optimization. This check is performed to
// ensure that subsequent merges don't lose type information - such as becoming an
// interface from a class that would lose information relevant to field checks.
+ //
+ // Note: do not do an access check. This may mark this with a runtime throw that actually
+ // happens at the instanceof, not the branch (and branches aren't flagged to throw).
const RegType& orig_type = work_line_->GetRegisterType(this, instance_of_inst.VRegB_22c());
- const RegType& cast_type = ResolveClass<CheckAccess::kYes>(
+ const RegType& cast_type = ResolveClass<CheckAccess::kNo>(
dex::TypeIndex(instance_of_inst.VRegC_22c()));
if (!orig_type.Equals(cast_type) &&