src/share/vm/opto/idealGraphPrinter.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/idealGraphPrinter.cpp

Print this page
rev 9032 : 8137167: JEP165: Compiler Control: Implementation task
Summary: Compiler Control JEP
Reviewed-by: roland, twisti


 275     GrowableArray<InlineTree *> subtrees = tree->subtrees();
 276     for (int i = 0; i < subtrees.length(); i++) {
 277       print_inline_tree(subtrees.at(i));
 278     }
 279     tail(INLINE_ELEMENT);
 280   }
 281 
 282   tail(METHOD_ELEMENT);
 283   _xml->flush();
 284 }
 285 
 286 void IdealGraphPrinter::print_inline_tree(InlineTree *tree) {
 287 
 288   if (tree == NULL) return;
 289 
 290   ciMethod *method = tree->method();
 291   print_method(tree->method(), tree->caller_bci(), tree);
 292 
 293 }
 294 
 295 void IdealGraphPrinter::print_inlining(Compile* compile) {
 296 
 297   // Print inline tree
 298   if (_should_send_method) {
 299     InlineTree *inlineTree = compile->ilt();
 300     if (inlineTree != NULL) {
 301       print_inline_tree(inlineTree);
 302     } else {
 303       // print this method only
 304     }
 305   }
 306 }
 307 
 308 // Has to be called whenever a method is compiled
 309 void IdealGraphPrinter::begin_method(Compile* compile) {
 310 
 311   ciMethod *method = compile->method();
 312   assert(_output, "output stream must exist!");
 313   assert(method, "null methods are not allowed!");
 314   assert(!_current_method, "current method must be null!");
 315 
 316   head(GROUP_ELEMENT);
 317 
 318   head(PROPERTIES_ELEMENT);
 319 
 320   // Print properties
 321   // Add method name
 322   stringStream strStream;
 323   method->print_name(&strStream);
 324   print_prop(METHOD_NAME_PROPERTY, strStream.as_string());
 325 
 326   if (method->flags().is_public()) {
 327     print_prop(METHOD_IS_PUBLIC_PROPERTY, TRUE_VALUE);
 328   }
 329 
 330   if (method->flags().is_static()) {
 331     print_prop(METHOD_IS_STATIC_PROPERTY, TRUE_VALUE);


 645 
 646     if (_traverse_outs) {
 647       for (DUIterator i = n->outs(); n->has_out(i); i++) {
 648         Node* p = n->out(i);
 649         if (!visited.test_set(p->_idx)) {
 650           nodeStack.push(p);
 651         }
 652       }
 653     }
 654 
 655     for ( uint i = 0; i < n->len(); i++ ) {
 656       if ( n->in(i) ) {
 657         if (!visited.test_set(n->in(i)->_idx)) {
 658           nodeStack.push(n->in(i));
 659         }
 660       }
 661     }
 662   }
 663 }
 664 
 665 void IdealGraphPrinter::print_method(Compile* compile, const char *name, int level, bool clear_nodes) {
 666   print(compile, name, (Node *)compile->root(), level, clear_nodes);
 667 }
 668 
 669 // Print current ideal graph
 670 void IdealGraphPrinter::print(Compile* compile, const char *name, Node *node, int level, bool clear_nodes) {
 671 
 672   if (!_current_method || !_should_send_method || !should_print(_current_method, level)) return;
 673 
 674   this->C = compile;
 675 
 676   // Warning, unsafe cast?
 677   _chaitin = (PhaseChaitin *)C->regalloc();
 678 
 679   begin_head(GRAPH_ELEMENT);
 680   print_attr(GRAPH_NAME_PROPERTY, (const char *)name);
 681   end_head();
 682 
 683   VectorSet temp_set(Thread::current()->resource_area());
 684 
 685   head(NODES_ELEMENT);
 686   walk_nodes(node, false, &temp_set);
 687   tail(NODES_ELEMENT);
 688 
 689   head(EDGES_ELEMENT);
 690   walk_nodes(node, true, &temp_set);
 691   tail(EDGES_ELEMENT);
 692   if (C->cfg() != NULL) {
 693     head(CONTROL_FLOW_ELEMENT);
 694     for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) {


 705       }
 706       tail(SUCCESSORS_ELEMENT);
 707 
 708       head(NODES_ELEMENT);
 709       for (uint s = 0; s < block->number_of_nodes(); s++) {
 710         begin_elem(NODE_ELEMENT);
 711         print_attr(NODE_ID_PROPERTY, block->get_node(s)->_idx);
 712         end_elem();
 713       }
 714       tail(NODES_ELEMENT);
 715 
 716       tail(BLOCK_ELEMENT);
 717     }
 718     tail(CONTROL_FLOW_ELEMENT);
 719   }
 720   tail(GRAPH_ELEMENT);
 721   _xml->flush();
 722 }
 723 
 724 // Should method be printed?
 725 bool IdealGraphPrinter::should_print(ciMethod* method, int level) {
 726   intx ideal_graph_level = PrintIdealGraphLevel;
 727   method->has_option_value("PrintIdealGraphLevel", ideal_graph_level); // update value with per-method value (if available)
 728   return ideal_graph_level >= level;
 729 }
 730 
 731 extern const char *NodeClassNames[];
 732 
 733 #endif


 275     GrowableArray<InlineTree *> subtrees = tree->subtrees();
 276     for (int i = 0; i < subtrees.length(); i++) {
 277       print_inline_tree(subtrees.at(i));
 278     }
 279     tail(INLINE_ELEMENT);
 280   }
 281 
 282   tail(METHOD_ELEMENT);
 283   _xml->flush();
 284 }
 285 
 286 void IdealGraphPrinter::print_inline_tree(InlineTree *tree) {
 287 
 288   if (tree == NULL) return;
 289 
 290   ciMethod *method = tree->method();
 291   print_method(tree->method(), tree->caller_bci(), tree);
 292 
 293 }
 294 
 295 void IdealGraphPrinter::print_inlining() {
 296 
 297   // Print inline tree
 298   if (_should_send_method) {
 299     InlineTree *inlineTree = C->ilt();
 300     if (inlineTree != NULL) {
 301       print_inline_tree(inlineTree);
 302     } else {
 303       // print this method only
 304     }
 305   }
 306 }
 307 
 308 // Has to be called whenever a method is compiled
 309 void IdealGraphPrinter::begin_method() {
 310 
 311   ciMethod *method = C->method();
 312   assert(_output, "output stream must exist!");
 313   assert(method, "null methods are not allowed!");
 314   assert(!_current_method, "current method must be null!");
 315 
 316   head(GROUP_ELEMENT);
 317 
 318   head(PROPERTIES_ELEMENT);
 319 
 320   // Print properties
 321   // Add method name
 322   stringStream strStream;
 323   method->print_name(&strStream);
 324   print_prop(METHOD_NAME_PROPERTY, strStream.as_string());
 325 
 326   if (method->flags().is_public()) {
 327     print_prop(METHOD_IS_PUBLIC_PROPERTY, TRUE_VALUE);
 328   }
 329 
 330   if (method->flags().is_static()) {
 331     print_prop(METHOD_IS_STATIC_PROPERTY, TRUE_VALUE);


 645 
 646     if (_traverse_outs) {
 647       for (DUIterator i = n->outs(); n->has_out(i); i++) {
 648         Node* p = n->out(i);
 649         if (!visited.test_set(p->_idx)) {
 650           nodeStack.push(p);
 651         }
 652       }
 653     }
 654 
 655     for ( uint i = 0; i < n->len(); i++ ) {
 656       if ( n->in(i) ) {
 657         if (!visited.test_set(n->in(i)->_idx)) {
 658           nodeStack.push(n->in(i));
 659         }
 660       }
 661     }
 662   }
 663 }
 664 
 665 void IdealGraphPrinter::print_method(const char *name, int level, bool clear_nodes) {
 666   print(name, (Node *)C->root(), level, clear_nodes);
 667 }
 668 
 669 // Print current ideal graph
 670 void IdealGraphPrinter::print(const char *name, Node *node, int level, bool clear_nodes) {
 671 
 672   if (!_current_method || !_should_send_method || !should_print(level)) return;


 673 
 674   // Warning, unsafe cast?
 675   _chaitin = (PhaseChaitin *)C->regalloc();
 676 
 677   begin_head(GRAPH_ELEMENT);
 678   print_attr(GRAPH_NAME_PROPERTY, (const char *)name);
 679   end_head();
 680 
 681   VectorSet temp_set(Thread::current()->resource_area());
 682 
 683   head(NODES_ELEMENT);
 684   walk_nodes(node, false, &temp_set);
 685   tail(NODES_ELEMENT);
 686 
 687   head(EDGES_ELEMENT);
 688   walk_nodes(node, true, &temp_set);
 689   tail(EDGES_ELEMENT);
 690   if (C->cfg() != NULL) {
 691     head(CONTROL_FLOW_ELEMENT);
 692     for (uint i = 0; i < C->cfg()->number_of_blocks(); i++) {


 703       }
 704       tail(SUCCESSORS_ELEMENT);
 705 
 706       head(NODES_ELEMENT);
 707       for (uint s = 0; s < block->number_of_nodes(); s++) {
 708         begin_elem(NODE_ELEMENT);
 709         print_attr(NODE_ID_PROPERTY, block->get_node(s)->_idx);
 710         end_elem();
 711       }
 712       tail(NODES_ELEMENT);
 713 
 714       tail(BLOCK_ELEMENT);
 715     }
 716     tail(CONTROL_FLOW_ELEMENT);
 717   }
 718   tail(GRAPH_ELEMENT);
 719   _xml->flush();
 720 }
 721 
 722 // Should method be printed?
 723 bool IdealGraphPrinter::should_print(int level) {
 724   return C->directive()->IGVPrintLevelOption >= level;


 725 }
 726 
 727 extern const char *NodeClassNames[];
 728 
 729 #endif
src/share/vm/opto/idealGraphPrinter.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File