< prev index next >

src/share/vm/opto/node.hpp

Print this page
rev 8739 : 8004073: Implement C2 Ideal node specific dump() method
Summary: add Node::dump_rel() to dump a node and its related nodes (the notion of "related" depends on the node at hand); add Node::dump_comp() to dump a node in compact representation; add Node::dump_rel_comp() to dump a node and its related nodes in compact representation; add the required machinery; extend some C2 IR nodes with compact and related dumping
Reviewed-by:

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -1036,17 +1036,48 @@
 public:
 #ifndef PRODUCT
   Node* find(int idx) const;         // Search the graph for the given idx.
   Node* find_ctrl(int idx) const;    // Search control ancestors for the given idx.
   void dump() const { dump("\n"); }  // Print this node.
-  void dump(const char* suffix, outputStream *st = tty) const;// Print this node.
+  void dump(const char* suffix, bool mark = false, outputStream *st = tty) const; // Print this node.
   void dump(int depth) const;        // Print this node, recursively to depth d
   void dump_ctrl(int depth) const;   // Print control nodes, to depth d
+  void dump_comp() const;            // Print this node in compact representation.
+  // Print this node in compact representation.
+  void dump_comp(const char* suffix, outputStream *st = tty) const;
   virtual void dump_req(outputStream *st = tty) const;     // Print required-edge info
   virtual void dump_prec(outputStream *st = tty) const;    // Print precedence-edge info
   virtual void dump_out(outputStream *st = tty) const;     // Print the output edge info
   virtual void dump_spec(outputStream *st) const {}; // Print per-node info
+  // Print compact per-node info
+  virtual void dump_comp_spec(outputStream *st) const { dump_spec(st); }
+  void dump_rel() const;             // Print related nodes (depends on node at hand).
+  // Print related nodes up to given depths for input and output nodes.
+  void dump_rel(uint d_in, uint d_out) const;
+  void dump_rel_comp() const;        // Print related nodes in compact representation.
+  // Collect related nodes.
+  virtual void rel(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const;
+  // Collect nodes starting from this node, explicitly including/excluding control and data links.
+  void collect_nodes(GrowableArray<Node*> *ns, int d, bool ctrl, bool data) const;
+
+  // Node collectors, to be used in implementations of Node::rel().
+  // Collect the entire data input graph. Include control inputs if requested.
+  void collect_nodes_in_all_data(GrowableArray<Node*> *ns, bool ctrl) const;
+  // Collect the entire control input graph. Include data inputs if requested.
+  void collect_nodes_in_all_ctrl(GrowableArray<Node*> *ns, bool data) const;
+  // Collect the entire output graph until hitting and including control nodes.
+  void collect_nodes_out_all_ctrl_boundary(GrowableArray<Node*> *ns) const;
+  // Collect the entire data input graph, and outputs till level 1.
+  void collect_nodes_in_data_out_1(GrowableArray<Node*> *is, GrowableArray<Node*> *os, bool compact) const {
+    if (compact) {
+      this->collect_nodes(is, 1, false, true);
+    } else {
+      this->collect_nodes_in_all_data(is, false);
+    }
+    this->collect_nodes(os, -1, false, false);
+  }
+
   void verify_edges(Unique_Node_List &visited); // Verify bi-directional edges
   void verify() const;               // Check Def-Use info for my subgraph
   static void verify_recur(const Node *n, int verify_depth, VectorSet &old_space, VectorSet &new_space);
 
   // This call defines a class-unique string used to identify class instances

@@ -1089,10 +1120,33 @@
   uint        _del_tick;               // Bumped when a deletion happens..
   #endif
 #endif
 };
 
+
+#ifndef PRODUCT
+
+// Used in debugging code to avoid walking across dead or uninitialized edges.
+inline bool NotANode(const Node* n) {
+  if (n == NULL)                   return true;
+  if (((intptr_t)n & 1) != 0)      return true;  // uninitialized, etc.
+  if (*(address*)n == badAddress)  return true;  // kill by Node::destruct
+  return false;
+}
+
+// This macro provides a common definition of related node retrieval for all
+// "arithmetic" nodes, which have no common superclass. The data input trees
+// are relevant (until a control node boundary is hit), and the outgoing edges
+// till level 1. In compact mode, inputs are collected till level 1 as well.
+#define REL_IN_DATA_OUT_1 \
+  virtual void rel(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const { \
+    this->collect_nodes_in_data_out_1(in_rel, out_rel, compact); \
+  }
+
+#endif
+
+
 //-----------------------------------------------------------------------------
 // Iterators over DU info, and associated Node functions.
 
 #if OPTO_DU_ITERATOR_ASSERT
 

@@ -1616,9 +1670,10 @@
   virtual const Type *Value( PhaseTransform *phase ) const;
   virtual const Type *bottom_type() const;
   virtual       uint  ideal_reg() const;
 #ifndef PRODUCT
   virtual void dump_spec(outputStream *st) const;
+  virtual void dump_comp_spec(outputStream *st) const;
 #endif
 };
 
 #endif // SHARE_VM_OPTO_NODE_HPP
< prev index next >