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 18 matching lines...) Expand all Loading... | |
| 29 DEFINE_FLAG(int, inline_getters_setters_smaller_than, 10, | 29 DEFINE_FLAG(int, inline_getters_setters_smaller_than, 10, |
| 30 "Always inline getters and setters that have fewer instructions"); | 30 "Always inline getters and setters that have fewer instructions"); |
| 31 DEFINE_FLAG(int, inlining_depth_threshold, 6, | 31 DEFINE_FLAG(int, inlining_depth_threshold, 6, |
| 32 "Inline function calls up to threshold nesting depth"); | 32 "Inline function calls up to threshold nesting depth"); |
| 33 DEFINE_FLAG(int, inlining_size_threshold, 25, | 33 DEFINE_FLAG(int, inlining_size_threshold, 25, |
| 34 "Always inline functions that have threshold or fewer instructions"); | 34 "Always inline functions that have threshold or fewer instructions"); |
| 35 DEFINE_FLAG(int, inlining_callee_call_sites_threshold, 1, | 35 DEFINE_FLAG(int, inlining_callee_call_sites_threshold, 1, |
| 36 "Always inline functions containing threshold or fewer calls."); | 36 "Always inline functions containing threshold or fewer calls."); |
| 37 DEFINE_FLAG(int, inlining_callee_size_threshold, 80, | 37 DEFINE_FLAG(int, inlining_callee_size_threshold, 80, |
| 38 "Do not inline callees larger than threshold"); | 38 "Do not inline callees larger than threshold"); |
| 39 DEFINE_FLAG(int, inlining_callee_size_threshold_with_constants, 200, | |
| 40 "Do not inline callees larger than threshold if constant arguments"); | |
| 39 DEFINE_FLAG(int, inlining_caller_size_threshold, 50000, | 41 DEFINE_FLAG(int, inlining_caller_size_threshold, 50000, |
| 40 "Stop inlining once caller reaches the threshold."); | 42 "Stop inlining once caller reaches the threshold."); |
| 41 DEFINE_FLAG(int, inlining_constant_arguments_count, 1, | 43 DEFINE_FLAG(int, inlining_constant_arguments_count, 1, |
| 42 "Inline function calls with sufficient constant arguments " | 44 "Inline function calls with sufficient constant arguments " |
| 43 "and up to the increased threshold on instructions"); | 45 "and up to the increased threshold on instructions"); |
| 44 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, | 46 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, |
| 45 "Inline function calls with sufficient constant arguments " | 47 "Inline function calls with sufficient constant arguments " |
| 46 "and up to the increased threshold on instructions"); | 48 "and up to the increased threshold on instructions"); |
| 47 DEFINE_FLAG(int, inlining_hotness, 10, | 49 DEFINE_FLAG(int, inlining_hotness, 10, |
| 48 "Inline only hotter calls, in percents (0 .. 100); " | 50 "Inline only hotter calls, in percents (0 .. 100); " |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 | 493 |
| 492 // Inlining heuristics based on Cooper et al. 2008. | 494 // Inlining heuristics based on Cooper et al. 2008. |
| 493 bool ShouldWeInline(const Function& callee, | 495 bool ShouldWeInline(const Function& callee, |
| 494 intptr_t instr_count, | 496 intptr_t instr_count, |
| 495 intptr_t call_site_count, | 497 intptr_t call_site_count, |
| 496 intptr_t const_arg_count) { | 498 intptr_t const_arg_count) { |
| 497 if (inlined_size_ > FLAG_inlining_caller_size_threshold) { | 499 if (inlined_size_ > FLAG_inlining_caller_size_threshold) { |
| 498 // Prevent methods becoming humongous and thus slow to compile. | 500 // Prevent methods becoming humongous and thus slow to compile. |
| 499 return false; | 501 return false; |
| 500 } | 502 } |
| 501 if (instr_count > FLAG_inlining_callee_size_threshold) { | 503 if (const_arg_count > 0) { |
| 504 if (instr_count > FLAG_inlining_callee_size_threshold_with_constants) { | |
| 505 return false; | |
| 506 } | |
| 507 } else if (instr_count > FLAG_inlining_callee_size_threshold) { | |
| 502 return false; | 508 return false; |
| 503 } | 509 } |
| 504 // 'instr_count' can be 0 if it was not computed yet. | 510 // 'instr_count' can be 0 if it was not computed yet. |
| 505 if ((instr_count != 0) && (instr_count <= FLAG_inlining_size_threshold)) { | 511 if ((instr_count != 0) && (instr_count <= FLAG_inlining_size_threshold)) { |
| 506 return true; | 512 return true; |
| 507 } | 513 } |
| 508 if (call_site_count <= FLAG_inlining_callee_call_sites_threshold) { | 514 if (call_site_count <= FLAG_inlining_callee_call_sites_threshold) { |
| 509 return true; | 515 return true; |
| 510 } | 516 } |
| 511 if ((const_arg_count >= FLAG_inlining_constant_arguments_count) && | 517 if ((const_arg_count >= FLAG_inlining_constant_arguments_count) && |
| 512 (instr_count <= FLAG_inlining_constant_arguments_size_threshold)) { | 518 (instr_count <= FLAG_inlining_constant_arguments_size_threshold)) { |
|
Vyacheslav Egorov (Google)
2014/12/08 19:11:30
maybe renamed this flag because now we have a posi
srdjan
2014/12/08 21:19:09
Renamed flags to:
inlining_constant_arguments_max_
| |
| 513 return true; | 519 return true; |
| 514 } | 520 } |
| 515 if (FlowGraphInliner::AlwaysInline(callee)) { | 521 if (FlowGraphInliner::AlwaysInline(callee)) { |
| 516 return true; | 522 return true; |
| 517 } | 523 } |
| 518 return false; | 524 return false; |
| 519 } | 525 } |
| 520 | 526 |
| 521 void InlineCalls() { | 527 void InlineCalls() { |
| 522 // If inlining depth is less then one abort. | 528 // If inlining depth is less then one abort. |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1775 OS::Print("After Inlining of %s\n", flow_graph_-> | 1781 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1776 parsed_function()->function().ToFullyQualifiedCString()); | 1782 parsed_function()->function().ToFullyQualifiedCString()); |
| 1777 FlowGraphPrinter printer(*flow_graph_); | 1783 FlowGraphPrinter printer(*flow_graph_); |
| 1778 printer.PrintBlocks(); | 1784 printer.PrintBlocks(); |
| 1779 } | 1785 } |
| 1780 } | 1786 } |
| 1781 } | 1787 } |
| 1782 } | 1788 } |
| 1783 | 1789 |
| 1784 } // namespace dart | 1790 } // namespace dart |
| OLD | NEW |