| 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 28 matching lines...) Expand all Loading... |
| 39 "Do conditional constant propagation/unreachable code elimination."); | 39 "Do conditional constant propagation/unreachable code elimination."); |
| 40 DEFINE_FLAG(bool, common_subexpression_elimination, true, | 40 DEFINE_FLAG(bool, common_subexpression_elimination, true, |
| 41 "Do common subexpression elimination."); | 41 "Do common subexpression elimination."); |
| 42 DEFINE_FLAG(bool, loop_invariant_code_motion, true, | 42 DEFINE_FLAG(bool, loop_invariant_code_motion, true, |
| 43 "Do loop invariant code motion."); | 43 "Do loop invariant code motion."); |
| 44 DEFINE_FLAG(bool, propagate_types, true, "Do static type propagation."); | 44 DEFINE_FLAG(bool, propagate_types, true, "Do static type propagation."); |
| 45 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, | 45 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, |
| 46 "How many times we allow deoptimization before we disallow" | 46 "How many times we allow deoptimization before we disallow" |
| 47 " certain optimizations"); | 47 " certain optimizations"); |
| 48 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 48 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 49 DEFINE_FLAG(bool, range_analysis, false, "Enable range analysis"); |
| 49 DECLARE_FLAG(bool, print_flow_graph); | 50 DECLARE_FLAG(bool, print_flow_graph); |
| 50 | 51 |
| 51 | 52 |
| 52 // Compile a function. Should call only if the function has not been compiled. | 53 // Compile a function. Should call only if the function has not been compiled. |
| 53 // Arg0: function object. | 54 // Arg0: function object. |
| 54 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 55 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
| 55 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); | 56 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); |
| 56 const Function& function = Function::CheckedHandle(arguments.At(0)); | 57 const Function& function = Function::CheckedHandle(arguments.At(0)); |
| 57 ASSERT(!function.HasCode()); | 58 ASSERT(!function.HasCode()); |
| 58 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 59 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (FLAG_constant_propagation) { | 210 if (FLAG_constant_propagation) { |
| 210 ConstantPropagator::Optimize(flow_graph); | 211 ConstantPropagator::Optimize(flow_graph); |
| 211 } | 212 } |
| 212 if (FLAG_common_subexpression_elimination) { | 213 if (FLAG_common_subexpression_elimination) { |
| 213 DominatorBasedCSE::Optimize(flow_graph); | 214 DominatorBasedCSE::Optimize(flow_graph); |
| 214 } | 215 } |
| 215 if (FLAG_loop_invariant_code_motion) { | 216 if (FLAG_loop_invariant_code_motion) { |
| 216 LICM::Optimize(flow_graph); | 217 LICM::Optimize(flow_graph); |
| 217 } | 218 } |
| 218 | 219 |
| 219 // We have to perform range analysis after LICM because it | 220 if (FLAG_range_analysis) { |
| 220 // optimistically moves CheckSmi through phis into loop preheaders | 221 // We have to perform range analysis after LICM because it |
| 221 // making some phis smi. | 222 // optimistically moves CheckSmi through phis into loop preheaders |
| 222 flow_graph->ComputeUseLists(); | 223 // making some phis smi. |
| 223 optimizer.InferSmiRanges(); | 224 flow_graph->ComputeUseLists(); |
| 225 optimizer.InferSmiRanges(); |
| 226 } |
| 224 | 227 |
| 225 // Perform register allocation on the SSA graph. | 228 // Perform register allocation on the SSA graph. |
| 226 FlowGraphAllocator allocator(*flow_graph); | 229 FlowGraphAllocator allocator(*flow_graph); |
| 227 allocator.AllocateRegisters(); | 230 allocator.AllocateRegisters(); |
| 228 | 231 |
| 229 if (FLAG_print_flow_graph) { | 232 if (FLAG_print_flow_graph) { |
| 230 OS::Print("After Optimizations:\n"); | 233 OS::Print("After Optimizations:\n"); |
| 231 FlowGraphPrinter printer(*flow_graph); | 234 FlowGraphPrinter printer(*flow_graph); |
| 232 printer.PrintBlocks(); | 235 printer.PrintBlocks(); |
| 233 } | 236 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 result = isolate->object_store()->sticky_error(); | 582 result = isolate->object_store()->sticky_error(); |
| 580 isolate->object_store()->clear_sticky_error(); | 583 isolate->object_store()->clear_sticky_error(); |
| 581 isolate->set_long_jump_base(base); | 584 isolate->set_long_jump_base(base); |
| 582 return result.raw(); | 585 return result.raw(); |
| 583 } | 586 } |
| 584 UNREACHABLE(); | 587 UNREACHABLE(); |
| 585 return Object::null(); | 588 return Object::null(); |
| 586 } | 589 } |
| 587 | 590 |
| 588 } // namespace dart | 591 } // namespace dart |
| OLD | NEW |