| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 "Do loop invariant code motion."); | 45 "Do loop invariant code motion."); |
| 46 DEFINE_FLAG(bool, propagate_types, true, "Do static type propagation."); | 46 DEFINE_FLAG(bool, propagate_types, true, "Do static type propagation."); |
| 47 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, | 47 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, |
| 48 "How many times we allow deoptimization before we disallow" | 48 "How many times we allow deoptimization before we disallow" |
| 49 " certain optimizations"); | 49 " certain optimizations"); |
| 50 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 50 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 51 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); | 51 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); |
| 52 DEFINE_FLAG(bool, verify_compiler, false, | 52 DEFINE_FLAG(bool, verify_compiler, false, |
| 53 "Enable compiler verification assertions"); | 53 "Enable compiler verification assertions"); |
| 54 DECLARE_FLAG(bool, print_flow_graph); | 54 DECLARE_FLAG(bool, print_flow_graph); |
| 55 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 55 | 56 |
| 56 | 57 |
| 57 // Compile a function. Should call only if the function has not been compiled. | 58 // Compile a function. Should call only if the function has not been compiled. |
| 58 // Arg0: function object. | 59 // Arg0: function object. |
| 59 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 60 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
| 60 ASSERT(arguments.ArgCount() == kCompileFunctionRuntimeEntry.argument_count()); | 61 ASSERT(arguments.ArgCount() == kCompileFunctionRuntimeEntry.argument_count()); |
| 61 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); | 62 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); |
| 62 ASSERT(!function.HasCode()); | 63 ASSERT(!function.HasCode()); |
| 63 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 64 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| 64 if (!error.IsNull()) { | 65 if (!error.IsNull()) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 154 } |
| 154 | 155 |
| 155 if (optimized) { | 156 if (optimized) { |
| 156 TimerScope timer(FLAG_compiler_stats, | 157 TimerScope timer(FLAG_compiler_stats, |
| 157 &CompilerStats::ssa_timer, | 158 &CompilerStats::ssa_timer, |
| 158 isolate); | 159 isolate); |
| 159 // Transform to SSA (virtual register 0 and no inlining arguments). | 160 // Transform to SSA (virtual register 0 and no inlining arguments). |
| 160 flow_graph->ComputeSSA(0, NULL); | 161 flow_graph->ComputeSSA(0, NULL); |
| 161 } | 162 } |
| 162 | 163 |
| 163 if (FLAG_print_flow_graph) { | 164 if (FLAG_print_flow_graph || |
| 165 (optimized && FLAG_print_flow_graph_optimized)) { |
| 164 OS::Print("Before Optimizations\n"); | 166 OS::Print("Before Optimizations\n"); |
| 165 FlowGraphPrinter printer(*flow_graph); | 167 FlowGraphPrinter printer(*flow_graph); |
| 166 printer.PrintBlocks(); | 168 printer.PrintBlocks(); |
| 167 } | 169 } |
| 168 | 170 |
| 169 if (optimized) { | 171 if (optimized) { |
| 170 TimerScope timer(FLAG_compiler_stats, | 172 TimerScope timer(FLAG_compiler_stats, |
| 171 &CompilerStats::graphoptimizer_timer, | 173 &CompilerStats::graphoptimizer_timer, |
| 172 isolate); | 174 isolate); |
| 173 | 175 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // optimistically moves CheckSmi through phis into loop preheaders | 241 // optimistically moves CheckSmi through phis into loop preheaders |
| 240 // making some phis smi. | 242 // making some phis smi. |
| 241 flow_graph->ComputeUseLists(); | 243 flow_graph->ComputeUseLists(); |
| 242 optimizer.InferSmiRanges(); | 244 optimizer.InferSmiRanges(); |
| 243 } | 245 } |
| 244 | 246 |
| 245 // Perform register allocation on the SSA graph. | 247 // Perform register allocation on the SSA graph. |
| 246 FlowGraphAllocator allocator(*flow_graph); | 248 FlowGraphAllocator allocator(*flow_graph); |
| 247 allocator.AllocateRegisters(); | 249 allocator.AllocateRegisters(); |
| 248 | 250 |
| 249 if (FLAG_print_flow_graph) { | 251 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { |
| 250 OS::Print("After Optimizations:\n"); | 252 OS::Print("After Optimizations:\n"); |
| 251 FlowGraphPrinter printer(*flow_graph); | 253 FlowGraphPrinter printer(*flow_graph); |
| 252 printer.PrintBlocks(); | 254 printer.PrintBlocks(); |
| 253 } | 255 } |
| 254 } | 256 } |
| 255 | 257 |
| 256 Assembler assembler; | 258 Assembler assembler; |
| 257 FlowGraphCompiler graph_compiler(&assembler, | 259 FlowGraphCompiler graph_compiler(&assembler, |
| 258 *flow_graph, | 260 *flow_graph, |
| 259 optimized); | 261 optimized); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 result = isolate->object_store()->sticky_error(); | 638 result = isolate->object_store()->sticky_error(); |
| 637 isolate->object_store()->clear_sticky_error(); | 639 isolate->object_store()->clear_sticky_error(); |
| 638 isolate->set_long_jump_base(base); | 640 isolate->set_long_jump_base(base); |
| 639 return result.raw(); | 641 return result.raw(); |
| 640 } | 642 } |
| 641 UNREACHABLE(); | 643 UNREACHABLE(); |
| 642 return Object::null(); | 644 return Object::null(); |
| 643 } | 645 } |
| 644 | 646 |
| 645 } // namespace dart | 647 } // namespace dart |
| OLD | NEW |