From 0c3c2668ef44fdbd18d97f9134a85d1a7d561aa4 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Thu, 15 Oct 2015 13:53:04 +0100 Subject: Use DlMallocSpace for the JIT code cache. - Also tidy up some code in the JIT compiler. - And mprotect code space to be writable only when allocating. Change-Id: I46ea5c029aec489f2af63452de31db3736aebc20 --- compiler/optimizing/optimizing_compiler.cc | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index c7f08066d4..51fdd81ba8 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -839,18 +839,26 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, Handle dex_cache) const { CompilerDriver* compiler_driver = GetCompilerDriver(); CompiledMethod* method = nullptr; - const VerifiedMethod* verified_method = compiler_driver->GetVerifiedMethod(&dex_file, method_idx); - DCHECK(!verified_method->HasRuntimeThrow()); - if (compiler_driver->IsMethodVerifiedWithoutFailures(method_idx, class_def_idx, dex_file) - || CanHandleVerificationFailure(verified_method)) { - method = TryCompile(code_item, access_flags, invoke_type, class_def_idx, - method_idx, jclass_loader, dex_file, dex_cache); - } else { - if (compiler_driver->GetCompilerOptions().VerifyAtRuntime()) { - MaybeRecordStat(MethodCompilationStat::kNotCompiledVerifyAtRuntime); + if (Runtime::Current()->IsAotCompiler()) { + const VerifiedMethod* verified_method = compiler_driver->GetVerifiedMethod(&dex_file, method_idx); + DCHECK(!verified_method->HasRuntimeThrow()); + if (compiler_driver->IsMethodVerifiedWithoutFailures(method_idx, class_def_idx, dex_file) + || CanHandleVerificationFailure(verified_method)) { + method = TryCompile(code_item, access_flags, invoke_type, class_def_idx, + method_idx, jclass_loader, dex_file, dex_cache); } else { - MaybeRecordStat(MethodCompilationStat::kNotCompiledClassNotVerified); + if (compiler_driver->GetCompilerOptions().VerifyAtRuntime()) { + MaybeRecordStat(MethodCompilationStat::kNotCompiledVerifyAtRuntime); + } else { + MaybeRecordStat(MethodCompilationStat::kNotCompiledClassNotVerified); + } } + } else { + // This is for the JIT compiler, which has already ensured the class is verified. + // We can go straight to compiling. + DCHECK(Runtime::Current()->UseJit()); + method = TryCompile(code_item, access_flags, invoke_type, class_def_idx, + method_idx, jclass_loader, dex_file, dex_cache); } if (kIsDebugBuild && -- cgit v1.2.3-59-g8ed1b