8073607: add trace events for inlining
authoriignatyev
Fri, 13 Mar 2015 21:53:13 +0300
changeset 29582 9a0bb63adf5a
parent 29477 82f545c6572b
child 29583 acaac5dcf557
8073607: add trace events for inlining Reviewed-by: kvn, fzhinkin, mgronlun
hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
hotspot/src/share/vm/ci/ciMethod.cpp
hotspot/src/share/vm/ci/ciMethod.hpp
hotspot/src/share/vm/opto/bytecodeInfo.cpp
hotspot/src/share/vm/opto/parse.hpp
hotspot/src/share/vm/trace/trace.xml
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Fri Mar 13 21:53:13 2015 +0300
@@ -4306,7 +4306,18 @@
         log->inline_fail("reason unknown");
     }
   }
-
+#if INCLUDE_TRACE
+  EventCompilerInlining event;
+  if (event.should_commit()) {
+    event.set_compileID(compilation()->env()->task()->compile_id());
+    event.set_message(msg);
+    event.set_succeeded(success);
+    event.set_bci(bci());
+    event.set_caller(method()->get_Method());
+    event.set_callee(callee->to_trace_struct());
+    event.commit();
+  }
+#endif // INCLUDE_TRACE
   if (!PrintInlining && !compilation()->method()->has_option("PrintInlining")) {
     return;
   }
--- a/hotspot/src/share/vm/ci/ciMethod.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp	Fri Mar 13 21:53:13 2015 +0300
@@ -48,6 +48,7 @@
 #include "runtime/deoptimization.hpp"
 #include "utilities/bitMap.inline.hpp"
 #include "utilities/xmlstream.hpp"
+#include "trace/tracing.hpp"
 #ifdef COMPILER2
 #include "ci/bcEscapeAnalyzer.hpp"
 #include "ci/ciTypeFlow.hpp"
@@ -1466,3 +1467,13 @@
     st->print(" loaded=false");
   }
 }
+
+#if INCLUDE_TRACE
+TraceStructCiMethod ciMethod::to_trace_struct() const {
+  TraceStructCiMethod result;
+  result.set_class(holder()->name()->as_utf8());
+  result.set_name(name()->as_utf8());
+  result.set_signature(signature()->as_symbol()->as_utf8());
+  return result;
+}
+#endif
--- a/hotspot/src/share/vm/ci/ciMethod.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp	Fri Mar 13 21:53:13 2015 +0300
@@ -32,13 +32,14 @@
 #include "compiler/methodLiveness.hpp"
 #include "prims/methodHandles.hpp"
 #include "utilities/bitMap.hpp"
+#include "trace/tracing.hpp"
 
 class ciMethodBlocks;
 class MethodLiveness;
 class BitMap;
 class Arena;
 class BCEscapeAnalyzer;
-
+class InlineTree;
 
 // ciMethod
 //
@@ -52,6 +53,7 @@
   friend class ciBytecodeStream;
   friend class ciMethodHandle;
   friend class ciReplay;
+  friend class InlineTree;
 
  private:
   // General method information.
@@ -95,12 +97,6 @@
   ciMethod(methodHandle h_m, ciInstanceKlass* holder);
   ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
 
-  Method* get_Method() const {
-    Method* m = (Method*)_metadata;
-    assert(m != NULL, "illegal use of unloaded method");
-    return m;
-  }
-
   oop loader() const                             { return _holder->loader(); }
 
   const char* type_string()                      { return "ciMethod"; }
@@ -158,6 +154,11 @@
     }
   }
 
+  Method* get_Method() const {
+    Method* m = (Method*)_metadata;
+    assert(m != NULL, "illegal use of unloaded method");
+    return m;
+  }
 
   // Method code and related information.
   address code()                                 { if (_code == NULL) load_code(); return _code; }
@@ -339,6 +340,10 @@
   // Print the name of this method in various incarnations.
   void print_name(outputStream* st = tty);
   void print_short_name(outputStream* st = tty);
+
+#if INCLUDE_TRACE
+  TraceStructCiMethod to_trace_struct() const;
+#endif
 };
 
 #endif // SHARE_VM_CI_CIMETHOD_HPP
--- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp	Fri Mar 13 21:53:13 2015 +0300
@@ -33,6 +33,7 @@
 #include "opto/callGenerator.hpp"
 #include "opto/parse.hpp"
 #include "runtime/handles.inline.hpp"
