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

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

Issue 10826285: Optimize equality for case when all targets are Object.equals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | runtime/vm/intermediate_language.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/flow_graph_builder.h" 7 #include "vm/flow_graph_builder.h"
8 #include "vm/il_printer.h" 8 #include "vm/il_printer.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 const ICData& ic_data = *comp->ic_data(); 540 const ICData& ic_data = *comp->ic_data();
541 if (ic_data.NumberOfChecks() == 0) return; 541 if (ic_data.NumberOfChecks() == 0) return;
542 // TODO(srdjan): Add multiple receiver type support. 542 // TODO(srdjan): Add multiple receiver type support.
543 if (ic_data.NumberOfChecks() != 1) return; 543 if (ic_data.NumberOfChecks() != 1) return;
544 ASSERT(HasOneTarget(ic_data)); 544 ASSERT(HasOneTarget(ic_data));
545 545
546 if (HasOnlyTwoSmi(ic_data)) { 546 if (HasOnlyTwoSmi(ic_data)) {
547 comp->set_operands_class_id(kSmiCid); 547 comp->set_operands_class_id(kSmiCid);
548 } else if (HasOnlyTwoDouble(ic_data)) { 548 } else if (HasOnlyTwoDouble(ic_data)) {
549 comp->set_operands_class_id(kDoubleCid); 549 comp->set_operands_class_id(kDoubleCid);
550 } else if (comp->ic_data()->AllReceiversAreNumbers()) {
551 comp->set_operands_class_id(kNumberCid);
550 } 552 }
551 } 553 }
552 554
553 555
554 void FlowGraphOptimizer::VisitEqualityCompare(EqualityCompareComp* comp, 556 void FlowGraphOptimizer::VisitEqualityCompare(EqualityCompareComp* comp,
555 BindInstr* instr) { 557 BindInstr* instr) {
556 if (comp->HasICData() && (comp->ic_data()->NumberOfChecks() == 1)) { 558 if (!comp->HasICData() || (comp->ic_data()->NumberOfChecks() == 0)) return;
559 if (comp->ic_data()->NumberOfChecks() == 1) {
557 ASSERT(comp->ic_data()->num_args_tested() == 2); 560 ASSERT(comp->ic_data()->num_args_tested() == 2);
558 GrowableArray<intptr_t> class_ids; 561 GrowableArray<intptr_t> class_ids;
559 Function& target = Function::Handle(); 562 Function& target = Function::Handle();
560 comp->ic_data()->GetCheckAt(0, &class_ids, &target); 563 comp->ic_data()->GetCheckAt(0, &class_ids, &target);
561 // TODO(srdjan): allow for mixed mode comparison. 564 // TODO(srdjan): allow for mixed mode comparison.
562 if ((class_ids[0] == kSmiCid) && (class_ids[1] == kSmiCid)) { 565 if ((class_ids[0] == kSmiCid) && (class_ids[1] == kSmiCid)) {
563 comp->set_receiver_class_id(kSmiCid); 566 comp->set_receiver_class_id(kSmiCid);
564 } else if ((class_ids[0] == kDoubleCid) && (class_ids[1] == kDoubleCid)) { 567 } else if ((class_ids[0] == kDoubleCid) && (class_ids[1] == kDoubleCid)) {
565 comp->set_receiver_class_id(kDoubleCid); 568 comp->set_receiver_class_id(kDoubleCid);
569 } else {
570 ASSERT(comp->receiver_class_id() == kIllegalCid);
566 } 571 }
572 } else if (comp->ic_data()->AllReceiversAreNumbers()) {
573 comp->set_receiver_class_id(kNumberCid);
567 } 574 }
568 } 575 }
569 576
570 577
571 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { 578 void FlowGraphOptimizer::VisitBind(BindInstr* instr) {
572 instr->computation()->Accept(this, instr); 579 instr->computation()->Accept(this, instr);
573 } 580 }
574 581
575 582
576 void FlowGraphTypePropagator::VisitAssertAssignable(AssertAssignableComp* comp, 583 void FlowGraphTypePropagator::VisitAssertAssignable(AssertAssignableComp* comp,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 LocationSummary* locs = it.Current()->locs(); 718 LocationSummary* locs = it.Current()->locs();
712 if ((locs != NULL) && locs->is_call()) { 719 if ((locs != NULL) && locs->is_call()) {
713 is_leaf_ = false; 720 is_leaf_ = false;
714 return; 721 return;
715 } 722 }
716 } 723 }
717 } 724 }
718 } 725 }
719 726
720 } // namespace dart 727 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | runtime/vm/intermediate_language.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698