duke@435: /* minqi@5103: * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_OPTO_IDEALGRAPHPRINTER_HPP stefank@2314: #define SHARE_VM_OPTO_IDEALGRAPHPRINTER_HPP stefank@2314: stefank@2314: #include "libadt/dict.hpp" stefank@2314: #include "libadt/vectset.hpp" stefank@2314: #include "utilities/growableArray.hpp" stefank@2314: #include "utilities/ostream.hpp" stefank@2314: #include "utilities/xmlstream.hpp" stefank@2314: duke@435: #ifndef PRODUCT duke@435: duke@435: class Compile; duke@435: class PhaseIFG; duke@435: class PhaseChaitin; duke@435: class Matcher; duke@435: class Node; duke@435: class InlineTree; duke@435: class ciMethod; duke@435: minqi@5103: class IdealGraphPrinter : public CHeapObj { minqi@5103: private: duke@435: duke@435: static const char *INDENT; duke@435: static const char *TOP_ELEMENT; duke@435: static const char *GROUP_ELEMENT; duke@435: static const char *GRAPH_ELEMENT; duke@435: static const char *PROPERTIES_ELEMENT; duke@435: static const char *EDGES_ELEMENT; duke@435: static const char *PROPERTY_ELEMENT; duke@435: static const char *EDGE_ELEMENT; duke@435: static const char *NODE_ELEMENT; duke@435: static const char *NODES_ELEMENT; duke@435: static const char *CONTROL_FLOW_ELEMENT; duke@435: static const char *REMOVE_EDGE_ELEMENT; duke@435: static const char *REMOVE_NODE_ELEMENT; duke@435: static const char *METHOD_NAME_PROPERTY; duke@435: static const char *BLOCK_NAME_PROPERTY; duke@435: static const char *BLOCK_DOMINATOR_PROPERTY; duke@435: static const char *BLOCK_ELEMENT; duke@435: static const char *SUCCESSORS_ELEMENT; duke@435: static const char *SUCCESSOR_ELEMENT; duke@435: static const char *METHOD_IS_PUBLIC_PROPERTY; duke@435: static const char *METHOD_IS_STATIC_PROPERTY; duke@435: static const char *TRUE_VALUE; duke@435: static const char *NODE_NAME_PROPERTY; duke@435: static const char *EDGE_NAME_PROPERTY; duke@435: static const char *NODE_ID_PROPERTY; duke@435: static const char *FROM_PROPERTY; duke@435: static const char *TO_PROPERTY; duke@435: static const char *PROPERTY_NAME_PROPERTY; duke@435: static const char *GRAPH_NAME_PROPERTY; duke@435: static const char *INDEX_PROPERTY; duke@435: static const char *METHOD_ELEMENT; duke@435: static const char *INLINE_ELEMENT; duke@435: static const char *BYTECODES_ELEMENT; duke@435: static const char *METHOD_BCI_PROPERTY; duke@435: static const char *METHOD_SHORT_NAME_PROPERTY; duke@435: static const char *ASSEMBLY_ELEMENT; duke@435: never@657: elapsedTimer _walk_time; never@657: elapsedTimer _output_time; never@657: elapsedTimer _build_blocks_time; duke@435: duke@435: static int _file_count; duke@435: networkStream *_stream; never@657: xmlStream *_xml; duke@435: outputStream *_output; duke@435: ciMethod *_current_method; duke@435: int _depth; duke@435: char buffer[128]; duke@435: bool _should_send_method; duke@435: PhaseChaitin* _chaitin; duke@435: bool _traverse_outs; never@657: Compile *C; duke@435: duke@435: static void pre_node(Node* node, void *env); duke@435: static void post_node(Node* node, void *env); duke@435: duke@435: void print_indent(); duke@435: void print_method(ciMethod *method, int bci, InlineTree *tree); duke@435: void print_inline_tree(InlineTree *tree); never@3105: void visit_node(Node *n, bool edges, VectorSet* temp_set); never@3105: void walk_nodes(Node *start, bool edges, VectorSet* temp_set); never@657: void begin_elem(const char *s); never@657: void end_elem(); never@657: void begin_head(const char *s); never@657: void end_head(); never@657: void print_attr(const char *name, const char *val); never@657: void print_attr(const char *name, intptr_t val); never@657: void print_prop(const char *name, const char *val); never@657: void print_prop(const char *name, int val); never@657: void tail(const char *name); never@657: void head(const char *name); never@657: void text(const char *s); never@657: intptr_t get_node_id(Node *n); duke@435: IdealGraphPrinter(); duke@435: ~IdealGraphPrinter(); duke@435: minqi@5103: public: duke@435: duke@435: static void clean_up(); duke@435: static IdealGraphPrinter *printer(); duke@435: duke@435: bool traverse_outs(); duke@435: void set_traverse_outs(bool b); duke@435: outputStream *output(); duke@435: void print_inlining(Compile* compile); duke@435: void begin_method(Compile* compile); duke@435: void end_method(); duke@435: void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false); duke@435: void print(Compile* compile, const char *name, Node *root, int level=1, bool clear_nodes = false); duke@435: void print_xml(const char *name); duke@435: }; duke@435: duke@435: #endif stefank@2314: stefank@2314: #endif // SHARE_VM_OPTO_IDEALGRAPHPRINTER_HPP