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/upcall_compiler.cc b/src/compiler_llvm/upcall_compiler.cc
index 20bd94b..85bfe24 100644
--- a/src/compiler_llvm/upcall_compiler.cc
+++ b/src/compiler_llvm/upcall_compiler.cc
@@ -24,6 +24,7 @@
#include "logging.h"
#include "object.h"
#include "runtime_support_func.h"
+#include "utils_llvm.h"
#include <llvm/Analysis/Verifier.h>
#include <llvm/BasicBlock.h>
@@ -42,7 +43,8 @@
UpcallCompiler::UpcallCompiler(CompilationUnit* cunit, Compiler& compiler)
: cunit_(cunit), compiler_(&compiler), module_(cunit_->GetModule()),
- context_(cunit_->GetLLVMContext()), irb_(*cunit_->GetIRBuilder()) {
+ context_(cunit_->GetLLVMContext()), irb_(*cunit_->GetIRBuilder()),
+ elf_func_idx_(cunit_->AcquireUniqueElfFuncIndex()) {
}
@@ -53,13 +55,7 @@
size_t shorty_size = strlen(shorty);
// Function name
- std::string func_name;
-
- if (is_static) {
- StringAppendF(&func_name, "ArtSUpcall_%s", shorty);
- } else {
- StringAppendF(&func_name, "ArtUpcall_%s", shorty);
- }
+ std::string func_name(ElfFuncName(elf_func_idx_));
// Get argument types
llvm::Type* arg_types[] = {
@@ -179,7 +175,7 @@
// store ret_addr, and ret_void. Beside, we guess that we have to use
// 50 bytes to represent one LLVM instruction.
- return new CompiledInvokeStub(cunit_->GetElfIndex());
+ return new CompiledInvokeStub(cunit_->GetElfIndex(), elf_func_idx_);
}