diff options
author | 2021-11-29 14:47:21 +0000 | |
---|---|---|
committer | 2021-11-29 16:50:35 +0000 | |
commit | 8a608fab3f7479db4b21e7ad13b8f69c21658d32 (patch) | |
tree | cb0d7c4217fc253b0b0ccca99397cefa011ca197 | |
parent | c813dd285835a8edc7e71082f48ff76060804232 (diff) |
Handle baseline/optimized compilation kind in the runtime.
It used to be adjusted in the compiler, but that does not work anymore
as the compiler now always requests a baseline compilation to have a
profiling info.
Test: 457-regs
Bug: 146423102
Change-Id: I522bc515ef1c6f8737ada311265a6f8e0f4db3fd
-rw-r--r-- | compiler/jit/jit_compiler.cc | 4 | ||||
-rw-r--r-- | compiler/jit/jit_compiler.h | 2 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 5 | ||||
-rw-r--r-- | runtime/jit/jit.cc | 13 | ||||
-rw-r--r-- | runtime/jit/jit.h | 1 | ||||
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 3 |
6 files changed, 22 insertions, 6 deletions
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index f819cd8c97..44a4283ae1 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -208,5 +208,9 @@ bool JitCompiler::CompileMethod( return success; } +bool JitCompiler::IsBaselineCompiler() const { + return compiler_options_->IsBaseline(); +} + } // namespace jit } // namespace art diff --git a/compiler/jit/jit_compiler.h b/compiler/jit/jit_compiler.h index 9dd84f0e0a..8e9966db0e 100644 --- a/compiler/jit/jit_compiler.h +++ b/compiler/jit/jit_compiler.h @@ -48,6 +48,8 @@ class JitCompiler : public JitCompilerInterface { return *compiler_options_.get(); } + bool IsBaselineCompiler() const override; + bool GenerateDebugInfo() override; void ParseCompilerOptions() override; diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 10b59d2277..18e0512c6e 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -1213,11 +1213,6 @@ bool OptimizingCompiler::JitCompile(Thread* self, CompilationKind compilation_kind, jit::JitLogger* jit_logger) { const CompilerOptions& compiler_options = GetCompilerOptions(); - // If the baseline flag was explicitly passed, change the compilation kind - // from optimized to baseline. - if (compiler_options.IsBaseline() && compilation_kind == CompilationKind::kOptimized) { - compilation_kind = CompilationKind::kBaseline; - } DCHECK(compiler_options.IsJitCompiler()); DCHECK_EQ(compiler_options.IsJitCompilerForSharedCode(), code_cache->IsSharedRegion(*region)); StackHandleScope<3> hs(self); diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc index b964b7ca1d..9c5eff5282 100644 --- a/runtime/jit/jit.cc +++ b/runtime/jit/jit.cc @@ -273,6 +273,19 @@ bool Jit::CompileMethod(ArtMethod* method, DCHECK(Runtime::Current()->UseJitCompilation()); DCHECK(!method->IsRuntimeMethod()); + // If the baseline flag was explicitly passed in the compiler options, change the compilation kind + // from optimized to baseline. + if (jit_compiler_->IsBaselineCompiler() && compilation_kind == CompilationKind::kOptimized) { + compilation_kind = CompilationKind::kBaseline; + } + + // If we're asked to compile baseline, but we cannot allocate profiling infos, + // change the compilation kind to optimized. + if ((compilation_kind == CompilationKind::kBaseline) && + !GetCodeCache()->CanAllocateProfilingInfo()) { + compilation_kind = CompilationKind::kOptimized; + } + RuntimeCallbacks* cb = Runtime::Current()->GetRuntimeCallbacks(); // Don't compile the method if it has breakpoints. if (cb->IsMethodBeingInspected(method) && !cb->IsMethodSafeToJit(method)) { diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h index e6c93aac65..24dab6d66b 100644 --- a/runtime/jit/jit.h +++ b/runtime/jit/jit.h @@ -200,6 +200,7 @@ class JitCompilerInterface { REQUIRES_SHARED(Locks::mutator_lock_) = 0; virtual bool GenerateDebugInfo() = 0; virtual void ParseCompilerOptions() = 0; + virtual bool IsBaselineCompiler() const; virtual std::vector<uint8_t> PackElfFileForJIT(ArrayRef<const JITCodeEntry*> elf_files, ArrayRef<const void*> removed_symbols, diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 047f7a4cd4..8b91f9eee1 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -1670,7 +1670,8 @@ bool JitCodeCache::NotifyCompilationOf(ArtMethod* method, } return new_compilation; } else { - if (CanAllocateProfilingInfo() && (compilation_kind == CompilationKind::kBaseline)) { + if (compilation_kind == CompilationKind::kBaseline) { + DCHECK(CanAllocateProfilingInfo()); bool has_profiling_info = false; { MutexLock mu(self, *Locks::jit_lock_); |