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 | |
Elliott Hughes | 1aa246d | 2012-12-13 09:29:36 -0800 | [diff] [blame] | 19 | #include "base/stl_util.h" |
Shih-wei Liao | 26e9307 | 2012-05-30 19:13:08 -0700 | [diff] [blame] | 20 | #include "backend_options.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" |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 23 | #include "compiler.h" |
| 24 | #include "ir_builder.h" |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 25 | #include "jni_compiler.h" |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 26 | #include "llvm_compilation_unit.h" |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 27 | #include "oat_compilation_unit.h" |
Logan Chien | 0c717dd | 2012-03-28 18:31:07 +0800 | [diff] [blame] | 28 | #include "oat_file.h" |
TDYa127 | eead4ac | 2012-06-03 07:15:25 -0700 | [diff] [blame] | 29 | #include "stub_compiler.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> |
| 34 | #include <llvm/LinkAllVMCore.h> |
Logan Chien | 013b6f2 | 2012-03-02 17:20:33 +0800 | [diff] [blame] | 35 | #include <llvm/Support/ManagedStatic.h> |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 36 | #include <llvm/Support/TargetSelect.h> |
| 37 | #include <llvm/Support/Threading.h> |
| 38 | |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 39 | namespace art { |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame] | 40 | void CompileOneMethod(Compiler& compiler, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 41 | const CompilerBackend compilerBackend, |
| 42 | const DexFile::CodeItem* code_item, |
| 43 | uint32_t access_flags, InvokeType invoke_type, |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 44 | uint32_t class_def_idx, uint32_t method_idx, jobject class_loader, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 45 | const DexFile& dex_file, |
| 46 | LLVMInfo* llvm_info); |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 47 | } |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 48 | |
Logan Chien | 013b6f2 | 2012-03-02 17:20:33 +0800 | [diff] [blame] | 49 | namespace llvm { |
| 50 | extern bool TimePassesIsEnabled; |
| 51 | } |
| 52 | |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 53 | namespace { |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 54 | |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 55 | pthread_once_t llvm_initialized = PTHREAD_ONCE_INIT; |
| 56 | |
| 57 | void InitializeLLVM() { |
Logan Chien | c3f8fa5 | 2012-05-11 11:23:39 +0800 | [diff] [blame] | 58 | // Initialize LLVM internal data structure for multithreading |
| 59 | llvm::llvm_start_multithreaded(); |
| 60 | |
Logan Chien | 013b6f2 | 2012-03-02 17:20:33 +0800 | [diff] [blame] | 61 | // NOTE: Uncomment following line to show the time consumption of LLVM passes |
| 62 | //llvm::TimePassesIsEnabled = true; |
| 63 | |
Shih-wei Liao | 26e9307 | 2012-05-30 19:13:08 -0700 | [diff] [blame] | 64 | // Initialize LLVM target-specific options. |
| 65 | art::compiler_llvm::InitialBackendOptions(); |
Logan Chien | c3f8fa5 | 2012-05-11 11:23:39 +0800 | [diff] [blame] | 66 | |
Shih-wei Liao | 1335a95 | 2012-07-23 18:03:00 -0700 | [diff] [blame] | 67 | // Initialize LLVM target, MC subsystem, asm printer, and asm parser. |
| 68 | #if defined(ART_TARGET) |
| 69 | // Don't initialize all targets on device. Just initialize the device's native target |
| 70 | llvm::InitializeNativeTarget(); |
| 71 | llvm::InitializeNativeTargetAsmPrinter(); |
| 72 | llvm::InitializeNativeTargetAsmParser(); |
| 73 | #else |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 74 | llvm::InitializeAllTargets(); |
| 75 | llvm::InitializeAllTargetMCs(); |
| 76 | llvm::InitializeAllAsmPrinters(); |
| 77 | llvm::InitializeAllAsmParsers(); |
Shih-wei Liao | 1335a95 | 2012-07-23 18:03:00 -0700 | [diff] [blame] | 78 | #endif |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 79 | |
Logan Chien | dd7cf5b | 2012-03-01 12:55:19 +0800 | [diff] [blame] | 80 | // Initialize LLVM optimization passes |
| 81 | llvm::PassRegistry ®istry = *llvm::PassRegistry::getPassRegistry(); |
| 82 | |
| 83 | llvm::initializeCore(registry); |
| 84 | llvm::initializeScalarOpts(registry); |
| 85 | llvm::initializeIPO(registry); |
| 86 | llvm::initializeAnalysis(registry); |
| 87 | llvm::initializeIPA(registry); |
| 88 | llvm::initializeTransformUtils(registry); |
| 89 | llvm::initializeInstCombine(registry); |
| 90 | llvm::initializeInstrumentation(registry); |
| 91 | llvm::initializeTarget(registry); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 92 | } |
| 93 | |
Logan Chien | f130655 | 2012-03-16 11:17:53 +0800 | [diff] [blame] | 94 | // The Guard to Shutdown LLVM |
Logan Chien | aeb5303 | 2012-03-18 02:29:38 +0800 | [diff] [blame] | 95 | // llvm::llvm_shutdown_obj llvm_guard; |
| 96 | // TODO: We are commenting out this line because this will cause SEGV from |
| 97 | // time to time. |
| 98 | // Two reasons: (1) the order of the destruction of static objects, or |
| 99 | // (2) dlopen/dlclose side-effect on static objects. |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 100 | |
| 101 | } // anonymous namespace |
| 102 | |
| 103 | |
| 104 | namespace art { |
| 105 | namespace compiler_llvm { |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 106 | |
| 107 | |
Logan Chien | e75a8cc | 2012-02-24 12:26:43 +0800 | [diff] [blame] | 108 | llvm::Module* makeLLVMModuleContents(llvm::Module* module); |
Logan Chien | 42e0e15 | 2012-01-13 15:42:36 +0800 | [diff] [blame] | 109 | |
| 110 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 111 | CompilerLLVM::CompilerLLVM(Compiler* compiler, InstructionSet insn_set) |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 112 | : compiler_(compiler), insn_set_(insn_set), |
| 113 | num_cunits_lock_("compilation unit counter lock"), num_cunits_(0), |
| 114 | plt_(insn_set) { |
Shih-wei Liao | fc34adb | 2012-03-07 08:51:44 -0800 | [diff] [blame] | 115 | |
| 116 | // Initialize LLVM libraries |
| 117 | pthread_once(&llvm_initialized, InitializeLLVM); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | |
| 121 | CompilerLLVM::~CompilerLLVM() { |
| 122 | } |
| 123 | |
| 124 | |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 125 | LlvmCompilationUnit* CompilerLLVM::AllocateCompilationUnit() { |
Ian Rogers | 50b35e2 | 2012-10-04 10:09:15 -0700 | [diff] [blame] | 126 | MutexLock GUARD(Thread::Current(), num_cunits_lock_); |
Logan Chien | 69307df | 2013-01-28 09:14:36 +0800 | [diff] [blame] | 127 | LlvmCompilationUnit* cunit = new LlvmCompilationUnit(this, ++num_cunits_); |
TDYa127 | b672d1e | 2012-06-28 21:21:45 -0700 | [diff] [blame] | 128 | if (!bitcode_filename_.empty()) { |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 129 | cunit->SetBitcodeFileName(StringPrintf("%s-%zu", bitcode_filename_.c_str(), cunit->GetIndex())); |
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:: |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 136 | CompileDexMethod(OatCompilationUnit* oat_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 | |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 139 | std::string methodName(PrettyMethod(oat_compilation_unit->GetDexMethodIndex(), |
| 140 | *oat_compilation_unit->GetDexFile())); |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 141 | // TODO: consolidate ArtCompileMethods |
| 142 | CompileOneMethod(*compiler_, |
| 143 | kPortable, |
| 144 | oat_compilation_unit->GetCodeItem(), |
| 145 | oat_compilation_unit->access_flags_, |
| 146 | invoke_type, |
| 147 | oat_compilation_unit->GetClassDefIndex(), |
| 148 | oat_compilation_unit->GetDexMethodIndex(), |
| 149 | oat_compilation_unit->GetClassLoader(), |
| 150 | *oat_compilation_unit->GetDexFile(), |
| 151 | cunit->GetQuickContext() |
| 152 | ); |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 153 | |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 154 | cunit->SetCompiler(compiler_); |
| 155 | cunit->SetOatCompilationUnit(oat_compilation_unit); |
buzbee | 26f10ee | 2012-12-21 11:16:29 -0800 | [diff] [blame] | 156 | |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 157 | cunit->Materialize(); |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 158 | |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 159 | Compiler::MethodReference mref(oat_compilation_unit->GetDexFile(), |
| 160 | oat_compilation_unit->GetDexMethodIndex()); |
| 161 | return new CompiledMethod(compiler_->GetInstructionSet(), |
| 162 | cunit->GetCompiledCode(), |
| 163 | *verifier::MethodVerifier::GetDexGcMap(mref)); |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 164 | } |
Logan Chien | 8342616 | 2011-12-09 09:29:50 +0800 | [diff] [blame] | 165 | |
| 166 | |
Logan Chien | 7f76761 | 2012-03-01 18:54:49 +0800 | [diff] [blame] | 167 | CompiledMethod* CompilerLLVM:: |
| 168 | CompileNativeMethod(OatCompilationUnit* oat_compilation_unit) { |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 169 | UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit()); |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 170 | |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 171 | UniquePtr<JniCompiler> jni_compiler( |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 172 | new JniCompiler(cunit.get(), *compiler_, oat_compilation_unit)); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 173 | |
Logan Chien | 7f76761 | 2012-03-01 18:54:49 +0800 | [diff] [blame] | 174 | return jni_compiler->Compile(); |
Logan Chien | 88894ee | 2012-02-13 16:42:22 +0800 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | |
Logan Chien | f04364f | 2012-02-10 12:01:39 +0800 | [diff] [blame] | 178 | CompiledInvokeStub* CompilerLLVM::CreateInvokeStub(bool is_static, |
| 179 | char const *shorty) { |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 180 | UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit()); |
Logan Chien | 8ba2fc5 | 2012-04-23 09:10:46 +0800 | [diff] [blame] | 181 | |
TDYa127 | eead4ac | 2012-06-03 07:15:25 -0700 | [diff] [blame] | 182 | UniquePtr<StubCompiler> stub_compiler( |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 183 | new StubCompiler(cunit.get(), *compiler_)); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 184 | |
Logan Chien | 7a2a23a | 2012-06-06 11:01:00 +0800 | [diff] [blame] | 185 | return stub_compiler->CreateInvokeStub(is_static, shorty); |
| 186 | } |
TDYa127 | eead4ac | 2012-06-03 07:15:25 -0700 | [diff] [blame] | 187 | |
TDYa127 | eead4ac | 2012-06-03 07:15:25 -0700 | [diff] [blame] | 188 | |
Logan Chien | 7a2a23a | 2012-06-06 11:01:00 +0800 | [diff] [blame] | 189 | CompiledInvokeStub* CompilerLLVM::CreateProxyStub(char const *shorty) { |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 190 | UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit()); |
Logan Chien | 7a2a23a | 2012-06-06 11:01:00 +0800 | [diff] [blame] | 191 | |
| 192 | UniquePtr<StubCompiler> stub_compiler( |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 193 | new StubCompiler(cunit.get(), *compiler_)); |
Logan Chien | 7a2a23a | 2012-06-06 11:01:00 +0800 | [diff] [blame] | 194 | |
| 195 | return stub_compiler->CreateProxyStub(shorty); |
Logan Chien | f04364f | 2012-02-10 12:01:39 +0800 | [diff] [blame] | 196 | } |
| 197 | |
Logan Chien | 8342616 | 2011-12-09 09:29:50 +0800 | [diff] [blame] | 198 | } // namespace compiler_llvm |
| 199 | } // namespace art |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 200 | |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 201 | inline static art::compiler_llvm::CompilerLLVM* ContextOf(art::Compiler& compiler) { |
| 202 | void *compiler_context = compiler.GetCompilerContext(); |
| 203 | CHECK(compiler_context != NULL); |
| 204 | return reinterpret_cast<art::compiler_llvm::CompilerLLVM*>(compiler_context); |
| 205 | } |
| 206 | |
| 207 | inline static const art::compiler_llvm::CompilerLLVM* ContextOf(const art::Compiler& compiler) { |
| 208 | void *compiler_context = compiler.GetCompilerContext(); |
| 209 | CHECK(compiler_context != NULL); |
| 210 | return reinterpret_cast<const art::compiler_llvm::CompilerLLVM*>(compiler_context); |
| 211 | } |
| 212 | |
| 213 | extern "C" void ArtInitCompilerContext(art::Compiler& compiler) { |
| 214 | CHECK(compiler.GetCompilerContext() == NULL); |
| 215 | |
| 216 | art::compiler_llvm::CompilerLLVM* compiler_llvm = |
| 217 | new art::compiler_llvm::CompilerLLVM(&compiler, |
| 218 | compiler.GetInstructionSet()); |
| 219 | |
| 220 | compiler.SetCompilerContext(compiler_llvm); |
| 221 | } |
| 222 | |
Logan Chien | 971bf3f | 2012-05-01 15:47:55 +0800 | [diff] [blame] | 223 | extern "C" void ArtUnInitCompilerContext(art::Compiler& compiler) { |
| 224 | delete ContextOf(compiler); |
| 225 | compiler.SetCompilerContext(NULL); |
| 226 | } |
Elliott Hughes | 3fa1b7e | 2012-03-13 17:06:22 -0700 | [diff] [blame] | 227 | extern "C" art::CompiledMethod* ArtCompileMethod(art::Compiler& compiler, |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 228 | const art::DexFile::CodeItem* code_item, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 229 | uint32_t access_flags, |
| 230 | art::InvokeType invoke_type, |
Ian Rogers | fffdb02 | 2013-01-04 15:14:08 -0800 | [diff] [blame] | 231 | uint32_t class_def_idx, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 232 | uint32_t method_idx, |
Shih-wei Liao | cd05a62 | 2012-08-15 00:02:05 -0700 | [diff] [blame] | 233 | jobject class_loader, |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 234 | const art::DexFile& dex_file) { |
Ian Rogers | fffdb02 | 2013-01-04 15:14:08 -0800 | [diff] [blame] | 235 | UNUSED(class_def_idx); // TODO: this is used with Compiler::RequiresConstructorBarrier. |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 236 | art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker(); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 237 | |
| 238 | art::OatCompilationUnit oat_compilation_unit( |
Shih-wei Liao | cd05a62 | 2012-08-15 00:02:05 -0700 | [diff] [blame] | 239 | class_loader, class_linker, dex_file, code_item, |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 240 | class_def_idx, method_idx, access_flags); |
TDYa127 | 0200d07 | 2012-04-17 20:55:08 -0700 | [diff] [blame] | 241 | art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler); |
Shih-wei Liao | bb33f2f | 2012-08-23 13:20:00 -0700 | [diff] [blame] | 242 | art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&oat_compilation_unit, invoke_type); |
TDYa127 | 0200d07 | 2012-04-17 20:55:08 -0700 | [diff] [blame] | 243 | return result; |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Brian Carlstrom | 00bc1dc | 2013-02-01 15:56:27 -0800 | [diff] [blame] | 246 | extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::Compiler& compiler, |
| 247 | uint32_t access_flags, uint32_t method_idx, |
| 248 | const art::DexFile& dex_file) { |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 249 | art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker(); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 250 | |
| 251 | art::OatCompilationUnit oat_compilation_unit( |
Shih-wei Liao | cd05a62 | 2012-08-15 00:02:05 -0700 | [diff] [blame] | 252 | NULL, class_linker, dex_file, NULL, |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 253 | 0, method_idx, access_flags); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 254 | |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 255 | art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler); |
Elliott Hughes | 6f4976c | 2012-03-13 21:19:01 -0700 | [diff] [blame] | 256 | art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&oat_compilation_unit); |
Elliott Hughes | 13b835a | 2012-03-13 19:45:22 -0700 | [diff] [blame] | 257 | return result; |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 258 | } |
| 259 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 260 | extern "C" art::CompiledInvokeStub* ArtCreateLLVMInvokeStub(art::Compiler& compiler, |
| 261 | bool is_static, |
| 262 | const char* shorty, |
| 263 | uint32_t shorty_len) { |
TDYa127 | 0200d07 | 2012-04-17 20:55:08 -0700 | [diff] [blame] | 264 | art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler); |
| 265 | art::CompiledInvokeStub* result = compiler_llvm->CreateInvokeStub(is_static, shorty); |
TDYa127 | 0200d07 | 2012-04-17 20:55:08 -0700 | [diff] [blame] | 266 | return result; |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 267 | } |
| 268 | |
Logan Chien | 7a2a23a | 2012-06-06 11:01:00 +0800 | [diff] [blame] | 269 | extern "C" art::CompiledInvokeStub* ArtCreateProxyStub(art::Compiler& compiler, |
| 270 | const char* shorty, |
| 271 | uint32_t shorty_len) { |
| 272 | art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler); |
| 273 | art::CompiledInvokeStub* result = compiler_llvm->CreateProxyStub(shorty); |
Logan Chien | 7a2a23a | 2012-06-06 11:01:00 +0800 | [diff] [blame] | 274 | return result; |
| 275 | } |
| 276 | |
Logan Chien | 106b2a0 | 2012-03-18 04:41:38 +0800 | [diff] [blame] | 277 | extern "C" void compilerLLVMSetBitcodeFileName(art::Compiler& compiler, |
| 278 | std::string const& filename) { |
| 279 | ContextOf(compiler)->SetBitcodeFileName(filename); |
Shih-wei Liao | c4c9881 | 2012-03-10 21:55:51 -0800 | [diff] [blame] | 280 | } |