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

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

Issue 12540002: Implement a branch optimization pass. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 7 years, 9 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/il_printer.h ('k') | runtime/vm/intermediate_language.h » ('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 #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
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
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
OLDNEW
« no previous file with comments | « runtime/vm/il_printer.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698