| OLD | NEW |
| 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 616 |
| 617 | 617 |
| 618 void FlowGraphOptimizer::VisitStrictCompareComp(StrictCompareComp* comp) { | 618 void FlowGraphOptimizer::VisitStrictCompareComp(StrictCompareComp* comp) { |
| 619 // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion | 619 // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion |
| 620 // and a branch. | 620 // and a branch. |
| 621 TryFuseComparisonWithBranch(comp); | 621 TryFuseComparisonWithBranch(comp); |
| 622 } | 622 } |
| 623 | 623 |
| 624 | 624 |
| 625 void FlowGraphOptimizer::VisitEqualityCompare(EqualityCompareComp* comp) { | 625 void FlowGraphOptimizer::VisitEqualityCompare(EqualityCompareComp* comp) { |
| 626 if (!comp->HasICData()) return; | 626 const intptr_t kMaxChecks = 4; |
| 627 const ICData& ic_data = *comp->ic_data(); | 627 if (comp->ic_data()->num_args_tested() <= kMaxChecks) { |
| 628 if (ic_data.NumberOfChecks() != 1) return; | 628 ZoneGrowableArray<intptr_t>* class_ids = |
| 629 ASSERT(HasOneTarget(ic_data)); | 629 new ZoneGrowableArray<intptr_t>(); |
| 630 if (HasTwoSmi(ic_data)) { | 630 ZoneGrowableArray<Function*>* targets = |
| 631 comp->set_operands_class_id(kSmi); | 631 new ZoneGrowableArray<Function*>(); |
| 632 } else { | 632 ExtractClassIdsAndTargets(*comp->ic_data(), class_ids, targets); |
| 633 return; | 633 comp->SetPolymorphicTargets(class_ids, targets); |
| 634 } | 634 } |
| 635 |
| 635 // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion | 636 // TODO(vegorov): recognize the pattern with BooleanNegate between comparsion |
| 636 // and a branch. | 637 // and a branch. |
| 637 TryFuseComparisonWithBranch(comp); | 638 TryFuseComparisonWithBranch(comp); |
| 638 } | 639 } |
| 639 | 640 |
| 640 | 641 |
| 641 void FlowGraphOptimizer::VisitDo(DoInstr* instr) { | 642 void FlowGraphOptimizer::VisitDo(DoInstr* instr) { |
| 642 instr->computation()->Accept(this); | 643 instr->computation()->Accept(this); |
| 643 } | 644 } |
| 644 | 645 |
| 645 | 646 |
| 646 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { | 647 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { |
| 647 instr->computation()->Accept(this); | 648 instr->computation()->Accept(this); |
| 648 } | 649 } |
| 649 | 650 |
| 650 | 651 |
| 651 } // namespace dart | 652 } // namespace dart |
| OLD | NEW |