| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 163 } |
| 164 | 164 |
| 165 if (FLAG_print_flow_graph || | 165 if (FLAG_print_flow_graph || |
| 166 (optimized && FLAG_print_flow_graph_optimized)) { | 166 (optimized && FLAG_print_flow_graph_optimized)) { |
| 167 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); | 167 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Collect all instance fields that are loaded in the graph and | 170 // Collect all instance fields that are loaded in the graph and |
| 171 // have non-generic type feedback attached to them that can | 171 // have non-generic type feedback attached to them that can |
| 172 // potentially affect optimizations. | 172 // potentially affect optimizations. |
| 173 GrowableArray<Field*> guarded_fields(10); | 173 GrowableArray<const Field*> guarded_fields(10); |
| 174 if (optimized) { | 174 if (optimized) { |
| 175 TimerScope timer(FLAG_compiler_stats, | 175 TimerScope timer(FLAG_compiler_stats, |
| 176 &CompilerStats::graphoptimizer_timer, | 176 &CompilerStats::graphoptimizer_timer, |
| 177 isolate); | 177 isolate); |
| 178 | 178 |
| 179 FlowGraphOptimizer optimizer(flow_graph, &guarded_fields); | 179 FlowGraphOptimizer optimizer(flow_graph, &guarded_fields); |
| 180 optimizer.ApplyICData(); | 180 optimizer.ApplyICData(); |
| 181 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 181 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 182 | 182 |
| 183 // Optimize (a << b) & c patterns. Must occur before | 183 // Optimize (a << b) & c patterns. Must occur before |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 // The final canonicalization pass before the code generation. | 286 // The final canonicalization pass before the code generation. |
| 287 if (FLAG_propagate_types) { | 287 if (FLAG_propagate_types) { |
| 288 // Recompute types after code movement was done to ensure correct | 288 // Recompute types after code movement was done to ensure correct |
| 289 // reaching types for hoisted values. | 289 // reaching types for hoisted values. |
| 290 FlowGraphTypePropagator propagator(flow_graph); | 290 FlowGraphTypePropagator propagator(flow_graph); |
| 291 propagator.Propagate(); | 291 propagator.Propagate(); |
| 292 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 292 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 293 } | 293 } |
| 294 optimizer.Canonicalize(); | 294 if (optimizer.Canonicalize()) { |
| 295 // To fully remove redundant boxing (e.g. BoxDouble used only in |
| 296 // environments and UnboxDouble instructions) instruction we |
| 297 // first need to replace all their uses and then fold them away. |
| 298 // For now we just repeat Canonicalize twice to do that. |
| 299 // TODO(vegorov): implement a separate representation folding pass. |
| 300 optimizer.Canonicalize(); |
| 301 } |
| 295 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 302 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 296 | 303 |
| 297 // Perform register allocation on the SSA graph. | 304 // Perform register allocation on the SSA graph. |
| 298 FlowGraphAllocator allocator(*flow_graph); | 305 FlowGraphAllocator allocator(*flow_graph); |
| 299 allocator.AllocateRegisters(); | 306 allocator.AllocateRegisters(); |
| 300 | 307 |
| 301 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { | 308 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { |
| 302 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); | 309 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); |
| 303 } | 310 } |
| 304 } | 311 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 Object::Handle(isolate->object_store()->sticky_error()); | 708 Object::Handle(isolate->object_store()->sticky_error()); |
| 702 isolate->object_store()->clear_sticky_error(); | 709 isolate->object_store()->clear_sticky_error(); |
| 703 isolate->set_long_jump_base(base); | 710 isolate->set_long_jump_base(base); |
| 704 return result.raw(); | 711 return result.raw(); |
| 705 } | 712 } |
| 706 UNREACHABLE(); | 713 UNREACHABLE(); |
| 707 return Object::null(); | 714 return Object::null(); |
| 708 } | 715 } |
| 709 | 716 |
| 710 } // namespace dart | 717 } // namespace dart |
| OLD | NEW |