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 14 matching lines...) Expand all Loading... |
25 #include "vm/il_printer.h" | 25 #include "vm/il_printer.h" |
26 #include "vm/longjump.h" | 26 #include "vm/longjump.h" |
27 #include "vm/object.h" | 27 #include "vm/object.h" |
28 #include "vm/object_store.h" | 28 #include "vm/object_store.h" |
29 #include "vm/os.h" | 29 #include "vm/os.h" |
30 #include "vm/parser.h" | 30 #include "vm/parser.h" |
31 #include "vm/scanner.h" | 31 #include "vm/scanner.h" |
32 #include "vm/symbols.h" | 32 #include "vm/symbols.h" |
33 #include "vm/tags.h" | 33 #include "vm/tags.h" |
34 #include "vm/timer.h" | 34 #include "vm/timer.h" |
| 35 #include "vm/trace_buffer.h" |
35 | 36 |
36 namespace dart { | 37 namespace dart { |
37 | 38 |
38 DEFINE_FLAG(bool, allocation_sinking, true, | 39 DEFINE_FLAG(bool, allocation_sinking, true, |
39 "Attempt to sink temporary allocations to side exits"); | 40 "Attempt to sink temporary allocations to side exits"); |
40 DEFINE_FLAG(bool, common_subexpression_elimination, true, | 41 DEFINE_FLAG(bool, common_subexpression_elimination, true, |
41 "Do common subexpression elimination."); | 42 "Do common subexpression elimination."); |
42 DEFINE_FLAG(bool, constant_propagation, true, | 43 DEFINE_FLAG(bool, constant_propagation, true, |
43 "Do conditional constant propagation/unreachable code elimination."); | 44 "Do conditional constant propagation/unreachable code elimination."); |
44 DEFINE_FLAG(int, deoptimization_counter_threshold, 16, | 45 DEFINE_FLAG(int, deoptimization_counter_threshold, 16, |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 Object::branch_offset_error().raw()) { | 598 Object::branch_offset_error().raw()) { |
598 // Compilation failed due to an out of range branch offset in the | 599 // Compilation failed due to an out of range branch offset in the |
599 // assembler. We try again (done = false) with far branches enabled. | 600 // assembler. We try again (done = false) with far branches enabled. |
600 done = false; | 601 done = false; |
601 ASSERT(!use_far_branches); | 602 ASSERT(!use_far_branches); |
602 use_far_branches = true; | 603 use_far_branches = true; |
603 } else { | 604 } else { |
604 // If the error isn't due to an out of range branch offset, we don't | 605 // If the error isn't due to an out of range branch offset, we don't |
605 // try again (done = true), and indicate that we did not finish | 606 // try again (done = true), and indicate that we did not finish |
606 // compiling (is_compiled = false). | 607 // compiling (is_compiled = false). |
| 608 const Error& bailout_error = Error::Handle( |
| 609 isolate->object_store()->sticky_error()); |
607 if (FLAG_trace_bailout) { | 610 if (FLAG_trace_bailout) { |
608 const Error& bailout_error = Error::Handle( | |
609 isolate->object_store()->sticky_error()); | |
610 OS::Print("%s\n", bailout_error.ToErrorCString()); | 611 OS::Print("%s\n", bailout_error.ToErrorCString()); |
611 } | 612 } |
| 613 function.log()->TraceF("Failed to compile optimized code: %s", |
| 614 bailout_error.ToErrorCString()); |
612 done = true; | 615 done = true; |
613 ASSERT(optimized); | 616 ASSERT(optimized); |
614 } | 617 } |
615 | 618 |
616 isolate->object_store()->clear_sticky_error(); | 619 isolate->object_store()->clear_sticky_error(); |
617 is_compiled = false; | 620 is_compiled = false; |
618 } | 621 } |
619 // Reset global isolate state. | 622 // Reset global isolate state. |
620 isolate->set_deopt_id(prev_deopt_id); | 623 isolate->set_deopt_id(prev_deopt_id); |
621 } | 624 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 if (!optimized && !unoptimized_code.IsNull()) { | 763 if (!optimized && !unoptimized_code.IsNull()) { |
761 InstallUnoptimizedCode(function); | 764 InstallUnoptimizedCode(function); |
762 return Error::null(); | 765 return Error::null(); |
763 } | 766 } |
764 if (setjmp(*jump.Set()) == 0) { | 767 if (setjmp(*jump.Set()) == 0) { |
765 TIMERSCOPE(isolate, time_compilation); | 768 TIMERSCOPE(isolate, time_compilation); |
766 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); | 769 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); |
767 per_compile_timer.Start(); | 770 per_compile_timer.Start(); |
768 ParsedFunction* parsed_function = | 771 ParsedFunction* parsed_function = |
769 new ParsedFunction(Function::ZoneHandle(function.raw())); | 772 new ParsedFunction(Function::ZoneHandle(function.raw())); |
| 773 function.log()->TraceF("Compiled %s%s", |
| 774 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), |
| 775 (optimized ? "optimized " : "")); |
770 if (FLAG_trace_compiler) { | 776 if (FLAG_trace_compiler) { |
771 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", | 777 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", |
772 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), | 778 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), |
773 (optimized ? "optimized " : ""), | 779 (optimized ? "optimized " : ""), |
774 function.ToFullyQualifiedCString(), | 780 function.ToFullyQualifiedCString(), |
775 function.token_pos(), | 781 function.token_pos(), |
776 (function.end_token_pos() - function.token_pos())); | 782 (function.end_token_pos() - function.token_pos())); |
777 } | 783 } |
778 { | 784 { |
779 HANDLESCOPE(isolate); | 785 HANDLESCOPE(isolate); |
780 Parser::ParseFunction(parsed_function); | 786 Parser::ParseFunction(parsed_function); |
781 parsed_function->AllocateVariables(); | 787 parsed_function->AllocateVariables(); |
782 } | 788 } |
783 | 789 |
784 const bool success = | 790 const bool success = |
785 CompileParsedFunctionHelper(parsed_function, optimized, osr_id); | 791 CompileParsedFunctionHelper(parsed_function, optimized, osr_id); |
786 if (optimized && !success) { | 792 if (optimized && !success) { |
787 // Optimizer bailed out. Disable optimizations and to never try again. | 793 // Optimizer bailed out. Disable optimizations and to never try again. |
| 794 function.log()->TraceF("Optimizations disabled"); |
788 if (FLAG_trace_compiler) { | 795 if (FLAG_trace_compiler) { |
789 OS::Print("--> disabling optimizations for '%s'\n", | 796 OS::Print("--> disabling optimizations for '%s'\n", |
790 function.ToFullyQualifiedCString()); | 797 function.ToFullyQualifiedCString()); |
791 } else if (FLAG_trace_failed_optimization_attempts) { | 798 } else if (FLAG_trace_failed_optimization_attempts) { |
792 OS::Print("Cannot optimize: %s\n", function.ToFullyQualifiedCString()); | 799 OS::Print("Cannot optimize: %s\n", function.ToFullyQualifiedCString()); |
793 } | 800 } |
794 function.SetIsOptimizable(false); | 801 function.SetIsOptimizable(false); |
795 return Error::null(); | 802 return Error::null(); |
796 } | 803 } |
797 | 804 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 const Object& result = | 966 const Object& result = |
960 Object::Handle(isolate->object_store()->sticky_error()); | 967 Object::Handle(isolate->object_store()->sticky_error()); |
961 isolate->object_store()->clear_sticky_error(); | 968 isolate->object_store()->clear_sticky_error(); |
962 return result.raw(); | 969 return result.raw(); |
963 } | 970 } |
964 UNREACHABLE(); | 971 UNREACHABLE(); |
965 return Object::null(); | 972 return Object::null(); |
966 } | 973 } |
967 | 974 |
968 } // namespace dart | 975 } // namespace dart |
OLD | NEW |