Fallback to quick in case of soft verification errors
Add a regression test: using uninitialized values triggers a soft
verification error and optimizing should not crash.
Thanks to Stephen Kyle (stephenckyle@googlemail.com) for the bug report.
Bug: 19988704
Change-Id: I67174538eed853baff735694b3ae8eb34afe2a39
diff --git a/compiler/dex/verified_method.cc b/compiler/dex/verified_method.cc
index ae814b4..977757f 100644
--- a/compiler/dex/verified_method.cc
+++ b/compiler/dex/verified_method.cc
@@ -40,6 +40,7 @@
const VerifiedMethod* VerifiedMethod::Create(verifier::MethodVerifier* method_verifier,
bool compile) {
std::unique_ptr<VerifiedMethod> verified_method(new VerifiedMethod);
+ verified_method->has_verification_failures_ = method_verifier->HasFailures();
if (compile) {
/* Generate a register map. */
if (!verified_method->GenerateGcMap(method_verifier)) {
diff --git a/compiler/dex/verified_method.h b/compiler/dex/verified_method.h
index 954cbf4..437ae52 100644
--- a/compiler/dex/verified_method.h
+++ b/compiler/dex/verified_method.h
@@ -70,6 +70,11 @@
// by using the check-cast elision peephole optimization in the verifier.
bool IsSafeCast(uint32_t pc) const;
+ // Returns true if there were any errors during verification.
+ bool HasVerificationFailures() const {
+ return has_verification_failures_;
+ }
+
private:
VerifiedMethod() = default;
@@ -107,6 +112,8 @@
// dex PC to dex method index or dex field index based on the instruction.
DequickenMap dequicken_map_;
SafeCastSet safe_cast_set_;
+
+ bool has_verification_failures_;
};
} // namespace art