src/share/vm/opto/idealGraphPrinter.hpp

Fri, 07 Mar 2008 11:09:13 -0800

author
kvn
date
Fri, 07 Mar 2008 11:09:13 -0800
changeset 476
874b2c4f43d1
parent 435
a61af66fc99e
child 657
2a1a77d3458f
permissions
-rw-r--r--

6667605: (Escape Analysis) inline java constructors when EA is on
Summary: java constructors should be inlined to be able scalar replace a new object
Reviewed-by: rasbold

duke@435 1 /*
duke@435 2 * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #ifndef PRODUCT
duke@435 26
duke@435 27 class Compile;
duke@435 28 class PhaseIFG;
duke@435 29 class PhaseChaitin;
duke@435 30 class Matcher;
duke@435 31 class Node;
duke@435 32 class InlineTree;
duke@435 33 class ciMethod;
duke@435 34
duke@435 35 class IdealGraphPrinter
duke@435 36 {
duke@435 37 private:
duke@435 38
duke@435 39 enum State
duke@435 40 {
duke@435 41 Invalid,
duke@435 42 Valid,
duke@435 43 New
duke@435 44 };
duke@435 45
duke@435 46 private:
duke@435 47
duke@435 48 static const char *INDENT;
duke@435 49 static const char *TOP_ELEMENT;
duke@435 50 static const char *GROUP_ELEMENT;
duke@435 51 static const char *GRAPH_ELEMENT;
duke@435 52 static const char *PROPERTIES_ELEMENT;
duke@435 53 static const char *EDGES_ELEMENT;
duke@435 54 static const char *PROPERTY_ELEMENT;
duke@435 55 static const char *EDGE_ELEMENT;
duke@435 56 static const char *NODE_ELEMENT;
duke@435 57 static const char *NODES_ELEMENT;
duke@435 58 static const char *CONTROL_FLOW_ELEMENT;
duke@435 59 static const char *REMOVE_EDGE_ELEMENT;
duke@435 60 static const char *REMOVE_NODE_ELEMENT;
duke@435 61 static const char *METHOD_NAME_PROPERTY;
duke@435 62 static const char *BLOCK_NAME_PROPERTY;
duke@435 63 static const char *BLOCK_DOMINATOR_PROPERTY;
duke@435 64 static const char *BLOCK_ELEMENT;
duke@435 65 static const char *SUCCESSORS_ELEMENT;
duke@435 66 static const char *SUCCESSOR_ELEMENT;
duke@435 67 static const char *METHOD_IS_PUBLIC_PROPERTY;
duke@435 68 static const char *METHOD_IS_STATIC_PROPERTY;
duke@435 69 static const char *TRUE_VALUE;
duke@435 70 static const char *NODE_NAME_PROPERTY;
duke@435 71 static const char *EDGE_NAME_PROPERTY;
duke@435 72 static const char *NODE_ID_PROPERTY;
duke@435 73 static const char *FROM_PROPERTY;
duke@435 74 static const char *TO_PROPERTY;
duke@435 75 static const char *PROPERTY_NAME_PROPERTY;
duke@435 76 static const char *GRAPH_NAME_PROPERTY;
duke@435 77 static const char *INDEX_PROPERTY;
duke@435 78 static const char *METHOD_ELEMENT;
duke@435 79 static const char *INLINE_ELEMENT;
duke@435 80 static const char *BYTECODES_ELEMENT;
duke@435 81 static const char *METHOD_BCI_PROPERTY;
duke@435 82 static const char *METHOD_SHORT_NAME_PROPERTY;
duke@435 83 static const char *ASSEMBLY_ELEMENT;
duke@435 84
duke@435 85 class Property {
duke@435 86
duke@435 87 private:
duke@435 88
duke@435 89 const char *_name;
duke@435 90 const char *_value;
duke@435 91
duke@435 92 public:
duke@435 93
duke@435 94 Property();
duke@435 95 Property(const Property* p);
duke@435 96 ~Property();
duke@435 97 Property(const char *name, const char *value);
duke@435 98 Property(const char *name, int value);
duke@435 99 bool equals(Property* p);
duke@435 100 void print(IdealGraphPrinter *printer);
duke@435 101 void print_as_attribute(IdealGraphPrinter *printer);
duke@435 102 bool is_null();
duke@435 103 void clean();
duke@435 104 const char *name();
duke@435 105
duke@435 106 static const char* dup(const char *str) {
duke@435 107 char * copy = new char[strlen(str)+1];
duke@435 108 strcpy(copy, str);
duke@435 109 return copy;
duke@435 110 }
duke@435 111
duke@435 112 };
duke@435 113
duke@435 114 class Properties {
duke@435 115
duke@435 116 private:
duke@435 117
duke@435 118 GrowableArray<Property *> *list;
duke@435 119
duke@435 120 public:
duke@435 121
duke@435 122 Properties();
duke@435 123 ~Properties();
duke@435 124 void add(Property *p);
duke@435 125 void remove(const char *name);
duke@435 126 bool equals(Properties* p);
duke@435 127 void print(IdealGraphPrinter *printer);
duke@435 128 void print_as_attributes(IdealGraphPrinter *printer);
duke@435 129 void clean();
duke@435 130
duke@435 131 };
duke@435 132
duke@435 133
duke@435 134 class Description {
duke@435 135
duke@435 136 private:
duke@435 137
duke@435 138 State _state;
duke@435 139
duke@435 140 public:
duke@435 141
duke@435 142 Description();
duke@435 143
duke@435 144 State state();
duke@435 145 void set_state(State s);
duke@435 146 void print(IdealGraphPrinter *printer);
duke@435 147 virtual void print_changed(IdealGraphPrinter *printer) = 0;
duke@435 148 virtual void print_removed(IdealGraphPrinter *printer) = 0;
duke@435 149
duke@435 150 };
duke@435 151
duke@435 152 class NodeDescription : public Description{
duke@435 153
duke@435 154 public:
duke@435 155
duke@435 156 static int count;
duke@435 157
duke@435 158 private:
duke@435 159
duke@435 160 GrowableArray<NodeDescription *> _succs;
duke@435 161 int _block_index;
duke@435 162 uintptr_t _id;
duke@435 163 Properties _properties;
duke@435 164 Node* _node;
duke@435 165
duke@435 166 public:
duke@435 167
duke@435 168 NodeDescription(Node* node);
duke@435 169 ~NodeDescription();
duke@435 170 Node* node();
duke@435 171
duke@435 172 // void set_node(Node* node);
duke@435 173 GrowableArray<NodeDescription *>* succs();
duke@435 174 void init_succs();
duke@435 175 void clear_succs();
duke@435 176 void add_succ(NodeDescription *desc);
duke@435 177 int block_index();
duke@435 178 void set_block_index(int i);
duke@435 179 Properties* properties();
duke@435 180 virtual void print_changed(IdealGraphPrinter *printer);
duke@435 181 virtual void print_removed(IdealGraphPrinter *printer);
duke@435 182 bool equals(NodeDescription *desc);
duke@435 183 uint id();
duke@435 184
duke@435 185 };
duke@435 186
duke@435 187 class Block {
duke@435 188
duke@435 189 private:
duke@435 190
duke@435 191 NodeDescription *_start;
duke@435 192 NodeDescription *_proj;
duke@435 193 GrowableArray<int> _succs;
duke@435 194 GrowableArray<NodeDescription *> _nodes;
duke@435 195 GrowableArray<int> _dominates;
duke@435 196 GrowableArray<int> _children;
duke@435 197 int _semi;
duke@435 198 int _parent;
duke@435 199 GrowableArray<int> _pred;
duke@435 200 GrowableArray<int> _bucket;
duke@435 201 int _index;
duke@435 202 int _dominator;
duke@435 203 int _ancestor;
duke@435 204 int _label;
duke@435 205
duke@435 206 public:
duke@435 207
duke@435 208 Block();
duke@435 209 Block(int index);
duke@435 210
duke@435 211 void add_node(NodeDescription *n);
duke@435 212 GrowableArray<NodeDescription *>* nodes();
duke@435 213 GrowableArray<int>* children();
duke@435 214 void add_child(int i);
duke@435 215 void add_succ(int index);
duke@435 216 GrowableArray<int>* succs();
duke@435 217 GrowableArray<int>* dominates();
duke@435 218 void add_dominates(int i);
duke@435 219 NodeDescription *start();
duke@435 220 NodeDescription *proj();
duke@435 221 void set_start(NodeDescription *n);
duke@435 222 void set_proj(NodeDescription *n);
duke@435 223
duke@435 224 int label();
duke@435 225 void set_label(int i);
duke@435 226 int ancestor();
duke@435 227 void set_ancestor(int i);
duke@435 228 int index();
duke@435 229 int dominator();
duke@435 230 void set_dominator(int i);
duke@435 231 int parent();
duke@435 232 void set_parent(int i);
duke@435 233 int semi();
duke@435 234 GrowableArray<int>* bucket();
duke@435 235 void add_to_bucket(int i);
duke@435 236 void clear_bucket();
duke@435 237 GrowableArray<int>* pred();
duke@435 238 void set_semi(int i);
duke@435 239 void add_pred(int i);
duke@435 240
duke@435 241 };
duke@435 242
duke@435 243 class EdgeDescription : public Description {
duke@435 244
duke@435 245 private:
duke@435 246
duke@435 247 int _from;
duke@435 248 int _to;
duke@435 249 int _index;
duke@435 250 public:
duke@435 251
duke@435 252 EdgeDescription(int from, int to, int index);
duke@435 253 ~EdgeDescription();
duke@435 254
duke@435 255 virtual void print_changed(IdealGraphPrinter *printer);
duke@435 256 virtual void print_removed(IdealGraphPrinter *printer);
duke@435 257 bool equals(EdgeDescription *desc);
duke@435 258 int from();
duke@435 259 int to();
duke@435 260 };
duke@435 261
duke@435 262
duke@435 263 static int _file_count;
duke@435 264 networkStream *_stream;
duke@435 265 outputStream *_output;
duke@435 266 ciMethod *_current_method;
duke@435 267 GrowableArray<NodeDescription *> _nodes;
duke@435 268 GrowableArray<EdgeDescription *> _edges;
duke@435 269 int _depth;
duke@435 270 Arena *_arena;
duke@435 271 char buffer[128];
duke@435 272 bool _should_send_method;
duke@435 273 PhaseChaitin* _chaitin;
duke@435 274 bool _clear_nodes;
duke@435 275 Matcher* _matcher;
duke@435 276 bool _traverse_outs;
duke@435 277
duke@435 278 void start_element_helper(const char *name, Properties *properties, bool endElement, bool print_indent = false, bool print_return = true);
duke@435 279 NodeDescription *create_node_description(Node* node);
duke@435 280
duke@435 281 static void pre_node(Node* node, void *env);
duke@435 282 static void post_node(Node* node, void *env);
duke@435 283
duke@435 284 void schedule_latest(int **common_dominator, GrowableArray<Block>* blocks);
duke@435 285 void build_common_dominator(int **common_dominator, int index, GrowableArray<Block>* blocks);
duke@435 286 void compress(int index, GrowableArray<Block>* blocks);
duke@435 287 int eval(int index, GrowableArray<Block>* blocks);
duke@435 288 void link(int index1, int index2, GrowableArray<Block>* blocks);
duke@435 289 void build_dominators(GrowableArray<Block>* blocks);
duke@435 290 void build_blocks(Node *node);
duke@435 291 void walk(Node *n);
duke@435 292 void start_element(const char *name, Properties *properties = NULL, bool print_indent = false, bool print_return = true);
duke@435 293 void simple_element(const char *name, Properties *properties = NULL, bool print_indent = false);
duke@435 294 void end_element(const char *name, bool print_indent = false, bool print_return = true);
duke@435 295 void print_edge(int from, int to, int index);
duke@435 296 void print_indent();
duke@435 297 void print_method(ciMethod *method, int bci, InlineTree *tree);
duke@435 298 void print_inline_tree(InlineTree *tree);
duke@435 299 void clear_nodes();
duke@435 300
duke@435 301 IdealGraphPrinter();
duke@435 302 ~IdealGraphPrinter();
duke@435 303
duke@435 304 public:
duke@435 305
duke@435 306 static void clean_up();
duke@435 307 static IdealGraphPrinter *printer();
duke@435 308
duke@435 309 bool traverse_outs();
duke@435 310 void set_traverse_outs(bool b);
duke@435 311 void print_ifg(PhaseIFG* ifg);
duke@435 312 outputStream *output();
duke@435 313 void print_inlining(Compile* compile);
duke@435 314 void begin_method(Compile* compile);
duke@435 315 void end_method();
duke@435 316 void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false);
duke@435 317 void print(Compile* compile, const char *name, Node *root, int level=1, bool clear_nodes = false);
duke@435 318 void print_xml(const char *name);
duke@435 319
duke@435 320
duke@435 321 };
duke@435 322
duke@435 323 #endif

mercurial