hotspot/src/share/vm/opto/idealGraphPrinter.hpp

Print this page
rev 611 : Merge
   1 #ifdef USE_PRAGMA_IDENT_HDR
   2 #pragma ident "@(#)idealGraphPrinter.hpp        1.1 07/09/28 11:48:37 JVM"
   3 #endif
   4 /*
   5  * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or


  68   static const char *SUCCESSORS_ELEMENT;
  69   static const char *SUCCESSOR_ELEMENT;
  70   static const char *METHOD_IS_PUBLIC_PROPERTY;
  71   static const char *METHOD_IS_STATIC_PROPERTY;
  72   static const char *TRUE_VALUE;
  73   static const char *NODE_NAME_PROPERTY;
  74   static const char *EDGE_NAME_PROPERTY; 
  75   static const char *NODE_ID_PROPERTY;
  76   static const char *FROM_PROPERTY;
  77   static const char *TO_PROPERTY;
  78   static const char *PROPERTY_NAME_PROPERTY;
  79   static const char *GRAPH_NAME_PROPERTY;
  80   static const char *INDEX_PROPERTY;
  81   static const char *METHOD_ELEMENT;
  82   static const char *INLINE_ELEMENT;
  83   static const char *BYTECODES_ELEMENT;
  84   static const char *METHOD_BCI_PROPERTY;
  85   static const char *METHOD_SHORT_NAME_PROPERTY;
  86   static const char *ASSEMBLY_ELEMENT;
  87 
  88   class Property { 
  89     
  90   private:
  91 
  92     const char *_name;
  93     const char *_value;
  94 
  95   public:
  96 
  97     Property();
  98     Property(const Property* p);
  99     ~Property();
 100     Property(const char *name, const char *value);
 101     Property(const char *name, int value);
 102     bool equals(Property* p);
 103     void print(IdealGraphPrinter *printer);
 104     void print_as_attribute(IdealGraphPrinter *printer);
 105     bool is_null();
 106     void clean();
 107     const char *name();
 108 
 109     static const char* dup(const char *str) {
 110       char * copy = new char[strlen(str)+1];
 111       strcpy(copy, str);
 112       return copy;
 113     }
 114 
 115   };
 116 
 117   class Properties {
 118   
 119   private:
 120 
 121     GrowableArray<Property *> *list;
 122 
 123   public:
 124 
 125     Properties();
 126     ~Properties();
 127     void add(Property *p);
 128     void remove(const char *name);
 129     bool equals(Properties* p);
 130     void print(IdealGraphPrinter *printer);
 131     void print_as_attributes(IdealGraphPrinter *printer);
 132     void clean();
 133 
 134   };
 135 
 136 
 137   class Description {
 138 
 139   private:
 140 
 141     State _state;
 142 
 143   public:
 144 
 145     Description();
 146 
 147     State state();
 148     void set_state(State s);
 149     void print(IdealGraphPrinter *printer);
 150     virtual void print_changed(IdealGraphPrinter *printer) = 0;
 151     virtual void print_removed(IdealGraphPrinter *printer) = 0;
 152 
 153   };
 154 
 155   class NodeDescription : public Description{
 156   
 157   public:
 158 
 159     static int count;
 160 
 161   private:
 162 
 163     GrowableArray<NodeDescription *> _succs;
 164     int _block_index;
 165     uintptr_t _id;
 166     Properties _properties;
 167     Node* _node;
 168 
 169   public:
 170 
 171     NodeDescription(Node* node);
 172     ~NodeDescription();
 173     Node* node();
 174     
 175     // void set_node(Node* node);
 176     GrowableArray<NodeDescription *>* succs();
 177     void init_succs();
 178     void clear_succs();
 179     void add_succ(NodeDescription *desc);
 180     int block_index();
 181     void set_block_index(int i);
 182     Properties* properties();
 183     virtual void print_changed(IdealGraphPrinter *printer);
 184     virtual void print_removed(IdealGraphPrinter *printer);
 185     bool equals(NodeDescription *desc);
 186     uint id();
 187 
 188   };
 189 
 190   class Block {
 191     
 192   private:
 193 
 194     NodeDescription *_start;
 195     NodeDescription *_proj;
 196     GrowableArray<int> _succs;
 197     GrowableArray<NodeDescription *> _nodes;
 198     GrowableArray<int> _dominates;
 199     GrowableArray<int> _children;
 200     int _semi;
 201     int _parent;
 202     GrowableArray<int> _pred;
 203     GrowableArray<int> _bucket;
 204     int _index;
 205     int _dominator;
 206     int _ancestor;
 207     int _label;
 208 
 209   public:
 210 
 211     Block();
 212     Block(int index);
 213 
 214     void add_node(NodeDescription *n);
 215     GrowableArray<NodeDescription *>* nodes();
 216     GrowableArray<int>* children();
 217     void add_child(int i);
 218     void add_succ(int index);
 219     GrowableArray<int>* succs();
 220     GrowableArray<int>* dominates();
 221     void add_dominates(int i);
 222     NodeDescription *start();
 223     NodeDescription *proj();
 224     void set_start(NodeDescription *n);
 225     void set_proj(NodeDescription *n);
 226 
 227     int label();
 228     void set_label(int i);
 229     int ancestor();
 230     void set_ancestor(int i);
 231     int index();
 232     int dominator();
 233     void set_dominator(int i);
 234     int parent();
 235     void set_parent(int i);
 236     int semi();
 237     GrowableArray<int>* bucket();
 238     void add_to_bucket(int i);
 239     void clear_bucket();
 240     GrowableArray<int>* pred();
 241     void set_semi(int i);
 242     void add_pred(int i);
 243 
 244   };
 245 
 246   class EdgeDescription : public Description {
 247 
 248   private:
 249 
 250     int _from;
 251     int _to;
 252     int _index;
 253   public:
 254 
 255     EdgeDescription(int from, int to, int index);
 256     ~EdgeDescription();
 257 
 258     virtual void print_changed(IdealGraphPrinter *printer);
 259     virtual void print_removed(IdealGraphPrinter *printer);
 260     bool equals(EdgeDescription *desc);
 261     int from();
 262     int to();
 263   };
 264 
 265 
 266   static int _file_count;
 267   networkStream *_stream;

 268   outputStream *_output;
 269   ciMethod *_current_method;
 270   GrowableArray<NodeDescription *> _nodes;
 271   GrowableArray<EdgeDescription *> _edges;
 272   int _depth;
 273   Arena *_arena;
 274   char buffer[128];
 275   bool _should_send_method;
 276   PhaseChaitin* _chaitin;
 277   bool _clear_nodes;
 278   Matcher* _matcher;
 279   bool _traverse_outs;
 280 
 281   void start_element_helper(const char *name, Properties *properties, bool endElement, bool print_indent = false, bool print_return = true);
 282   NodeDescription *create_node_description(Node* node);
 283 
 284   static void pre_node(Node* node, void *env);
 285   static void post_node(Node* node, void *env);
 286 
 287   void schedule_latest(int **common_dominator, GrowableArray<Block>* blocks);
 288   void build_common_dominator(int **common_dominator, int index, GrowableArray<Block>* blocks);
 289   void compress(int index, GrowableArray<Block>* blocks);
 290   int eval(int index, GrowableArray<Block>* blocks);
 291   void link(int index1, int index2, GrowableArray<Block>* blocks);
 292   void build_dominators(GrowableArray<Block>* blocks);
 293   void build_blocks(Node *node);
 294   void walk(Node *n);
 295   void start_element(const char *name, Properties *properties = NULL, bool print_indent = false, bool print_return = true);
 296   void simple_element(const char *name, Properties *properties = NULL, bool print_indent = false);
 297   void end_element(const char *name, bool print_indent = false, bool print_return = true);
 298   void print_edge(int from, int to, int index);
 299   void print_indent();
 300   void print_method(ciMethod *method, int bci, InlineTree *tree);
 301   void print_inline_tree(InlineTree *tree);
 302   void clear_nodes();
 303 












 304   IdealGraphPrinter();
 305   ~IdealGraphPrinter();
 306   
 307 public:
 308   
 309   static void clean_up();
 310   static IdealGraphPrinter *printer();
 311 
 312   bool traverse_outs();
 313   void set_traverse_outs(bool b);
 314   void print_ifg(PhaseIFG* ifg);
 315   outputStream *output();
 316   void print_inlining(Compile* compile);
 317   void begin_method(Compile* compile);
 318   void end_method();
 319   void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false);
 320   void print(Compile* compile, const char *name, Node *root, int level=1, bool clear_nodes = false);
 321   void print_xml(const char *name);
 322 
 323 
 324 };
 325 
 326 #endif



   1 /*
   2  * Copyright 2007 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or


  65   static const char *SUCCESSORS_ELEMENT;
  66   static const char *SUCCESSOR_ELEMENT;
  67   static const char *METHOD_IS_PUBLIC_PROPERTY;
  68   static const char *METHOD_IS_STATIC_PROPERTY;
  69   static const char *TRUE_VALUE;
  70   static const char *NODE_NAME_PROPERTY;
  71   static const char *EDGE_NAME_PROPERTY;
  72   static const char *NODE_ID_PROPERTY;
  73   static const char *FROM_PROPERTY;
  74   static const char *TO_PROPERTY;
  75   static const char *PROPERTY_NAME_PROPERTY;
  76   static const char *GRAPH_NAME_PROPERTY;
  77   static const char *INDEX_PROPERTY;
  78   static const char *METHOD_ELEMENT;
  79   static const char *INLINE_ELEMENT;
  80   static const char *BYTECODES_ELEMENT;
  81   static const char *METHOD_BCI_PROPERTY;
  82   static const char *METHOD_SHORT_NAME_PROPERTY;
  83   static const char *ASSEMBLY_ELEMENT;
  84 
  85   elapsedTimer _walk_time;
  86   elapsedTimer _output_time;
  87   elapsedTimer _build_blocks_time;














































































































































































  88 
  89   static int _file_count;
  90   networkStream *_stream;
  91   xmlStream *_xml;
  92   outputStream *_output;
  93   ciMethod *_current_method;


  94   int _depth;

  95   char buffer[128];
  96   bool _should_send_method;
  97   PhaseChaitin* _chaitin;


  98   bool _traverse_outs;
  99   Compile *C;


 100 
 101   static void pre_node(Node* node, void *env);
 102   static void post_node(Node* node, void *env);
 103 












 104   void print_indent();
 105   void print_method(ciMethod *method, int bci, InlineTree *tree);
 106   void print_inline_tree(InlineTree *tree);
 107   void visit_node(Node *n, void *param);
 108   void walk_nodes(Node *start, void *param);
 109   void begin_elem(const char *s);
 110   void end_elem();
 111   void begin_head(const char *s);
 112   void end_head();
 113   void print_attr(const char *name, const char *val);
 114   void print_attr(const char *name, intptr_t val);
 115   void print_prop(const char *name, const char *val);
 116   void print_prop(const char *name, int val);
 117   void tail(const char *name);
 118   void head(const char *name);
 119   void text(const char *s);
 120   intptr_t get_node_id(Node *n);
 121   IdealGraphPrinter();
 122   ~IdealGraphPrinter();
 123 
 124 public:
 125 
 126   static void clean_up();
 127   static IdealGraphPrinter *printer();
 128 
 129   bool traverse_outs();
 130   void set_traverse_outs(bool b);

 131   outputStream *output();
 132   void print_inlining(Compile* compile);
 133   void begin_method(Compile* compile);
 134   void end_method();
 135   void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false);
 136   void print(Compile* compile, const char *name, Node *root, int level=1, bool clear_nodes = false);
 137   void print_xml(const char *name);
 138 
 139 
 140 };
 141 
 142 #endif