| 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/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/block_scheduler.h" | 8 #include "vm/block_scheduler.h" |
| 9 #include "vm/branch_optimizer.h" | 9 #include "vm/branch_optimizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 GrowthFactor(), | 994 GrowthFactor(), |
| 995 initial_size_, | 995 initial_size_, |
| 996 inlined_size_); | 996 inlined_size_); |
| 997 PrintInlinedInfoFor(top, 1); | 997 PrintInlinedInfoFor(top, 1); |
| 998 } | 998 } |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 private: | 1001 private: |
| 1002 friend class PolymorphicInliner; | 1002 friend class PolymorphicInliner; |
| 1003 | 1003 |
| 1004 | |
| 1005 static bool Contains(const GrowableArray<intptr_t>& a, intptr_t deopt_id) { | 1004 static bool Contains(const GrowableArray<intptr_t>& a, intptr_t deopt_id) { |
| 1006 for (intptr_t i = 0; i < a.length(); i++) { | 1005 for (intptr_t i = 0; i < a.length(); i++) { |
| 1007 if (a[i] == deopt_id) return true; | 1006 if (a[i] == deopt_id) return true; |
| 1008 } | 1007 } |
| 1009 return false; | 1008 return false; |
| 1010 } | 1009 } |
| 1011 | 1010 |
| 1012 void PrintInlinedInfoFor(const Function& caller, intptr_t depth) { | 1011 void PrintInlinedInfoFor(const Function& caller, intptr_t depth) { |
| 1013 // Prevent duplicate printing as inlined_info aggregates all inlinining. | 1012 // Prevent duplicate printing as inlined_info aggregates all inlinining. |
| 1014 GrowableArray<intptr_t> call_instructions_printed; | 1013 GrowableArray<intptr_t> call_instructions_printed; |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 return true; | 1462 return true; |
| 1464 } | 1463 } |
| 1465 } | 1464 } |
| 1466 | 1465 |
| 1467 return false; | 1466 return false; |
| 1468 } | 1467 } |
| 1469 | 1468 |
| 1470 | 1469 |
| 1471 bool PolymorphicInliner::TryInliningPoly(intptr_t receiver_cid, | 1470 bool PolymorphicInliner::TryInliningPoly(intptr_t receiver_cid, |
| 1472 const Function& target) { | 1471 const Function& target) { |
| 1473 if (TryInlineRecognizedMethod(receiver_cid, target)) { | 1472 if (owner_->inliner_->use_speculative_inlining() && |
| 1473 TryInlineRecognizedMethod(receiver_cid, target)) { |
| 1474 owner_->inlined_ = true; | 1474 owner_->inlined_ = true; |
| 1475 return true; | 1475 return true; |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 GrowableArray<Value*> arguments(call_->ArgumentCount()); | 1478 GrowableArray<Value*> arguments(call_->ArgumentCount()); |
| 1479 for (int i = 0; i < call_->ArgumentCount(); ++i) { | 1479 for (int i = 0; i < call_->ArgumentCount(); ++i) { |
| 1480 arguments.Add(call_->PushArgumentAt(i)->value()); | 1480 arguments.Add(call_->PushArgumentAt(i)->value()); |
| 1481 } | 1481 } |
| 1482 InlinedCallData call_data(call_, &arguments, | 1482 InlinedCallData call_data(call_, &arguments, |
| 1483 caller_function_, | 1483 caller_function_, |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 | 2891 |
| 2892 bool FlowGraphInliner::TryInlineRecognizedMethod(FlowGraph* flow_graph, | 2892 bool FlowGraphInliner::TryInlineRecognizedMethod(FlowGraph* flow_graph, |
| 2893 intptr_t receiver_cid, | 2893 intptr_t receiver_cid, |
| 2894 const Function& target, | 2894 const Function& target, |
| 2895 Instruction* call, | 2895 Instruction* call, |
| 2896 Definition* receiver, | 2896 Definition* receiver, |
| 2897 TokenPosition token_pos, | 2897 TokenPosition token_pos, |
| 2898 const ICData& ic_data, | 2898 const ICData& ic_data, |
| 2899 TargetEntryInstr** entry, | 2899 TargetEntryInstr** entry, |
| 2900 Definition** last) { | 2900 Definition** last) { |
| 2901 if (FLAG_precompiled_mode) { | |
| 2902 // The graphs generated below include deopts. | |
| 2903 return false; | |
| 2904 } | |
| 2905 | |
| 2906 ICData& value_check = ICData::ZoneHandle(Z); | 2901 ICData& value_check = ICData::ZoneHandle(Z); |
| 2907 MethodRecognizer::Kind kind = MethodRecognizer::RecognizeKind(target); | 2902 MethodRecognizer::Kind kind = MethodRecognizer::RecognizeKind(target); |
| 2908 switch (kind) { | 2903 switch (kind) { |
| 2909 // Recognized [] operators. | 2904 // Recognized [] operators. |
| 2910 case MethodRecognizer::kImmutableArrayGetIndexed: | 2905 case MethodRecognizer::kImmutableArrayGetIndexed: |
| 2911 case MethodRecognizer::kObjectArrayGetIndexed: | 2906 case MethodRecognizer::kObjectArrayGetIndexed: |
| 2912 case MethodRecognizer::kGrowableArrayGetIndexed: | 2907 case MethodRecognizer::kGrowableArrayGetIndexed: |
| 2913 case MethodRecognizer::kInt8ArrayGetIndexed: | 2908 case MethodRecognizer::kInt8ArrayGetIndexed: |
| 2914 case MethodRecognizer::kUint8ArrayGetIndexed: | 2909 case MethodRecognizer::kUint8ArrayGetIndexed: |
| 2915 case MethodRecognizer::kUint8ClampedArrayGetIndexed: | 2910 case MethodRecognizer::kUint8ClampedArrayGetIndexed: |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3133 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); | 3128 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); |
| 3134 case MethodRecognizer::kDoubleDiv: | 3129 case MethodRecognizer::kDoubleDiv: |
| 3135 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); | 3130 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); |
| 3136 default: | 3131 default: |
| 3137 return false; | 3132 return false; |
| 3138 } | 3133 } |
| 3139 } | 3134 } |
| 3140 | 3135 |
| 3141 | 3136 |
| 3142 } // namespace dart | 3137 } // namespace dart |
| OLD | NEW |