| 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 | 8 |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 if (optimized) { | 172 if (optimized) { |
| 173 TimerScope timer(FLAG_compiler_stats, | 173 TimerScope timer(FLAG_compiler_stats, |
| 174 &CompilerStats::graphoptimizer_timer, | 174 &CompilerStats::graphoptimizer_timer, |
| 175 isolate); | 175 isolate); |
| 176 | 176 |
| 177 flow_graph->ComputeUseLists(); | 177 flow_graph->ComputeUseLists(); |
| 178 | 178 |
| 179 FlowGraphOptimizer optimizer(flow_graph); | 179 FlowGraphOptimizer optimizer(flow_graph); |
| 180 optimizer.ApplyICData(); | 180 optimizer.ApplyICData(); |
| 181 | 181 |
| 182 // Compute the use lists. | |
| 183 flow_graph->ComputeUseLists(); | |
| 184 | |
| 185 // Inlining (mutates the flow graph) | 182 // Inlining (mutates the flow graph) |
| 186 if (FLAG_use_inlining) { | 183 if (FLAG_use_inlining) { |
| 187 TimerScope timer(FLAG_compiler_stats, | 184 TimerScope timer(FLAG_compiler_stats, |
| 188 &CompilerStats::graphinliner_timer); | 185 &CompilerStats::graphinliner_timer); |
| 189 FlowGraphInliner inliner(flow_graph); | 186 FlowGraphInliner inliner(flow_graph); |
| 190 inliner.Inline(); | 187 inliner.Inline(); |
| 191 // Use lists are maintained and validated by the inliner. | 188 // Use lists are maintained and validated by the inliner. |
| 192 } | 189 } |
| 193 | 190 |
| 194 if (FLAG_trace_type_propagation) { | 191 if (FLAG_trace_type_propagation) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 207 OS::Print("After type propagation:\n"); | 204 OS::Print("After type propagation:\n"); |
| 208 FlowGraphPrinter printer(*flow_graph); | 205 FlowGraphPrinter printer(*flow_graph); |
| 209 printer.PrintBlocks(); | 206 printer.PrintBlocks(); |
| 210 } | 207 } |
| 211 | 208 |
| 212 flow_graph->ComputeUseLists(); | 209 flow_graph->ComputeUseLists(); |
| 213 | 210 |
| 214 // Use propagated class-ids to optimize further. | 211 // Use propagated class-ids to optimize further. |
| 215 optimizer.ApplyClassIds(); | 212 optimizer.ApplyClassIds(); |
| 216 | 213 |
| 217 // Recompute use lists after applying class ids. | |
| 218 flow_graph->ComputeUseLists(); | |
| 219 | |
| 220 // Do optimizations that depend on the propagated type information. | 214 // Do optimizations that depend on the propagated type information. |
| 221 optimizer.Canonicalize(); | 215 optimizer.Canonicalize(); |
| 222 | 216 |
| 223 flow_graph->ComputeUseLists(); | |
| 224 | |
| 225 if (FLAG_constant_propagation) { | 217 if (FLAG_constant_propagation) { |
| 226 ConstantPropagator::Optimize(flow_graph); | 218 ConstantPropagator::Optimize(flow_graph); |
| 227 // A canonicalization pass to remove e.g. smi checks on smi constants. | 219 // A canonicalization pass to remove e.g. smi checks on smi constants. |
| 228 optimizer.Canonicalize(); | 220 optimizer.Canonicalize(); |
| 229 } | 221 } |
| 230 | 222 |
| 231 // Unbox doubles. Performed after constant propagation to minimize | 223 // Unbox doubles. Performed after constant propagation to minimize |
| 232 // interference from phis merging double values and tagged | 224 // interference from phis merging double values and tagged |
| 233 // values comming from dead paths. | 225 // values comming from dead paths. |
| 234 flow_graph->ComputeUseLists(); | |
| 235 optimizer.SelectRepresentations(); | 226 optimizer.SelectRepresentations(); |
| 236 flow_graph->ComputeUseLists(); | |
| 237 | 227 |
| 238 if (FLAG_common_subexpression_elimination) { | 228 if (FLAG_common_subexpression_elimination) { |
| 239 if (DominatorBasedCSE::Optimize(flow_graph)) { | 229 if (DominatorBasedCSE::Optimize(flow_graph)) { |
| 240 // Do another round of CSE to take secondary effects into account: | 230 // Do another round of CSE to take secondary effects into account: |
| 241 // e.g. when eliminating dependent loads (a.x[0] + a.x[0]) | 231 // e.g. when eliminating dependent loads (a.x[0] + a.x[0]) |
| 242 // TODO(fschneider): Change to a one-pass optimization pass. | 232 // TODO(fschneider): Change to a one-pass optimization pass. |
| 243 DominatorBasedCSE::Optimize(flow_graph); | 233 DominatorBasedCSE::Optimize(flow_graph); |
| 244 } | 234 } |
| 245 } | 235 } |
| 246 if (FLAG_loop_invariant_code_motion && | 236 if (FLAG_loop_invariant_code_motion && |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 Object::Handle(isolate->object_store()->sticky_error()); | 645 Object::Handle(isolate->object_store()->sticky_error()); |
| 656 isolate->object_store()->clear_sticky_error(); | 646 isolate->object_store()->clear_sticky_error(); |
| 657 isolate->set_long_jump_base(base); | 647 isolate->set_long_jump_base(base); |
| 658 return result.raw(); | 648 return result.raw(); |
| 659 } | 649 } |
| 660 UNREACHABLE(); | 650 UNREACHABLE(); |
| 661 return Object::null(); | 651 return Object::null(); |
| 662 } | 652 } |
| 663 | 653 |
| 664 } // namespace dart | 654 } // namespace dart |
| OLD | NEW |