| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
| 6 | 6 |
| 7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/block_scheduler.h" | 8 #include "vm/block_scheduler.h" |
| 9 #include "vm/branch_optimizer.h" | 9 #include "vm/branch_optimizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 DEFINE_FLAG(int, inlining_recursion_depth_threshold, 1, | 55 DEFINE_FLAG(int, inlining_recursion_depth_threshold, 1, |
| 56 "Inline recursive function calls up to threshold recursion depth."); | 56 "Inline recursive function calls up to threshold recursion depth."); |
| 57 DEFINE_FLAG(int, max_inlined_per_depth, 500, | 57 DEFINE_FLAG(int, max_inlined_per_depth, 500, |
| 58 "Max. number of inlined calls per depth"); | 58 "Max. number of inlined calls per depth"); |
| 59 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); | 59 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); |
| 60 DEFINE_FLAG(bool, enable_inlining_annotations, false, | 60 DEFINE_FLAG(bool, enable_inlining_annotations, false, |
| 61 "Enable inlining annotations"); | 61 "Enable inlining annotations"); |
| 62 | 62 |
| 63 DECLARE_FLAG(bool, compiler_stats); | 63 DECLARE_FLAG(bool, compiler_stats); |
| 64 DECLARE_FLAG(int, max_deoptimization_counter_threshold); | 64 DECLARE_FLAG(int, max_deoptimization_counter_threshold); |
| 65 DECLARE_FLAG(bool, precompilation); | |
| 66 DECLARE_FLAG(bool, print_flow_graph); | 65 DECLARE_FLAG(bool, print_flow_graph); |
| 67 DECLARE_FLAG(bool, print_flow_graph_optimized); | 66 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 68 DECLARE_FLAG(bool, verify_compiler); | 67 DECLARE_FLAG(bool, verify_compiler); |
| 69 | 68 |
| 70 // Quick access to the current zone. | 69 // Quick access to the current zone. |
| 71 #define Z (zone()) | 70 #define Z (zone()) |
| 72 #define I (isolate()) | 71 #define I (isolate()) |
| 73 | 72 |
| 74 #define TRACE_INLINING(statement) \ | 73 #define TRACE_INLINING(statement) \ |
| 75 do { \ | 74 do { \ |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // Abort if the inlinable bit on the function is low. | 624 // Abort if the inlinable bit on the function is low. |
| 626 if (!function.CanBeInlined()) { | 625 if (!function.CanBeInlined()) { |
| 627 TRACE_INLINING(THR_Print(" Bailout: not inlinable\n")); | 626 TRACE_INLINING(THR_Print(" Bailout: not inlinable\n")); |
| 628 PRINT_INLINING_TREE("Not inlinable", | 627 PRINT_INLINING_TREE("Not inlinable", |
| 629 &call_data->caller, &function, call_data->call); | 628 &call_data->caller, &function, call_data->call); |
| 630 return false; | 629 return false; |
| 631 } | 630 } |
| 632 | 631 |
| 633 // Function has no type feedback. With precompilation we don't rely on | 632 // Function has no type feedback. With precompilation we don't rely on |
| 634 // type feedback. | 633 // type feedback. |
| 635 if (!FLAG_precompilation && | 634 if (!FLAG_precompiled_mode && |
| 636 function.ic_data_array() == Object::null()) { | 635 function.ic_data_array() == Object::null()) { |
| 637 TRACE_INLINING(THR_Print(" Bailout: not compiled yet\n")); | 636 TRACE_INLINING(THR_Print(" Bailout: not compiled yet\n")); |
| 638 PRINT_INLINING_TREE("Not compiled", | 637 PRINT_INLINING_TREE("Not compiled", |
| 639 &call_data->caller, &function, call_data->call); | 638 &call_data->caller, &function, call_data->call); |
| 640 return false; | 639 return false; |
| 641 } | 640 } |
| 642 | 641 |
| 643 // Abort if this function has deoptimized too much. | 642 // Abort if this function has deoptimized too much. |
| 644 if (function.deoptimization_counter() >= | 643 if (function.deoptimization_counter() >= |
| 645 FLAG_max_deoptimization_counter_threshold) { | 644 FLAG_max_deoptimization_counter_threshold) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 // Compute SSA on the callee graph, catching bailouts. | 782 // Compute SSA on the callee graph, catching bailouts. |
| 784 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 783 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
| 785 param_stubs); | 784 param_stubs); |
| 786 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 785 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 787 } | 786 } |
| 788 | 787 |
| 789 { | 788 { |
| 790 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); | 789 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); |
| 791 // TODO(fschneider): Improve suppression of speculative inlining. | 790 // TODO(fschneider): Improve suppression of speculative inlining. |
| 792 // Deopt-ids overlap between caller and callee. | 791 // Deopt-ids overlap between caller and callee. |
| 793 if (FLAG_precompilation) { | 792 if (FLAG_precompiled_mode) { |
| 794 AotOptimizer optimizer(callee_graph, | 793 AotOptimizer optimizer(callee_graph, |
| 795 inliner_->use_speculative_inlining_, | 794 inliner_->use_speculative_inlining_, |
| 796 inliner_->inlining_black_list_); | 795 inliner_->inlining_black_list_); |
| 797 optimizer.PopulateWithICData(); | 796 optimizer.PopulateWithICData(); |
| 798 | 797 |
| 799 optimizer.ApplyClassIds(); | 798 optimizer.ApplyClassIds(); |
| 800 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 799 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 801 | 800 |
| 802 FlowGraphTypePropagator::Propagate(callee_graph); | 801 FlowGraphTypePropagator::Propagate(callee_graph); |
| 803 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 802 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 return false; | 922 return false; |
| 924 } else { | 923 } else { |
| 925 // Fall through to exit long jump scope. | 924 // Fall through to exit long jump scope. |
| 926 } | 925 } |
| 927 } | 926 } |
| 928 } | 927 } |
| 929 | 928 |
| 930 // Propagate a compile-time error. Only in precompilation do we attempt to | 929 // Propagate a compile-time error. Only in precompilation do we attempt to |
| 931 // inline functions that have never been compiled before; when JITing we | 930 // inline functions that have never been compiled before; when JITing we |
| 932 // should only see compile-time errors in unoptimized compilation. | 931 // should only see compile-time errors in unoptimized compilation. |
| 933 ASSERT(FLAG_precompilation); | 932 ASSERT(FLAG_precompiled_mode); |
| 934 Thread::Current()->long_jump_base()->Jump(1, error); | 933 Thread::Current()->long_jump_base()->Jump(1, error); |
| 935 UNREACHABLE(); | 934 UNREACHABLE(); |
| 936 return false; | 935 return false; |
| 937 } | 936 } |
| 938 | 937 |
| 939 void PrintInlinedInfo(const Function& top) { | 938 void PrintInlinedInfo(const Function& top) { |
| 940 if (inlined_info_.length() > 0) { | 939 if (inlined_info_.length() > 0) { |
| 941 THR_Print("Inlining into: '%s' growth: %f (%" Pd " -> %" Pd ")\n", | 940 THR_Print("Inlining into: '%s' growth: %f (%" Pd " -> %" Pd ")\n", |
| 942 top.ToFullyQualifiedCString(), | 941 top.ToFullyQualifiedCString(), |
| 943 GrowthFactor(), | 942 GrowthFactor(), |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); | 3054 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); |
| 3056 case MethodRecognizer::kDoubleDiv: | 3055 case MethodRecognizer::kDoubleDiv: |
| 3057 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); | 3056 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); |
| 3058 default: | 3057 default: |
| 3059 return false; | 3058 return false; |
| 3060 } | 3059 } |
| 3061 } | 3060 } |
| 3062 | 3061 |
| 3063 | 3062 |
| 3064 } // namespace dart | 3063 } // namespace dart |
| OLD | NEW |