Index: vm/il_printer.h |
=================================================================== |
--- vm/il_printer.h (revision 8145) |
+++ vm/il_printer.h (working copy) |
@@ -34,8 +34,6 @@ |
const GrowableArray<BlockEntryInstr*>& block_order) |
: function_(function), block_order_(block_order) { } |
- virtual ~FlowGraphPrinter() {} |
- |
// Print the instructions in a block terminated by newlines. Add "goto N" |
// to the end of the block if it ends with an unconditional jump to |
// another block and that block is not next in reverse postorder. |
@@ -48,6 +46,40 @@ |
const GrowableArray<BlockEntryInstr*>& block_order_; |
}; |
+ |
+class FlowGraphVisualizer : public ValueObject { |
+ public: |
+ FlowGraphVisualizer(const Function& function, |
+ const GrowableArray<BlockEntryInstr*>& block_order) |
+ : function_(function), block_order_(block_order), indent_(0) { |
+ // Open a new file the first time. |
+ Isolate* isolate = Isolate::Current(); |
+ if (isolate->flow_graph_file() == NULL) { |
+ char file_name[80]; |
+ OS::SNPrint(file_name, sizeof(file_name), "flowgraph-%p.cfg", |
+ reinterpret_cast<void*>(isolate)); |
+ FILE* file = OS::FOpen(file_name, "wb"); |
+ ASSERT(file != NULL); |
+ isolate->set_flow_graph_file(file); |
+ } |
+ file_ = isolate->flow_graph_file(); |
srdjan
2012/06/01 15:35:26
Move the code into .cc
|
+ } |
+ |
+ void PrintFunction(); |
+ |
+ private: |
+ // Helpers for printing. |
+ void PrintInstruction(Instruction* instr); |
+ void Print(const char* format, ...); |
+ |
+ FILE* file_; |
+ const Function& function_; |
+ const GrowableArray<BlockEntryInstr*>& block_order_; |
+ intptr_t indent_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FlowGraphVisualizer); |
+}; |
+ |
} // namespace dart |
#endif // VM_IL_PRINTER_H_ |