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