| 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, | 38 DEFINE_FLAG(bool, constant_propagation, true, |
| 39 "Do conditional constant propagation/unreachable code elimination."); | 39 "Do conditional constant propagation/unreachable code elimination."); |
| 40 DEFINE_FLAG(bool, cse, true, "Do common subexpression elimination."); | 40 DEFINE_FLAG(bool, common_subexpression_elimination, true, |
| 41 DEFINE_FLAG(bool, licm, true, "Do loop invariant code motion."); | 41 "Do common subexpression elimination."); |
| 42 DEFINE_FLAG(bool, loop_invariant_code_motion, true, |
| 43 "Do loop invariant code motion."); |
| 42 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, | 44 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, |
| 43 "How many times we allow deoptimization before we disallow" | 45 "How many times we allow deoptimization before we disallow" |
| 44 " certain optimizations"); | 46 " certain optimizations"); |
| 45 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 47 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 46 DECLARE_FLAG(bool, print_flow_graph); | 48 DECLARE_FLAG(bool, print_flow_graph); |
| 47 | 49 |
| 48 | 50 |
| 49 // Compile a function. Should call only if the function has not been compiled. | 51 // Compile a function. Should call only if the function has not been compiled. |
| 50 // Arg0: function object. | 52 // Arg0: function object. |
| 51 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 53 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Propagate sminess from CheckSmi to phis. | 192 // Propagate sminess from CheckSmi to phis. |
| 191 optimizer.PropagateSminess(); | 193 optimizer.PropagateSminess(); |
| 192 | 194 |
| 193 // Do optimizations that depend on the propagated type information. | 195 // Do optimizations that depend on the propagated type information. |
| 194 optimizer.OptimizeComputations(); | 196 optimizer.OptimizeComputations(); |
| 195 | 197 |
| 196 // Unbox doubles. | 198 // Unbox doubles. |
| 197 flow_graph->ComputeUseLists(); | 199 flow_graph->ComputeUseLists(); |
| 198 optimizer.SelectRepresentations(); | 200 optimizer.SelectRepresentations(); |
| 199 | 201 |
| 200 if (FLAG_cp || FLAG_cse) flow_graph->ComputeUseLists(); | 202 if (FLAG_constant_propagation || |
| 201 if (FLAG_cp) ConstantPropagator::Optimize(flow_graph); | 203 FLAG_common_subexpression_elimination) { |
| 202 if (FLAG_cse) DominatorBasedCSE::Optimize(flow_graph); | 204 flow_graph->ComputeUseLists(); |
| 203 if (FLAG_licm) LICM::Optimize(flow_graph); | 205 } |
| 206 if (FLAG_constant_propagation) { |
| 207 ConstantPropagator::Optimize(flow_graph); |
| 208 } |
| 209 if (FLAG_common_subexpression_elimination) { |
| 210 DominatorBasedCSE::Optimize(flow_graph); |
| 211 } |
| 212 if (FLAG_loop_invariant_code_motion) { |
| 213 LICM::Optimize(flow_graph); |
| 214 } |
| 204 | 215 |
| 205 // Perform register allocation on the SSA graph. | 216 // Perform register allocation on the SSA graph. |
| 206 FlowGraphAllocator allocator(*flow_graph); | 217 FlowGraphAllocator allocator(*flow_graph); |
| 207 allocator.AllocateRegisters(); | 218 allocator.AllocateRegisters(); |
| 208 | 219 |
| 209 if (FLAG_print_flow_graph) { | 220 if (FLAG_print_flow_graph) { |
| 210 OS::Print("After Optimizations:\n"); | 221 OS::Print("After Optimizations:\n"); |
| 211 FlowGraphPrinter printer(*flow_graph); | 222 FlowGraphPrinter printer(*flow_graph); |
| 212 printer.PrintBlocks(); | 223 printer.PrintBlocks(); |
| 213 } | 224 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 result = isolate->object_store()->sticky_error(); | 570 result = isolate->object_store()->sticky_error(); |
| 560 isolate->object_store()->clear_sticky_error(); | 571 isolate->object_store()->clear_sticky_error(); |
| 561 isolate->set_long_jump_base(base); | 572 isolate->set_long_jump_base(base); |
| 562 return result.raw(); | 573 return result.raw(); |
| 563 } | 574 } |
| 564 UNREACHABLE(); | 575 UNREACHABLE(); |
| 565 return Object::null(); | 576 return Object::null(); |
| 566 } | 577 } |
| 567 | 578 |
| 568 } // namespace dart | 579 } // namespace dart |
| OLD | NEW |