< 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 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1021   // return operand position that can convert from reg to memory access
1022   virtual int cisc_operand() const { return AdlcVMDeps::Not_cisc_spillable; }
1023   bool is_cisc_alternate() const { return (_flags & Flag_is_cisc_alternate) != 0; }
1024 
1025 //----------------- Graph walking
1026 public:
1027   // Walk and apply member functions recursively.
1028   // Supplied (this) pointer is root.
1029   void walk(NFunc pre, NFunc post, void *env);
1030   static void nop(Node &, void*); // Dummy empty function
1031   static void packregion( Node &n, void* );
1032 private:
1033   void walk_(NFunc pre, NFunc post, void *env, VectorSet &visited);
1034 
1035 //----------------- Printing, etc
1036 public:
1037 #ifndef PRODUCT
1038   Node* find(int idx) const;         // Search the graph for the given idx.
1039   Node* find_ctrl(int idx) const;    // Search control ancestors for the given idx.
1040   void dump() const { dump("\n"); }  // Print this node.
1041   void dump(const char* suffix, outputStream *st = tty) const;// Print this node.
1042   void dump(int depth) const;        // Print this node, recursively to depth d
1043   void dump_ctrl(int depth) const;   // Print control nodes, to depth d



1044   virtual void dump_req(outputStream *st = tty) const;     // Print required-edge info
1045   virtual void dump_prec(outputStream *st = tty) const;    // Print precedence-edge info
1046   virtual void dump_out(outputStream *st = tty) const;     // Print the output edge info
1047   virtual void dump_spec(outputStream *st) const {}; // Print per-node info




























1048   void verify_edges(Unique_Node_List &visited); // Verify bi-directional edges
1049   void verify() const;               // Check Def-Use info for my subgraph
1050   static void verify_recur(const Node *n, int verify_depth, VectorSet &old_space, VectorSet &new_space);
1051 
1052   // This call defines a class-unique string used to identify class instances
1053   virtual const char *Name() const;
1054 
1055   void dump_format(PhaseRegAlloc *ra) const; // debug access to MachNode::format(...)
1056   // RegMask Print Functions
1057   void dump_in_regmask(int idx) { in_RegMask(idx).dump(); }
1058   void dump_out_regmask() { out_RegMask().dump(); }
1059   static bool in_dump() { return Compile::current()->_in_dump_cnt > 0; }
1060   void fast_dump() const {
1061     tty->print("%4d: %-17s", _idx, Name());
1062     for (uint i = 0; i < len(); i++)
1063       if (in(i))
1064         tty->print(" %4d", in(i)->_idx);
1065       else
1066         tty->print(" NULL");
1067     tty->print("\n");


1074   int   debug_idx() const              { return _debug_idx; }
1075   void  set_debug_idx( int debug_idx ) { _debug_idx = debug_idx; }
1076 
1077   Node* _debug_orig;                   // Original version of this, if any.
1078   Node*  debug_orig() const            { return _debug_orig; }
1079   void   set_debug_orig(Node* orig);   // _debug_orig = orig
1080 
1081   int        _hash_lock;               // Barrier to modifications of nodes in the hash table
1082   void  enter_hash_lock() { ++_hash_lock; assert(_hash_lock < 99, "in too many hash tables?"); }
1083   void   exit_hash_lock() { --_hash_lock; assert(_hash_lock >= 0, "mispaired hash locks"); }
1084 
1085   static void init_NodeProperty();
1086 
1087   #if OPTO_DU_ITERATOR_ASSERT
1088   const Node* _last_del;               // The last deleted node.
1089   uint        _del_tick;               // Bumped when a deletion happens..
1090   #endif
1091 #endif
1092 };
1093 























1094 //-----------------------------------------------------------------------------
1095 // Iterators over DU info, and associated Node functions.
1096 
1097 #if OPTO_DU_ITERATOR_ASSERT
1098 
1099 // Common code for assertion checking on DU iterators.
1100 class DUIterator_Common VALUE_OBJ_CLASS_SPEC {
1101 #ifdef ASSERT
1102  protected:
1103   bool         _vdui;               // cached value of VerifyDUIterators
1104   const Node*  _node;               // the node containing the _out array
1105   uint         _outcnt;             // cached node->_outcnt
1106   uint         _del_tick;           // cached node->_del_tick
1107   Node*        _last;               // last value produced by the iterator
1108 
1109   void sample(const Node* node);    // used by c'tor to set up for verifies
1110   void verify(const Node* node, bool at_end_ok = false);
1111   void verify_resync();
1112   void reset(const DUIterator_Common& that);
1113 


1601   virtual uint cmp( const Node &n ) const;
1602   virtual uint size_of() const; // Size is bigger
1603   const Type* const _type;
1604 public:
1605   void set_type(const Type* t) {
1606     assert(t != NULL, "sanity");
1607     debug_only(uint check_hash = (VerifyHashTableKeys && _hash_lock) ? hash() : NO_HASH);
1608     *(const Type**)&_type = t;   // cast away const-ness
1609     // If this node is in the hash table, make sure it doesn't need a rehash.
1610     assert(check_hash == NO_HASH || check_hash == hash(), "type change must preserve hash code");
1611   }
1612   const Type* type() const { assert(_type != NULL, "sanity"); return _type; };
1613   TypeNode( const Type *t, uint required ) : Node(required), _type(t) {
1614     init_class_id(Class_Type);
1615   }
1616   virtual const Type *Value( PhaseTransform *phase ) const;
1617   virtual const Type *bottom_type() const;
1618   virtual       uint  ideal_reg() const;
1619 #ifndef PRODUCT
1620   virtual void dump_spec(outputStream *st) const;

1621 #endif
1622 };
1623 
1624 #endif // SHARE_VM_OPTO_NODE_HPP
   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1021   // return operand position that can convert from reg to memory access
