| 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 16 matching lines...) Expand all Loading... |
| 27 #include "vm/timer.h" | 27 #include "vm/timer.h" |
| 28 | 28 |
| 29 namespace dart { | 29 namespace dart { |
| 30 | 30 |
| 31 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); | 31 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); |
| 32 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 32 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
| 33 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, | 33 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, |
| 34 "How many times we allow deoptimization before we disallow" | 34 "How many times we allow deoptimization before we disallow" |
| 35 " certain optimizations"); | 35 " certain optimizations"); |
| 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 DECLARE_FLAG(bool, print_flow_graph); |
| 37 DECLARE_FLAG(bool, use_ssa); | 38 DECLARE_FLAG(bool, use_ssa); |
| 38 | 39 |
| 39 | 40 |
| 40 // Compile a function. Should call only if the function has not been compiled. | 41 // Compile a function. Should call only if the function has not been compiled. |
| 41 // Arg0: function object. | 42 // Arg0: function object. |
| 42 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 43 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
| 43 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); | 44 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); |
| 44 const Function& function = Function::CheckedHandle(arguments.At(0)); | 45 const Function& function = Function::CheckedHandle(arguments.At(0)); |
| 45 ASSERT(!function.HasCode()); | 46 ASSERT(!function.HasCode()); |
| 46 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 47 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 166 } |
| 166 if (optimized) { | 167 if (optimized) { |
| 167 FlowGraphOptimizer optimizer(block_order); | 168 FlowGraphOptimizer optimizer(block_order); |
| 168 optimizer.ApplyICData(); | 169 optimizer.ApplyICData(); |
| 169 | 170 |
| 170 if (use_ssa) { | 171 if (use_ssa) { |
| 171 // Perform register allocation on the SSA graph. | 172 // Perform register allocation on the SSA graph. |
| 172 FlowGraphAllocator allocator(block_order, &graph_builder); | 173 FlowGraphAllocator allocator(block_order, &graph_builder); |
| 173 allocator.AllocateRegisters(); | 174 allocator.AllocateRegisters(); |
| 174 } | 175 } |
| 176 if (FLAG_print_flow_graph) { |
| 177 OS::Print("After Optimizations:\n"); |
| 178 FlowGraphPrinter printer(Function::Handle(), block_order); |
| 179 printer.PrintBlocks(); |
| 180 } |
| 175 } | 181 } |
| 176 } | 182 } |
| 177 | 183 |
| 178 bool is_leaf = false; | 184 bool is_leaf = false; |
| 179 if (optimized) { | 185 if (optimized) { |
| 180 FlowGraphAnalyzer analyzer(block_order); | 186 FlowGraphAnalyzer analyzer(block_order); |
| 181 analyzer.Analyze(); | 187 analyzer.Analyze(); |
| 182 is_leaf = analyzer.is_leaf(); | 188 is_leaf = analyzer.is_leaf(); |
| 183 } | 189 } |
| 184 Assembler assembler; | 190 Assembler assembler; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 isolate->object_store()->clear_sticky_error(); | 482 isolate->object_store()->clear_sticky_error(); |
| 477 isolate->set_long_jump_base(base); | 483 isolate->set_long_jump_base(base); |
| 478 return result.raw(); | 484 return result.raw(); |
| 479 } | 485 } |
| 480 UNREACHABLE(); | 486 UNREACHABLE(); |
| 481 return Object::null(); | 487 return Object::null(); |
| 482 } | 488 } |
| 483 | 489 |
| 484 | 490 |
| 485 } // namespace dart | 491 } // namespace dart |
| OLD | NEW |