| 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 26 matching lines...) Expand all Loading... |
| 37 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); | 37 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); |
| 38 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); | 38 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); |
| 39 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 39 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
| 40 DEFINE_FLAG(bool, constant_propagation, true, | 40 DEFINE_FLAG(bool, constant_propagation, true, |
| 41 "Do conditional constant propagation/unreachable code elimination."); | 41 "Do conditional constant propagation/unreachable code elimination."); |
| 42 DEFINE_FLAG(bool, common_subexpression_elimination, true, | 42 DEFINE_FLAG(bool, common_subexpression_elimination, true, |
| 43 "Do common subexpression elimination."); | 43 "Do common subexpression elimination."); |
| 44 DEFINE_FLAG(bool, loop_invariant_code_motion, true, | 44 DEFINE_FLAG(bool, loop_invariant_code_motion, true, |
| 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, 16, |
| 48 "How many times we allow deoptimization before we disallow" | 48 "How many times we allow deoptimization before we disallow optimization."); |
| 49 " certain optimizations"); | |
| 50 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 49 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 51 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); | 50 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); |
| 52 DEFINE_FLAG(bool, verify_compiler, false, | 51 DEFINE_FLAG(bool, verify_compiler, false, |
| 53 "Enable compiler verification assertions"); | 52 "Enable compiler verification assertions"); |
| 54 DECLARE_FLAG(bool, print_flow_graph); | 53 DECLARE_FLAG(bool, print_flow_graph); |
| 55 DECLARE_FLAG(bool, print_flow_graph_optimized); | 54 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 55 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
| 56 | 56 |
| 57 | 57 |
| 58 // 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. |
| 59 // Arg0: function object. | 59 // Arg0: function object. |
| 60 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 60 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
| 61 ASSERT(arguments.ArgCount() == kCompileFunctionRuntimeEntry.argument_count()); | 61 ASSERT(arguments.ArgCount() == kCompileFunctionRuntimeEntry.argument_count()); |
| 62 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); | 62 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); |
| 63 ASSERT(!function.HasCode()); | 63 ASSERT(!function.HasCode()); |
| 64 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 64 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| 65 if (!error.IsNull()) { | 65 if (!error.IsNull()) { |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 parsed_function->AllocateVariables(); | 475 parsed_function->AllocateVariables(); |
| 476 } | 476 } |
| 477 | 477 |
| 478 const bool success = | 478 const bool success = |
| 479 CompileParsedFunctionHelper(*parsed_function, optimized); | 479 CompileParsedFunctionHelper(*parsed_function, optimized); |
| 480 if (optimized && !success) { | 480 if (optimized && !success) { |
| 481 // Optimizer bailed out. Disable optimizations and to never try again. | 481 // Optimizer bailed out. Disable optimizations and to never try again. |
| 482 if (FLAG_trace_compiler) { | 482 if (FLAG_trace_compiler) { |
| 483 OS::Print("--> disabling optimizations for '%s'\n", | 483 OS::Print("--> disabling optimizations for '%s'\n", |
| 484 function.ToFullyQualifiedCString()); | 484 function.ToFullyQualifiedCString()); |
| 485 } else if (FLAG_trace_failed_optimization_attempts) { |
| 486 OS::Print("Cannot optimize: %s\n", function.ToFullyQualifiedCString()); |
| 485 } | 487 } |
| 486 function.set_is_optimizable(false); | 488 function.set_is_optimizable(false); |
| 487 isolate->set_long_jump_base(base); | 489 isolate->set_long_jump_base(base); |
| 488 return Error::null(); | 490 return Error::null(); |
| 489 } | 491 } |
| 490 | 492 |
| 491 ASSERT(success); | 493 ASSERT(success); |
| 492 per_compile_timer.Stop(); | 494 per_compile_timer.Stop(); |
| 493 | 495 |
| 494 if (FLAG_trace_compiler) { | 496 if (FLAG_trace_compiler) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 Object::Handle(isolate->object_store()->sticky_error()); | 638 Object::Handle(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 |