Brian Carlstrom | 751d4ed | 2013-07-18 16:20:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 17 | #ifdef ART_SEA_IR_MODE |
| 18 | #include <llvm/Support/Threading.h> |
| 19 | #include "base/logging.h" |
| 20 | #include "dex/portable/mir_to_gbc.h" |
| 21 | #include "driver/compiler_driver.h" |
| 22 | #include "leb128.h" |
| 23 | #include "llvm/llvm_compilation_unit.h" |
| 24 | #include "mirror/object.h" |
| 25 | #include "runtime.h" |
| 26 | #include "sea_ir/sea.h" |
| 27 | |
| 28 | namespace art { |
| 29 | |
| 30 | static CompiledMethod* CompileMethodWithSeaIr(CompilerDriver& compiler, |
| 31 | const CompilerBackend compiler_backend, |
| 32 | const DexFile::CodeItem* code_item, |
| 33 | uint32_t access_flags, InvokeType invoke_type, |
| 34 | uint32_t class_def_idx, uint32_t method_idx, |
| 35 | jobject class_loader, const DexFile& dex_file |
| 36 | #if defined(ART_USE_PORTABLE_COMPILER) |
| 37 | , llvm::LlvmCompilationUnit* llvm_compilation_unit |
| 38 | #endif |
| 39 | ) { |
| 40 | // NOTE: Instead of keeping the convention from the Dalvik frontend.cc |
| 41 | // and silencing the cpplint.py warning, I just corrected the formatting. |
| 42 | VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "..."; |
| 43 | sea_ir::SeaGraph* sg = sea_ir::SeaGraph::GetCurrentGraph(); |
| 44 | sg->CompileMethod(code_item, class_def_idx, method_idx, dex_file); |
| 45 | sg->DumpSea("/tmp/temp.dot"); |
| 46 | CHECK(0 && "No SEA compiled function exists yet."); |
| 47 | return NULL; |
| 48 | } |
| 49 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 50 | CompiledMethod* SeaIrCompileOneMethod(CompilerDriver& compiler, |
| 51 | const CompilerBackend backend, |
| 52 | const DexFile::CodeItem* code_item, |
| 53 | uint32_t access_flags, |
| 54 | InvokeType invoke_type, |
| 55 | uint32_t class_def_idx, |
| 56 | uint32_t method_idx, |
| 57 | jobject class_loader, |
| 58 | const DexFile& dex_file, |
| 59 | llvm::LlvmCompilationUnit* llvm_compilation_unit) { |
| 60 | return CompileMethodWithSeaIr(compiler, backend, code_item, access_flags, invoke_type, class_def_idx, |
| 61 | method_idx, class_loader, dex_file |
| 62 | #if defined(ART_USE_PORTABLE_COMPILER) |
| 63 | , llvm_compilation_unit |
| 64 | #endif |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame^] | 65 | ); // NOLINT |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | extern "C" art::CompiledMethod* |
| 69 | SeaIrCompileMethod(art::CompilerDriver& compiler, |
| 70 | const art::DexFile::CodeItem* code_item, |
| 71 | uint32_t access_flags, art::InvokeType invoke_type, |
| 72 | uint32_t class_def_idx, uint32_t method_idx, jobject class_loader, |
| 73 | const art::DexFile& dex_file) { |
| 74 | // TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default |
| 75 | art::CompilerBackend backend = compiler.GetCompilerBackend(); |
| 76 | return art::SeaIrCompileOneMethod(compiler, backend, code_item, access_flags, invoke_type, |
| 77 | class_def_idx, method_idx, class_loader, dex_file, |
| 78 | NULL /* use thread llvm_info */); |
| 79 | } |
| 80 | #endif |
| 81 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame^] | 82 | } // namespace art |