| 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 17 matching lines...) Expand all Loading... |
| 28 #include "vm/scanner.h" | 28 #include "vm/scanner.h" |
| 29 #include "vm/symbols.h" | 29 #include "vm/symbols.h" |
| 30 #include "vm/timer.h" | 30 #include "vm/timer.h" |
| 31 | 31 |
| 32 namespace dart { | 32 namespace dart { |
| 33 | 33 |
| 34 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); | 34 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); |
| 35 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); | 35 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); |
| 36 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); | 36 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); |
| 37 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 37 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
| 38 DEFINE_FLAG(bool, cp, true, | |
| 39 "Do conditional constant propagation/unreachable code elimination."); | |
| 40 DEFINE_FLAG(bool, cse, true, "Do common subexpression elimination."); | 38 DEFINE_FLAG(bool, cse, true, "Do common subexpression elimination."); |
| 41 DEFINE_FLAG(bool, licm, true, "Do loop invariant code motion."); | 39 DEFINE_FLAG(bool, licm, true, "Do loop invariant code motion."); |
| 42 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, | 40 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, |
| 43 "How many times we allow deoptimization before we disallow" | 41 "How many times we allow deoptimization before we disallow" |
| 44 " certain optimizations"); | 42 " certain optimizations"); |
| 45 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 43 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 46 DECLARE_FLAG(bool, print_flow_graph); | 44 DECLARE_FLAG(bool, print_flow_graph); |
| 47 | 45 |
| 48 | 46 |
| 49 // Compile a function. Should call only if the function has not been compiled. | 47 // Compile a function. Should call only if the function has not been compiled. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Propagate sminess from CheckSmi to phis. | 188 // Propagate sminess from CheckSmi to phis. |
| 191 optimizer.PropagateSminess(); | 189 optimizer.PropagateSminess(); |
| 192 | 190 |
| 193 // Do optimizations that depend on the propagated type information. | 191 // Do optimizations that depend on the propagated type information. |
| 194 optimizer.OptimizeComputations(); | 192 optimizer.OptimizeComputations(); |
| 195 | 193 |
| 196 // Unbox doubles. | 194 // Unbox doubles. |
| 197 flow_graph->ComputeUseLists(); | 195 flow_graph->ComputeUseLists(); |
| 198 optimizer.SelectRepresentations(); | 196 optimizer.SelectRepresentations(); |
| 199 | 197 |
| 200 if (FLAG_cp || FLAG_cse) flow_graph->ComputeUseLists(); | 198 if (FLAG_cse) { |
| 201 if (FLAG_cp) ConstantPropagator::Optimize(flow_graph); | 199 flow_graph->ComputeUseLists(); |
| 202 if (FLAG_cse) DominatorBasedCSE::Optimize(flow_graph); | 200 DominatorBasedCSE::Optimize(flow_graph); |
| 203 if (FLAG_licm) LICM::Optimize(flow_graph); | 201 } |
| 202 if (FLAG_licm) { |
| 203 LICM::Optimize(flow_graph); |
| 204 } |
| 204 | 205 |
| 205 // Perform register allocation on the SSA graph. | 206 // Perform register allocation on the SSA graph. |
| 206 FlowGraphAllocator allocator(*flow_graph); | 207 FlowGraphAllocator allocator(*flow_graph); |
| 207 allocator.AllocateRegisters(); | 208 allocator.AllocateRegisters(); |
| 208 | 209 |
| 209 if (FLAG_print_flow_graph) { | 210 if (FLAG_print_flow_graph) { |
| 210 OS::Print("After Optimizations:\n"); | 211 OS::Print("After Optimizations:\n"); |
| 211 FlowGraphPrinter printer(*flow_graph); | 212 FlowGraphPrinter printer(*flow_graph); |
| 212 printer.PrintBlocks(); | 213 printer.PrintBlocks(); |
| 213 } | 214 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 result = isolate->object_store()->sticky_error(); | 560 result = isolate->object_store()->sticky_error(); |
| 560 isolate->object_store()->clear_sticky_error(); | 561 isolate->object_store()->clear_sticky_error(); |
| 561 isolate->set_long_jump_base(base); | 562 isolate->set_long_jump_base(base); |
| 562 return result.raw(); | 563 return result.raw(); |
| 563 } | 564 } |
| 564 UNREACHABLE(); | 565 UNREACHABLE(); |
| 565 return Object::null(); | 566 return Object::null(); |
| 566 } | 567 } |
| 567 | 568 |
| 568 } // namespace dart | 569 } // namespace dart |
| OLD | NEW |