RFR: 8344122: IGV: Extend c2 IdealGraphPrinter to send subgraphs to IGV

Emanuel Peter epeter at openjdk.org
Thu Nov 14 08:46:01 UTC 2024


On Wed, 13 Nov 2024 14:41:24 GMT, Tobias Holenstein <tholenstein at openjdk.org> wrote:

> IGV XML already support to define which graphs are visible when opened. Extend the IdealGraphPrinter::print... in C2 to define which nodes should be visible in IGV when sent over the network
> 
> ### Add a new option "!" to dump_bfs
> The option ! send the printed nodes of dump_bfs to IGV and shows them 
> 
> p find_node(0)->dump_bfs(1,0,"dcmxo+!")
> 
> dist dump
> ---------------------------------------------
>    1  51  Return  === 46 6 47 8 9 returns 39  [[ 0 ]] 
>    0   0  Root  === 0 51  [[ 0 1 3 26 ]] 
> Method printed over network stream to IGV
> 
> 
> <img width="668" alt="dump" src="https://github.com/user-attachments/assets/d476e8b0-c444-4cd3-b40d-4a8f35caba83">

Very nice. I manually verified it, and it works!

I just have some code style suggestions.

![image](https://github.com/user-attachments/assets/5515a542-c8e1-487f-a17c-c6a558044cfa)

You also need to fix this.

src/hotspot/share/opto/compile.cpp line 5291:

> 5289: }
> 5290: 
> 5291: void Compile::igv_print_graph_to_network(const char *name, Node *node, GrowableArray<const Node*>  &visible_nodes) {

Suggestion:

void Compile::igv_print_graph_to_network(const char* name, Node* node, GrowableArray<const Node*> & visible_nodes) {

src/hotspot/share/opto/compile.cpp line 5298:

> 5296:   }
> 5297:   tty->print_cr("Method printed over network stream to IGV");
> 5298:   _debug_network_printer->print(name, (Node *) Compile::current()->root(), visible_nodes);

Suggestion:

  _debug_network_printer->print(name, (Node*) Compile::current()->root(), visible_nodes);

src/hotspot/share/opto/compile.hpp line 721:

> 719:   void igv_print_method_to_file(const char* phase_name = "Debug", bool append = false);
> 720:   void igv_print_method_to_network(const char* phase_name = "Debug");
> 721:   void igv_print_graph_to_network(const char *name, Node *node, GrowableArray<const Node *> &visible_nodes);

Suggestion:

  void igv_print_graph_to_network(const char* name, Node* node, GrowableArray<const Node*>& visible_nodes);

src/hotspot/share/opto/idealGraphPrinter.cpp line 359:

> 357: }
> 358: 
> 359: void IdealGraphPrinter::visit_node(Node *n, bool edges) {

Suggestion:

void IdealGraphPrinter::visit_node(Node* n, bool edges) {

src/hotspot/share/opto/idealGraphPrinter.cpp line 825:

> 823:     ResourceMark rm;
> 824:     GrowableArray<const Node*> empty_list;
> 825:     print(name, (Node *) C->root(), empty_list);

Suggestion:

void IdealGraphPrinter::print_graph(const char* name) {
  ResourceMark rm;
  GrowableArray<const Node*> empty_list;
  print(name, (Node*) C->root(), empty_list);

src/hotspot/share/opto/idealGraphPrinter.cpp line 829:

> 827: 
> 828: // Print current ideal graph
> 829: void IdealGraphPrinter::print(const char *name, Node *node, GrowableArray<const Node*>  &visible_nodes) {

Suggestion:

void IdealGraphPrinter::print(const char* name, Node* node, GrowableArray<const Node*>& visible_nodes) {

src/hotspot/share/opto/idealGraphPrinter.hpp line 117:

> 115:   ciField* find_source_field_of_array_access(const Node* node, uint& depth);
> 116:   static Node* get_load_node(const Node* node);
> 117:   void walk_nodes(Node *start, bool edges);

Suggestion:

  void walk_nodes(Node* start, bool edges);

src/hotspot/share/opto/idealGraphPrinter.hpp line 148:

> 146:   void end_method();
> 147:   void print_graph(const char *name);
> 148:   void print(const char *name, Node *root, GrowableArray<const Node *> &hidden_nodes);

Suggestion:

  void print_graph(const char* name);
  void print(const char* name, Node* root, GrowableArray<const Node*>& hidden_nodes);

src/hotspot/share/opto/node.cpp line 2055:

> 2053:       Compile* C = Compile::current();
> 2054:       if (C->should_print_igv(0)) {
> 2055:         C->igv_print_graph_to_network("PrintBFS", (Node *) Compile::current()->root(), _print_list);

Suggestion:

        C->igv_print_graph_to_network("PrintBFS", (Node*) Compile::current()->root(), _print_list);

-------------

Changes requested by epeter (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/22076#pullrequestreview-2435251368
PR Comment: https://git.openjdk.org/jdk/pull/22076#issuecomment-2475627084
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841697489
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841697713
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841698138
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841698710
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841699604
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841700130
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841700985
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841701436
PR Review Comment: https://git.openjdk.org/jdk/pull/22076#discussion_r1841701973


More information about the hotspot-compiler-dev mailing list