Chromium Code Reviews| 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/block_scheduler.h" | 7 #include "vm/block_scheduler.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 "Stop inlining once caller reaches the threshold."); | 40 "Stop inlining once caller reaches the threshold."); |
| 41 DEFINE_FLAG(int, inlining_constant_arguments_count, 1, | 41 DEFINE_FLAG(int, inlining_constant_arguments_count, 1, |
| 42 "Inline function calls with sufficient constant arguments " | 42 "Inline function calls with sufficient constant arguments " |
| 43 "and up to the increased threshold on instructions"); | 43 "and up to the increased threshold on instructions"); |
| 44 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, | 44 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, |
| 45 "Inline function calls with sufficient constant arguments " | 45 "Inline function calls with sufficient constant arguments " |
| 46 "and up to the increased threshold on instructions"); | 46 "and up to the increased threshold on instructions"); |
| 47 DEFINE_FLAG(int, inlining_hotness, 10, | 47 DEFINE_FLAG(int, inlining_hotness, 10, |
| 48 "Inline only hotter calls, in percents (0 .. 100); " | 48 "Inline only hotter calls, in percents (0 .. 100); " |
| 49 "default 10%: calls above-equal 10% of max-count are inlined."); | 49 "default 10%: calls above-equal 10% of max-count are inlined."); |
| 50 DEFINE_FLAG(bool, inline_recursive, true, | 50 DEFINE_FLAG(bool, inline_recursive, false, "Inline recursive calls."); |
| 51 "Inline recursive calls."); | |
| 52 DEFINE_FLAG(int, max_inlined_per_depth, 500, | 51 DEFINE_FLAG(int, max_inlined_per_depth, 500, |
| 53 "Max. number of inlined calls per depth"); | 52 "Max. number of inlined calls per depth"); |
| 54 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); | 53 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); |
| 55 | 54 |
| 56 DECLARE_FLAG(bool, compiler_stats); | 55 DECLARE_FLAG(bool, compiler_stats); |
| 57 DECLARE_FLAG(bool, enable_type_checks); | 56 DECLARE_FLAG(bool, enable_type_checks); |
| 58 DECLARE_FLAG(int, deoptimization_counter_threshold); | 57 DECLARE_FLAG(int, deoptimization_counter_threshold); |
| 59 DECLARE_FLAG(bool, print_flow_graph); | 58 DECLARE_FLAG(bool, print_flow_graph); |
| 60 DECLARE_FLAG(bool, print_flow_graph_optimized); | 59 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 61 DECLARE_FLAG(bool, verify_compiler); | 60 DECLARE_FLAG(bool, verify_compiler); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 function.optimized_call_site_count(), | 607 function.optimized_call_site_count(), |
| 609 constant_arguments)); | 608 constant_arguments)); |
| 610 PRINT_INLINING_TREE("Early heuristic", | 609 PRINT_INLINING_TREE("Early heuristic", |
| 611 &call_data->caller, &function, call_data->call); | 610 &call_data->caller, &function, call_data->call); |
| 612 return false; | 611 return false; |
| 613 } | 612 } |
| 614 | 613 |
| 615 // Abort if this is a recursive occurrence. | 614 // Abort if this is a recursive occurrence. |
| 616 Definition* call = call_data->call; | 615 Definition* call = call_data->call; |
| 617 if (!FLAG_inline_recursive && IsCallRecursive(unoptimized_code, call)) { | 616 if (!FLAG_inline_recursive && IsCallRecursive(unoptimized_code, call)) { |
| 618 function.set_is_inlinable(false); | 617 function.set_is_inlinable(false); |
|
Florian Schneider
2014/10/20 14:01:57
Maybe that should not mark the whole function as n
| |
| 619 TRACE_INLINING(OS::Print(" Bailout: recursive function\n")); | 618 TRACE_INLINING(OS::Print(" Bailout: recursive function\n")); |
| 620 PRINT_INLINING_TREE("Recursive function", | 619 PRINT_INLINING_TREE("Recursive function", |
| 621 &call_data->caller, &function, call_data->call); | 620 &call_data->caller, &function, call_data->call); |
| 622 return false; | 621 return false; |
| 623 } | 622 } |
| 624 | 623 |
| 625 // Save and clear deopt id. | 624 // Save and clear deopt id. |
| 626 const intptr_t prev_deopt_id = isolate()->deopt_id(); | 625 const intptr_t prev_deopt_id = isolate()->deopt_id(); |
| 627 isolate()->set_deopt_id(0); | 626 isolate()->set_deopt_id(0); |
| 628 // Install bailout jump. | 627 // Install bailout jump. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 "code size: %" Pd ", " | 756 "code size: %" Pd ", " |
| 758 "call sites: %" Pd ", " | 757 "call sites: %" Pd ", " |
| 759 "const args: %" Pd "\n", | 758 "const args: %" Pd "\n", |
| 760 size, | 759 size, |
| 761 call_site_count, | 760 call_site_count, |
| 762 constants_count)); | 761 constants_count)); |
| 763 PRINT_INLINING_TREE("Heuristic fail", | 762 PRINT_INLINING_TREE("Heuristic fail", |
| 764 &call_data->caller, &function, call_data->call); | 763 &call_data->caller, &function, call_data->call); |
| 765 return false; | 764 return false; |
| 766 } | 765 } |
| 767 | |
| 768 if (function.IsInvokeFieldDispatcher() || | 766 if (function.IsInvokeFieldDispatcher() || |
| 769 function.IsNoSuchMethodDispatcher()) { | 767 function.IsNoSuchMethodDispatcher()) { |
| 770 // Append call sites to the currently processed list so that dispatcher | 768 // Append call sites to the currently processed list so that dispatcher |
| 771 // methods get inlined regardless of the current depth. | 769 // methods get inlined regardless of the current depth. |
| 770 // Need a throttling mechanism for recursive inlining. | |
| 771 ASSERT(!FLAG_inline_recursive); | |
| 772 inlining_call_sites_->FindCallSites(callee_graph, | 772 inlining_call_sites_->FindCallSites(callee_graph, |
| 773 0, | 773 0, |
|
zerny-google
2014/10/20 11:28:21
DBC: It seems this issue is caused by ignoring the
Florian Schneider
2014/10/20 14:01:56
I agree that a separate threshold for recursive in
| |
| 774 &inlined_info_); | 774 &inlined_info_); |
| 775 } else { | 775 } else { |
| 776 collected_call_sites_->FindCallSites(callee_graph, | 776 collected_call_sites_->FindCallSites(callee_graph, |
| 777 inlining_depth_, | 777 inlining_depth_, |
| 778 &inlined_info_); | 778 &inlined_info_); |
| 779 } | 779 } |
| 780 | 780 |
| 781 // Add the function to the cache. | 781 // Add the function to the cache. |
| 782 if (!in_cache) { | 782 if (!in_cache) { |
| 783 function_cache_.Add(parsed_function); | 783 function_cache_.Add(parsed_function); |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1703 OS::Print("After Inlining of %s\n", flow_graph_-> | 1703 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1704 parsed_function().function().ToFullyQualifiedCString()); | 1704 parsed_function().function().ToFullyQualifiedCString()); |
| 1705 FlowGraphPrinter printer(*flow_graph_); | 1705 FlowGraphPrinter printer(*flow_graph_); |
| 1706 printer.PrintBlocks(); | 1706 printer.PrintBlocks(); |
| 1707 } | 1707 } |
| 1708 } | 1708 } |
| 1709 } | 1709 } |
| 1710 } | 1710 } |
| 1711 | 1711 |
| 1712 } // namespace dart | 1712 } // namespace dart |
| OLD | NEW |