From e86deeffad79c00ed2ebede04f4adc348bda790c Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 19 Mar 2015 13:43:37 -0700 Subject: Add verify-at-runtime compiler filter Verifies at runtime only, instead of at compilation time. AOSP HH boot time after clean-oat: ~30s instead of ~35s if enabled. Also helps install time if enabled there. TODO: See if there is any possible deadlocks that can result from this. Bug: 19762303 Change-Id: Ibfba77148da9039e8d7d7497c05486bc044eefe7 --- compiler/driver/compiler_driver.cc | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index ff4e0d850a..34963a9675 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -491,11 +491,12 @@ void CompilerDriver::CompileAll(jobject class_loader, } } -static DexToDexCompilationLevel GetDexToDexCompilationlevel( +DexToDexCompilationLevel CompilerDriver::GetDexToDexCompilationlevel( Thread* self, Handle class_loader, const DexFile& dex_file, - const DexFile::ClassDef& class_def) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + const DexFile::ClassDef& class_def) { auto* const runtime = Runtime::Current(); - if (runtime->UseJit()) { + if (runtime->UseJit() || GetCompilerOptions().VerifyAtRuntime()) { + // Verify at runtime shouldn't dex to dex since we didn't resolve of verify. return kDontDexToDexCompile; } const char* descriptor = dex_file.GetClassDescriptor(class_def); @@ -605,12 +606,22 @@ void CompilerDriver::PreCompile(jobject class_loader, const std::vectorIsVerificationEnabled(); + const bool never_verify = compiler_options_->NeverVerify(); - if (!compiler_options_->IsVerificationEnabled()) { + // We need to resolve for never_verify since it needs to run dex to dex to add the + // RETURN_VOID_NO_BARRIER. + if (never_verify || verification_enabled) { + Resolve(class_loader, dex_files, thread_pool, timings); + VLOG(compiler) << "Resolve: " << GetMemoryUsageString(false); + } + + if (never_verify) { VLOG(compiler) << "Verify none mode specified, skipping verification."; SetVerified(class_loader, dex_files, thread_pool, timings); + } + + if (!verification_enabled) { return; } @@ -2090,6 +2101,8 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz return; } + CompilerDriver* const driver = manager->GetCompiler(); + // Can we run DEX-to-DEX compiler on this class ? DexToDexCompilationLevel dex_to_dex_compilation_level = kDontDexToDexCompile; { @@ -2097,8 +2110,8 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz StackHandleScope<1> hs(soa.Self()); Handle class_loader( hs.NewHandle(soa.Decode(jclass_loader))); - dex_to_dex_compilation_level = GetDexToDexCompilationlevel(soa.Self(), class_loader, dex_file, - class_def); + dex_to_dex_compilation_level = driver->GetDexToDexCompilationlevel( + soa.Self(), class_loader, dex_file, class_def); } ClassDataItemIterator it(dex_file, class_data); // Skip fields @@ -2108,7 +2121,6 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz while (it.HasNextInstanceField()) { it.Next(); } - CompilerDriver* driver = manager->GetCompiler(); bool compilation_enabled = driver->IsClassToCompile( dex_file.StringByTypeIdx(class_def.class_idx_)); -- cgit v1.2.3-59-g8ed1b