| 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/compiler.h" | 5 #include "vm/compiler.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 isolate->set_ic_data_array( | 156 isolate->set_ic_data_array( |
| 157 ExtractTypeFeedbackArray(unoptimized_code)); | 157 ExtractTypeFeedbackArray(unoptimized_code)); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Build the flow graph. | 161 // Build the flow graph. |
| 162 FlowGraphBuilder builder(parsed_function); | 162 FlowGraphBuilder builder(parsed_function); |
| 163 flow_graph = builder.BuildGraph(); | 163 flow_graph = builder.BuildGraph(); |
| 164 | 164 |
| 165 // Transform to SSA. | 165 // Transform to SSA. |
| 166 if (optimized) { | 166 if (optimized) flow_graph->ComputeSSA(); |
| 167 flow_graph->ComputeSSA(); | |
| 168 } | |
| 169 | 167 |
| 170 if (FLAG_print_flow_graph) { | 168 if (FLAG_print_flow_graph) { |
| 171 OS::Print("Before Optimizations\n"); | 169 OS::Print("Before Optimizations\n"); |
| 172 FlowGraphPrinter printer(*flow_graph); | 170 FlowGraphPrinter printer(*flow_graph); |
| 173 printer.PrintBlocks(); | 171 printer.PrintBlocks(); |
| 174 } | 172 } |
| 175 if (Dart::flow_graph_writer() != NULL) { | 173 if (Dart::flow_graph_writer() != NULL) { |
| 176 // Write flow graph to file. | 174 // Write flow graph to file. |
| 177 FlowGraphVisualizer printer(*flow_graph); | 175 FlowGraphVisualizer printer(*flow_graph); |
| 178 printer.PrintFunction(); | 176 printer.PrintFunction(); |
| 179 } | 177 } |
| 180 | 178 |
| 181 if (optimized) { | 179 if (optimized) { |
| 182 FlowGraphOptimizer optimizer(*flow_graph); | 180 FlowGraphOptimizer optimizer(*flow_graph); |
| 183 optimizer.ApplyICData(); | 181 optimizer.ApplyICData(); |
| 184 | 182 |
| 183 // Compute the use lists. |
| 184 flow_graph->ComputeUseLists(); |
| 185 |
| 185 // Propagate types and eliminate more type tests. | 186 // Propagate types and eliminate more type tests. |
| 186 FlowGraphTypePropagator propagator(*flow_graph); | 187 FlowGraphTypePropagator propagator(*flow_graph); |
| 187 propagator.PropagateTypes(); | 188 propagator.PropagateTypes(); |
| 188 | 189 |
| 190 // TODO(zerny): Here we assume that the use lists remain valid after |
| 191 // type propagation. We should construct a use-list validator to make |
| 192 // this explicit in DEBUG mode. |
| 193 |
| 189 // Do optimizations that depend on the propagated type information. | 194 // Do optimizations that depend on the propagated type information. |
| 190 optimizer.OptimizeComputations(); | 195 optimizer.OptimizeComputations(); |
| 191 | 196 |
| 192 if (FLAG_local_cse) { | 197 if (FLAG_local_cse) { |
| 193 LocalCSE local_cse(*flow_graph); | 198 LocalCSE local_cse(*flow_graph); |
| 194 local_cse.Optimize(); | 199 local_cse.Optimize(); |
| 195 } | 200 } |
| 196 | 201 |
| 197 // Perform register allocation on the SSA graph. | 202 // Perform register allocation on the SSA graph. |
| 198 FlowGraphAllocator allocator(*flow_graph); | 203 FlowGraphAllocator allocator(*flow_graph); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 result = isolate->object_store()->sticky_error(); | 556 result = isolate->object_store()->sticky_error(); |
| 552 isolate->object_store()->clear_sticky_error(); | 557 isolate->object_store()->clear_sticky_error(); |
| 553 isolate->set_long_jump_base(base); | 558 isolate->set_long_jump_base(base); |
| 554 return result.raw(); | 559 return result.raw(); |
| 555 } | 560 } |
| 556 UNREACHABLE(); | 561 UNREACHABLE(); |
| 557 return Object::null(); | 562 return Object::null(); |
| 558 } | 563 } |
| 559 | 564 |
| 560 } // namespace dart | 565 } // namespace dart |
| OLD | NEW |