Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 1 | /* |
| 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 Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 17 | #include "optimizing_compiler.h" |
| 18 | |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 19 | #include <fstream> |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | |
| 22 | #include "builder.h" |
| 23 | #include "code_generator.h" |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 24 | #include "compiler.h" |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 25 | #include "driver/compiler_driver.h" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 26 | #include "driver/dex_compilation_unit.h" |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 27 | #include "graph_visualizer.h" |
Nicolas Geoffray | d31cf3d | 2014-09-08 17:30:24 +0100 | [diff] [blame] | 28 | #include "gvn.h" |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame^] | 29 | #include "instruction_simplifier.h" |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 30 | #include "nodes.h" |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 31 | #include "register_allocator.h" |
Nicolas Geoffray | 7dc206a | 2014-07-11 09:49:49 +0100 | [diff] [blame] | 32 | #include "ssa_phi_elimination.h" |
Nicolas Geoffray | 804d093 | 2014-05-02 08:46:00 +0100 | [diff] [blame] | 33 | #include "ssa_liveness_analysis.h" |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 34 | #include "utils/arena_allocator.h" |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 35 | |
| 36 | namespace art { |
| 37 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 38 | /** |
| 39 | * Used by the code generator, to allocate the code in a vector. |
| 40 | */ |
| 41 | class CodeVectorAllocator FINAL : public CodeAllocator { |
| 42 | public: |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 43 | CodeVectorAllocator() {} |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 44 | |
| 45 | virtual uint8_t* Allocate(size_t size) { |
| 46 | size_ = size; |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 47 | memory_.resize(size); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 48 | return &memory_[0]; |
| 49 | } |
| 50 | |
| 51 | size_t GetSize() const { return size_; } |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 52 | const std::vector<uint8_t>& GetMemory() const { return memory_; } |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | std::vector<uint8_t> memory_; |
| 56 | size_t size_; |
| 57 | |
| 58 | DISALLOW_COPY_AND_ASSIGN(CodeVectorAllocator); |
| 59 | }; |
| 60 | |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 61 | /** |
| 62 | * If set to true, generates a file suitable for the c1visualizer tool and IRHydra. |
| 63 | */ |
| 64 | static bool kIsVisualizerEnabled = false; |
| 65 | |
| 66 | /** |
| 67 | * Filter to apply to the visualizer. Methods whose name contain that filter will |
| 68 | * be in the file. |
| 69 | */ |
| 70 | static const char* kStringFilter = ""; |
| 71 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 72 | class OptimizingCompiler FINAL : public Compiler { |
| 73 | public: |
| 74 | explicit OptimizingCompiler(CompilerDriver* driver); |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 75 | ~OptimizingCompiler(); |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 76 | |
| 77 | bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const |
| 78 | OVERRIDE; |
| 79 | |
| 80 | CompiledMethod* Compile(const DexFile::CodeItem* code_item, |
| 81 | uint32_t access_flags, |
| 82 | InvokeType invoke_type, |
| 83 | uint16_t class_def_idx, |
| 84 | uint32_t method_idx, |
| 85 | jobject class_loader, |
| 86 | const DexFile& dex_file) const OVERRIDE; |
| 87 | |
| 88 | CompiledMethod* TryCompile(const DexFile::CodeItem* code_item, |
| 89 | uint32_t access_flags, |
| 90 | InvokeType invoke_type, |
| 91 | uint16_t class_def_idx, |
| 92 | uint32_t method_idx, |
| 93 | jobject class_loader, |
| 94 | const DexFile& dex_file) const; |
| 95 | |
| 96 | // For the following methods we will use the fallback. This is a delegation pattern. |
| 97 | CompiledMethod* JniCompile(uint32_t access_flags, |
| 98 | uint32_t method_idx, |
| 99 | const DexFile& dex_file) const OVERRIDE; |
| 100 | |
| 101 | uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE |
| 102 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 103 | |
| 104 | bool WriteElf(art::File* file, |
| 105 | OatWriter* oat_writer, |
| 106 | const std::vector<const art::DexFile*>& dex_files, |
| 107 | const std::string& android_root, |
| 108 | bool is_host) const OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 109 | |
| 110 | Backend* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const OVERRIDE; |
| 111 | |
| 112 | void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE; |
| 113 | |
| 114 | void Init() const OVERRIDE; |
| 115 | |
| 116 | void UnInit() const OVERRIDE; |
| 117 | |
| 118 | private: |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 119 | // Whether we should run any optimization or register allocation. If false, will |
| 120 | // just run the code generation after the graph was built. |
| 121 | const bool run_optimizations_; |
| 122 | mutable AtomicInteger total_compiled_methods_; |
| 123 | mutable AtomicInteger unoptimized_compiled_methods_; |
| 124 | mutable AtomicInteger optimized_compiled_methods_; |
| 125 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 126 | std::unique_ptr<std::ostream> visualizer_output_; |
| 127 | |
| 128 | // Delegate to another compiler in case the optimizing compiler cannot compile a method. |
| 129 | // Currently the fallback is the quick compiler. |
| 130 | std::unique_ptr<Compiler> delegate_; |
| 131 | |
| 132 | DISALLOW_COPY_AND_ASSIGN(OptimizingCompiler); |
| 133 | }; |
| 134 | |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 135 | static const int kMaximumCompilationTimeBeforeWarning = 100; /* ms */ |
| 136 | |
| 137 | OptimizingCompiler::OptimizingCompiler(CompilerDriver* driver) |
| 138 | : Compiler(driver, kMaximumCompilationTimeBeforeWarning), |
| 139 | run_optimizations_( |
| 140 | driver->GetCompilerOptions().GetCompilerFilter() != CompilerOptions::kTime), |
| 141 | total_compiled_methods_(0), |
| 142 | unoptimized_compiled_methods_(0), |
| 143 | optimized_compiled_methods_(0), |
| 144 | delegate_(Create(driver, Compiler::Kind::kQuick)) { |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 145 | if (kIsVisualizerEnabled) { |
| 146 | visualizer_output_.reset(new std::ofstream("art.cfg")); |
| 147 | } |
| 148 | } |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 149 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 150 | void OptimizingCompiler::Init() const { |
| 151 | delegate_->Init(); |
| 152 | } |
| 153 | |
| 154 | void OptimizingCompiler::UnInit() const { |
| 155 | delegate_->UnInit(); |
| 156 | } |
| 157 | |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 158 | OptimizingCompiler::~OptimizingCompiler() { |
Nicolas Geoffray | ce71ae7 | 2014-09-18 11:31:32 +0100 | [diff] [blame] | 159 | if (total_compiled_methods_ == 0) { |
| 160 | LOG(INFO) << "Did not compile any method."; |
| 161 | } else { |
| 162 | size_t unoptimized_percent = (unoptimized_compiled_methods_ * 100 / total_compiled_methods_); |
| 163 | size_t optimized_percent = (optimized_compiled_methods_ * 100 / total_compiled_methods_); |
| 164 | LOG(INFO) << "Compiled " << total_compiled_methods_ << " methods: " |
| 165 | << unoptimized_percent << "% (" << unoptimized_compiled_methods_ << ") unoptimized, " |
| 166 | << optimized_percent << "% (" << optimized_compiled_methods_ << ") optimized."; |
| 167 | } |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 170 | bool OptimizingCompiler::CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, |
| 171 | CompilationUnit* cu) const { |
| 172 | return delegate_->CanCompileMethod(method_idx, dex_file, cu); |
| 173 | } |
| 174 | |
| 175 | CompiledMethod* OptimizingCompiler::JniCompile(uint32_t access_flags, |
| 176 | uint32_t method_idx, |
| 177 | const DexFile& dex_file) const { |
| 178 | return delegate_->JniCompile(access_flags, method_idx, dex_file); |
| 179 | } |
| 180 | |
| 181 | uintptr_t OptimizingCompiler::GetEntryPointOf(mirror::ArtMethod* method) const { |
| 182 | return delegate_->GetEntryPointOf(method); |
| 183 | } |
| 184 | |
| 185 | bool OptimizingCompiler::WriteElf(art::File* file, OatWriter* oat_writer, |
| 186 | const std::vector<const art::DexFile*>& dex_files, |
| 187 | const std::string& android_root, bool is_host) const { |
| 188 | return delegate_->WriteElf(file, oat_writer, dex_files, android_root, is_host); |
| 189 | } |
| 190 | |
| 191 | Backend* OptimizingCompiler::GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const { |
| 192 | return delegate_->GetCodeGenerator(cu, compilation_unit); |
| 193 | } |
| 194 | |
| 195 | void OptimizingCompiler::InitCompilationUnit(CompilationUnit& cu) const { |
| 196 | delegate_->InitCompilationUnit(cu); |
| 197 | } |
| 198 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 199 | CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_item, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 200 | uint32_t access_flags, |
| 201 | InvokeType invoke_type, |
| 202 | uint16_t class_def_idx, |
| 203 | uint32_t method_idx, |
| 204 | jobject class_loader, |
| 205 | const DexFile& dex_file) const { |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 206 | total_compiled_methods_++; |
Nicolas Geoffray | 8fb5ce3 | 2014-07-04 09:43:26 +0100 | [diff] [blame] | 207 | InstructionSet instruction_set = GetCompilerDriver()->GetInstructionSet(); |
Nicolas Geoffray | 8d48673 | 2014-07-16 16:23:40 +0100 | [diff] [blame] | 208 | // Always use the thumb2 assembler: some runtime functionality (like implicit stack |
| 209 | // overflow checks) assume thumb2. |
| 210 | if (instruction_set == kArm) { |
| 211 | instruction_set = kThumb2; |
Nicolas Geoffray | 8fb5ce3 | 2014-07-04 09:43:26 +0100 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | // Do not attempt to compile on architectures we do not support. |
Nicolas Geoffray | 8d48673 | 2014-07-16 16:23:40 +0100 | [diff] [blame] | 215 | if (instruction_set != kX86 && instruction_set != kX86_64 && instruction_set != kThumb2) { |
Nicolas Geoffray | 8fb5ce3 | 2014-07-04 09:43:26 +0100 | [diff] [blame] | 216 | return nullptr; |
| 217 | } |
| 218 | |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 219 | DexCompilationUnit dex_compilation_unit( |
| 220 | nullptr, class_loader, art::Runtime::Current()->GetClassLinker(), dex_file, code_item, |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 221 | class_def_idx, method_idx, access_flags, |
| 222 | GetCompilerDriver()->GetVerifiedMethod(&dex_file, method_idx)); |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 223 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 224 | // For testing purposes, we put a special marker on method names that should be compiled |
| 225 | // with this compiler. This makes sure we're not regressing. |
| 226 | bool shouldCompile = dex_compilation_unit.GetSymbol().find("00024opt_00024") != std::string::npos; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 227 | bool shouldOptimize = |
| 228 | dex_compilation_unit.GetSymbol().find("00024reg_00024") != std::string::npos; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 229 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 230 | ArenaPool pool; |
| 231 | ArenaAllocator arena(&pool); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 232 | HGraphBuilder builder(&arena, &dex_compilation_unit, &dex_file, GetCompilerDriver()); |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 233 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 234 | HGraph* graph = builder.BuildGraph(*code_item); |
| 235 | if (graph == nullptr) { |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 236 | if (shouldCompile) { |
| 237 | LOG(FATAL) << "Could not build graph in optimizing compiler"; |
| 238 | } |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 239 | return nullptr; |
| 240 | } |
| 241 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 242 | CodeGenerator* codegen = CodeGenerator::Create(&arena, graph, instruction_set); |
| 243 | if (codegen == nullptr) { |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 244 | if (shouldCompile) { |
| 245 | LOG(FATAL) << "Could not find code generator for optimizing compiler"; |
| 246 | } |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 247 | return nullptr; |
| 248 | } |
| 249 | |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 250 | HGraphVisualizer visualizer( |
| 251 | visualizer_output_.get(), graph, kStringFilter, *codegen, dex_compilation_unit); |
| 252 | visualizer.DumpGraph("builder"); |
| 253 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 254 | CodeVectorAllocator allocator; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 255 | |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 256 | if (run_optimizations_ && RegisterAllocator::CanAllocateRegistersFor(*graph, instruction_set)) { |
| 257 | optimized_compiled_methods_++; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 258 | graph->BuildDominatorTree(); |
| 259 | graph->TransformToSSA(); |
| 260 | visualizer.DumpGraph("ssa"); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 261 | graph->FindNaturalLoops(); |
Nicolas Geoffray | 7dc206a | 2014-07-11 09:49:49 +0100 | [diff] [blame] | 262 | |
| 263 | SsaRedundantPhiElimination(graph).Run(); |
| 264 | SsaDeadPhiElimination(graph).Run(); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame^] | 265 | InstructionSimplifier(graph).Run(); |
Nicolas Geoffray | d31cf3d | 2014-09-08 17:30:24 +0100 | [diff] [blame] | 266 | GlobalValueNumberer(graph->GetArena(), graph).Run(); |
| 267 | visualizer.DumpGraph(kGVNPassName); |
Nicolas Geoffray | 7dc206a | 2014-07-11 09:49:49 +0100 | [diff] [blame] | 268 | |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 269 | SsaLivenessAnalysis liveness(*graph, codegen); |
| 270 | liveness.Analyze(); |
| 271 | visualizer.DumpGraph(kLivenessPassName); |
| 272 | |
| 273 | RegisterAllocator register_allocator(graph->GetArena(), codegen, liveness); |
| 274 | register_allocator.AllocateRegisters(); |
| 275 | |
| 276 | visualizer.DumpGraph(kRegisterAllocatorPassName); |
| 277 | codegen->CompileOptimized(&allocator); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 278 | |
| 279 | std::vector<uint8_t> mapping_table; |
| 280 | SrcMap src_mapping_table; |
| 281 | codegen->BuildMappingTable(&mapping_table, |
| 282 | GetCompilerDriver()->GetCompilerOptions().GetIncludeDebugSymbols() ? |
| 283 | &src_mapping_table : nullptr); |
| 284 | |
| 285 | std::vector<uint8_t> stack_map; |
| 286 | codegen->BuildStackMaps(&stack_map); |
| 287 | |
| 288 | return new CompiledMethod(GetCompilerDriver(), |
| 289 | instruction_set, |
| 290 | allocator.GetMemory(), |
| 291 | codegen->GetFrameSize(), |
| 292 | codegen->GetCoreSpillMask(), |
| 293 | 0, /* FPR spill mask, unused */ |
| 294 | mapping_table, |
| 295 | stack_map); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 296 | } else if (shouldOptimize && RegisterAllocator::Supports(instruction_set)) { |
| 297 | LOG(FATAL) << "Could not allocate registers in optimizing compiler"; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 298 | return nullptr; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 299 | } else { |
Nicolas Geoffray | 88157ef | 2014-09-12 10:29:53 +0100 | [diff] [blame] | 300 | unoptimized_compiled_methods_++; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 301 | codegen->CompileBaseline(&allocator); |
| 302 | |
| 303 | // Run these phases to get some test coverage. |
| 304 | graph->BuildDominatorTree(); |
| 305 | graph->TransformToSSA(); |
| 306 | visualizer.DumpGraph("ssa"); |
| 307 | graph->FindNaturalLoops(); |
Nicolas Geoffray | d31cf3d | 2014-09-08 17:30:24 +0100 | [diff] [blame] | 308 | SsaRedundantPhiElimination(graph).Run(); |
| 309 | SsaDeadPhiElimination(graph).Run(); |
| 310 | GlobalValueNumberer(graph->GetArena(), graph).Run(); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 311 | SsaLivenessAnalysis liveness(*graph, codegen); |
| 312 | liveness.Analyze(); |
| 313 | visualizer.DumpGraph(kLivenessPassName); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 314 | |
| 315 | std::vector<uint8_t> mapping_table; |
| 316 | SrcMap src_mapping_table; |
| 317 | codegen->BuildMappingTable(&mapping_table, |
| 318 | GetCompilerDriver()->GetCompilerOptions().GetIncludeDebugSymbols() ? |
| 319 | &src_mapping_table : nullptr); |
| 320 | std::vector<uint8_t> vmap_table; |
| 321 | codegen->BuildVMapTable(&vmap_table); |
| 322 | std::vector<uint8_t> gc_map; |
| 323 | codegen->BuildNativeGCMap(&gc_map, dex_compilation_unit); |
| 324 | |
| 325 | return new CompiledMethod(GetCompilerDriver(), |
| 326 | instruction_set, |
| 327 | allocator.GetMemory(), |
| 328 | codegen->GetFrameSize(), |
| 329 | codegen->GetCoreSpillMask(), |
| 330 | 0, /* FPR spill mask, unused */ |
| 331 | &src_mapping_table, |
| 332 | mapping_table, |
| 333 | vmap_table, |
| 334 | gc_map, |
| 335 | nullptr); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 336 | } |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 339 | CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, |
| 340 | uint32_t access_flags, |
| 341 | InvokeType invoke_type, |
| 342 | uint16_t class_def_idx, |
| 343 | uint32_t method_idx, |
| 344 | jobject class_loader, |
| 345 | const DexFile& dex_file) const { |
| 346 | CompiledMethod* method = TryCompile(code_item, access_flags, invoke_type, class_def_idx, |
| 347 | method_idx, class_loader, dex_file); |
| 348 | if (method != nullptr) { |
| 349 | return method; |
| 350 | } |
| 351 | |
| 352 | return delegate_->Compile(code_item, access_flags, invoke_type, class_def_idx, method_idx, |
| 353 | class_loader, dex_file); |
| 354 | } |
| 355 | |
| 356 | Compiler* CreateOptimizingCompiler(CompilerDriver* driver) { |
| 357 | return new OptimizingCompiler(driver); |
| 358 | } |
| 359 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 360 | } // namespace art |