| 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/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); | 53 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); |
| 54 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); | 54 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); |
| 55 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 55 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
| 56 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); | 56 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); |
| 57 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 57 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 58 DEFINE_FLAG(bool, verify_compiler, false, | 58 DEFINE_FLAG(bool, verify_compiler, false, |
| 59 "Enable compiler verification assertions"); | 59 "Enable compiler verification assertions"); |
| 60 | 60 |
| 61 DECLARE_FLAG(bool, trace_failed_optimization_attempts); | 61 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
| 62 DECLARE_FLAG(bool, trace_patching); | 62 DECLARE_FLAG(bool, trace_patching); |
| 63 DECLARE_FLAG(bool, warn_on_javascript_compatibility); | |
| 64 DECLARE_FLAG(bool, warning_as_error); | |
| 65 | 63 |
| 66 // Compile a function. Should call only if the function has not been compiled. | 64 // Compile a function. Should call only if the function has not been compiled. |
| 67 // Arg0: function object. | 65 // Arg0: function object. |
| 68 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 66 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
| 69 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); | 67 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); |
| 70 ASSERT(!function.HasCode()); | 68 ASSERT(!function.HasCode()); |
| 71 const Error& error = Error::Handle(Compiler::CompileFunction(isolate, | 69 const Error& error = Error::Handle(Compiler::CompileFunction(isolate, |
| 72 function)); | 70 function)); |
| 73 if (!error.IsNull()) { | 71 if (!error.IsNull()) { |
| 74 Exceptions::PropagateError(error); | 72 Exceptions::PropagateError(error); |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 ASSERT(!use_far_branches); | 604 ASSERT(!use_far_branches); |
| 607 use_far_branches = true; | 605 use_far_branches = true; |
| 608 } else { | 606 } else { |
| 609 // If the error isn't due to an out of range branch offset, we don't | 607 // If the error isn't due to an out of range branch offset, we don't |
| 610 // try again (done = true), and indicate that we did not finish | 608 // try again (done = true), and indicate that we did not finish |
| 611 // compiling (is_compiled = false). | 609 // compiling (is_compiled = false). |
| 612 if (FLAG_trace_bailout) { | 610 if (FLAG_trace_bailout) { |
| 613 OS::Print("%s\n", error.ToErrorCString()); | 611 OS::Print("%s\n", error.ToErrorCString()); |
| 614 } | 612 } |
| 615 done = true; | 613 done = true; |
| 616 ASSERT(optimized || | 614 ASSERT(optimized); |
| 617 (FLAG_warn_on_javascript_compatibility && | |
| 618 FLAG_warning_as_error)); | |
| 619 } | 615 } |
| 620 | 616 |
| 621 // Clear the error if it was not a real error, but just a bailout. | 617 // Clear the error if it was not a real error, but just a bailout. |
| 622 if (error.IsLanguageError() && | 618 if (error.IsLanguageError() && |
| 623 (LanguageError::Cast(error).kind() == Report::kBailout)) { | 619 (LanguageError::Cast(error).kind() == Report::kBailout)) { |
| 624 isolate->object_store()->clear_sticky_error(); | 620 isolate->object_store()->clear_sticky_error(); |
| 625 } | 621 } |
| 626 is_compiled = false; | 622 is_compiled = false; |
| 627 } | 623 } |
| 628 // Reset global isolate state. | 624 // Reset global isolate state. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 if (FLAG_trace_compiler) { | 790 if (FLAG_trace_compiler) { |
| 795 OS::Print("--> disabling optimizations for '%s'\n", | 791 OS::Print("--> disabling optimizations for '%s'\n", |
| 796 function.ToFullyQualifiedCString()); | 792 function.ToFullyQualifiedCString()); |
| 797 } else if (FLAG_trace_failed_optimization_attempts) { | 793 } else if (FLAG_trace_failed_optimization_attempts) { |
| 798 OS::Print("Cannot optimize: %s\n", | 794 OS::Print("Cannot optimize: %s\n", |
| 799 function.ToFullyQualifiedCString()); | 795 function.ToFullyQualifiedCString()); |
| 800 } | 796 } |
| 801 function.SetIsOptimizable(false); | 797 function.SetIsOptimizable(false); |
| 802 return Error::null(); | 798 return Error::null(); |
| 803 } | 799 } |
| 804 // So far, the only possible real error is a JS warning reported as error. | 800 UNREACHABLE(); |
| 805 ASSERT(FLAG_warn_on_javascript_compatibility && FLAG_warning_as_error); | |
| 806 Error& error = Error::Handle(); | |
| 807 // We got an error during compilation. | |
| 808 error = isolate->object_store()->sticky_error(); | |
| 809 ASSERT(!error.IsNull()); | |
| 810 isolate->object_store()->clear_sticky_error(); | |
| 811 return error.raw(); | |
| 812 } | 801 } |
| 813 | 802 |
| 814 per_compile_timer.Stop(); | 803 per_compile_timer.Stop(); |
| 815 | 804 |
| 816 if (FLAG_trace_compiler) { | 805 if (FLAG_trace_compiler) { |
| 817 OS::Print("--> '%s' entry: %#" Px " size: %" Pd " time: %" Pd64 " us\n", | 806 OS::Print("--> '%s' entry: %#" Px " size: %" Pd " time: %" Pd64 " us\n", |
| 818 function.ToFullyQualifiedCString(), | 807 function.ToFullyQualifiedCString(), |
| 819 Code::Handle(function.CurrentCode()).EntryPoint(), | 808 Code::Handle(function.CurrentCode()).EntryPoint(), |
| 820 Code::Handle(function.CurrentCode()).Size(), | 809 Code::Handle(function.CurrentCode()).Size(), |
| 821 per_compile_timer.TotalElapsedTime()); | 810 per_compile_timer.TotalElapsedTime()); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 const Object& result = | 969 const Object& result = |
| 981 Object::Handle(isolate->object_store()->sticky_error()); | 970 Object::Handle(isolate->object_store()->sticky_error()); |
| 982 isolate->object_store()->clear_sticky_error(); | 971 isolate->object_store()->clear_sticky_error(); |
| 983 return result.raw(); | 972 return result.raw(); |
| 984 } | 973 } |
| 985 UNREACHABLE(); | 974 UNREACHABLE(); |
| 986 return Object::null(); | 975 return Object::null(); |
| 987 } | 976 } |
| 988 | 977 |
| 989 } // namespace dart | 978 } // namespace dart |
| OLD | NEW |