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 | |
| 17 | #include "compiler.h" |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 18 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 19 | #include "base/logging.h" |
| 20 | #include "dex/quick/quick_compiler.h" |
| 21 | #include "driver/compiler_driver.h" |
| 22 | #include "llvm/llvm_compiler.h" |
| 23 | #include "optimizing/optimizing_compiler.h" |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 24 | |
| 25 | namespace art { |
| 26 | |
| 27 | #ifdef ART_SEA_IR_MODE |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 28 | extern "C" art::CompiledMethod* SeaIrCompileMethod(const art::DexFile::CodeItem* code_item, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 29 | uint32_t access_flags, |
| 30 | art::InvokeType invoke_type, |
| 31 | uint16_t class_def_idx, |
| 32 | uint32_t method_idx, |
| 33 | jobject class_loader, |
| 34 | const art::DexFile& dex_file); |
| 35 | #endif |
| 36 | |
| 37 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 38 | CompiledMethod* Compiler::TryCompileWithSeaIR(const art::DexFile::CodeItem* code_item, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 39 | uint32_t access_flags, |
| 40 | art::InvokeType invoke_type, |
| 41 | uint16_t class_def_idx, |
| 42 | uint32_t method_idx, |
| 43 | jobject class_loader, |
| 44 | const art::DexFile& dex_file) { |
| 45 | #ifdef ART_SEA_IR_MODE |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 46 | bool use_sea = (std::string::npos != PrettyMethod(method_idx, dex_file).find("fibonacci")); |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 47 | if (use_sea) { |
| 48 | LOG(INFO) << "Using SEA IR to compile..." << std::endl; |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 49 | return SeaIrCompileMethod(code_item, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 50 | access_flags, |
| 51 | invoke_type, |
| 52 | class_def_idx, |
| 53 | method_idx, |
| 54 | class_loader, |
| 55 | dex_file); |
| 56 | } |
| 57 | #endif |
| 58 | return nullptr; |
| 59 | } |
| 60 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 61 | Compiler* Compiler::Create(CompilerDriver* driver, Compiler::Kind kind) { |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 62 | switch (kind) { |
| 63 | case kQuick: |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 64 | return CreateQuickCompiler(driver); |
| 65 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 66 | case kOptimizing: |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 67 | return CreateOptimizingCompiler(driver); |
| 68 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 69 | case kPortable: |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 70 | { |
| 71 | Compiler* compiler = CreateLLVMCompiler(driver); |
| 72 | CHECK(compiler != nullptr) << "Portable compiler not compiled"; |
| 73 | return compiler; |
| 74 | } |
| 75 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 76 | default: |
| 77 | LOG(FATAL) << "UNREACHABLE"; |
| 78 | } |
| 79 | return nullptr; |
| 80 | } |
| 81 | |
| 82 | } // namespace art |