Use ELF function index to distinguish generated functions.
We replaced LLVMLongName and LLVMStubName with ElfFuncName,
and we are using the simple name: Art0, Art1, ..., ArtN,
as the function name of every generated functions. This
gives us 3 benefits:
1. We can avoid the ambiguous function name returned by
LLVMLongName() in some special situation.
2. We don't need to have the art::Method object during
the executable linking procedure. Besides, this will
make bootstrapping easier.
3. Reduce the size of the ELF executable, since we don't
have to save a long function name, which usually contains
more than 30 characters.
Change-Id: Ib698062b272458e847ad5545d7acf33a4dc9eb85
diff --git a/src/compiler_llvm/jni_compiler.cc b/src/compiler_llvm/jni_compiler.cc
index 097c4f1..285caab 100644
--- a/src/compiler_llvm/jni_compiler.cc
+++ b/src/compiler_llvm/jni_compiler.cc
@@ -52,7 +52,8 @@
class_loader_(oat_compilation_unit->class_loader_),
dex_cache_(oat_compilation_unit->dex_cache_),
dex_file_(oat_compilation_unit->dex_file_),
- method_(dex_cache_->GetResolvedMethod(method_idx_)) {
+ method_(dex_cache_->GetResolvedMethod(method_idx_)),
+ elf_func_idx_(cunit_->AcquireUniqueElfFuncIndex()) {
// Check: Ensure that the method is resolved
CHECK_NE(method_, static_cast<art::Method*>(NULL));
@@ -289,13 +290,14 @@
llvm::verifyFunction(*func_, llvm::PrintMessageAction);
return new CompiledMethod(cunit_->GetInstructionSet(),
- cunit_->GetElfIndex());
+ cunit_->GetElfIndex(),
+ elf_func_idx_);
}
void JniCompiler::CreateFunction() {
// LLVM function name
- std::string func_name(LLVMLongName(method_));
+ std::string func_name(ElfFuncName(elf_func_idx_));
// Get function type
llvm::FunctionType* func_type =