| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 DEFINE_FLAG(int, inlining_recursion_depth_threshold, 1, | 52 DEFINE_FLAG(int, inlining_recursion_depth_threshold, 1, |
| 53 "Inline recursive function calls up to threshold recursion depth."); | 53 "Inline recursive function calls up to threshold recursion depth."); |
| 54 DEFINE_FLAG(int, max_inlined_per_depth, 500, | 54 DEFINE_FLAG(int, max_inlined_per_depth, 500, |
| 55 "Max. number of inlined calls per depth"); | 55 "Max. number of inlined calls per depth"); |
| 56 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); | 56 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); |
| 57 DEFINE_FLAG(bool, enable_inlining_annotations, false, | 57 DEFINE_FLAG(bool, enable_inlining_annotations, false, |
| 58 "Enable inlining annotations"); | 58 "Enable inlining annotations"); |
| 59 | 59 |
| 60 DECLARE_FLAG(bool, compiler_stats); | 60 DECLARE_FLAG(bool, compiler_stats); |
| 61 DECLARE_FLAG(int, deoptimization_counter_threshold); | 61 DECLARE_FLAG(int, deoptimization_counter_threshold); |
| 62 DECLARE_FLAG(bool, polymorphic_with_deopt); |
| 62 DECLARE_FLAG(bool, print_flow_graph); | 63 DECLARE_FLAG(bool, print_flow_graph); |
| 63 DECLARE_FLAG(bool, print_flow_graph_optimized); | 64 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 64 DECLARE_FLAG(bool, verify_compiler); | 65 DECLARE_FLAG(bool, verify_compiler); |
| 65 | 66 |
| 66 // Quick access to the current zone. | 67 // Quick access to the current zone. |
| 67 #define Z (zone()) | 68 #define Z (zone()) |
| 68 | 69 |
| 69 #define TRACE_INLINING(statement) \ | 70 #define TRACE_INLINING(statement) \ |
| 70 do { \ | 71 do { \ |
| 71 if (trace_inlining()) statement; \ | 72 if (trace_inlining()) statement; \ |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 } | 1128 } |
| 1128 | 1129 |
| 1129 void InlineInstanceCalls() { | 1130 void InlineInstanceCalls() { |
| 1130 const GrowableArray<CallSites::InstanceCallInfo>& call_info = | 1131 const GrowableArray<CallSites::InstanceCallInfo>& call_info = |
| 1131 inlining_call_sites_->instance_calls(); | 1132 inlining_call_sites_->instance_calls(); |
| 1132 TRACE_INLINING(ISL_Print(" Polymorphic Instance Calls (%" Pd ")\n", | 1133 TRACE_INLINING(ISL_Print(" Polymorphic Instance Calls (%" Pd ")\n", |
| 1133 call_info.length())); | 1134 call_info.length())); |
| 1134 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) { | 1135 for (intptr_t call_idx = 0; call_idx < call_info.length(); ++call_idx) { |
| 1135 PolymorphicInstanceCallInstr* call = call_info[call_idx].call; | 1136 PolymorphicInstanceCallInstr* call = call_info[call_idx].call; |
| 1136 if (call->with_checks()) { | 1137 if (call->with_checks()) { |
| 1138 // PolymorphicInliner introduces deoptimization paths. |
| 1139 if (!FLAG_polymorphic_with_deopt) return; |
| 1137 const Function& cl = call_info[call_idx].caller(); | 1140 const Function& cl = call_info[call_idx].caller(); |
| 1138 intptr_t caller_inlining_id = | 1141 intptr_t caller_inlining_id = |
| 1139 call_info[call_idx].caller_graph->inlining_id(); | 1142 call_info[call_idx].caller_graph->inlining_id(); |
| 1140 PolymorphicInliner inliner(this, call, cl, caller_inlining_id); | 1143 PolymorphicInliner inliner(this, call, cl, caller_inlining_id); |
| 1141 inliner.Inline(); | 1144 inliner.Inline(); |
| 1142 continue; | 1145 continue; |
| 1143 } | 1146 } |
| 1144 | 1147 |
| 1145 const ICData& ic_data = call->ic_data(); | 1148 const ICData& ic_data = call->ic_data(); |
| 1146 const Function& target = Function::ZoneHandle(ic_data.GetTargetAt(0)); | 1149 const Function& target = Function::ZoneHandle(ic_data.GetTargetAt(0)); |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 intptr_t FlowGraphInliner::NextInlineId(const Function& function, | 1883 intptr_t FlowGraphInliner::NextInlineId(const Function& function, |
| 1881 intptr_t parent_id) { | 1884 intptr_t parent_id) { |
| 1882 const intptr_t id = inline_id_to_function_->length(); | 1885 const intptr_t id = inline_id_to_function_->length(); |
| 1883 inline_id_to_function_->Add(&function); | 1886 inline_id_to_function_->Add(&function); |
| 1884 caller_inline_id_->Add(parent_id); | 1887 caller_inline_id_->Add(parent_id); |
| 1885 return id; | 1888 return id; |
| 1886 } | 1889 } |
| 1887 | 1890 |
| 1888 | 1891 |
| 1889 } // namespace dart | 1892 } // namespace dart |
| OLD | NEW |