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