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/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
6 | 6 |
7 #include "vm/flow_graph_builder.h" | 7 #include "vm/flow_graph_builder.h" |
8 #include "vm/il_printer.h" | 8 #include "vm/il_printer.h" |
9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 DECLARE_FLAG(bool, print_flow_graph); | 13 DECLARE_FLAG(bool, print_flow_graph); |
14 DECLARE_FLAG(bool, trace_optimization); | 14 DECLARE_FLAG(bool, trace_optimization); |
15 | 15 |
16 void FlowGraphOptimizer::ApplyICData() { | 16 void FlowGraphOptimizer::ApplyICData() { |
17 VisitBlocks(); | 17 VisitBlocks(); |
18 if (FLAG_print_flow_graph) { | 18 if (FLAG_print_flow_graph) { |
19 OS::Print("After Optimizations:\n"); | 19 OS::Print("After Optimizations:\n"); |
20 intptr_t length = block_order_.length(); | 20 FlowGraphPrinter printer(Function::Handle(), block_order_); |
21 GrowableArray<BlockEntryInstr*> reverse_postorder(length); | |
22 for (intptr_t i = length - 1; i >= 0; --i) { | |
23 reverse_postorder.Add(block_order_[i]); | |
24 } | |
25 FlowGraphPrinter printer(Function::Handle(), reverse_postorder); | |
26 printer.PrintBlocks(); | 21 printer.PrintBlocks(); |
27 } | 22 } |
28 } | 23 } |
29 | 24 |
30 | 25 |
31 void FlowGraphOptimizer::VisitBlocks() { | 26 void FlowGraphOptimizer::VisitBlocks() { |
32 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 27 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
33 Instruction* instr = block_order_[i]->Accept(this); | 28 Instruction* instr = block_order_[i]->Accept(this); |
34 // Compile all successors until an exit, branch, or a block entry. | 29 // Compile all successors until an exit, branch, or a block entry. |
35 while ((instr != NULL) && !instr->IsBlockEntry()) { | 30 while ((instr != NULL) && !instr->IsBlockEntry()) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 instr->computation()->Accept(this); | 94 instr->computation()->Accept(this); |
100 } | 95 } |
101 | 96 |
102 | 97 |
103 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { | 98 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { |
104 instr->computation()->Accept(this); | 99 instr->computation()->Accept(this); |
105 } | 100 } |
106 | 101 |
107 | 102 |
108 } // namespace dart | 103 } // namespace dart |
OLD | NEW |