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