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

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 10
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 const ICData& ic_data = *comp->ic_data(); 537 const ICData& ic_data = *comp->ic_data();
538 if (ic_data.NumberOfChecks() == 0) return; 538 if (ic_data.NumberOfChecks() == 0) return;
539 // TODO(srdjan): Add multiple receiver type support. 539 // TODO(srdjan): Add multiple receiver type support.
540 if (ic_data.NumberOfChecks() != 1) return; 540 if (ic_data.NumberOfChecks() != 1) return;
541 ASSERT(HasOneTarget(ic_data)); 541 ASSERT(HasOneTarget(ic_data));
542 542
543 if (HasOnlyTwoSmi(ic_data)) { 543 if (HasOnlyTwoSmi(ic_data)) {
544 comp->set_operands_class_id(kSmiCid); 544 comp->set_operands_class_id(kSmiCid);
545 } else if (HasOnlyTwoDouble(ic_data)) { 545 } else if (HasOnlyTwoDouble(ic_data)) {
546 comp->set_operands_class_id(kDoubleCid); 546 comp->set_operands_class_id(kDoubleCid);
547 } else if (comp->ic_data()->AllReceiversAreNumbers()) {
548 comp->set_operands_class_id(kNumberCid);
547 } 549 }
548 } 550 }
549 551
550 552
551 void FlowGraphOptimizer::VisitEqualityCompare(EqualityCompareComp* comp, 553 void FlowGraphOptimizer::VisitEqualityCompare(EqualityCompareComp* comp,
552 BindInstr* instr) { 554 BindInstr* instr) {
553 if (comp->HasICData() && (comp->ic_data()->NumberOfChecks() == 1)) { 555 if (!comp->HasICData() || (comp->ic_data()->NumberOfChecks() == 0)) return;
556 if (comp->ic_data()->NumberOfChecks() == 1) {
554 ASSERT(comp->ic_data()->num_args_tested() == 2); 557 ASSERT(comp->ic_data()->num_args_tested() == 2);
555 GrowableArray<intptr_t> class_ids; 558 GrowableArray<intptr_t> class_ids;
556 Function& target = Function::Handle(); 559 Function& target = Function::Handle();
557 comp->ic_data()->GetCheckAt(0, &class_ids, &target); 560 comp->ic_data()->GetCheckAt(0, &class_ids, &target);
558 // TODO(srdjan): allow for mixed mode comparison. 561 // TODO(srdjan): allow for mixed mode comparison.
559 if ((class_ids[0] == kSmiCid) && (class_ids[1] == kSmiCid)) { 562 if ((class_ids[0] == kSmiCid) && (class_ids[1] == kSmiCid)) {
560 comp->set_receiver_class_id(kSmiCid); 563 comp->set_receiver_class_id(kSmiCid);
561 } else if ((class_ids[0] == kDoubleCid) && (class_ids[1] == kDoubleCid)) { 564 } else if ((class_ids[0] == kDoubleCid) && (class_ids[1] == kDoubleCid)) {
562 comp->set_receiver_class_id(kDoubleCid); 565 comp->set_receiver_class_id(kDoubleCid);
566 } else {
567 ASSERT(comp->receiver_class_id() == kIllegalCid);
563 } 568 }
569 } else if (comp->ic_data()->AllReceiversAreNumbers()) {
570 comp->set_receiver_class_id(kNumberCid);
564 } 571 }
565 } 572 }
566 573
567 574
568 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { 575 void FlowGraphOptimizer::VisitBind(BindInstr* instr) {
569 instr->computation()->Accept(this, instr); 576 instr->computation()->Accept(this, instr);
570 } 577 }
571 578
572 579
573 void FlowGraphTypePropagator::VisitAssertAssignable(AssertAssignableComp* comp, 580 void FlowGraphTypePropagator::VisitAssertAssignable(AssertAssignableComp* comp,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 LocationSummary* locs = it.Current()->locs(); 683 LocationSummary* locs = it.Current()->locs();
677 if ((locs != NULL) && locs->is_call()) { 684 if ((locs != NULL) && locs->is_call()) {
678 is_leaf_ = false; 685 is_leaf_ = false;
679 return; 686 return;
680 } 687 }
681 } 688 }
682 } 689 }
683 } 690 }
684 691
685 } // namespace dart 692 } // 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