1022   virtual int cisc_operand() const { return AdlcVMDeps::Not_cisc_spillable; }
1023   bool is_cisc_alternate() const { return (_flags & Flag_is_cisc_alternate) != 0; }
1024 
1025 //----------------- Graph walking
1026 public:
1027   // Walk and apply member functions recursively.
1028   // Supplied (this) pointer is root.
1029   void walk(NFunc pre, NFunc post, void *env);
1030   static void nop(Node &, void*); // Dummy empty function
1031   static void packregion( Node &n, void* );
1032 private:
1033   void walk_(NFunc pre, NFunc post, void *env, VectorSet &visited);
1034 
1035 //----------------- Printing, etc
1036 public:
1037 #ifndef PRODUCT
1038   Node* find(int idx) const;         // Search the graph for the given idx.
1039   Node* find_ctrl(int idx) const;    // Search control ancestors for the given idx.
1040   void dump() const { dump("\n"); }  // Print this node.
1041   void dump(const char* suffix, bool mark = false, outputStream *st = tty) const; // Print this node.
1042   void dump(int depth) const;        // Print this node, recursively to depth d
1043   void dump_ctrl(int depth) const;   // Print control nodes, to depth d
1044   void dump_comp() const;            // Print this node in compact representation.
1045   // Print this node in compact representation.
1046   void dump_comp(const char* suffix, outputStream *st = tty) const;
1047   virtual void dump_req(outputStream *st = tty) const;    // Print required-edge info
1048   virtual void dump_prec(outputStream *st = tty) const;   // Print precedence-edge info
1049   virtual void dump_out(outputStream *st = tty) const;    // Print the output edge info
1050   virtual void dump_spec(outputStream *st) const {};      // Print per-node info
1051   // Print compact per-node info
1052   virtual void dump_comp_spec(outputStream *st) const { dump_spec(st); }
1053   void dump_rel() const;             // Print related nodes (depends on node at hand).
1054   // Print related nodes up to given depths for input and output nodes.
1055   void dump_rel(uint d_in, uint d_out) const;
1056   void dump_rel_comp() const;        // Print related nodes in compact representation.
1057   // Collect related nodes.
1058   virtual void rel(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const;
1059   // Collect nodes starting from this node, explicitly including/excluding control and data links.
1060   void collect_nodes(GrowableArray<Node*> *ns, int d, bool ctrl, bool data) const;
1061 
1062   // Node collectors, to be used in implementations of Node::rel().
1063   // Collect the entire data input graph. Include control inputs if requested.
1064   void collect_nodes_in_all_data(GrowableArray<Node*> *ns, bool ctrl) const;
1065   // Collect the entire control input graph. Include data inputs if requested.
1066   void collect_nodes_in_all_ctrl(GrowableArray<Node*> *ns, bool data) const;
1067   // Collect the entire output graph until hitting and including control nodes.
1068   void collect_nodes_out_all_ctrl_boundary(GrowableArray<Node*> *ns) const;
1069   // Collect the entire data input graph, and outputs till level 1.
1070   void collect_nodes_in_data_out_1(GrowableArray<Node*> *is, GrowableArray<Node*> *os, bool compact) const {
1071     if (compact) {
1072       this->collect_nodes(is, 1, false, true);
1073     } else {
1074       this->collect_nodes_in_all_data(is, false);
1075     }
1076     this->collect_nodes(os, -1, false, false);
1077   }
1078 
1079   void verify_edges(Unique_Node_List &visited); // Verify bi-directional edges
1080   void verify() const;               // Check Def-Use info for my subgraph
1081   static void verify_recur(const Node *n, int verify_depth, VectorSet &old_space, VectorSet &new_space);
1082 
1083   // This call defines a class-unique string used to identify class instances
1084   virtual const char *Name() const;
1085 
1086   void dump_format(PhaseRegAlloc *ra) const; // debug access to MachNode::format(...)
1087   // RegMask Print Functions
1088   void dump_in_regmask(int idx) { in_RegMask(idx).dump(); }
1089   void dump_out_regmask() { out_RegMask().dump(); }
1090   static bool in_dump() { return Compile::current()->_in_dump_cnt > 0; }
1091   void fast_dump() const {
1092     tty->print("%4d: %-17s", _idx, Name());
1093     for (uint i = 0; i < len(); i++)
1094       if (in(i))
1095         tty->print(" %4d", in(i)->_idx);
1096       else
1097         tty->print(" NULL");
1098     tty->print("\n");


1105   int   debug_idx() const              { return _debug_idx; }
1106   void  set_debug_idx( int debug_idx ) { _debug_idx = debug_idx; }
1107 
1108   Node* _debug_orig;                   // Original version of this, if any.
1109   Node*  debug_orig() const            { return _debug_orig; }
1110   void   set_debug_orig(Node* orig);   // _debug_orig = orig
1111 
1112   int        _hash_lock;               // Barrier to modifications of nodes in the hash table
1113   void  enter_hash_lock() { ++_hash_lock; assert(_hash_lock < 99, "in too many hash tables?"); }
1114   void   exit_hash_lock() { --_hash_lock; assert(_hash_lock >= 0, "mispaired hash locks"); }
1115 
1116   static void init_NodeProperty();
1117 
1118   #if OPTO_DU_ITERATOR_ASSERT
1119   const Node* _last_del;               // The last deleted node.
1120   uint        _del_tick;               // Bumped when a deletion happens..
1121   #endif
1122 #endif
1123 };
1124 
1125 
1126 #ifndef PRODUCT
1127 
1128 // Used in debugging code to avoid walking across dead or uninitialized edges.
1129 inline bool NotANode(const Node* n) {
1130   if (n == NULL)                   return true;
1131   if (((intptr_t)n & 1) != 0)      return true;  // uninitialized, etc.
1132   if (*(address*)n == badAddress)  return true;  // kill by Node::destruct
1133   return false;
1134 }
1135 
1136 // This macro provides a common definition of related node retrieval for all
1137 // "arithmetic" nodes, which have no common superclass. The data input trees
1138 // are relevant (until a control node boundary is hit), and the outgoing edges
1139 // till level 1. In compact mode, inputs are collected till level 1 as well.
1140 #define REL_IN_DATA_OUT_1 \
1141   virtual void rel(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const { \
1142     this->collect_nodes_in_data_out_1(in_rel, out_rel, compact); \
1143   }
1144 
1145 #endif
1146 
1147 
1148 //-----------------------------------------------------------------------------
1149 // Iterators over DU info, and associated Node functions.
1150 
1151 #if OPTO_DU_ITERATOR_ASSERT
1152 
1153 // Common code for assertion checking on DU iterators.
1154 class DUIterator_Common VALUE_OBJ_CLASS_SPEC {
1155 #ifdef ASSERT
1156  protected:
1157   bool         _vdui;               // cached value of VerifyDUIterators
1158   const Node*  _node;               // the node containing the _out array
1159   uint         _outcnt;             // cached node->_outcnt
1160   uint         _del_tick;           // cached node->_del_tick
1161   Node*        _last;               // last value produced by the iterator
1162 
1163   void sample(const Node* node);    // used by c'tor to set up for verifies
1164   void verify(const Node* node, bool at_end_ok = false);
1165   void verify_resync();
1166   void reset(const DUIterator_Common& that);
1167 


1655   virtual uint cmp( const Node &n ) const;
1656   virtual uint size_of() const; // Size is bigger
1657   const Type* const _type;
1658 public:
1659   void set_type(const Type* t) {
1660     assert(t != NULL, "sanity");
1661     debug_only(uint check_hash = (VerifyHashTableKeys && _hash_lock) ? hash() : NO_HASH);
1662     *(const Type**)&_type = t;   // cast away const-ness
1663     // If this node is in the hash table, make sure it doesn't need a rehash.
1664     assert(check_hash == NO_HASH || check_hash == hash(), "type change must preserve hash code");
1665   }
1666   const Type* type() const { assert(_type != NULL, "sanity"); return _type; };
1667   TypeNode( const Type *t, uint required ) : Node(required), _type(t) {
1668     init_class_id(Class_Type);
1669   }
1670   virtual const Type *Value( PhaseTransform *phase ) const;
1671   virtual const Type *bottom_type() const;
1672   virtual       uint  ideal_reg() const;
1673 #ifndef PRODUCT
1674   virtual void dump_spec(outputStream *st) const;
1675   virtual void dump_comp_spec(outputStream *st) const;
1676 #endif
1677 };
1678 
1679 #endif // SHARE_VM_OPTO_NODE_HPP
< prev index next >