Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: runtime/vm/jit_optimizer.cc

Issue 1847293002: VM: Improve single-target polymorphic calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
2693 const intptr_t max_checks = (op_kind == Token::kEQ) 2694 const intptr_t max_checks = (op_kind == Token::kEQ)
2694 ? FLAG_max_equality_polymorphic_checks 2695 ? FLAG_max_equality_polymorphic_checks
2695 : FLAG_max_polymorphic_checks; 2696 : FLAG_max_polymorphic_checks;
2696 if ((unary_checks.NumberOfChecks() > max_checks) && 2697 if ((unary_checks.NumberOfChecks() > max_checks) &&
2698 !is_dense &&
2697 flow_graph()->InstanceCallNeedsClassCheck( 2699 flow_graph()->InstanceCallNeedsClassCheck(
2698 instr, RawFunction::kRegularFunction)) { 2700 instr, RawFunction::kRegularFunction)) {
2699 // Too many checks, it will be megamorphic which needs unary checks. 2701 // Too many checks, it will be megamorphic which needs unary checks.
2700 instr->set_ic_data(&unary_checks); 2702 instr->set_ic_data(&unary_checks);
2701 return; 2703 return;
2702 } 2704 }
2703 2705
2704 if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) { 2706 if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) {
2705 return; 2707 return;
2706 } 2708 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); 2754 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind();
2753 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { 2755 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) {
2754 PolymorphicInstanceCallInstr* call = 2756 PolymorphicInstanceCallInstr* call =
2755 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, 2757 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks,
2756 /* call_with_checks = */ false); 2758 /* call_with_checks = */ false);
2757 instr->ReplaceWith(call, current_iterator()); 2759 instr->ReplaceWith(call, current_iterator());
2758 return; 2760 return;
2759 } 2761 }
2760 } 2762 }
2761 2763
2762 if (unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) { 2764 if ((unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) ||
2765 (has_one_target && is_dense)) {
2763 bool call_with_checks; 2766 bool call_with_checks;
2764 if (has_one_target && FLAG_polymorphic_with_deopt) { 2767 if (has_one_target && FLAG_polymorphic_with_deopt) {
2765 // Type propagation has not run yet, we cannot eliminate the check. 2768 // Type propagation has not run yet, we cannot eliminate the check.
2766 AddReceiverCheck(instr); 2769 AddReceiverCheck(instr);
2767 // Call can still deoptimize, do not detach environment from instr. 2770 // Call can still deoptimize, do not detach environment from instr.
2768 call_with_checks = false; 2771 call_with_checks = false;
2769 } else { 2772 } else {
2770 call_with_checks = true; 2773 call_with_checks = true;
2771 } 2774 }
2772 PolymorphicInstanceCallInstr* call = 2775 PolymorphicInstanceCallInstr* call =
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 3125
3123 // Discard the environment from the original instruction because the store 3126 // Discard the environment from the original instruction because the store
3124 // can't deoptimize. 3127 // can't deoptimize.
3125 instr->RemoveEnvironment(); 3128 instr->RemoveEnvironment();
3126 ReplaceCall(instr, store); 3129 ReplaceCall(instr, store);
3127 return true; 3130 return true;
3128 } 3131 }
3129 3132
3130 3133
3131 } // namespace dart 3134 } // namespace dart
OLDNEW
« runtime/vm/intermediate_language.cc ('K') | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698