+#include "utilities/events.hpp"
 
 //=============================================================================
 //------------------------------InlineTree-------------------------------------
@@ -490,7 +491,7 @@
 
 //------------------------------print_inlining---------------------------------
 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
-                                bool success) const {
+                                ciMethod* caller_method, bool success) const {
   const char* inline_msg = msg();
   assert(inline_msg != NULL, "just checking");
   if (C->log() != NULL) {
@@ -509,6 +510,18 @@
       //tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
     }
   }
+#if INCLUDE_TRACE
+  EventCompilerInlining event;
+  if (event.should_commit()) {
+    event.set_compileID(C->compile_id());
+    event.set_message(inline_msg);
+    event.set_succeeded(success);
+    event.set_bci(caller_bci);
+    event.set_caller(caller_method->get_Method());
+    event.set_callee(callee_method->to_trace_struct());
+    event.commit();
+  }
+#endif // INCLUDE_TRACE
 }
 
 //------------------------------ok_to_inline-----------------------------------
@@ -531,14 +544,14 @@
   // Do some initial checks.
   if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
     set_msg("failed initial checks");
-    print_inlining(callee_method, caller_bci, false /* !success */);
+    print_inlining(callee_method, caller_bci, caller_method, false /* !success */);
     return NULL;
   }
 
   // Do some parse checks.
   set_msg(check_can_parse(callee_method));
   if (msg() != NULL) {
-    print_inlining(callee_method, caller_bci, false /* !success */);
+    print_inlining(callee_method, caller_bci, caller_method, false /* !success */);
     return NULL;
   }
 
@@ -580,10 +593,11 @@
     if (msg() == NULL) {
       set_msg("inline (hot)");
     }
-    print_inlining(callee_method, caller_bci, true /* success */);
+    print_inlining(callee_method, caller_bci, caller_method, true /* success */);
     build_inline_tree_for_callee(callee_method, jvms, caller_bci);
-    if (InlineWarmCalls && !wci.is_hot())
+    if (InlineWarmCalls && !wci.is_hot()) {
       return new (C) WarmCallInfo(wci);  // copy to heap
+    }
     return WarmCallInfo::always_hot();
   }
 
@@ -591,7 +605,7 @@
   if (msg() == NULL) {
     set_msg("too cold to inline");
   }
-  print_inlining(callee_method, caller_bci, false /* !success */ );
+  print_inlining(callee_method, caller_bci, caller_method, false /* !success */ );
   return NULL;
 }
 
--- a/hotspot/src/share/vm/opto/parse.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/opto/parse.hpp	Fri Mar 13 21:53:13 2015 +0300
@@ -87,7 +87,7 @@
                                 JVMState* jvms,
                                 WarmCallInfo* wci_result);
   void        print_inlining(ciMethod* callee_method, int caller_bci,
-                             bool success) const;
+                             ciMethod* caller_method, bool success) const;
 
   InlineTree* caller_tree()       const { return _caller_tree;  }
   InlineTree* callee_at(int bci, ciMethod* m) const;
--- a/hotspot/src/share/vm/trace/trace.xml	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/trace/trace.xml	Fri Mar 13 21:53:13 2015 +0300
@@ -400,6 +400,22 @@
       <value type="UINT" field="compileID" label="Compilation ID" relation="COMP_ID"/>
     </event>
 
+    <struct id="CiMethod">
+      <value type="UTF8" field="class" label="Class name"/>
+      <value type="UTF8" field="name" label="Method name"/>
+      <value type="UTF8" field="signature" label="Method signature"/>
+    </struct>
+
+    <event id="CompilerInlining" path="vm/compiler/optimization/inlining" label="Method Inlining"
+         has_thread="true" is_instant="true">
+      <value type="UINT" field="compileID" label="Compilation ID" relation="COMP_ID"/>
+      <value type="METHOD" field="caller" label="Caller Method"/>
+      <structvalue type="CiMethod" field="callee" label="Callee Method"/>
+      <value type="BOOLEAN" field="succeeded" label="Succeeded"/>
+      <value type="UTF8" field="message" label="Message"/>
+      <value type="INTEGER" field="bci" label="Byte Code Index"/>
+    </event>
+
     <!-- Code sweeper events -->
 
     <event id="SweepCodeCache" path="vm/code_sweeper/sweep" label="Sweep Code Cache"