Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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_llvm.h" |
| 18 | |
Shih-wei Liao | 26e9307 | 2012-05-30 19:13:08 -0700 | [diff] [blame] | 19 | #include "backend_options.h" |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 20 | #include "base/stl_util.h" |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 21 | #include "class_linker.h" |
Logan Chien | f7015fd | 2012-03-18 01:19:37 +0800 | [diff] [blame] | 22 | #include "compiled_method.h" |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 23 | #include "compiler/driver/compiler_driver.h" |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 24 | #include "compiler/driver/dex_compilation_unit.h" |
Ian Rogers | 0211378 | 2013-03-04 12:12:48 -0800 | [diff] [blame] | 25 | #include "compiler/jni/portable/jni_compiler.h" |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 26 | #include "globals.h" |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 27 | #include "ir_builder.h" |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 28 | #include "llvm_compilation_unit.h" |
Logan Chien | 0c717dd | 2012-03-28 18:31:07 +0800 | [diff] [blame] | 29 | #include "oat_file.h" |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame] | 30 | #include "utils_llvm.h" |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 31 | #include "verifier/method_verifier.h" |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 32 | |
Logan Chien | dd7cf5b | 2012-03-01 12:55:19 +0800 | [diff] [blame] | 33 | #include <llvm/LinkAllPasses.h> |
Logan Chien | 013b6f2 | 2012-03-02 17:20:33 +0800 | [diff] [blame] | 34 | #include <llvm/Support/ManagedStatic.h> |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 35 | #include <llvm/Support/TargetSelect.h> |
| 36 | #include <llvm/Support/Threading.h> |
| 37 | |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 38 | namespace art { |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 39 | void CompileOneMethod(CompilerDriver& driver, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 40 | const CompilerBackend compilerBackend, |
| 41 | const DexFile::CodeItem* code_item, |
| 42 | uint32_t access_flags, InvokeType invoke_type, |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 43 | uint32_t class_def_idx, uint32_t method_idx, jobject class_loader, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 44 | const DexFile& dex_file, |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 45 | llvm::LlvmCompilationUnit* llvm_info); |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 46 | } |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 47 | |
Logan Chien | 013b6f2 | 2012-03-02 17:20:33 +0800 | [diff] [blame] | 48 | namespace llvm { |
| 49 | extern bool TimePassesIsEnabled; |
| 50 | } |
| 51 | |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 52 | namespace { |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 53 | |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 54 | pthread_once_t llvm_initialized = PTHREAD_ONCE_INIT; |
| 55 | |
| 56 | void InitializeLLVM() { |
Logan Chien | c3f8fa5 | 2012-05-11 11:23:39 +0800 | [diff] [blame] | 57 | // Initialize LLVM internal data structure for multithreading |
| 58 | llvm::llvm_start_multithreaded(); |
| 59 | |
Logan Chien | 013b6f2 | 2012-03-02 17:20:33 +0800 | [diff] [blame] | 60 | // NOTE: Uncomment following line to show the time consumption of LLVM passes |
| 61 | //llvm::TimePassesIsEnabled = true; |
| 62 | |
Shih-wei Liao | 26e9307 | 2012-05-30 19:13:08 -0700 | [diff] [blame] | 63 | // Initialize LLVM target-specific options. |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 64 | art::llvm::InitialBackendOptions(); |
Logan Chien | c3f8fa5 | 2012-05-11 11:23:39 +0800 | [diff] [blame] | 65 | |
Shih-wei Liao | 1335a95 | 2012-07-23 18:03:00 -0700 | [diff] [blame] | 66 | // Initialize LLVM target, MC subsystem, asm printer, and asm parser. |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 67 | if (art::kIsTargetBuild) { |
| 68 | // Don't initialize all targets on device. Just initialize the device's native target |
| 69 | llvm::InitializeNativeTarget(); |
| 70 | llvm::InitializeNativeTargetAsmPrinter(); |
| 71 | llvm::InitializeNativeTargetAsmParser(); |
| 72 | } else { |
| 73 | llvm::InitializeAllTargets(); |
| 74 | llvm::InitializeAllTargetMCs(); |
| 75 | llvm::InitializeAllAsmPrinters(); |
| 76 | llvm::InitializeAllAsmParsers(); |
| 77 | } |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 78 | |
Logan Chien | dd7cf5b | 2012-03-01 12:55:19 +0800 | [diff] [blame] | 79 | // Initialize LLVM optimization passes |
| 80 | llvm::PassRegistry ®istry = *llvm::PassRegistry::getPassRegistry(); |
| 81 | |
| 82 | llvm::initializeCore(registry); |
| 83 | llvm::initializeScalarOpts(registry); |
| 84 | llvm::initializeIPO(registry); |
| 85 | llvm::initializeAnalysis(registry); |
| 86 | llvm::initializeIPA(registry); |
| 87 | llvm::initializeTransformUtils(registry); |
| 88 | llvm::initializeInstCombine(registry); |
| 89 | llvm::initializeInstrumentation(registry); |
| 90 | llvm::initializeTarget(registry); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 91 | } |
| 92 | |
Logan Chien | f130655 | 2012-03-16 11:17:53 +0800 | [diff] [blame] | 93 | // The Guard to Shutdown LLVM |
Logan Chien | aeb5303 | 2012-03-18 02:29:38 +0800 | [diff] [blame] | 94 | // llvm::llvm_shutdown_obj llvm_guard; |
| 95 | // TODO: We are commenting out this line because this will cause SEGV from |
| 96 | // time to time. |
| 97 | // Two reasons: (1) the order of the destruction of static objects, or |
| 98 | // (2) dlopen/dlclose side-effect on static objects. |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 99 | |
| 100 | } // anonymous namespace |
| 101 | |
| 102 | |
| 103 | namespace art { |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 104 | namespace llvm { |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 105 | |
| 106 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 107 | ::llvm::Module* makeLLVMModuleContents(::llvm::Module* module); |
Logan Chien | 42e0e15 | 2012-01-13 15:42:36 +0800 | [diff] [blame] | 108 | |
| 109 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 110 | CompilerLLVM::CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set) |
| 111 | : compiler_driver_(driver), insn_set_(insn_set), |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 112 | next_cunit_id_lock_("compilation unit id lock"), next_cunit_id_(1) { |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 113 | |
| 114 | // Initialize LLVM libraries |
| 115 | pthread_once(&llvm_initialized, InitializeLLVM); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | |
| 119 | CompilerLLVM::~CompilerLLVM() { |
| 120 | } |
| 121 | |
| 122 | |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 123 | LlvmCompilationUnit* CompilerLLVM::AllocateCompilationUnit() { |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 124 | MutexLock GUARD(Thread::Current(), next_cunit_id_lock_); |
| 125 | LlvmCompilationUnit* cunit = new LlvmCompilationUnit(this, next_cunit_id_++); |
TDYa127 | b672d1e | 2012-06-28 21:21:45 -0700 | [diff] [blame] | 126 | if (!bitcode_filename_.empty()) { |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 127 | cunit->SetBitcodeFileName(StringPrintf("%s-%zu", |
| 128 | bitcode_filename_.c_str(), |
| 129 | cunit->GetCompilationUnitId())); |
TDYa127 | b672d1e | 2012-06-28 21:21:45 -0700 | [diff] [blame] | 130 | } |
| 131 | return cunit; |
Logan Chien | df57614 | 2012-03-20 17:36:32 +0800 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | |
Logan Chien | 7f76761 | 2012-03-01 18:54:49 +0800 | [diff] [blame] | 135 | CompiledMethod* CompilerLLVM:: |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 136 | CompileDexMethod(DexCompilationUnit* dex_compilation_unit, InvokeType invoke_type) { |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 137 | UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit()); |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 138 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 139 | cunit->SetDexCompilationUnit(dex_compilation_unit); |
Ian Rogers | 0d94eb6 | 2013-03-06 15:20:50 -0800 | [diff] [blame] | 140 | cunit->SetCompilerDriver(compiler_driver_); |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 141 | // TODO: consolidate ArtCompileMethods |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 142 | CompileOneMethod(*compiler_driver_, |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 143 | kPortable, |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 144 | dex_compilation_unit->GetCodeItem(), |
| 145 | dex_compilation_unit->GetAccessFlags(), |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 146 | invoke_type, |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 147 | dex_compilation_unit->GetClassDefIndex(), |
| 148 | dex_compilation_unit->GetDexMethodIndex(), |
| 149 | dex_compilation_unit->GetClassLoader(), |
| 150 | *dex_compilation_unit->GetDexFile(), |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 151 | cunit.get()); |
buzbee | 26f10ee | 2012-12-21 11:16:29 -0800 | [diff] [blame] | 152 | |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 153 | cunit->Materialize(); |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 154 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 155 | CompilerDriver::MethodReference mref(dex_compilation_unit->GetDexFile(), |
| 156 | dex_compilation_unit->GetDexMethodIndex()); |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 157 | return new CompiledMethod(compiler_driver_->GetInstructionSet(), |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 158 | cunit->GetElfObject(), |
| 159 | *verifier::MethodVerifier::GetDexGcMap(mref), |
| 160 | cunit->GetDexCompilationUnit()->GetSymbol()); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 161 | } |
Logan Chien | 8342616 | 2011-12-09 09:29:50 +0800 | [diff] [blame] | 162 | |
| 163 | |
Logan Chien | 7f76761 | 2012-03-01 18:54:49 +0800 | [diff] [blame] | 164 | CompiledMethod* CompilerLLVM:: |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 165 | CompileNativeMethod(DexCompilationUnit* dex_compilation_unit) { |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 166 | UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit()); |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 167 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 168 | UniquePtr<JniCompiler> jni_compiler( |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 169 | new JniCompiler(cunit.get(), *compiler_driver_, dex_compilation_unit)); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 170 | |
Logan Chien | 7f76761 | 2012-03-01 18:54:49 +0800 | [diff] [blame] | 171 | return jni_compiler->Compile(); |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 175 | } // namespace llvm |
Logan Chien | 8342616 | 2011-12-09 09:29:50 +0800 | [diff] [blame] | 176 | } // namespace art |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 177 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 178 | inline static art::llvm::CompilerLLVM* ContextOf(art::CompilerDriver& driver) { |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 179 | void *compiler_context = driver.GetCompilerContext(); |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 180 | CHECK(compiler_context != NULL); |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 181 | return reinterpret_cast<art::llvm::CompilerLLVM*>(compiler_context); |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 182 | } |
| 183 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 184 | inline static const art::llvm::CompilerLLVM* ContextOf(const art::CompilerDriver& driver) { |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 185 | void *compiler_context = driver.GetCompilerContext(); |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 186 | CHECK(compiler_context != NULL); |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 187 | return reinterpret_cast<const art::llvm::CompilerLLVM*>(compiler_context); |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 188 | } |
| 189 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 190 | extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver) { |
| 191 | CHECK(driver.GetCompilerContext() == NULL); |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 192 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 193 | art::llvm::CompilerLLVM* compiler_llvm = new art::llvm::CompilerLLVM(&driver, |
| 194 | driver.GetInstructionSet()); |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 195 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 196 | driver.SetCompilerContext(compiler_llvm); |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 197 | } |
| 198 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 199 | extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver) { |
| 200 | delete ContextOf(driver); |
| 201 | driver.SetCompilerContext(NULL); |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 202 | } |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 203 | extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 204 | const art::DexFile::CodeItem* code_item, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 205 | uint32_t access_flags, |
| 206 | art::InvokeType invoke_type, |
Ian Rogers | fffdb02 | 2013-01-04 15:14:08 -0800 | [diff] [blame] | 207 | uint32_t class_def_idx, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 208 | uint32_t method_idx, |
Shih-wei Liao | cd05a62 | 2012-08-15 00:02:05 -0700 | [diff] [blame] | 209 | jobject class_loader, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 210 | const art::DexFile& dex_file) { |
Ian Rogers | fffdb02 | 2013-01-04 15:14:08 -0800 | [diff] [blame] | 211 | UNUSED(class_def_idx); // TODO: this is used with Compiler::RequiresConstructorBarrier. |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 212 | art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker(); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 213 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 214 | art::DexCompilationUnit dex_compilation_unit( |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 215 | NULL, class_loader, class_linker, dex_file, code_item, |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 216 | class_def_idx, method_idx, access_flags); |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 217 | art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver); |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 218 | art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&dex_compilation_unit, invoke_type); |
TDYa127 | 0200d07 | 2012-04-17 20:55:08 -0700 | [diff] [blame] | 219 | return result; |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 220 | } |
| 221 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 222 | extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver, |
Brian Carlstrom | 00bc1dc | 2013-02-01 15:56:27 -0800 | [diff] [blame] | 223 | uint32_t access_flags, uint32_t method_idx, |
| 224 | const art::DexFile& dex_file) { |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 225 | art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker(); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 226 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 227 | art::DexCompilationUnit dex_compilation_unit( |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 228 | NULL, NULL, class_linker, dex_file, NULL, |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 229 | 0, method_idx, access_flags); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 230 | |
Ian Rogers | 4c1c283 | 2013-03-04 18:30:13 -0800 | [diff] [blame] | 231 | art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver); |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 232 | art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&dex_compilation_unit); |
Elliott Hughes | 13b835a | 2012-03-13 19:45:22 -0700 | [diff] [blame] | 233 | return result; |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 234 | } |
| 235 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 236 | extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver, |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 237 | std::string const& filename) { |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 238 | ContextOf(driver)->SetBitcodeFileName(filename); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 239 | } |