| OLD | NEW |
| 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 { |
| 11 | 11 |
| 12 class BufferFormatter : public ValueObject { | 12 class BufferFormatter : public ValueObject { |
| 13 public: | 13 public: |
| 14 BufferFormatter(char* buffer, intptr_t size) | 14 BufferFormatter(char* buffer, intptr_t size) |
| 15 : position_(0), | 15 : position_(0), |
| 16 buffer_(buffer), | 16 buffer_(buffer), |
| 17 size_(size) { } | 17 size_(size) { } |
| 18 | 18 |
| 19 void VPrint(const char* format, va_list args); |
| 19 void Print(const char* format, ...); | 20 void Print(const char* format, ...); |
| 20 | 21 |
| 21 private: | 22 private: |
| 22 intptr_t position_; | 23 intptr_t position_; |
| 23 char* buffer_; | 24 char* buffer_; |
| 24 const intptr_t size_; | 25 const intptr_t size_; |
| 25 | 26 |
| 26 DISALLOW_COPY_AND_ASSIGN(BufferFormatter); | 27 DISALLOW_COPY_AND_ASSIGN(BufferFormatter); |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 | 30 |
| 30 // Graph printing. | 31 // Graph printing. |
| 31 class FlowGraphPrinter : public ValueObject { | 32 class FlowGraphPrinter : public ValueObject { |
| 32 public: | 33 public: |
| 33 FlowGraphPrinter(const Function& function, | 34 FlowGraphPrinter(const Function& function, |
| 34 const GrowableArray<BlockEntryInstr*>& block_order) | 35 const GrowableArray<BlockEntryInstr*>& block_order) |
| 35 : function_(function), block_order_(block_order) { } | 36 : function_(function), block_order_(block_order) { } |
| 36 | 37 |
| 37 virtual ~FlowGraphPrinter() {} | |
| 38 | |
| 39 // Print the instructions in a block terminated by newlines. Add "goto N" | 38 // 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 | 39 // 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. | 40 // another block and that block is not next in reverse postorder. |
| 42 void PrintBlocks(); | 41 void PrintBlocks(); |
| 43 static void PrintInstruction(Instruction* instr); | 42 static void PrintInstruction(Instruction* instr); |
| 44 static void PrintComputation(Computation* comp); | 43 static void PrintComputation(Computation* comp); |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 const Function& function_; | 46 const Function& function_; |
| 48 const GrowableArray<BlockEntryInstr*>& block_order_; | 47 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 49 }; | 48 }; |
| 50 | 49 |
| 50 |
| 51 class FlowGraphVisualizer : public ValueObject { |
| 52 public: |
| 53 FlowGraphVisualizer(const Function& function, |
| 54 const GrowableArray<BlockEntryInstr*>& block_order) |
| 55 : function_(function), block_order_(block_order), indent_(0) { } |
| 56 |
| 57 void PrintFunction(); |
| 58 |
| 59 private: |
| 60 // Helpers for printing. |
| 61 void PrintInstruction(Instruction* instr); |
| 62 void Print(const char* format, ...); |
| 63 |
| 64 const Function& function_; |
| 65 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 66 intptr_t indent_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisualizer); |
| 69 }; |
| 70 |
| 51 } // namespace dart | 71 } // namespace dart |
| 52 | 72 |
| 53 #endif // VM_IL_PRINTER_H_ | 73 #endif // VM_IL_PRINTER_H_ |
| OLD | NEW |