diff options
| author | 2017-10-19 15:06:59 -0700 | |
|---|---|---|
| committer | 2017-10-19 18:01:03 -0700 | |
| commit | f39208f6787928151153795a3cdae28cba964df6 (patch) | |
| tree | 59ea0bc7ddf2b20ecf501e3ddca7d71ebb9df851 /compiler/driver/compiler_driver.cc | |
| parent | 5ef8128014b1796ae56dba3031f64ce6bfef4496 (diff) | |
ART: Add abort-on-soft-verifier-error
Add an option to abort compilation if any class fails compile-time
verification.
Bug: 65318848
Bug: 67358823
Test: m test-art-host-gtest-dex2oat_test
Change-Id: I5d2a7cd1d2ed048ab39d6f787ecc9eb2f41d3d77
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 7573367788..547ffbcf62 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -296,6 +296,7 @@ CompilerDriver::CompilerDriver( image_classes_(image_classes), classes_to_compile_(compiled_classes), methods_to_compile_(compiled_methods), + number_of_soft_verifier_failures_(0), had_hard_verifier_failure_(false), parallel_thread_count_(thread_count), stats_(new AOTCompilationStats), @@ -923,6 +924,12 @@ void CompilerDriver::PreCompile(jobject class_loader, LOG(FATAL_WITHOUT_ABORT) << "Had a hard failure verifying all classes, and was asked to abort " << "in such situations. Please check the log."; abort(); + } else if (number_of_soft_verifier_failures_ > 0 && + GetCompilerOptions().AbortOnSoftVerifierFailure()) { + LOG(FATAL_WITHOUT_ABORT) << "Had " << number_of_soft_verifier_failures_ << " soft failure(s) " + << "verifying all classes, and was asked to abort in such situations. " + << "Please check the log."; + abort(); } if (compiler_options_->IsAnyCompilationEnabled()) { @@ -2069,13 +2076,13 @@ class VerifyClassVisitor : public CompilationVisitor { LOG(ERROR) << "Verification failed on class " << PrettyDescriptor(descriptor) << " because: " << error_msg; manager_->GetCompiler()->SetHadHardVerifierFailure(); + } else if (failure_kind == verifier::FailureKind::kSoftFailure) { + manager_->GetCompiler()->AddSoftVerifierFailure(); } else { // Force a soft failure for the VerifierDeps. This is a sanity measure, as // the vdex file already records that the class hasn't been resolved. It avoids // trying to do future verification optimizations when processing the vdex file. - DCHECK(failure_kind == verifier::FailureKind::kSoftFailure || - failure_kind == verifier::FailureKind::kNoFailure) - << failure_kind; + DCHECK(failure_kind == verifier::FailureKind::kNoFailure) << failure_kind; failure_kind = verifier::FailureKind::kSoftFailure; } } else if (!SkipClass(jclass_loader, dex_file, klass.Get())) { @@ -2087,6 +2094,8 @@ class VerifyClassVisitor : public CompilationVisitor { CHECK(soa.Self()->IsExceptionPending()); soa.Self()->ClearException(); manager_->GetCompiler()->SetHadHardVerifierFailure(); + } else if (failure_kind == verifier::FailureKind::kSoftFailure) { + manager_->GetCompiler()->AddSoftVerifierFailure(); } CHECK(klass->ShouldVerifyAtRuntime() || klass->IsVerified() || klass->IsErroneous()) @@ -2152,7 +2161,9 @@ void CompilerDriver::VerifyDexFile(jobject class_loader, ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); ParallelCompilationManager context(class_linker, class_loader, this, &dex_file, dex_files, thread_pool); - verifier::HardFailLogMode log_level = GetCompilerOptions().AbortOnHardVerifierFailure() + bool abort_on_verifier_failures = GetCompilerOptions().AbortOnHardVerifierFailure() + || GetCompilerOptions().AbortOnSoftVerifierFailure(); + verifier::HardFailLogMode log_level = abort_on_verifier_failures ? verifier::HardFailLogMode::kLogInternalFatal : verifier::HardFailLogMode::kLogWarning; VerifyClassVisitor visitor(&context, log_level); |