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

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

Issue 1867913004: Specialize instance calls when the call receiver is the method receiver and the method class has a … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return; // No information about receiver was infered. 243 return; // No information about receiver was infered.
244 } 244 }
245 245
246 const ICData& ic_data = TrySpecializeICData(call->ic_data(), receiver_cid); 246 const ICData& ic_data = TrySpecializeICData(call->ic_data(), receiver_cid);
247 if (ic_data.raw() == call->ic_data().raw()) { 247 if (ic_data.raw() == call->ic_data().raw()) {
248 // No specialization. 248 // No specialization.
249 return; 249 return;
250 } 250 }
251 251
252 const bool with_checks = false; 252 const bool with_checks = false;
253 const bool complete = false;
253 PolymorphicInstanceCallInstr* specialized = 254 PolymorphicInstanceCallInstr* specialized =
254 new(Z) PolymorphicInstanceCallInstr(call->instance_call(), 255 new(Z) PolymorphicInstanceCallInstr(call->instance_call(),
255 ic_data, 256 ic_data,
256 with_checks); 257 with_checks,
258 complete);
257 call->ReplaceWith(specialized, current_iterator()); 259 call->ReplaceWith(specialized, current_iterator());
258 } 260 }
259 261
260 262
261 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) { 263 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) {
262 BinarySmiOpInstr* instr = d->AsBinarySmiOp(); 264 BinarySmiOpInstr* instr = d->AsBinarySmiOp();
263 if ((instr != NULL) && (instr->op_kind() == Token::kSHL)) { 265 if ((instr != NULL) && (instr->op_kind() == Token::kSHL)) {
264 return instr; 266 return instr;
265 } 267 }
266 return NULL; 268 return NULL;
(...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2749 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target); 2751 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target);
2750 has_one_target = !polymorphic_target; 2752 has_one_target = !polymorphic_target;
2751 } 2753 }
2752 2754
2753 if (has_one_target) { 2755 if (has_one_target) {
2754 RawFunction::Kind function_kind = 2756 RawFunction::Kind function_kind =
2755 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); 2757 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind();
2756 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { 2758 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) {
2757 PolymorphicInstanceCallInstr* call = 2759 PolymorphicInstanceCallInstr* call =
2758 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, 2760 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks,
2759 /* call_with_checks = */ false); 2761 /* call_with_checks = */ false,
2762 /* complete = */ false);
2760 instr->ReplaceWith(call, current_iterator()); 2763 instr->ReplaceWith(call, current_iterator());
2761 return; 2764 return;
2762 } 2765 }
2763 } 2766 }
2764 2767
2765 if ((unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) || 2768 if ((unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) ||
2766 (has_one_target && is_dense)) { 2769 (has_one_target && is_dense)) {
2767 bool call_with_checks; 2770 bool call_with_checks;
2768 if (has_one_target && FLAG_polymorphic_with_deopt) { 2771 if (has_one_target && FLAG_polymorphic_with_deopt) {
2769 // Type propagation has not run yet, we cannot eliminate the check. 2772 // Type propagation has not run yet, we cannot eliminate the check.
2770 AddReceiverCheck(instr); 2773 AddReceiverCheck(instr);
2771 // Call can still deoptimize, do not detach environment from instr. 2774 // Call can still deoptimize, do not detach environment from instr.
2772 call_with_checks = false; 2775 call_with_checks = false;
2773 } else { 2776 } else {
2774 call_with_checks = true; 2777 call_with_checks = true;
2775 } 2778 }
2776 PolymorphicInstanceCallInstr* call = 2779 PolymorphicInstanceCallInstr* call =
2777 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, 2780 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks,
2778 call_with_checks); 2781 call_with_checks,
2782 /* complete = */ false);
2779 instr->ReplaceWith(call, current_iterator()); 2783 instr->ReplaceWith(call, current_iterator());
2780 } 2784 }
2781 } 2785 }
2782 2786
2783 2787
2784 void JitOptimizer::VisitStaticCall(StaticCallInstr* call) { 2788 void JitOptimizer::VisitStaticCall(StaticCallInstr* call) {
2785 if (!CanUnboxDouble()) { 2789 if (!CanUnboxDouble()) {
2786 return; 2790 return;
2787 } 2791 }
2788 MethodRecognizer::Kind recognized_kind = 2792 MethodRecognizer::Kind recognized_kind =
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
3126 3130
3127 // Discard the environment from the original instruction because the store 3131 // Discard the environment from the original instruction because the store
3128 // can't deoptimize. 3132 // can't deoptimize.
3129 instr->RemoveEnvironment(); 3133 instr->RemoveEnvironment();
3130 ReplaceCall(instr, store); 3134 ReplaceCall(instr, store);
3131 return true; 3135 return true;
3132 } 3136 }
3133 3137
3134 3138
3135 } // namespace dart 3139 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698