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

Side by Side Diff: runtime/vm/il_printer.h

Issue 10857016: Refactored FlowGraphBuilder into a separate FlowGraph representation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revision based on Kevin's review. Created 8 years, 4 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
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/flow_graph.h"
8 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
9 10
10 namespace dart { 11 namespace dart {
11 12
12 class BufferFormatter : public ValueObject { 13 class BufferFormatter : public ValueObject {
13 public: 14 public:
14 BufferFormatter(char* buffer, intptr_t size) 15 BufferFormatter(char* buffer, intptr_t size)
15 : position_(0), 16 : position_(0),
16 buffer_(buffer), 17 buffer_(buffer),
17 size_(size) { } 18 size_(size) { }
18 19
19 void VPrint(const char* format, va_list args); 20 void VPrint(const char* format, va_list args);
20 void Print(const char* format, ...); 21 void Print(const char* format, ...);
21 22
22 private: 23 private:
23 intptr_t position_; 24 intptr_t position_;
24 char* buffer_; 25 char* buffer_;
25 const intptr_t size_; 26 const intptr_t size_;
26 27
27 DISALLOW_COPY_AND_ASSIGN(BufferFormatter); 28 DISALLOW_COPY_AND_ASSIGN(BufferFormatter);
28 }; 29 };
29 30
30 31
31 class ParsedFunction; 32 class ParsedFunction;
32 33
33 34
34 // Graph printing. 35 // Graph printing.
35 class FlowGraphPrinter : public ValueObject { 36 class FlowGraphPrinter : public ValueObject {
36 public: 37 public:
37 FlowGraphPrinter(const Function& function, 38 FlowGraphPrinter(const FlowGraph& flow_graph,
38 const GrowableArray<BlockEntryInstr*>& block_order,
39 bool print_locations = false) 39 bool print_locations = false)
40 : function_(function), 40 : function_(flow_graph.parsed_function().function()),
41 block_order_(block_order), 41 block_order_(flow_graph.reverse_postorder()),
42 print_locations_(print_locations) { } 42 print_locations_(print_locations) { }
43 43
44 // Print the instructions in a block terminated by newlines. Add "goto N" 44 // Print the instructions in a block terminated by newlines. Add "goto N"
45 // to the end of the block if it ends with an unconditional jump to 45 // to the end of the block if it ends with an unconditional jump to
46 // another block and that block is not next in reverse postorder. 46 // another block and that block is not next in reverse postorder.
47 void PrintBlocks(); 47 void PrintBlocks();
48 void PrintInstruction(Instruction* instr); 48 void PrintInstruction(Instruction* instr);
49 static void PrintComputation(Computation* comp); 49 static void PrintComputation(Computation* comp);
50 static void PrintTypeCheck(const ParsedFunction& parsed_function, 50 static void PrintTypeCheck(const ParsedFunction& parsed_function,
51 intptr_t token_pos, 51 intptr_t token_pos,
52 Value* value, 52 Value* value,
53 const AbstractType& dst_type, 53 const AbstractType& dst_type,
54 const String& dst_name, 54 const String& dst_name,
55 bool eliminated); 55 bool eliminated);
56 56
57 private: 57 private:
58 const Function& function_; 58 const Function& function_;
59 const GrowableArray<BlockEntryInstr*>& block_order_; 59 const GrowableArray<BlockEntryInstr*>& block_order_;
60 const bool print_locations_; 60 const bool print_locations_;
61 }; 61 };
62 62
63 63
64 class FlowGraphVisualizer : public ValueObject { 64 class FlowGraphVisualizer : public ValueObject {
65 public: 65 public:
66 FlowGraphVisualizer(const Function& function, 66 explicit FlowGraphVisualizer(const FlowGraph& flow_graph)
67 const GrowableArray<BlockEntryInstr*>& block_order) 67 : function_(flow_graph.parsed_function().function()),
68 : function_(function), block_order_(block_order), indent_(0) { } 68 block_order_(flow_graph.reverse_postorder()),
69 indent_(0) { }
69 70
70 void PrintFunction(); 71 void PrintFunction();
71 72
72 private: 73 private:
73 // Helpers for printing. 74 // Helpers for printing.
74 void PrintInstruction(Instruction* instr); 75 void PrintInstruction(Instruction* instr);
75 void Print(const char* format, ...); 76 void Print(const char* format, ...);
76 77
77 const Function& function_; 78 const Function& function_;
78 const GrowableArray<BlockEntryInstr*>& block_order_; 79 const GrowableArray<BlockEntryInstr*>& block_order_;
79 intptr_t indent_; 80 intptr_t indent_;
80 81
81 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisualizer); 82 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisualizer);
82 }; 83 };
83 84
84 } // namespace dart 85 } // namespace dart
85 86
86 #endif // VM_IL_PRINTER_H_ 87 #endif // VM_IL_PRINTER_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698