diff options
author | 2017-07-19 15:05:49 +0100 | |
---|---|---|
committer | 2017-07-19 15:05:49 +0100 | |
commit | 01db5f78f627cc64f80b0c0a4eedd0a3dc8b46ca (patch) | |
tree | d1ee9267408e2f4d777d28bfc3f65c480f7ecd3f | |
parent | c5b1b067fb91c10c75dd0e6dbfd91bebe74347d5 (diff) |
Pass the logger to the JIT compiler.
To avoid effects of concurrent method entrypoints update,
just pass the logger to the JIT compiler, which will invoke
it directly with the pointer to the newly allocated code.
Test: test.py --trace
Change-Id: I5fbcd7cbc948b7d46c98c1545d6e530fb1190602
-rw-r--r-- | compiler/compiler.h | 4 | ||||
-rw-r--r-- | compiler/jit/jit_compiler.cc | 6 | ||||
-rw-r--r-- | compiler/jit/jit_logger.cc | 14 | ||||
-rw-r--r-- | compiler/jit/jit_logger.h | 10 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 13 |
5 files changed, 25 insertions, 22 deletions
diff --git a/compiler/compiler.h b/compiler/compiler.h index cd4c59101e..ba89cb1aed 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -25,6 +25,7 @@ namespace art { namespace jit { class JitCodeCache; + class JitLogger; } // namespace jit namespace mirror { class ClassLoader; @@ -76,7 +77,8 @@ class Compiler { virtual bool JitCompile(Thread* self ATTRIBUTE_UNUSED, jit::JitCodeCache* code_cache ATTRIBUTE_UNUSED, ArtMethod* method ATTRIBUTE_UNUSED, - bool osr ATTRIBUTE_UNUSED) + bool osr ATTRIBUTE_UNUSED, + jit::JitLogger* jit_logger ATTRIBUTE_UNUSED) REQUIRES_SHARED(Locks::mutator_lock_) { return false; } diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index 28a3f1edae..5fdf9ff07c 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -184,10 +184,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 && (jit_logger_ != nullptr)) { - jit_logger_->WriteLog(code_cache, method, osr); - } + success = compiler_driver_->GetCompiler()->JitCompile( + self, code_cache, method, osr, jit_logger_.get()); } // Trim maps to reduce memory usage. diff --git a/compiler/jit/jit_logger.cc b/compiler/jit/jit_logger.cc index aa4f66773a..2199b64139 100644 --- a/compiler/jit/jit_logger.cc +++ b/compiler/jit/jit_logger.cc @@ -50,11 +50,8 @@ void JitLogger::OpenPerfMapLog() { } } -void JitLogger::WritePerfMapLog(JitCodeCache* code_cache, ArtMethod* method, bool osr) { +void JitLogger::WritePerfMapLog(const void* ptr, size_t code_size, ArtMethod* method) { if (perf_file_ != nullptr) { - const void* ptr = osr ? code_cache->LookupOsrMethodHeader(method)->GetCode() - : method->GetEntryPointFromQuickCompiledCode(); - size_t code_size = code_cache->GetMemorySizeOfCodePointer(ptr); std::string method_name = method->PrettyMethod(); std::ostringstream stream; @@ -270,11 +267,8 @@ void JitLogger::OpenJitDumpLog() { WriteJitDumpHeader(); } -void JitLogger::WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method, bool osr) { +void JitLogger::WriteJitDumpLog(const void* ptr, size_t code_size, ArtMethod* method) { if (jit_dump_file_ != nullptr) { - const void* code = osr ? code_cache->LookupOsrMethodHeader(method)->GetCode() - : method->GetEntryPointFromQuickCompiledCode(); - size_t code_size = code_cache->GetMemorySizeOfCodePointer(code); std::string method_name = method->PrettyMethod(); PerfJitCodeLoad jit_code; @@ -285,7 +279,7 @@ void JitLogger::WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method, boo jit_code.process_id_ = static_cast<uint32_t>(getpid()); jit_code.thread_id_ = static_cast<uint32_t>(art::GetTid()); jit_code.vma_ = 0x0; - jit_code.code_address_ = reinterpret_cast<uint64_t>(code); + jit_code.code_address_ = reinterpret_cast<uint64_t>(ptr); jit_code.code_size_ = code_size; jit_code.code_id_ = code_index_++; @@ -297,7 +291,7 @@ void JitLogger::WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method, boo // Use UNUSED() here to avoid compiler warnings. UNUSED(jit_dump_file_->WriteFully(reinterpret_cast<const char*>(&jit_code), sizeof(jit_code))); UNUSED(jit_dump_file_->WriteFully(method_name.c_str(), method_name.size() + 1)); - UNUSED(jit_dump_file_->WriteFully(code, code_size)); + UNUSED(jit_dump_file_->WriteFully(ptr, code_size)); WriteJitDumpDebugInfo(); } diff --git a/compiler/jit/jit_logger.h b/compiler/jit/jit_logger.h index 460864e8a9..19be9aa88e 100644 --- a/compiler/jit/jit_logger.h +++ b/compiler/jit/jit_logger.h @@ -94,10 +94,10 @@ class JitLogger { OpenJitDumpLog(); } - void WriteLog(JitCodeCache* code_cache, ArtMethod* method, bool osr) + void WriteLog(const void* ptr, size_t code_size, ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_) { - WritePerfMapLog(code_cache, method, osr); - WriteJitDumpLog(code_cache, method, osr); + WritePerfMapLog(ptr, code_size, method); + WriteJitDumpLog(ptr, code_size, method); } void CloseLog() { @@ -108,13 +108,13 @@ class JitLogger { private: // For perf-map profiling void OpenPerfMapLog(); - void WritePerfMapLog(JitCodeCache* code_cache, ArtMethod* method, bool osr) + void WritePerfMapLog(const void* ptr, size_t code_size, ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); void ClosePerfMapLog(); // For perf-inject profiling void OpenJitDumpLog(); - void WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method, bool osr) + void WriteJitDumpLog(const void* ptr, size_t code_size, ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); void CloseJitDumpLog(); diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 890ba674b5..b76a0df861 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -76,6 +76,7 @@ #include "jit/debugger_interface.h" #include "jit/jit.h" #include "jit/jit_code_cache.h" +#include "jit/jit_logger.h" #include "jni/quick/jni_compiler.h" #include "licm.h" #include "load_store_analysis.h" @@ -334,7 +335,11 @@ class OptimizingCompiler FINAL : public Compiler { } } - bool JitCompile(Thread* self, jit::JitCodeCache* code_cache, ArtMethod* method, bool osr) + bool JitCompile(Thread* self, + jit::JitCodeCache* code_cache, + ArtMethod* method, + bool osr, + jit::JitLogger* jit_logger) OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_); @@ -1136,7 +1141,8 @@ bool CanEncodeInlinedMethodInStackMap(const DexFile& caller_dex_file, ArtMethod* bool OptimizingCompiler::JitCompile(Thread* self, jit::JitCodeCache* code_cache, ArtMethod* method, - bool osr) { + bool osr, + jit::JitLogger* jit_logger) { StackHandleScope<3> hs(self); Handle<mirror::ClassLoader> class_loader(hs.NewHandle( method->GetDeclaringClass()->GetClassLoader())); @@ -1272,6 +1278,9 @@ bool OptimizingCompiler::JitCompile(Thread* self, } Runtime::Current()->GetJit()->AddMemoryUsage(method, arena.BytesUsed()); + if (jit_logger != nullptr) { + jit_logger->WriteLog(code, code_allocator.GetSize(), method); + } return true; } |