blob: 94751f876c804dcb556ab6c62436e0281fb46dab [file] [log] [blame]
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +00001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Andreas Gampe53c913b2014-08-12 23:19:23 -070017#include "optimizing_compiler.h"
18
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010019#include <fstream>
Nicolas Geoffray787c3072014-03-17 10:20:19 +000020#include <stdint.h>
21
Mingyao Yangf384f882014-10-22 16:08:18 -070022#include "bounds_check_elimination.h"
Nicolas Geoffray787c3072014-03-17 10:20:19 +000023#include "builder.h"
24#include "code_generator.h"
Andreas Gampe53c913b2014-08-12 23:19:23 -070025#include "compiler.h"
Roland Levillain75be2832014-10-17 17:02:00 +010026#include "constant_folding.h"
27#include "dead_code_elimination.h"
Nicolas Geoffray787c3072014-03-17 10:20:19 +000028#include "driver/compiler_driver.h"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +000029#include "driver/dex_compilation_unit.h"
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +000030#include "elf_writer_quick.h"
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010031#include "graph_visualizer.h"
Nicolas Geoffrayd31cf3d2014-09-08 17:30:24 +010032#include "gvn.h"
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000033#include "inliner.h"
Nicolas Geoffray3c049742014-09-24 18:10:46 +010034#include "instruction_simplifier.h"
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +000035#include "jni/quick/jni_compiler.h"
36#include "mirror/art_method-inl.h"
Nicolas Geoffray787c3072014-03-17 10:20:19 +000037#include "nodes.h"
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010038#include "prepare_for_register_allocation.h"
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010039#include "register_allocator.h"
Nicolas Geoffray31596742014-11-24 15:28:45 +000040#include "ssa_builder.h"
Nicolas Geoffray7dc206a2014-07-11 09:49:49 +010041#include "ssa_phi_elimination.h"
Nicolas Geoffray804d0932014-05-02 08:46:00 +010042#include "ssa_liveness_analysis.h"
Nicolas Geoffray787c3072014-03-17 10:20:19 +000043#include "utils/arena_allocator.h"
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000044
45namespace art {
46
Nicolas Geoffray787c3072014-03-17 10:20:19 +000047/**
48 * Used by the code generator, to allocate the code in a vector.
49 */
50class CodeVectorAllocator FINAL : public CodeAllocator {
51 public:
Nicolas Geoffray88157ef2014-09-12 10:29:53 +010052 CodeVectorAllocator() {}
Nicolas Geoffray787c3072014-03-17 10:20:19 +000053
54 virtual uint8_t* Allocate(size_t size) {
55 size_ = size;
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +000056 memory_.resize(size);
Nicolas Geoffray787c3072014-03-17 10:20:19 +000057 return &memory_[0];
58 }
59
60 size_t GetSize() const { return size_; }
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +000061 const std::vector<uint8_t>& GetMemory() const { return memory_; }
Nicolas Geoffray787c3072014-03-17 10:20:19 +000062
63 private:
64 std::vector<uint8_t> memory_;
65 size_t size_;
66
67 DISALLOW_COPY_AND_ASSIGN(CodeVectorAllocator);
68};
69
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010070/**
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010071 * Filter to apply to the visualizer. Methods whose name contain that filter will
David Brazdilee690a32014-12-01 17:04:16 +000072 * be dumped.
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010073 */
74static const char* kStringFilter = "";
75
Andreas Gampe53c913b2014-08-12 23:19:23 -070076class OptimizingCompiler FINAL : public Compiler {
77 public:
78 explicit OptimizingCompiler(CompilerDriver* driver);
Nicolas Geoffray88157ef2014-09-12 10:29:53 +010079 ~OptimizingCompiler();
Andreas Gampe53c913b2014-08-12 23:19:23 -070080
81 bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const
82 OVERRIDE;
83
84 CompiledMethod* Compile(const DexFile::CodeItem* code_item,
85 uint32_t access_flags,
86 InvokeType invoke_type,
87 uint16_t class_def_idx,
88 uint32_t method_idx,
89 jobject class_loader,
90 const DexFile& dex_file) const OVERRIDE;
91
Andreas Gampe53c913b2014-08-12 23:19:23 -070092 CompiledMethod* JniCompile(uint32_t access_flags,
93 uint32_t method_idx,
94 const DexFile& dex_file) const OVERRIDE;
95
96 uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE
97 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
98
99 bool WriteElf(art::File* file,
100 OatWriter* oat_writer,
101 const std::vector<const art::DexFile*>& dex_files,
102 const std::string& android_root,
103 bool is_host) const OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
104
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +0000105 Backend* GetCodeGenerator(CompilationUnit* cu ATTRIBUTE_UNUSED,
106 void* compilation_unit ATTRIBUTE_UNUSED) const OVERRIDE {
107 return nullptr;
108 }
Andreas Gampe53c913b2014-08-12 23:19:23 -0700109
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +0000110 void InitCompilationUnit(CompilationUnit& cu ATTRIBUTE_UNUSED) const OVERRIDE {}
Andreas Gampe53c913b2014-08-12 23:19:23 -0700111
David Brazdilee690a32014-12-01 17:04:16 +0000112 void Init() OVERRIDE;
Andreas Gampe53c913b2014-08-12 23:19:23 -0700113
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +0000114 void UnInit() const OVERRIDE {}
Andreas Gampe53c913b2014-08-12 23:19:23 -0700115
116 private:
Nicolas Geoffray88157ef2014-09-12 10:29:53 +0100117 // Whether we should run any optimization or register allocation. If false, will
118 // just run the code generation after the graph was built.
119 const bool run_optimizations_;
Calin Juravle48c2b032014-12-09 18:11:36 +0000120
121 mutable OptimizingCompilerStats compilation_stats_;
Nicolas Geoffray88157ef2014-09-12 10:29:53 +0100122
Andreas Gampe53c913b2014-08-12 23:19:23 -0700123 std::unique_ptr<std::ostream> visualizer_output_;
124
Andreas Gampe53c913b2014-08-12 23:19:23 -0700125 DISALLOW_COPY_AND_ASSIGN(OptimizingCompiler);
126};
127
Nicolas Geoffray88157ef2014-09-12 10:29:53 +0100128static const int kMaximumCompilationTimeBeforeWarning = 100; /* ms */
129
130OptimizingCompiler::OptimizingCompiler(CompilerDriver* driver)
131 : Compiler(driver, kMaximumCompilationTimeBeforeWarning),
132 run_optimizations_(
133 driver->GetCompilerOptions().GetCompilerFilter() != CompilerOptions::kTime),
David Brazdilee690a32014-12-01 17:04:16 +0000134 compilation_stats_() {}
135
136void OptimizingCompiler::Init() {
137 // Enable C1visualizer output. Must be done in Init() because the compiler
138 // driver is not fully initialized when passed to the compiler's constructor.
139 CompilerDriver* driver = GetCompilerDriver();
140 if (driver->GetDumpPasses()) {
141 CHECK_EQ(driver->GetThreadCount(), 1U)
142 << "Graph visualizer requires the compiler to run single-threaded. "
143 << "Invoke the compiler with '-j1'.";
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100144 visualizer_output_.reset(new std::ofstream("art.cfg"));
145 }
146}
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000147
Nicolas Geoffray88157ef2014-09-12 10:29:53 +0100148OptimizingCompiler::~OptimizingCompiler() {
Calin Juravle48c2b032014-12-09 18:11:36 +0000149 compilation_stats_.Log();
Nicolas Geoffray88157ef2014-09-12 10:29:53 +0100150}
151
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +0000152bool OptimizingCompiler::CanCompileMethod(uint32_t method_idx ATTRIBUTE_UNUSED,
153 const DexFile& dex_file ATTRIBUTE_UNUSED,
154 CompilationUnit* cu ATTRIBUTE_UNUSED) const {
155 return true;
Andreas Gampe53c913b2014-08-12 23:19:23 -0700156}
157
158CompiledMethod* OptimizingCompiler::JniCompile(uint32_t access_flags,
159 uint32_t method_idx,
160 const DexFile& dex_file) const {
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +0000161 return ArtQuickJniCompileMethod(GetCompilerDriver(), access_flags, method_idx, dex_file);
Andreas Gampe53c913b2014-08-12 23:19:23 -0700162}
163
164uintptr_t OptimizingCompiler::GetEntryPointOf(mirror::ArtMethod* method) const {
Nicolas Geoffray4179cc12014-11-19 08:35:17 +0000165 return reinterpret_cast<uintptr_t>(method->GetEntryPointFromQuickCompiledCodePtrSize(
166 InstructionSetPointerSize(GetCompilerDriver()->GetInstructionSet())));
Andreas Gampe53c913b2014-08-12 23:19:23 -0700167}
168
169bool OptimizingCompiler::WriteElf(art::File* file, OatWriter* oat_writer,
170 const std::vector<const art::DexFile*>& dex_files,
171 const std::string& android_root, bool is_host) const {
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +0000172 return art::ElfWriterQuick32::Create(file, oat_writer, dex_files, android_root, is_host,
173 *GetCompilerDriver());
Andreas Gampe53c913b2014-08-12 23:19:23 -0700174}
175
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000176static bool IsInstructionSetSupported(InstructionSet instruction_set) {
177 return instruction_set == kArm64
178 || (instruction_set == kThumb2 && !kArm32QuickCodeUseSoftFloat)
179 || instruction_set == kX86
180 || instruction_set == kX86_64;
181}
182
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000183static bool CanOptimize(const DexFile::CodeItem& code_item) {
184 // TODO: We currently cannot optimize methods with try/catch.
185 return code_item.tries_size_ == 0;
186}
187
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000188static void RunOptimizations(HGraph* graph,
189 CompilerDriver* driver,
190 OptimizingCompilerStats* stats,
191 const DexCompilationUnit& dex_compilation_unit,
192 const HGraphVisualizer& visualizer) {
193 SsaRedundantPhiElimination redundant_phi(graph);
194 SsaDeadPhiElimination dead_phi(graph);
195 HDeadCodeElimination dce(graph);
196 HConstantFolding fold(graph);
197 InstructionSimplifier simplify1(graph);
198
199 HInliner inliner(graph, dex_compilation_unit, driver, stats);
200
201 GVNOptimization gvn(graph);
Mingyao Yangf384f882014-10-22 16:08:18 -0700202 BoundsCheckElimination bce(graph);
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000203 InstructionSimplifier simplify2(graph);
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +0000204
Nicolas Geoffray31596742014-11-24 15:28:45 +0000205 HOptimization* optimizations[] = {
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000206 &redundant_phi,
207 &dead_phi,
208 &dce,
209 &fold,
210 &simplify1,
211 &inliner,
212 &gvn,
Mingyao Yangf384f882014-10-22 16:08:18 -0700213 &bce,
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000214 &simplify2
Nicolas Geoffray31596742014-11-24 15:28:45 +0000215 };
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +0000216
217 for (size_t i = 0; i < arraysize(optimizations); ++i) {
218 HOptimization* optimization = optimizations[i];
David Brazdilee690a32014-12-01 17:04:16 +0000219 visualizer.DumpGraph(optimization->GetPassName(), /*is_after=*/false);
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +0000220 optimization->Run();
David Brazdilee690a32014-12-01 17:04:16 +0000221 visualizer.DumpGraph(optimization->GetPassName(), /*is_after=*/true);
Nicolas Geoffray31596742014-11-24 15:28:45 +0000222 optimization->Check();
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +0000223 }
224}
225
Nicolas Geoffray376b2bb2014-12-09 14:26:32 +0000226// The stack map we generate must be 4-byte aligned on ARM. Since existing
227// maps are generated alongside these stack maps, we must also align them.
228static std::vector<uint8_t>& AlignVectorSize(std::vector<uint8_t>& vector) {
229 size_t size = vector.size();
230 size_t aligned_size = RoundUp(size, 4);
231 for (; size < aligned_size; ++size) {
232 vector.push_back(0);
233 }
234 return vector;
235}
236
Nicolas Geoffraye2dc6fa2014-11-17 12:55:12 +0000237CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item,
238 uint32_t access_flags,
239 InvokeType invoke_type,
240 uint16_t class_def_idx,
241 uint32_t method_idx,
242 jobject class_loader,
243 const DexFile& dex_file) const {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700244 UNUSED(invoke_type);
Calin Juravle48c2b032014-12-09 18:11:36 +0000245 compilation_stats_.RecordStat(MethodCompilationStat::kAttemptCompilation);
Nicolas Geoffray8fb5ce32014-07-04 09:43:26 +0100246 InstructionSet instruction_set = GetCompilerDriver()->GetInstructionSet();
Nicolas Geoffray8d486732014-07-16 16:23:40 +0100247 // Always use the thumb2 assembler: some runtime functionality (like implicit stack
248 // overflow checks) assume thumb2.
249 if (instruction_set == kArm) {
250 instruction_set = kThumb2;
Nicolas Geoffray8fb5ce32014-07-04 09:43:26 +0100251 }
252
253 // Do not attempt to compile on architectures we do not support.
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000254 if (!IsInstructionSetSupported(instruction_set)) {
Calin Juravle48c2b032014-12-09 18:11:36 +0000255 compilation_stats_.RecordStat(MethodCompilationStat::kNotCompiledUnsupportedIsa);
Nicolas Geoffray8fb5ce32014-07-04 09:43:26 +0100256 return nullptr;
257 }
258
Nicolas Geoffrayb5f62b32014-10-30 10:58:41 +0000259 if (Compiler::IsPathologicalCase(*code_item, method_idx, dex_file)) {
Calin Juravle48c2b032014-12-09 18:11:36 +0000260 compilation_stats_.RecordStat(MethodCompilationStat::kNotCompiledPathological);
Nicolas Geoffrayb5f62b32014-10-30 10:58:41 +0000261 return nullptr;
262 }
263
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000264 DexCompilationUnit dex_compilation_unit(
265 nullptr, class_loader, art::Runtime::Current()->GetClassLinker(), dex_file, code_item,
Ian Rogers72d32622014-05-06 16:20:11 -0700266 class_def_idx, method_idx, access_flags,
267 GetCompilerDriver()->GetVerifiedMethod(&dex_file, method_idx));
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000268
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000269 std::string method_name = PrettyMethod(method_idx, dex_file);
270
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000271 // For testing purposes, we put a special marker on method names that should be compiled
272 // with this compiler. This makes sure we're not regressing.
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000273 bool shouldCompile = method_name.find("$opt$") != std::string::npos;
274 bool shouldOptimize = method_name.find("$opt$reg$") != std::string::npos;
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000275
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000276 ArenaPool pool;
277 ArenaAllocator arena(&pool);
Calin Juravle48c2b032014-12-09 18:11:36 +0000278 HGraphBuilder builder(&arena,
279 &dex_compilation_unit,
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000280 &dex_compilation_unit,
281 &dex_file,
282 GetCompilerDriver(),
Calin Juravle48c2b032014-12-09 18:11:36 +0000283 &compilation_stats_);
Nicolas Geoffrayf635e632014-05-14 09:43:38 +0100284
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000285 VLOG(compiler) << "Building " << PrettyMethod(method_idx, dex_file);
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000286 HGraph* graph = builder.BuildGraph(*code_item);
287 if (graph == nullptr) {
Zheng Xu5667fdb2014-10-23 18:29:55 +0800288 CHECK(!shouldCompile) << "Could not build graph in optimizing compiler";
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000289 return nullptr;
290 }
291
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000292 CodeGenerator* codegen = CodeGenerator::Create(&arena, graph, instruction_set);
293 if (codegen == nullptr) {
Zheng Xu5667fdb2014-10-23 18:29:55 +0800294 CHECK(!shouldCompile) << "Could not find code generator for optimizing compiler";
Calin Juravle48c2b032014-12-09 18:11:36 +0000295 compilation_stats_.RecordStat(MethodCompilationStat::kNotCompiledNoCodegen);
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000296 return nullptr;
297 }
298
Nicolas Geoffraya7062e02014-05-22 12:50:17 +0100299 HGraphVisualizer visualizer(
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000300 visualizer_output_.get(), graph, kStringFilter, *codegen, method_name.c_str());
Nicolas Geoffraya7062e02014-05-22 12:50:17 +0100301 visualizer.DumpGraph("builder");
302
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000303 CodeVectorAllocator allocator;
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100304
Calin Juravle48c2b032014-12-09 18:11:36 +0000305 bool can_optimize = CanOptimize(*code_item);
306 bool can_allocate_registers = RegisterAllocator::CanAllocateRegistersFor(*graph, instruction_set);
307 if (run_optimizations_ && can_optimize && can_allocate_registers) {
Nicolas Geoffray43a539f2014-12-02 10:19:51 +0000308 VLOG(compiler) << "Optimizing " << PrettyMethod(method_idx, dex_file);
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000309 if (!graph->TryBuildingSsa()) {
310 LOG(INFO) << "Skipping compilation of "
311 << PrettyMethod(method_idx, dex_file)
312 << ": it contains a non natural loop";
Nicolas Geoffrayf5370122014-12-02 11:51:19 +0000313 // We could not transform the graph to SSA, bailout.
Calin Juravle48c2b032014-12-09 18:11:36 +0000314 compilation_stats_.RecordStat(MethodCompilationStat::kNotCompiledCannotBuildSSA);
Nicolas Geoffrayf5370122014-12-02 11:51:19 +0000315 return nullptr;
316 }
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000317 RunOptimizations(
318 graph, GetCompilerDriver(), &compilation_stats_, dex_compilation_unit, visualizer);
Roland Levillain75be2832014-10-17 17:02:00 +0100319
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +0100320 PrepareForRegisterAllocation(graph).Run();
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100321 SsaLivenessAnalysis liveness(*graph, codegen);
322 liveness.Analyze();
323 visualizer.DumpGraph(kLivenessPassName);
324
325 RegisterAllocator register_allocator(graph->GetArena(), codegen, liveness);
326 register_allocator.AllocateRegisters();
327
328 visualizer.DumpGraph(kRegisterAllocatorPassName);
329 codegen->CompileOptimized(&allocator);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100330
Nicolas Geoffray39468442014-09-02 15:17:15 +0100331 std::vector<uint8_t> stack_map;
332 codegen->BuildStackMaps(&stack_map);
333
Calin Juravle48c2b032014-12-09 18:11:36 +0000334 compilation_stats_.RecordStat(MethodCompilationStat::kCompiledOptimized);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100335 return new CompiledMethod(GetCompilerDriver(),
336 instruction_set,
337 allocator.GetMemory(),
338 codegen->GetFrameSize(),
339 codegen->GetCoreSpillMask(),
340 0, /* FPR spill mask, unused */
Nicolas Geoffray39468442014-09-02 15:17:15 +0100341 stack_map);
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100342 } else if (shouldOptimize && RegisterAllocator::Supports(instruction_set)) {
343 LOG(FATAL) << "Could not allocate registers in optimizing compiler";
Zheng Xu5667fdb2014-10-23 18:29:55 +0800344 UNREACHABLE();
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100345 } else {
Nicolas Geoffray43a539f2014-12-02 10:19:51 +0000346 VLOG(compiler) << "Compile baseline " << PrettyMethod(method_idx, dex_file);
Calin Juravle48c2b032014-12-09 18:11:36 +0000347
348 if (!run_optimizations_) {
349 compilation_stats_.RecordStat(MethodCompilationStat::kNotOptimizedDisabled);
350 } else if (!can_optimize) {
351 compilation_stats_.RecordStat(MethodCompilationStat::kNotOptimizedTryCatch);
352 } else if (!can_allocate_registers) {
353 compilation_stats_.RecordStat(MethodCompilationStat::kNotOptimizedRegisterAllocator);
354 }
355
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100356 codegen->CompileBaseline(&allocator);
357
Nicolas Geoffray39468442014-09-02 15:17:15 +0100358 std::vector<uint8_t> mapping_table;
359 SrcMap src_mapping_table;
360 codegen->BuildMappingTable(&mapping_table,
361 GetCompilerDriver()->GetCompilerOptions().GetIncludeDebugSymbols() ?
362 &src_mapping_table : nullptr);
363 std::vector<uint8_t> vmap_table;
364 codegen->BuildVMapTable(&vmap_table);
365 std::vector<uint8_t> gc_map;
366 codegen->BuildNativeGCMap(&gc_map, dex_compilation_unit);
367
Calin Juravle48c2b032014-12-09 18:11:36 +0000368 compilation_stats_.RecordStat(MethodCompilationStat::kCompiledBaseline);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100369 return new CompiledMethod(GetCompilerDriver(),
370 instruction_set,
371 allocator.GetMemory(),
372 codegen->GetFrameSize(),
373 codegen->GetCoreSpillMask(),
374 0, /* FPR spill mask, unused */
375 &src_mapping_table,
Nicolas Geoffray376b2bb2014-12-09 14:26:32 +0000376 AlignVectorSize(mapping_table),
377 AlignVectorSize(vmap_table),
378 AlignVectorSize(gc_map),
Nicolas Geoffray39468442014-09-02 15:17:15 +0100379 nullptr);
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100380 }
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +0000381}
382
Andreas Gampe53c913b2014-08-12 23:19:23 -0700383Compiler* CreateOptimizingCompiler(CompilerDriver* driver) {
384 return new OptimizingCompiler(driver);
385}
386
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +0000387} // namespace art