80 static const char *BYTECODES_ELEMENT; |
80 static const char *BYTECODES_ELEMENT; |
81 static const char *METHOD_BCI_PROPERTY; |
81 static const char *METHOD_BCI_PROPERTY; |
82 static const char *METHOD_SHORT_NAME_PROPERTY; |
82 static const char *METHOD_SHORT_NAME_PROPERTY; |
83 static const char *ASSEMBLY_ELEMENT; |
83 static const char *ASSEMBLY_ELEMENT; |
84 |
84 |
85 class Property { |
85 elapsedTimer _walk_time; |
86 |
86 elapsedTimer _output_time; |
87 private: |
87 elapsedTimer _build_blocks_time; |
88 |
|
89 const char *_name; |
|
90 const char *_value; |
|
91 |
|
92 public: |
|
93 |
|
94 Property(); |
|
95 Property(const Property* p); |
|
96 ~Property(); |
|
97 Property(const char *name, const char *value); |
|
98 Property(const char *name, int value); |
|
99 bool equals(Property* p); |
|
100 void print(IdealGraphPrinter *printer); |
|
101 void print_as_attribute(IdealGraphPrinter *printer); |
|
102 bool is_null(); |
|
103 void clean(); |
|
104 const char *name(); |
|
105 |
|
106 static const char* dup(const char *str) { |
|
107 char * copy = new char[strlen(str)+1]; |
|
108 strcpy(copy, str); |
|
109 return copy; |
|
110 } |
|
111 |
|
112 }; |
|
113 |
|
114 class Properties { |
|
115 |
|
116 private: |
|
117 |
|
118 GrowableArray<Property *> *list; |
|
119 |
|
120 public: |
|
121 |
|
122 Properties(); |
|
123 ~Properties(); |
|
124 void add(Property *p); |
|
125 void remove(const char *name); |
|
126 bool equals(Properties* p); |
|
127 void print(IdealGraphPrinter *printer); |
|
128 void print_as_attributes(IdealGraphPrinter *printer); |
|
129 void clean(); |
|
130 |
|
131 }; |
|
132 |
|
133 |
|
134 class Description { |
|
135 |
|
136 private: |
|
137 |
|
138 State _state; |
|
139 |
|
140 public: |
|
141 |
|
142 Description(); |
|
143 |
|
144 State state(); |
|
145 void set_state(State s); |
|
146 void print(IdealGraphPrinter *printer); |
|
147 virtual void print_changed(IdealGraphPrinter *printer) = 0; |
|
148 virtual void print_removed(IdealGraphPrinter *printer) = 0; |
|
149 |
|
150 }; |
|
151 |
|
152 class NodeDescription : public Description{ |
|
153 |
|
154 public: |
|
155 |
|
156 static int count; |
|
157 |
|
158 private: |
|
159 |
|
160 GrowableArray<NodeDescription *> _succs; |
|
161 int _block_index; |
|
162 uintptr_t _id; |
|
163 Properties _properties; |
|
164 Node* _node; |
|
165 |
|
166 public: |
|
167 |
|
168 NodeDescription(Node* node); |
|
169 ~NodeDescription(); |
|
170 Node* node(); |
|
171 |
|
172 // void set_node(Node* node); |
|
173 GrowableArray<NodeDescription *>* succs(); |
|
174 void init_succs(); |
|
175 void clear_succs(); |
|
176 void add_succ(NodeDescription *desc); |
|
177 int block_index(); |
|
178 void set_block_index(int i); |
|
179 Properties* properties(); |
|
180 virtual void print_changed(IdealGraphPrinter *printer); |
|
181 virtual void print_removed(IdealGraphPrinter *printer); |
|
182 bool equals(NodeDescription *desc); |
|
183 uint id(); |
|
184 |
|
185 }; |
|
186 |
|
187 class Block { |
|
188 |
|
189 private: |
|
190 |
|
191 NodeDescription *_start; |
|
192 NodeDescription *_proj; |
|
193 GrowableArray<int> _succs; |
|
194 GrowableArray<NodeDescription *> _nodes; |
|
195 GrowableArray<int> _dominates; |
|
196 GrowableArray<int> _children; |
|
197 int _semi; |
|
198 int _parent; |
|
199 GrowableArray<int> _pred; |
|
200 GrowableArray<int> _bucket; |
|
201 int _index; |
|
202 int _dominator; |
|
203 int _ancestor; |
|
204 int _label; |
|
205 |
|
206 public: |
|
207 |
|
208 Block(); |
|
209 Block(int index); |
|
210 |
|
211 void add_node(NodeDescription *n); |
|
212 GrowableArray<NodeDescription *>* nodes(); |
|
213 GrowableArray<int>* children(); |
|
214 void add_child(int i); |
|
215 void add_succ(int index); |
|
216 GrowableArray<int>* succs(); |
|
217 GrowableArray<int>* dominates(); |
|
218 void add_dominates(int i); |
|
219 NodeDescription *start(); |
|
220 NodeDescription *proj(); |
|
221 void set_start(NodeDescription *n); |
|
222 void set_proj(NodeDescription *n); |
|
223 |
|
224 int label(); |
|
225 void set_label(int i); |
|
226 int ancestor(); |
|
227 void set_ancestor(int i); |
|
228 int index(); |
|
229 int dominator(); |
|
230 void set_dominator(int i); |
|
231 int parent(); |
|
232 void set_parent(int i); |
|
233 int semi(); |
|
234 GrowableArray<int>* bucket(); |
|
235 void add_to_bucket(int i); |
|
236 void clear_bucket(); |
|
237 GrowableArray<int>* pred(); |
|
238 void set_semi(int i); |
|
239 void add_pred(int i); |
|
240 |
|
241 }; |
|
242 |
|
243 class EdgeDescription : public Description { |
|
244 |
|
245 private: |
|
246 |
|
247 int _from; |
|
248 int _to; |
|
249 int _index; |
|
250 public: |
|
251 |
|
252 EdgeDescription(int from, int to, int index); |
|
253 ~EdgeDescription(); |
|
254 |
|
255 virtual void print_changed(IdealGraphPrinter *printer); |
|
256 virtual void print_removed(IdealGraphPrinter *printer); |
|
257 bool equals(EdgeDescription *desc); |
|
258 int from(); |
|
259 int to(); |
|
260 }; |
|
261 |
|
262 |
88 |
263 static int _file_count; |
89 static int _file_count; |
264 networkStream *_stream; |
90 networkStream *_stream; |
|
91 xmlStream *_xml; |
265 outputStream *_output; |
92 outputStream *_output; |
266 ciMethod *_current_method; |
93 ciMethod *_current_method; |
267 GrowableArray<NodeDescription *> _nodes; |
|
268 GrowableArray<EdgeDescription *> _edges; |
|
269 int _depth; |
94 int _depth; |
270 Arena *_arena; |
|
271 char buffer[128]; |
95 char buffer[128]; |
272 bool _should_send_method; |
96 bool _should_send_method; |
273 PhaseChaitin* _chaitin; |
97 PhaseChaitin* _chaitin; |
274 bool _clear_nodes; |
|
275 Matcher* _matcher; |
|
276 bool _traverse_outs; |
98 bool _traverse_outs; |
277 |
99 Compile *C; |
278 void start_element_helper(const char *name, Properties *properties, bool endElement, bool print_indent = false, bool print_return = true); |
|
279 NodeDescription *create_node_description(Node* node); |
|
280 |
100 |
281 static void pre_node(Node* node, void *env); |
101 static void pre_node(Node* node, void *env); |
282 static void post_node(Node* node, void *env); |
102 static void post_node(Node* node, void *env); |
283 |
103 |
284 void schedule_latest(int **common_dominator, GrowableArray<Block>* blocks); |
|
285 void build_common_dominator(int **common_dominator, int index, GrowableArray<Block>* blocks); |
|
286 void compress(int index, GrowableArray<Block>* blocks); |
|
287 int eval(int index, GrowableArray<Block>* blocks); |
|
288 void link(int index1, int index2, GrowableArray<Block>* blocks); |
|
289 void build_dominators(GrowableArray<Block>* blocks); |
|
290 void build_blocks(Node *node); |
|
291 void walk(Node *n); |
|
292 void start_element(const char *name, Properties *properties = NULL, bool print_indent = false, bool print_return = true); |
|
293 void simple_element(const char *name, Properties *properties = NULL, bool print_indent = false); |
|
294 void end_element(const char *name, bool print_indent = false, bool print_return = true); |
|
295 void print_edge(int from, int to, int index); |
|
296 void print_indent(); |
104 void print_indent(); |
297 void print_method(ciMethod *method, int bci, InlineTree *tree); |
105 void print_method(ciMethod *method, int bci, InlineTree *tree); |
298 void print_inline_tree(InlineTree *tree); |
106 void print_inline_tree(InlineTree *tree); |
299 void clear_nodes(); |
107 void visit_node(Node *n, void *param); |
300 |
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); |
301 IdealGraphPrinter(); |
121 IdealGraphPrinter(); |
302 ~IdealGraphPrinter(); |
122 ~IdealGraphPrinter(); |
303 |
123 |
304 public: |
124 public: |
305 |
125 |
306 static void clean_up(); |
126 static void clean_up(); |
307 static IdealGraphPrinter *printer(); |
127 static IdealGraphPrinter *printer(); |
308 |
128 |
309 bool traverse_outs(); |
129 bool traverse_outs(); |
310 void set_traverse_outs(bool b); |
130 void set_traverse_outs(bool b); |
311 void print_ifg(PhaseIFG* ifg); |
|
312 outputStream *output(); |
131 outputStream *output(); |
313 void print_inlining(Compile* compile); |
132 void print_inlining(Compile* compile); |
314 void begin_method(Compile* compile); |
133 void begin_method(Compile* compile); |
315 void end_method(); |
134 void end_method(); |
316 void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false); |
135 void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false); |