| 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/jit_optimizer.h" | 5 #include "vm/jit_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 2672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2683 } | 2683 } |
| 2684 | 2684 |
| 2685 if (Token::IsTypeCastOperator(op_kind)) { | 2685 if (Token::IsTypeCastOperator(op_kind)) { |
| 2686 ReplaceWithTypeCast(instr); | 2686 ReplaceWithTypeCast(instr); |
| 2687 return; | 2687 return; |
| 2688 } | 2688 } |
| 2689 | 2689 |
| 2690 const ICData& unary_checks = | 2690 const ICData& unary_checks = |
| 2691 ICData::ZoneHandle(Z, instr->ic_data()->AsUnaryClassChecks()); | 2691 ICData::ZoneHandle(Z, instr->ic_data()->AsUnaryClassChecks()); |
| 2692 | 2692 |
| 2693 const bool is_dense = CheckClassInstr::IsDenseCidRange(unary_checks); | |
| 2694 const intptr_t max_checks = (op_kind == Token::kEQ) | 2693 const intptr_t max_checks = (op_kind == Token::kEQ) |
| 2695 ? FLAG_max_equality_polymorphic_checks | 2694 ? FLAG_max_equality_polymorphic_checks |
| 2696 : FLAG_max_polymorphic_checks; | 2695 : FLAG_max_polymorphic_checks; |
| 2697 if ((unary_checks.NumberOfChecks() > max_checks) && | 2696 if ((unary_checks.NumberOfChecks() > max_checks) && |
| 2698 !is_dense && | |
| 2699 flow_graph()->InstanceCallNeedsClassCheck( | 2697 flow_graph()->InstanceCallNeedsClassCheck( |
| 2700 instr, RawFunction::kRegularFunction)) { | 2698 instr, RawFunction::kRegularFunction)) { |
| 2701 // Too many checks, it will be megamorphic which needs unary checks. | 2699 // Too many checks, it will be megamorphic which needs unary checks. |
| 2702 instr->set_ic_data(&unary_checks); | 2700 instr->set_ic_data(&unary_checks); |
| 2703 return; | 2701 return; |
| 2704 } | 2702 } |
| 2705 | 2703 |
| 2706 if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) { | 2704 if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) { |
| 2707 return; | 2705 return; |
| 2708 } | 2706 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2754 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); | 2752 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); |
| 2755 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { | 2753 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { |
| 2756 PolymorphicInstanceCallInstr* call = | 2754 PolymorphicInstanceCallInstr* call = |
| 2757 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, | 2755 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, |
| 2758 /* call_with_checks = */ false); | 2756 /* call_with_checks = */ false); |
| 2759 instr->ReplaceWith(call, current_iterator()); | 2757 instr->ReplaceWith(call, current_iterator()); |
| 2760 return; | 2758 return; |
| 2761 } | 2759 } |
| 2762 } | 2760 } |
| 2763 | 2761 |
| 2764 if ((unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) || | 2762 if (unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) { |
| 2765 (has_one_target && is_dense)) { | |
| 2766 bool call_with_checks; | 2763 bool call_with_checks; |
| 2767 if (has_one_target && FLAG_polymorphic_with_deopt) { | 2764 if (has_one_target && FLAG_polymorphic_with_deopt) { |
| 2768 // Type propagation has not run yet, we cannot eliminate the check. | 2765 // Type propagation has not run yet, we cannot eliminate the check. |
| 2769 AddReceiverCheck(instr); | 2766 AddReceiverCheck(instr); |
| 2770 // Call can still deoptimize, do not detach environment from instr. | 2767 // Call can still deoptimize, do not detach environment from instr. |
| 2771 call_with_checks = false; | 2768 call_with_checks = false; |
| 2772 } else { | 2769 } else { |
| 2773 call_with_checks = true; | 2770 call_with_checks = true; |
| 2774 } | 2771 } |
| 2775 PolymorphicInstanceCallInstr* call = | 2772 PolymorphicInstanceCallInstr* call = |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3125 | 3122 |
| 3126 // Discard the environment from the original instruction because the store | 3123 // Discard the environment from the original instruction because the store |
| 3127 // can't deoptimize. | 3124 // can't deoptimize. |
| 3128 instr->RemoveEnvironment(); | 3125 instr->RemoveEnvironment(); |
| 3129 ReplaceCall(instr, store); | 3126 ReplaceCall(instr, store); |
| 3130 return true; | 3127 return true; |
| 3131 } | 3128 } |
| 3132 | 3129 |
| 3133 | 3130 |
| 3134 } // namespace dart | 3131 } // namespace dart |
| OLD | NEW |