| 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 #include "vm/il_printer.h" | 5 #include "vm/il_printer.h" |
| 6 | 6 |
| 7 #include "vm/intermediate_language.h" | 7 #include "vm/intermediate_language.h" |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 #include "vm/parser.h" | 9 #include "vm/parser.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 | 34 |
| 35 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) { | 35 void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) { |
| 36 OS::Print("*** BEGIN CFG\n%s\n", phase); | 36 OS::Print("*** BEGIN CFG\n%s\n", phase); |
| 37 FlowGraphPrinter printer(*flow_graph); | 37 FlowGraphPrinter printer(*flow_graph); |
| 38 printer.PrintBlocks(); | 38 printer.PrintBlocks(); |
| 39 OS::Print("*** END CFG\n"); | 39 OS::Print("*** END CFG\n"); |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 void FlowGraphPrinter::PrintBlock(BlockEntryInstr* block, |
| 44 bool print_locations) { |
| 45 // Print the block entry. |
| 46 PrintOneInstruction(block, print_locations); |
| 47 OS::Print("\n"); |
| 48 // And all the successors in the block. |
| 49 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 50 Instruction* current = it.Current(); |
| 51 PrintOneInstruction(current, print_locations); |
| 52 OS::Print("\n"); |
| 53 } |
| 54 } |
| 55 |
| 56 |
| 43 void FlowGraphPrinter::PrintBlocks() { | 57 void FlowGraphPrinter::PrintBlocks() { |
| 44 if (!function_.IsNull()) { | 58 if (!function_.IsNull()) { |
| 45 OS::Print("==== %s\n", function_.ToFullyQualifiedCString()); | 59 OS::Print("==== %s\n", function_.ToFullyQualifiedCString()); |
| 46 } | 60 } |
| 47 | 61 |
| 48 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 62 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 49 // Print the block entry. | 63 PrintBlock(block_order_[i], print_locations_); |
| 50 PrintInstruction(block_order_[i]); | |
| 51 // And all the successors until an exit, branch, or a block entry. | |
| 52 Instruction* current = block_order_[i]; | |
| 53 for (ForwardInstructionIterator it(current->AsBlockEntry()); | |
| 54 !it.Done(); | |
| 55 it.Advance()) { | |
| 56 current = it.Current(); | |
| 57 OS::Print("\n"); | |
| 58 PrintInstruction(current); | |
| 59 } | |
| 60 if (current->next() != NULL) { | |
| 61 ASSERT(current->next()->IsBlockEntry()); | |
| 62 OS::Print(" goto %"Pd"", current->next()->AsBlockEntry()->block_id()); | |
| 63 } | |
| 64 OS::Print("\n"); | |
| 65 } | 64 } |
| 66 } | 65 } |
| 67 | 66 |
| 68 | 67 |
| 69 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { | 68 void FlowGraphPrinter::PrintInstruction(Instruction* instr) { |
| 70 PrintOneInstruction(instr, print_locations_); | 69 PrintOneInstruction(instr, print_locations_); |
| 71 } | 70 } |
| 72 | 71 |
| 73 | 72 |
| 74 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr, | 73 void FlowGraphPrinter::PrintOneInstruction(Instruction* instr, |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 f->Print(" ["); | 713 f->Print(" ["); |
| 715 locations_[i].PrintTo(f); | 714 locations_[i].PrintTo(f); |
| 716 f->Print("]"); | 715 f->Print("]"); |
| 717 } | 716 } |
| 718 } | 717 } |
| 719 f->Print(" }"); | 718 f->Print(" }"); |
| 720 if (outer_ != NULL) outer_->PrintTo(f); | 719 if (outer_ != NULL) outer_->PrintTo(f); |
| 721 } | 720 } |
| 722 | 721 |
| 723 } // namespace dart | 722 } // namespace dart |
| OLD | NEW |