summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimizing_compiler.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2023-12-17 19:34:50 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2023-12-19 13:33:14 +0000
commitb7223542c7ee3f667822fb0eff3020b8123601af (patch)
tree11049423af057e5054be8d90a455110f7e43fb64 /compiler/optimizing/optimizing_compiler.cc
parente828df143f5eefedfede026d8913b20725f528a0 (diff)
Reland "Move the construction of ProfilingInfo in the compiler."
This reverts commit 9fedb9f473fd77f31285203f5baa9533b8e21ce6. Reason for reland: - Use CodeGenerator::IsImplementedIntrinsic in IsInlineCacheUseful, to match inliner behavior. - Address some missing type propagation opportunities in aosp/2880687 - Be robust when there is a missing inline cache. Test: test.py Change-Id: Ib6e4a624174d6891a0fd425af88a9c16e09afa99
Diffstat (limited to 'compiler/optimizing/optimizing_compiler.cc')
-rw-r--r--compiler/optimizing/optimizing_compiler.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 0069a20a26..d458462226 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -53,6 +53,7 @@
#include "oat_quick_method_header.h"
#include "optimizing/write_barrier_elimination.h"
#include "prepare_for_register_allocation.h"
+#include "profiling_info_builder.h"
#include "reference_type_propagation.h"
#include "register_allocator_linear_scan.h"
#include "select_generator.h"
@@ -835,8 +836,6 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* allocator,
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr) {
ProfilingInfo* info = jit->GetCodeCache()->GetProfilingInfo(method, Thread::Current());
- DCHECK_IMPLIES(compilation_kind == CompilationKind::kBaseline, info != nullptr)
- << "Compiling a method baseline should always have a ProfilingInfo";
graph->SetProfilingInfo(info);
}
@@ -920,6 +919,21 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* allocator,
&pass_observer,
regalloc_strategy,
compilation_stats_.get());
+ // If we are compiling baseline and we haven't created a profiling info for
+ // this method already, do it now.
+ if (jit != nullptr &&
+ compilation_kind == CompilationKind::kBaseline &&
+ graph->GetProfilingInfo() == nullptr) {
+ ProfilingInfoBuilder(
+ graph, codegen->GetCompilerOptions(), codegen.get(), compilation_stats_.get()).Run();
+ // We expect a profiling info to be created and attached to the graph.
+ // However, we may have run out of memory trying to create it, so in this
+ // case just abort the compilation.
+ if (graph->GetProfilingInfo() == nullptr) {
+ MaybeRecordStat(compilation_stats_.get(), MethodCompilationStat::kJitOutOfMemoryForCommit);
+ return nullptr;
+ }
+ }
codegen->Compile();
pass_observer.DumpDisassembly();