| 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/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" |
| 11 #include "vm/flow_graph_optimizer.h" | 11 #include "vm/flow_graph_optimizer.h" |
| 12 #include "vm/il_printer.h" | 12 #include "vm/il_printer.h" |
| 13 #include "vm/intrinsifier.h" | 13 #include "vm/intrinsifier.h" |
| 14 #include "vm/longjump.h" | 14 #include "vm/longjump.h" |
| 15 #include "vm/object.h" | 15 #include "vm/object.h" |
| 16 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
| 17 #include "vm/timer.h" | 17 #include "vm/timer.h" |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 DEFINE_FLAG(bool, trace_inlining, false, "Trace inlining"); | 21 DEFINE_FLAG(bool, trace_inlining, false, "Trace inlining"); |
| 22 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); | 22 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); |
| 23 | 23 |
| 24 // Flags for inlining heuristics. | 24 // Flags for inlining heuristics. |
| 25 DEFINE_FLAG(int, inlining_depth_threshold, 3, | 25 DEFINE_FLAG(int, inlining_depth_threshold, 3, |
| 26 "Inline function calls up to threshold nesting depth"); | 26 "Inline function calls up to threshold nesting depth"); |
| 27 DEFINE_FLAG(int, inlining_size_threshold, 20, | 27 DEFINE_FLAG(int, inlining_size_threshold, 22, |
| 28 "Always inline functions that have threshold or fewer instructions"); | 28 "Always inline functions that have threshold or fewer instructions"); |
| 29 DEFINE_FLAG(int, inlining_callee_call_sites_threshold, 1, | 29 DEFINE_FLAG(int, inlining_callee_call_sites_threshold, 1, |
| 30 "Always inline functions containing threshold or fewer calls."); | 30 "Always inline functions containing threshold or fewer calls."); |
| 31 DEFINE_FLAG(int, inlining_constant_arguments_count, 1, | 31 DEFINE_FLAG(int, inlining_constant_arguments_count, 1, |
| 32 "Inline function calls with sufficient constant arguments " | 32 "Inline function calls with sufficient constant arguments " |
| 33 "and up to the increased threshold on instructions"); | 33 "and up to the increased threshold on instructions"); |
| 34 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, | 34 DEFINE_FLAG(int, inlining_constant_arguments_size_threshold, 60, |
| 35 "Inline function calls with sufficient constant arguments " | 35 "Inline function calls with sufficient constant arguments " |
| 36 "and up to the increased threshold on instructions"); | 36 "and up to the increased threshold on instructions"); |
| 37 DEFINE_FLAG(int, inlining_hotness, 10, | 37 DEFINE_FLAG(int, inlining_hotness, 10, |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 GrowableArray<ClosureCallInstr*> closure_calls_; | 285 GrowableArray<ClosureCallInstr*> closure_calls_; |
| 286 GrowableArray<InstanceCallInfo> instance_calls_; | 286 GrowableArray<InstanceCallInfo> instance_calls_; |
| 287 GrowableArray<intptr_t> skip_static_call_deopt_ids_; | 287 GrowableArray<intptr_t> skip_static_call_deopt_ids_; |
| 288 | 288 |
| 289 DISALLOW_COPY_AND_ASSIGN(CallSites); | 289 DISALLOW_COPY_AND_ASSIGN(CallSites); |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 | 292 |
| 293 class CallSiteInliner : public ValueObject { | 293 class CallSiteInliner : public ValueObject { |
| 294 public: | 294 public: |
| 295 CallSiteInliner(FlowGraph* flow_graph, GrowableArray<Field*>* guarded_fields) | 295 CallSiteInliner(FlowGraph* flow_graph, |
| 296 GrowableArray<const Field*>* guarded_fields) |
| 296 : caller_graph_(flow_graph), | 297 : caller_graph_(flow_graph), |
| 297 inlined_(false), | 298 inlined_(false), |
| 298 initial_size_(flow_graph->InstructionCount()), | 299 initial_size_(flow_graph->InstructionCount()), |
| 299 inlined_size_(0), | 300 inlined_size_(0), |
| 300 inlining_depth_(1), | 301 inlining_depth_(1), |
| 301 collected_call_sites_(NULL), | 302 collected_call_sites_(NULL), |
| 302 inlining_call_sites_(NULL), | 303 inlining_call_sites_(NULL), |
| 303 function_cache_(), | 304 function_cache_(), |
| 304 guarded_fields_(guarded_fields) { } | 305 guarded_fields_(guarded_fields) { } |
| 305 | 306 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 | 863 |
| 863 | 864 |
| 864 FlowGraph* caller_graph_; | 865 FlowGraph* caller_graph_; |
| 865 bool inlined_; | 866 bool inlined_; |
| 866 intptr_t initial_size_; | 867 intptr_t initial_size_; |
| 867 intptr_t inlined_size_; | 868 intptr_t inlined_size_; |
| 868 intptr_t inlining_depth_; | 869 intptr_t inlining_depth_; |
| 869 CallSites* collected_call_sites_; | 870 CallSites* collected_call_sites_; |
| 870 CallSites* inlining_call_sites_; | 871 CallSites* inlining_call_sites_; |
| 871 GrowableArray<ParsedFunction*> function_cache_; | 872 GrowableArray<ParsedFunction*> function_cache_; |
| 872 GrowableArray<Field*>* guarded_fields_; | 873 GrowableArray<const Field*>* guarded_fields_; |
| 873 | 874 |
| 874 DISALLOW_COPY_AND_ASSIGN(CallSiteInliner); | 875 DISALLOW_COPY_AND_ASSIGN(CallSiteInliner); |
| 875 }; | 876 }; |
| 876 | 877 |
| 877 | 878 |
| 878 void FlowGraphInliner::CollectGraphInfo(FlowGraph* flow_graph) { | 879 void FlowGraphInliner::CollectGraphInfo(FlowGraph* flow_graph) { |
| 879 GraphInfoCollector info; | 880 GraphInfoCollector info; |
| 880 info.Collect(*flow_graph); | 881 info.Collect(*flow_graph); |
| 881 const Function& function = flow_graph->parsed_function().function(); | 882 const Function& function = flow_graph->parsed_function().function(); |
| 882 function.set_optimized_instruction_count( | 883 function.set_optimized_instruction_count( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 OS::Print("After Inlining of %s\n", flow_graph_-> | 922 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 922 parsed_function().function().ToFullyQualifiedCString()); | 923 parsed_function().function().ToFullyQualifiedCString()); |
| 923 FlowGraphPrinter printer(*flow_graph_); | 924 FlowGraphPrinter printer(*flow_graph_); |
| 924 printer.PrintBlocks(); | 925 printer.PrintBlocks(); |
| 925 } | 926 } |
| 926 } | 927 } |
| 927 } | 928 } |
| 928 } | 929 } |
| 929 | 930 |
| 930 } // namespace dart | 931 } // namespace dart |
| OLD | NEW |