8060215: per-method PrintIdealGraphLevel

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
This commit is contained in:
Zoltan Majo 2014-10-15 10:51:43 +02:00
parent 38e46e728d
commit bde7fd61b4
7 changed files with 39 additions and 9 deletions

View File

@ -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") \
\

View File

@ -827,7 +827,7 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr
// Drain the list.
Finish_Warm();
#ifndef PRODUCT
if (_printer) {
if (_printer && _printer->should_print(_method)) {
_printer->print_inlining(this);
}
#endif

View File

@ -622,7 +622,9 @@ class Compile : public Phase {
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 @@ class Compile : public Phase {
#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 @@ class Compile : public Phase {
event.commit();
}
#ifndef PRODUCT
if (_printer) _printer->end_method();
if (_printer && _printer->should_print(_method)) {
_printer->end_method();
}
#endif
}

View File

@ -73,7 +73,9 @@ const char *IdealGraphPrinter::ASSEMBLY_ELEMENT = "assembly";
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 @@ IdealGraphPrinter::~IdealGraphPrinter() {
}
}
void IdealGraphPrinter::begin_elem(const char *s) {
_xml->begin_elem("%s", s);
}
@ -680,7 +681,7 @@ void IdealGraphPrinter::print_method(Compile* compile, const char *name, int lev
// 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 @@ void IdealGraphPrinter::print(Compile* compile, const char *name, Node *node, in
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() {

View File

@ -134,6 +134,7 @@ class IdealGraphPrinter : public CHeapObj<mtCompiler> {
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

View File

@ -2344,7 +2344,7 @@ void Parse::do_one_bytecode() {
#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();

View File

@ -3922,6 +3922,15 @@ jint Arguments::apply_ergo() {
"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));