summaryrefslogtreecommitdiff
path: root/compiler/jit/jit_compiler.cc
diff options
context:
space:
mode:
author xueliang.zhong <xueliang.zhong@linaro.org> 2016-10-04 11:19:17 +0100
committer xueliang.zhong <xueliang.zhong@linaro.org> 2016-10-27 11:09:18 +0100
commit383b57d985adadc4cbccb4a62a0ef6afd243e511 (patch)
tree7d806c8b531b8e9f91c2d52b06ccbf16e10ac04e /compiler/jit/jit_compiler.cc
parent2f2533f686f759ccd29d2712da2c7610382fb59f (diff)
ART jitted code profiling support.
- Generate perf map for method level profiling. - Generate jit dump for instruction level profiling. Command line example of perf map approach: $ perf record dalvikvm -Xcompiler-option -g -cp <classpath> MyClass $ perf report Command line example of perf jit dump approach: $ perf record -k mono dalvikvm -Xcompiler-option -g -cp <classpath> MyClass $ perf inject -i perf.data -o perf.data.jitted $ perf report -i perf.data.jitted $ perf annotate -i perf.data.jitted NOTE: 4.1 or newer kernel is needed for this jit dump analysis. Test: Compile. Test: Verified that perf-PID.map and jit-PID.dump files are only generated when running ART JIT with -g option. Tested on aosp_angler-userdebug and hikey-userdebug devices. The file formats are correct. Change-Id: I1bd3ce280f953811d3dfcc27dc8e59b3e1f481aa
Diffstat (limited to 'compiler/jit/jit_compiler.cc')
-rw-r--r--compiler/jit/jit_compiler.cc33
1 files changed, 6 insertions, 27 deletions
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index c398703bb8..64aaabdeb0 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -171,19 +171,10 @@ JitCompiler::JitCompiler() {
size_t thread_count = compiler_driver_->GetThreadCount();
if (compiler_options_->GetGenerateDebugInfo()) {
-#ifdef ART_TARGET_ANDROID
- const char* prefix = "/data/misc/trace";
-#else
- const char* prefix = "/tmp";
-#endif
DCHECK_EQ(thread_count, 1u)
<< "Generating debug info only works with one compiler thread";
- std::string perf_filename = std::string(prefix) + "/perf-" + std::to_string(getpid()) + ".map";
- perf_file_.reset(OS::CreateEmptyFileWriteOnly(perf_filename.c_str()));
- if (perf_file_ == nullptr) {
- LOG(ERROR) << "Could not create perf file at " << perf_filename <<
- " Are you on a user build? Perf only works on userdebug/eng builds";
- }
+ jit_logger_.reset(new JitLogger());
+ jit_logger_->OpenLog();
}
size_t inline_depth_limit = compiler_driver_->GetCompilerOptions().GetInlineDepthLimit();
@@ -192,9 +183,8 @@ JitCompiler::JitCompiler() {
}
JitCompiler::~JitCompiler() {
- if (perf_file_ != nullptr) {
- UNUSED(perf_file_->Flush());
- UNUSED(perf_file_->Close());
+ if (compiler_options_->GetGenerateDebugInfo()) {
+ jit_logger_->CloseLog();
}
}
@@ -218,19 +208,8 @@ bool JitCompiler::CompileMethod(Thread* self, ArtMethod* method, bool osr) {
TimingLogger::ScopedTiming t2("Compiling", &logger);
JitCodeCache* const code_cache = runtime->GetJit()->GetCodeCache();
success = compiler_driver_->GetCompiler()->JitCompile(self, code_cache, method, osr);
- if (success && (perf_file_ != nullptr)) {
- const void* ptr = method->GetEntryPointFromQuickCompiledCode();
- std::ostringstream stream;
- stream << std::hex
- << reinterpret_cast<uintptr_t>(ptr)
- << " "
- << code_cache->GetMemorySizeOfCodePointer(ptr)
- << " "
- << method->PrettyMethod()
- << std::endl;
- std::string str = stream.str();
- bool res = perf_file_->WriteFully(str.c_str(), str.size());
- CHECK(res);
+ if (success && (jit_logger_ != nullptr)) {
+ jit_logger_->WriteLog(code_cache, method);
}
}