8172285: UL support for PrintCompilation
authorysuenaga
Tue, 14 Feb 2017 20:00:28 -0800
changeset 46270 2e7898927798
parent 46269 7e725659ea12
child 46271 979ebd346ecf
8172285: UL support for PrintCompilation Reviewed-by: kvn
hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
hotspot/src/share/vm/code/nmethod.cpp
hotspot/src/share/vm/compiler/compileBroker.cpp
hotspot/src/share/vm/compiler/compileTask.hpp
hotspot/src/share/vm/logging/logTag.hpp
hotspot/src/share/vm/opto/bytecodeInfo.cpp
hotspot/src/share/vm/opto/library_call.cpp
hotspot/src/share/vm/runtime/sharedRuntime.cpp
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Tue Feb 14 20:00:28 2017 -0800
@@ -4289,6 +4289,8 @@
   }
 #endif // INCLUDE_TRACE
 
+  CompileTask::print_inlining_ul(callee, scope()->level(), bci(), msg);
+
   if (!compilation()->directive()->PrintInliningOption) {
     return;
   }
--- a/hotspot/src/share/vm/code/nmethod.cpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Tue Feb 14 20:00:28 2017 -0800
@@ -1134,8 +1134,11 @@
       xtty->end_elem();
     }
   }
+
+  const char *state_msg = _state == zombie ? "made zombie" : "made not entrant";
+  CompileTask::print_ul(this, state_msg);
   if (PrintCompilation && _state != unloaded) {
-    print_on(tty, _state == zombie ? "made zombie" : "made not entrant");
+    print_on(tty, state_msg);
   }
 }
 
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Tue Feb 14 20:00:28 2017 -0800
@@ -1765,6 +1765,7 @@
 // Compile a method.
 //
 void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
+  task->print_ul();
   if (PrintCompilation) {
     ResourceMark rm;
     task->print_tty();
--- a/hotspot/src/share/vm/compiler/compileTask.hpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/compiler/compileTask.hpp	Tue Feb 14 20:00:28 2017 -0800
@@ -180,11 +180,27 @@
 
 public:
   void         print(outputStream* st = tty, const char* msg = NULL, bool short_form = false, bool cr = true);
+  void         print_ul(const char* msg = NULL){
+    Log(jit, compilation) log;
+    if (log.is_debug()) {
+      print(log.debug_stream(), msg, /* short form */ true, /* cr */ true);
+    }
+  }
   static void  print(outputStream* st, const nmethod* nm, const char* msg = NULL, bool short_form = false, bool cr = true) {
     print_impl(st, nm->method(), nm->compile_id(), nm->comp_level(),
                            nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false,
                            msg, short_form, cr);
   }
+  static void  print_ul(const nmethod* nm, const char* msg = NULL) {
+    Log(jit, compilation) log;
+    if (log.is_debug()) {
+      print_impl(log.debug_stream(), nm->method(), nm->compile_id(),
+                 nm->comp_level(), nm->is_osr_method(),
+                 nm->is_osr_method() ? nm->osr_entry_bci() : -1,
+                 /*is_blocking*/ false,
+                 msg, /* short form */ true, /* cr */ true);
+    }
+  }
 
   static void  print_inline_indent(int inline_level, outputStream* st = tty);
 
@@ -206,6 +222,12 @@
   static void print_inlining_tty(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
     print_inlining_inner(tty, method, inline_level, bci, msg);
   }
+  static void print_inlining_ul(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
+    Log(jit, inlining) log;
+    if (log.is_debug()) {
+      print_inlining_inner(log.debug_stream(), method, inline_level, bci, msg);
+    }
+  }
 };
 
 #endif // SHARE_VM_COMPILER_COMPILETASK_HPP
--- a/hotspot/src/share/vm/logging/logTag.hpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/logging/logTag.hpp	Tue Feb 14 20:00:28 2017 -0800
@@ -50,6 +50,7 @@
   LOG_TAG(cleanup) \
   LOG_TAG(codecache) \
   LOG_TAG(compaction) \
+  LOG_TAG(compilation) \
   LOG_TAG(constraints) \
   LOG_TAG(constantpool) \
   LOG_TAG(coops) \
@@ -70,7 +71,9 @@
   LOG_TAG(ihop) \
   LOG_TAG(iklass) \
   LOG_TAG(init) \
+  LOG_TAG(inlining) \
   LOG_TAG(itables) \
+  LOG_TAG(jit) \
   LOG_TAG(jni) \
   LOG_TAG(jvmti) \
   LOG_TAG(liveness) \
--- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp	Tue Feb 14 20:00:28 2017 -0800
@@ -496,6 +496,8 @@
       C->log()->inline_fail(inline_msg);
     }
   }
