Compilation_unit experiment. Fix because of no long_call.
Change-Id: Id8ab9c50317ade34f80be6e72784db00c0b23f6b
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index 443950d..8945210 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -318,8 +318,10 @@
art::OatCompilationUnit oat_compilation_unit(
class_loader, class_linker, dex_file, *dex_cache, code_item,
method_idx, access_flags);
-
- return ContextOf(compiler)->CompileDexMethod(&oat_compilation_unit);
+ art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
+ art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&oat_compilation_unit);
+ compiler_llvm->MaterializeIfThresholdReached();
+ return result;
}
extern "C" art::CompiledMethod* ArtJniCompileMethod(art::Compiler& compiler,
@@ -340,7 +342,10 @@
extern "C" art::CompiledInvokeStub* ArtCreateInvokeStub(art::Compiler& compiler, bool is_static,
const char* shorty, uint32_t shorty_len) {
- return ContextOf(compiler)->CreateInvokeStub(is_static, shorty);
+ art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
+ art::CompiledInvokeStub* result = compiler_llvm->CreateInvokeStub(is_static, shorty);
+ compiler_llvm->MaterializeIfThresholdReached();
+ return result;
}
extern "C" void compilerLLVMSetBitcodeFileName(art::Compiler& compiler,
diff --git a/src/compiler_llvm/jni_compiler.cc b/src/compiler_llvm/jni_compiler.cc
index 7855be0..198cd1a 100644
--- a/src/compiler_llvm/jni_compiler.cc
+++ b/src/compiler_llvm/jni_compiler.cc
@@ -296,6 +296,12 @@
// Verify the generated bitcode
llvm::verifyFunction(*func_, llvm::PrintMessageAction);
+ // Add the memory usage approximation of the compilation unit
+ cunit_->AddMemUsageApproximation((sirt_size * 4 + 50) * 50);
+ // NOTE: We will emit 4 LLVM instructions per object argument,
+ // And about 50 instructions for other operations. (Some runtime support will be inlined.)
+ // Beside, we guess that we have to use 50 bytes to represent one LLVM instruction.
+
CompiledMethod* compiled_method =
new CompiledMethod(cunit_->GetInstructionSet(),
cunit_->GetElfIndex(),
diff --git a/src/compiler_llvm/upcall_compiler.cc b/src/compiler_llvm/upcall_compiler.cc
index 691d7e5..4b99cf7 100644
--- a/src/compiler_llvm/upcall_compiler.cc
+++ b/src/compiler_llvm/upcall_compiler.cc
@@ -184,7 +184,7 @@
llvm::verifyFunction(*func, llvm::PrintMessageAction);
// Add the memory usage approximation of the compilation unit
- cunit_->AddMemUsageApproximation((shorty_size * 3 + 8) * 500);
+ cunit_->AddMemUsageApproximation((shorty_size * 3 + 8) * 50);
// NOTE: We will emit 3 LLVM instructions per shorty for the argument,
// plus 3 for pointer arithmetic, and 5 for code_addr, retval, ret_addr,
// store ret_addr, and ret_void. Beside, we guess that we have to use