| 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/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
| 6 | 6 |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 "Inline function calls with sufficient constant arguments " | 34 "Inline function calls with sufficient constant arguments " |
| 35 "and up to the increased threshold on instructions"); | 35 "and up to the increased threshold on instructions"); |
| 36 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, | 36 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, |
| 37 "Inline function calls with sufficient constant arguments " | 37 "Inline function calls with sufficient constant arguments " |
| 38 "and up to the increased threshold on instructions"); | 38 "and up to the increased threshold on instructions"); |
| 39 DEFINE_FLAG(int, inlining_hotness, 10, | 39 DEFINE_FLAG(int, inlining_hotness, 10, |
| 40 "Inline only hotter calls, in percents (0 .. 100); " | 40 "Inline only hotter calls, in percents (0 .. 100); " |
| 41 "default 10%: calls above-equal 10% of max-count are inlined."); | 41 "default 10%: calls above-equal 10% of max-count are inlined."); |
| 42 | 42 |
| 43 DECLARE_FLAG(bool, print_flow_graph); | 43 DECLARE_FLAG(bool, print_flow_graph); |
| 44 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 44 DECLARE_FLAG(int, deoptimization_counter_threshold); | 45 DECLARE_FLAG(int, deoptimization_counter_threshold); |
| 45 DECLARE_FLAG(bool, verify_compiler); | 46 DECLARE_FLAG(bool, verify_compiler); |
| 46 DECLARE_FLAG(bool, compiler_stats); | 47 DECLARE_FLAG(bool, compiler_stats); |
| 47 | 48 |
| 48 #define TRACE_INLINING(statement) \ | 49 #define TRACE_INLINING(statement) \ |
| 49 do { \ | 50 do { \ |
| 50 if (FLAG_trace_inlining) statement; \ | 51 if (FLAG_trace_inlining) statement; \ |
| 51 } while (false) | 52 } while (false) |
| 52 | 53 |
| 53 | 54 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 { | 508 { |
| 508 TimerScope timer(FLAG_compiler_stats, | 509 TimerScope timer(FLAG_compiler_stats, |
| 509 &CompilerStats::graphinliner_opt_timer, | 510 &CompilerStats::graphinliner_opt_timer, |
| 510 isolate); | 511 isolate); |
| 511 // TODO(zerny): Do more optimization passes on the callee graph. | 512 // TODO(zerny): Do more optimization passes on the callee graph. |
| 512 FlowGraphOptimizer optimizer(callee_graph); | 513 FlowGraphOptimizer optimizer(callee_graph); |
| 513 optimizer.ApplyICData(); | 514 optimizer.ApplyICData(); |
| 514 callee_graph->ComputeUseLists(); | 515 callee_graph->ComputeUseLists(); |
| 515 } | 516 } |
| 516 | 517 |
| 517 if (FLAG_trace_inlining && FLAG_print_flow_graph) { | 518 if (FLAG_trace_inlining && |
| 519 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
| 518 OS::Print("Callee graph for inlining %s\n", | 520 OS::Print("Callee graph for inlining %s\n", |
| 519 function.ToFullyQualifiedCString()); | 521 function.ToFullyQualifiedCString()); |
| 520 FlowGraphPrinter printer(*callee_graph); | 522 FlowGraphPrinter printer(*callee_graph); |
| 521 printer.PrintBlocks(); | 523 printer.PrintBlocks(); |
| 522 } | 524 } |
| 523 | 525 |
| 524 // Collect information about the call site and caller graph. | 526 // Collect information about the call site and caller graph. |
| 525 // TODO(zerny): Do this after CP and dead code elimination. | 527 // TODO(zerny): Do this after CP and dead code elimination. |
| 526 intptr_t constants_count = 0; | 528 intptr_t constants_count = 0; |
| 527 for (intptr_t i = 0; i < param_stubs.length(); ++i) { | 529 for (intptr_t i = 0; i < param_stubs.length(); ++i) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 (strstr(flow_graph_-> | 859 (strstr(flow_graph_-> |
| 858 parsed_function().function().ToFullyQualifiedCString(), | 860 parsed_function().function().ToFullyQualifiedCString(), |
| 859 FLAG_inlining_filter) == NULL)) { | 861 FLAG_inlining_filter) == NULL)) { |
| 860 return; | 862 return; |
| 861 } | 863 } |
| 862 | 864 |
| 863 TRACE_INLINING(OS::Print( | 865 TRACE_INLINING(OS::Print( |
| 864 "Inlining calls in %s\n", | 866 "Inlining calls in %s\n", |
| 865 flow_graph_->parsed_function().function().ToCString())); | 867 flow_graph_->parsed_function().function().ToCString())); |
| 866 | 868 |
| 867 if (FLAG_trace_inlining && FLAG_print_flow_graph) { | 869 if (FLAG_trace_inlining && |
| 870 (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized)) { |
| 868 OS::Print("Before Inlining of %s\n", flow_graph_-> | 871 OS::Print("Before Inlining of %s\n", flow_graph_-> |
| 869 parsed_function().function().ToFullyQualifiedCString()); | 872 parsed_function().function().ToFullyQualifiedCString()); |
| 870 FlowGraphPrinter printer(*flow_graph_); | 873 FlowGraphPrinter printer(*flow_graph_); |
| 871 printer.PrintBlocks(); | 874 printer.PrintBlocks(); |
| 872 } | 875 } |
| 873 | 876 |
| 874 CallSiteInliner inliner(flow_graph_); | 877 CallSiteInliner inliner(flow_graph_); |
| 875 inliner.InlineCalls(); | 878 inliner.InlineCalls(); |
| 876 | 879 |
| 877 if (inliner.inlined()) { | 880 if (inliner.inlined()) { |
| 878 flow_graph_->RepairGraphAfterInlining(); | 881 flow_graph_->RepairGraphAfterInlining(); |
| 879 if (FLAG_trace_inlining) { | 882 if (FLAG_trace_inlining) { |
| 880 OS::Print("Inlining growth factor: %f\n", inliner.GrowthFactor()); | 883 OS::Print("Inlining growth factor: %f\n", inliner.GrowthFactor()); |
| 881 if (FLAG_print_flow_graph) { | 884 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { |
| 882 OS::Print("After Inlining of %s\n", flow_graph_-> | 885 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 883 parsed_function().function().ToFullyQualifiedCString()); | 886 parsed_function().function().ToFullyQualifiedCString()); |
| 884 FlowGraphPrinter printer(*flow_graph_); | 887 FlowGraphPrinter printer(*flow_graph_); |
| 885 printer.PrintBlocks(); | 888 printer.PrintBlocks(); |
| 886 } | 889 } |
| 887 } | 890 } |
| 888 } | 891 } |
| 889 } | 892 } |
| 890 | 893 |
| 891 } // namespace dart | 894 } // namespace dart |
| OLD | NEW |