Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: vm/il_printer.h

Issue 10446116: Add flow graph printing into a .cfg file with flag --print-flow-graph-file. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_IL_PRINTER_H_ 5 #ifndef VM_IL_PRINTER_H_
6 #define VM_IL_PRINTER_H_ 6 #define VM_IL_PRINTER_H_
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 16 matching lines...) Expand all
27 }; 27 };
28 28
29 29
30 // Graph printing. 30 // Graph printing.
31 class FlowGraphPrinter : public ValueObject { 31 class FlowGraphPrinter : public ValueObject {
32 public: 32 public:
33 FlowGraphPrinter(const Function& function, 33 FlowGraphPrinter(const Function& function,
34 const GrowableArray<BlockEntryInstr*>& block_order) 34 const GrowableArray<BlockEntryInstr*>& block_order)
35 : function_(function), block_order_(block_order) { } 35 : function_(function), block_order_(block_order) { }
36 36
37 virtual ~FlowGraphPrinter() {}
38
39 // Print the instructions in a block terminated by newlines. Add "goto N" 37 // Print the instructions in a block terminated by newlines. Add "goto N"
40 // to the end of the block if it ends with an unconditional jump to 38 // to the end of the block if it ends with an unconditional jump to
41 // another block and that block is not next in reverse postorder. 39 // another block and that block is not next in reverse postorder.
42 void PrintBlocks(); 40 void PrintBlocks();
43 static void PrintInstruction(Instruction* instr); 41 static void PrintInstruction(Instruction* instr);
44 static void PrintComputation(Computation* comp); 42 static void PrintComputation(Computation* comp);
45 43
46 private: 44 private:
47 const Function& function_; 45 const Function& function_;
48 const GrowableArray<BlockEntryInstr*>& block_order_; 46 const GrowableArray<BlockEntryInstr*>& block_order_;
49 }; 47 };
50 48
49
50 class FlowGraphVisualizer : public ValueObject {
51 public:
52 FlowGraphVisualizer(const Function& function,
53 const GrowableArray<BlockEntryInstr*>& block_order)
54 : function_(function), block_order_(block_order), indent_(0) {
55 // Open a new file the first time.
56 Isolate* isolate = Isolate::Current();
57 if (isolate->flow_graph_file() == NULL) {
58 char file_name[80];
59 OS::SNPrint(file_name, sizeof(file_name), "flowgraph-%p.cfg",
60 reinterpret_cast<void*>(isolate));
61 FILE* file = OS::FOpen(file_name, "wb");
62 ASSERT(file != NULL);
63 isolate->set_flow_graph_file(file);
64 }
65 file_ = isolate->flow_graph_file();
srdjan 2012/06/01 15:35:26 Move the code into .cc
66 }
67
68 void PrintFunction();
69
70 private:
71 // Helpers for printing.
72 void PrintInstruction(Instruction* instr);
73 void Print(const char* format, ...);
74
75 FILE* file_;
76 const Function& function_;
77 const GrowableArray<BlockEntryInstr*>& block_order_;
78 intptr_t indent_;
79
80 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisualizer);
81 };
82
51 } // namespace dart 83 } // namespace dart
52 84
53 #endif // VM_IL_PRINTER_H_ 85 #endif // VM_IL_PRINTER_H_
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.cc ('k') | vm/il_printer.cc » ('j') | vm/intermediate_language.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698