changeset 7218:8a8f6e7c5180

8060215: per-method PrintIdealGraphLevel Summary: Use CompileCommand=option to set PrintIdealGraphLevel on a per-method level. Introduce the PrintIdealGraph develop to control/check if printing the graph is enabled for any method Reviewed-by: kvn, dlong, thartmann
author zmajo
date Wed, 15 Oct 2014 10:51:43 +0200
parents 2b1ea93ea45e
children ffe9c8c82350
files src/share/vm/opto/c2_globals.hpp src/share/vm/opto/compile.cpp src/share/vm/opto/compile.hpp src/share/vm/opto/idealGraphPrinter.cpp src/share/vm/opto/idealGraphPrinter.hpp src/share/vm/opto/parse2.cpp src/share/vm/runtime/arguments.cpp
diffstat 7 files changed, 39 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/c2_globals.hpp	Mon Oct 13 12:30:37 2014 +0200
+++ b/src/share/vm/opto/c2_globals.hpp	Wed Oct 15 10:51:43 2014 +0200
@@ -343,10 +343,16 @@
   product(bool, UseRDPCForConstantTableBase, false,                         \
           "Use Sparc RDPC instruction for the constant table base.")        \
                                                                             \
-  develop(intx, PrintIdealGraphLevel, 0,                                    \
+  develop(bool, PrintIdealGraph, false,                                     \
           "Print ideal graph to XML file / network interface. "             \
           "By default attempts to connect to the visualizer on a socket.")  \
                                                                             \
+  develop(intx, PrintIdealGraphLevel, 0,                                    \
+          "Level of detail of the ideal graph printout. "                   \
+          "System-wide value, 0=nothing is printed, 3=all details printed. "\
+          "Level of detail of printouts can be set on a per-method level "  \
+          "as well by using CompileCommand=option.")                        \
+                                                                            \
   develop(intx, PrintIdealGraphPort, 4444,                                  \
           "Ideal graph printer to network port")                            \
                                                                             \
--- a/src/share/vm/opto/compile.cpp	Mon Oct 13 12:30:37 2014 +0200
+++ b/src/share/vm/opto/compile.cpp	Wed Oct 15 10:51:43 2014 +0200
@@ -827,7 +827,7 @@
   // Drain the list.
   Finish_Warm();
 #ifndef PRODUCT
-  if (_printer) {
+  if (_printer && _printer->should_print(_method)) {
     _printer->print_inlining(this);
   }
 #endif
--- a/src/share/vm/opto/compile.hpp	Mon Oct 13 12:30:37 2014 +0200
+++ b/src/share/vm/opto/compile.hpp	Wed Oct 15 10:51:43 2014 +0200
@@ -622,7 +622,9 @@
 
   void begin_method() {
 #ifndef PRODUCT
-    if (_printer) _printer->begin_method(this);
+    if (_printer && _printer->should_print(_method)) {
+      _printer->begin_method(this);
+    }
 #endif
     C->_latest_stage_start_counter.stamp();
   }
@@ -639,7 +641,9 @@
 
 
 #ifndef PRODUCT
-    if (_printer) _printer->print_method(this, CompilerPhaseTypeHelper::to_string(cpt), level);
+    if (_printer && _printer->should_print(_method)) {
+      _printer->print_method(this, CompilerPhaseTypeHelper::to_string(cpt), level);
+    }
 #endif
     C->_latest_stage_start_counter.stamp();
   }
@@ -654,7 +658,9 @@
       event.commit();
     }
 #ifndef PRODUCT
-    if (_printer) _printer->end_method();
+    if (_printer && _printer->should_print(_method)) {
+      _printer->end_method();
+    }
 #endif
   }
 
--- a/src/share/vm/opto/idealGraphPrinter.cpp	Mon Oct 13 12:30:37 2014 +0200
+++ b/src/share/vm/opto/idealGraphPrinter.cpp	Wed Oct 15 10:51:43 2014 +0200
@@ -73,7 +73,9 @@
 int IdealGraphPrinter::_file_count = 0;
 
 IdealGraphPrinter *IdealGraphPrinter::printer() {
-  if (PrintIdealGraphLevel == 0) return NULL;
+  if (!PrintIdealGraph) {
+    return NULL;
+  }
 
   JavaThread *thread = JavaThread::current();
   if (!thread->is_Compiler_thread()) return NULL;
@@ -193,7 +195,6 @@
   }
 }
 
-
 void IdealGraphPrinter::begin_elem(const char *s) {
   _xml->begin_elem("%s", s);
 }
@@ -680,7 +681,7 @@
 // Print current ideal graph
 void IdealGraphPrinter::print(Compile* compile, const char *name, Node *node, int level, bool clear_nodes) {
 
-  if (!_current_method || !_should_send_method || level > PrintIdealGraphLevel) return;
+  if (!_current_method || !_should_send_method || !should_print(_current_method, level)) return;
 
   this->C = compile;
 
@@ -732,6 +733,13 @@
   output()->flush();
 }
 
+// Should method be printed?
+bool IdealGraphPrinter::should_print(ciMethod* method, int level) {
+  intx ideal_graph_level = PrintIdealGraphLevel;
+  method->has_option_value("PrintIdealGraphLevel", ideal_graph_level); // update value with per-method value (if available)
+  return ideal_graph_level >= level;
+}
+
 extern const char *NodeClassNames[];
 
 outputStream *IdealGraphPrinter::output() {
--- a/src/share/vm/opto/idealGraphPrinter.hpp	Mon Oct 13 12:30:37 2014 +0200
+++ b/src/share/vm/opto/idealGraphPrinter.hpp	Wed Oct 15 10:51:43 2014 +0200
@@ -134,6 +134,7 @@
   void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false);
   void print(Compile* compile, const char *name, Node *root, int level=1, bool clear_nodes = false);
   void print_xml(const char *name);
+  static bool should_print(ciMethod* method, int level = 1);
 };
 
 #endif
--- a/src/share/vm/opto/parse2.cpp	Mon Oct 13 12:30:37 2014 +0200
+++ b/src/share/vm/opto/parse2.cpp	Wed Oct 15 10:51:43 2014 +0200
@@ -2344,7 +2344,7 @@
 
 #ifndef PRODUCT
   IdealGraphPrinter *printer = IdealGraphPrinter::printer();
-  if(printer) {
+  if (printer && printer->should_print(_method)) {
     char buffer[256];
     sprintf(buffer, "Bytecode %d: %s", bci(), Bytecodes::name(bc()));
     bool old = printer->traverse_outs();
--- a/src/share/vm/runtime/arguments.cpp	Mon Oct 13 12:30:37 2014 +0200
+++ b/src/share/vm/runtime/arguments.cpp	Wed Oct 15 10:51:43 2014 +0200
@@ -3922,6 +3922,15 @@
         "Incompatible compilation policy selected", NULL);
     }
   }
+
+#ifdef COMPILER2
+#ifndef PRODUCT
+  if (PrintIdealGraphLevel > 0) {
+    FLAG_SET_ERGO(bool, PrintIdealGraph, true);
+  }
+#endif
+#endif
+
   // Set NmethodSweepFraction after the size of the code cache is adapted (in case of tiered)
   if (FLAG_IS_DEFAULT(NmethodSweepFraction)) {
     FLAG_SET_DEFAULT(NmethodSweepFraction, 1 + ReservedCodeCacheSize / (16 * M));