+  CompileTask::print_inlining_ul(callee_method, inline_level(),
+                                               caller_bci, inline_msg);
   if (C->print_inlining()) {
     C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
     if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
--- a/hotspot/src/share/vm/opto/library_call.cpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Tue Feb 14 20:00:28 2017 -0800
@@ -387,8 +387,11 @@
   // Try to inline the intrinsic.
   if ((CheckIntrinsics ? callee->intrinsic_candidate() : true) &&
       kit.try_to_inline(_last_predicate)) {
+    const char *inline_msg = is_virtual() ? "(intrinsic, virtual)"
+                                          : "(intrinsic)";
+    CompileTask::print_inlining_ul(callee, jvms->depth() - 1, bci, inline_msg);
     if (C->print_intrinsics() || C->print_inlining()) {
-      C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
+      C->print_inlining(callee, jvms->depth() - 1, bci, inline_msg);
     }
     C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
     if (C->log()) {
@@ -404,22 +407,30 @@
   }
 
   // The intrinsic bailed out
-  if (C->print_intrinsics() || C->print_inlining()) {
-    if (jvms->has_method()) {
-      // Not a root compile.
-      const char* msg;
-      if (callee->intrinsic_candidate()) {
-        msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
-      } else {
-        msg = is_virtual() ? "failed to inline (intrinsic, virtual), method not annotated"
-                           : "failed to inline (intrinsic), method not annotated";
-      }
+  if (jvms->has_method()) {
+    // Not a root compile.
+    const char* msg;
+    if (callee->intrinsic_candidate()) {
+      msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
+    } else {
+      msg = is_virtual() ? "failed to inline (intrinsic, virtual), method not annotated"
+                         : "failed to inline (intrinsic), method not annotated";
+    }
+    CompileTask::print_inlining_ul(callee, jvms->depth() - 1, bci, msg);
+    if (C->print_intrinsics() || C->print_inlining()) {
       C->print_inlining(callee, jvms->depth() - 1, bci, msg);
-    } else {
-      // Root compile
-      tty->print("Did not generate intrinsic %s%s at bci:%d in",
-               vmIntrinsics::name_at(intrinsic_id()),
-               (is_virtual() ? " (virtual)" : ""), bci);
+    }
+  } else {
+    // Root compile
+    ResourceMark rm;
+    stringStream msg_stream;
+    msg_stream.print("Did not generate intrinsic %s%s at bci:%d in",
+                     vmIntrinsics::name_at(intrinsic_id()),
+                     is_virtual() ? " (virtual)" : "", bci);
+    const char *msg = msg_stream.as_string();
+    log_debug(jit, inlining)("%s", msg);
+    if (C->print_intrinsics() || C->print_inlining()) {
+      tty->print("%s", msg);
     }
   }
   C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
@@ -445,8 +456,11 @@
 
   Node* slow_ctl = kit.try_to_predicate(predicate);
   if (!kit.failing()) {
+    const char *inline_msg = is_virtual() ? "(intrinsic, virtual, predicate)"
+                                          : "(intrinsic, predicate)";
+    CompileTask::print_inlining_ul(callee, jvms->depth() - 1, bci, inline_msg);
     if (C->print_intrinsics() || C->print_inlining()) {
-      C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual, predicate)" : "(intrinsic, predicate)");
+      C->print_inlining(callee, jvms->depth() - 1, bci, inline_msg);
     }
     C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
     if (C->log()) {
@@ -459,16 +473,24 @@
   }
 
   // The intrinsic bailed out
-  if (C->print_intrinsics() || C->print_inlining()) {
-    if (jvms->has_method()) {
-      // Not a root compile.
-      const char* msg = "failed to generate predicate for intrinsic";
+  if (jvms->has_method()) {
+    // Not a root compile.
+    const char* msg = "failed to generate predicate for intrinsic";
+    CompileTask::print_inlining_ul(kit.callee(), jvms->depth() - 1, bci, msg);
+    if (C->print_intrinsics() || C->print_inlining()) {
       C->print_inlining(kit.callee(), jvms->depth() - 1, bci, msg);
-    } else {
-      // Root compile
-      C->print_inlining_stream()->print("Did not generate predicate for intrinsic %s%s at bci:%d in",
-                                        vmIntrinsics::name_at(intrinsic_id()),
-                                        (is_virtual() ? " (virtual)" : ""), bci);
+    }
+  } else {
+    // Root compile
+    ResourceMark rm;
+    stringStream msg_stream;
+    msg_stream.print("Did not generate intrinsic %s%s at bci:%d in",
+                     vmIntrinsics::name_at(intrinsic_id()),
+                     is_virtual() ? " (virtual)" : "", bci);
+    const char *msg = msg_stream.as_string();
+    log_debug(jit, inlining)("%s", msg);
+    if (C->print_intrinsics() || C->print_inlining()) {
+      C->print_inlining_stream()->print("%s", msg);
     }
   }
   C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Tue Feb 14 19:16:46 2017 -0800
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Tue Feb 14 20:00:28 2017 -0800
@@ -2891,9 +2891,11 @@
 
   // Install the generated code.
   if (nm != NULL) {
+    const char *msg = method->is_static() ? "(static)" : "";
+    CompileTask::print_ul(nm, msg);
     if (PrintCompilation) {
       ttyLocker ttyl;
-      CompileTask::print(tty, nm, method->is_static() ? "(static)" : "");
+      CompileTask::print(tty, nm, msg);
     }
     nm->post_compiled_method_load_event();
   }