Fix perf-inject jit profiling for osr method.

When OSR jit compilation is triggered, the jit compiler should log osr compiled
method address for perf.

Test: Compile.
Test: Verified perf-PID.map and jit-PID.dump files generated by ART JIT with -g option.

Change-Id: I66ca62c65ee84067aeaf551be05911def78f9aaf
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index 148ce4f..88bdb0d 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -211,7 +211,7 @@
     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);
+      jit_logger_->WriteLog(code_cache, method, osr);
     }
   }
 
diff --git a/compiler/jit/jit_logger.cc b/compiler/jit/jit_logger.cc
index 9ce3b0c..aa4f667 100644
--- a/compiler/jit/jit_logger.cc
+++ b/compiler/jit/jit_logger.cc
@@ -23,6 +23,7 @@
 #include "driver/compiler_driver.h"
 #include "jit/jit.h"
 #include "jit/jit_code_cache.h"
+#include "oat_file-inl.h"
 
 namespace art {
 namespace jit {
@@ -49,9 +50,10 @@
   }
 }
 
-void JitLogger::WritePerfMapLog(JitCodeCache* code_cache, ArtMethod* method) {
+void JitLogger::WritePerfMapLog(JitCodeCache* code_cache, ArtMethod* method, bool osr) {
   if (perf_file_ != nullptr) {
-    const void* ptr = method->GetEntryPointFromQuickCompiledCode();
+    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();
 
@@ -268,9 +270,10 @@
   WriteJitDumpHeader();
 }
 
-void JitLogger::WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method) {
+void JitLogger::WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method, bool osr) {
   if (jit_dump_file_ != nullptr) {
-    const void* code = method->GetEntryPointFromQuickCompiledCode();
+    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();
 
diff --git a/compiler/jit/jit_logger.h b/compiler/jit/jit_logger.h
index 0f8cfe4..460864e 100644
--- a/compiler/jit/jit_logger.h
+++ b/compiler/jit/jit_logger.h
@@ -94,10 +94,10 @@
       OpenJitDumpLog();
     }
 
-    void WriteLog(JitCodeCache* code_cache, ArtMethod* method)
+    void WriteLog(JitCodeCache* code_cache, ArtMethod* method, bool osr)
         REQUIRES_SHARED(Locks::mutator_lock_) {
-      WritePerfMapLog(code_cache, method);
-      WriteJitDumpLog(code_cache, method);
+      WritePerfMapLog(code_cache, method, osr);
+      WriteJitDumpLog(code_cache, method, osr);
     }
 
     void CloseLog() {
@@ -108,13 +108,13 @@
   private:
     // For perf-map profiling
     void OpenPerfMapLog();
-    void WritePerfMapLog(JitCodeCache* code_cache, ArtMethod* method)
+    void WritePerfMapLog(JitCodeCache* code_cache, ArtMethod* method, bool osr)
         REQUIRES_SHARED(Locks::mutator_lock_);
     void ClosePerfMapLog();
 
     // For perf-inject profiling
     void OpenJitDumpLog();
-    void WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method)
+    void WriteJitDumpLog(JitCodeCache* code_cache, ArtMethod* method, bool osr)
         REQUIRES_SHARED(Locks::mutator_lock_);
     void CloseJitDumpLog();