| 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" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/debugger.h" | 12 #include "vm/debugger.h" |
| 13 #include "vm/disassembler.h" | 13 #include "vm/disassembler.h" |
| 14 #include "vm/exceptions.h" | 14 #include "vm/exceptions.h" |
| 15 #include "vm/flags.h" | 15 #include "vm/flags.h" |
| 16 #include "vm/flow_graph.h" | 16 #include "vm/flow_graph.h" |
| 17 #include "vm/flow_graph_allocator.h" | 17 #include "vm/flow_graph_allocator.h" |
| 18 #include "vm/flow_graph_builder.h" | 18 #include "vm/flow_graph_builder.h" |
| 19 #include "vm/flow_graph_compiler.h" | 19 #include "vm/flow_graph_compiler.h" |
| 20 #include "vm/flow_graph_inliner.h" |
| 20 #include "vm/flow_graph_optimizer.h" | 21 #include "vm/flow_graph_optimizer.h" |
| 21 #include "vm/il_printer.h" | 22 #include "vm/il_printer.h" |
| 22 #include "vm/longjump.h" | 23 #include "vm/longjump.h" |
| 23 #include "vm/object.h" | 24 #include "vm/object.h" |
| 24 #include "vm/object_store.h" | 25 #include "vm/object_store.h" |
| 25 #include "vm/os.h" | 26 #include "vm/os.h" |
| 26 #include "vm/parser.h" | 27 #include "vm/parser.h" |
| 27 #include "vm/scanner.h" | 28 #include "vm/scanner.h" |
| 28 #include "vm/symbols.h" | 29 #include "vm/symbols.h" |
| 29 #include "vm/timer.h" | 30 #include "vm/timer.h" |
| 30 | 31 |
| 31 namespace dart { | 32 namespace dart { |
| 32 | 33 |
| 33 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); | 34 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); |
| 34 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); | 35 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); |
| 35 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); | 36 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); |
| 36 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 37 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
| 37 DEFINE_FLAG(bool, cse, true, "Do common subexpression elimination."); | 38 DEFINE_FLAG(bool, cse, true, "Do common subexpression elimination."); |
| 38 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, | 39 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, |
| 39 "How many times we allow deoptimization before we disallow" | 40 "How many times we allow deoptimization before we disallow" |
| 40 " certain optimizations"); | 41 " certain optimizations"); |
| 42 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 41 DECLARE_FLAG(bool, print_flow_graph); | 43 DECLARE_FLAG(bool, print_flow_graph); |
| 42 | 44 |
| 43 | 45 |
| 44 // Compile a function. Should call only if the function has not been compiled. | 46 // Compile a function. Should call only if the function has not been compiled. |
| 45 // Arg0: function object. | 47 // Arg0: function object. |
| 46 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 48 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
| 47 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); | 49 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); |
| 48 const Function& function = Function::CheckedHandle(arguments.At(0)); | 50 const Function& function = Function::CheckedHandle(arguments.At(0)); |
| 49 ASSERT(!function.HasCode()); | 51 ASSERT(!function.HasCode()); |
| 50 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 52 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // stage. | 184 // stage. |
| 183 // Compute the use lists. | 185 // Compute the use lists. |
| 184 flow_graph->ComputeUseLists(); | 186 flow_graph->ComputeUseLists(); |
| 185 | 187 |
| 186 FlowGraphOptimizer optimizer(flow_graph); | 188 FlowGraphOptimizer optimizer(flow_graph); |
| 187 optimizer.ApplyICData(); | 189 optimizer.ApplyICData(); |
| 188 | 190 |
| 189 // Compute the use lists. | 191 // Compute the use lists. |
| 190 flow_graph->ComputeUseLists(); | 192 flow_graph->ComputeUseLists(); |
| 191 | 193 |
| 194 // Inlining (mutates the flow graph) |
| 195 if (FLAG_use_inlining) { |
| 196 FlowGraphInliner inliner(flow_graph); |
| 197 inliner.Inline(); |
| 198 // Verify that the use lists are still valid. |
| 199 DEBUG_ASSERT(flow_graph->ValidateUseLists()); |
| 200 } |
| 201 |
| 192 // Propagate types and eliminate more type tests. | 202 // Propagate types and eliminate more type tests. |
| 193 FlowGraphTypePropagator propagator(*flow_graph); | 203 FlowGraphTypePropagator propagator(*flow_graph); |
| 194 propagator.PropagateTypes(); | 204 propagator.PropagateTypes(); |
| 195 | 205 |
| 196 // Verify that the use lists are still valid. | 206 // Verify that the use lists are still valid. |
| 197 DEBUG_ASSERT(flow_graph->ValidateUseLists()); | 207 DEBUG_ASSERT(flow_graph->ValidateUseLists()); |
| 198 | 208 |
| 199 // Do optimizations that depend on the propagated type information. | 209 // Do optimizations that depend on the propagated type information. |
| 200 optimizer.OptimizeComputations(); | 210 optimizer.OptimizeComputations(); |
| 201 | 211 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 result = isolate->object_store()->sticky_error(); | 570 result = isolate->object_store()->sticky_error(); |
| 561 isolate->object_store()->clear_sticky_error(); | 571 isolate->object_store()->clear_sticky_error(); |
| 562 isolate->set_long_jump_base(base); | 572 isolate->set_long_jump_base(base); |
| 563 return result.raw(); | 573 return result.raw(); |
| 564 } | 574 } |
| 565 UNREACHABLE(); | 575 UNREACHABLE(); |
| 566 return Object::null(); | 576 return Object::null(); |
| 567 } | 577 } |
| 568 | 578 |
| 569 } // namespace dart | 579 } // namespace dart |
| OLD | NEW |