summaryrefslogtreecommitdiff
path: root/src/compiler_llvm/compiler_llvm.cc
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-03-13 21:19:01 -0700
committer Elliott Hughes <enh@google.com> 2012-03-14 11:27:16 -0700
commit6f4976c1a9fdaf108974143cd11e6b46037fd24e (patch)
treef0c21b703eab0039f5c31e1b272144c5228b8fa3 /src/compiler_llvm/compiler_llvm.cc
parent13b835a45f3dccff1c6d024ad82a2044831c7c41 (diff)
Replace some LLVM-specific code with something more general.
This basically gives any compiler a place to hang extra private data off art::Compiler, even though only LLVM needs it right now. Change-Id: I408778ea1010ab2ad9ec4810e5c53d468a8772c2
Diffstat (limited to 'src/compiler_llvm/compiler_llvm.cc')
-rw-r--r--src/compiler_llvm/compiler_llvm.cc43
1 files changed, 15 insertions, 28 deletions
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index 5ef171088d..dc3b7cbcf2 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -206,23 +206,18 @@ CompiledInvokeStub* CompilerLLVM::CreateInvokeStub(bool is_static,
return upcall_compiler->CreateStub(is_static, shorty);
}
-
-} // namespace compiler_llvm
-} // namespace art
-
-namespace {
-
-void ensureCompilerLLVM(art::Compiler& compiler) {
- if (compiler.GetCompilerLLVM() == NULL) {
- compiler.SetCompilerLLVM(new art::compiler_llvm::CompilerLLVM(&compiler,
- compiler.GetInstructionSet()));
+CompilerLLVM* EnsureCompilerLLVM(art::Compiler& compiler) {
+ if (compiler.GetCompilerContext() == NULL) {
+ compiler.SetCompilerContext(new CompilerLLVM(&compiler, compiler.GetInstructionSet()));
}
- art::compiler_llvm::CompilerLLVM* compiler_llvm = compiler.GetCompilerLLVM();
+ CompilerLLVM* compiler_llvm = reinterpret_cast<CompilerLLVM*>(compiler.GetCompilerContext());
compiler_llvm->SetElfFileName(compiler.GetElfFileName());
compiler_llvm->SetBitcodeFileName(compiler.GetBitcodeFileName());
+ return compiler_llvm;
}
-} // anonymous namespace
+} // namespace compiler_llvm
+} // namespace art
extern "C" art::CompiledMethod* ArtCompileMethod(art::Compiler& compiler,
const art::DexFile::CodeItem* code_item,
@@ -230,8 +225,6 @@ extern "C" art::CompiledMethod* ArtCompileMethod(art::Compiler& compiler,
const art::ClassLoader* class_loader,
const art::DexFile& dex_file)
{
- ensureCompilerLLVM(compiler);
-
art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker();
art::DexCache *dex_cache = class_linker->FindDexCache(dex_file);
@@ -239,15 +232,13 @@ extern "C" art::CompiledMethod* ArtCompileMethod(art::Compiler& compiler,
class_loader, class_linker, dex_file, *dex_cache, code_item,
method_idx, access_flags);
- return compiler.GetCompilerLLVM()->CompileDexMethod(&oat_compilation_unit);
+ return art::compiler_llvm::EnsureCompilerLLVM(compiler)->CompileDexMethod(&oat_compilation_unit);
}
extern "C" art::CompiledMethod* ArtJniCompileMethod(art::Compiler& compiler,
uint32_t access_flags, uint32_t method_idx,
const art::ClassLoader* class_loader,
const art::DexFile& dex_file) {
- ensureCompilerLLVM(compiler);
-
art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker();
art::DexCache *dex_cache = class_linker->FindDexCache(dex_file);
@@ -255,30 +246,26 @@ extern "C" art::CompiledMethod* ArtJniCompileMethod(art::Compiler& compiler,
class_loader, class_linker, dex_file, *dex_cache, NULL,
method_idx, access_flags);
- art::CompiledMethod* result =
- compiler.GetCompilerLLVM()->CompileNativeMethod(&oat_compilation_unit);
- compiler.GetCompilerLLVM()->MaterializeIfThresholdReached();
+ art::compiler_llvm::CompilerLLVM* compiler_llvm = art::compiler_llvm::EnsureCompilerLLVM(compiler);
+ art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&oat_compilation_unit);
+ compiler_llvm->MaterializeIfThresholdReached();
return result;
}
extern "C" art::CompiledInvokeStub* ArtCreateInvokeStub(art::Compiler& compiler, bool is_static,
const char* shorty, uint32_t shorty_len) {
- ensureCompilerLLVM(compiler);
- //shorty_len = 0; // To make the compiler happy
- return compiler.GetCompilerLLVM()->CreateInvokeStub(is_static, shorty);
+ return art::compiler_llvm::EnsureCompilerLLVM(compiler)->CreateInvokeStub(is_static, shorty);
}
extern "C" void compilerLLVMMaterializeRemainder(art::Compiler& compiler) {
- ensureCompilerLLVM(compiler);
- compiler.GetCompilerLLVM()->MaterializeRemainder();
+ art::compiler_llvm::EnsureCompilerLLVM(compiler)->MaterializeRemainder();
}
// Note: Using this function carefully!!! This is temporary solution, we will remove it.
extern "C" art::MutexLock* compilerLLVMMutexLock(art::Compiler& compiler) {
- ensureCompilerLLVM(compiler);
- return new art::MutexLock(compiler.GetCompilerLLVM()->compiler_lock_);
+ return new art::MutexLock(art::compiler_llvm::EnsureCompilerLLVM(compiler)->compiler_lock_);
}
extern "C" void compilerLLVMDispose(art::Compiler& compiler) {
- delete compiler.GetCompilerLLVM();
+ delete art::compiler_llvm::EnsureCompilerLLVM(compiler);
}