| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 switch (class_id) { | 533 switch (class_id) { |
| 534 case kArray: | 534 case kArray: |
| 535 case kGrowableObjectArray: | 535 case kGrowableObjectArray: |
| 536 comp->set_receiver_type(static_cast<ObjectKind>(class_id)); | 536 comp->set_receiver_type(static_cast<ObjectKind>(class_id)); |
| 537 } | 537 } |
| 538 } | 538 } |
| 539 | 539 |
| 540 | 540 |
| 541 static void TryFuseComparisonWithBranch(BindInstr* instr, | 541 static void TryFuseComparisonWithBranch(BindInstr* instr, |
| 542 ComparisonComp* comp) { | 542 ComparisonComp* comp) { |
| 543 Instruction* next_instr = instr->successor(); | 543 Instruction* next_instr = instr->next(); |
| 544 if ((next_instr != NULL) && next_instr->IsBranch()) { | 544 if ((next_instr != NULL) && next_instr->IsBranch()) { |
| 545 BranchInstr* branch = next_instr->AsBranch(); | 545 BranchInstr* branch = next_instr->AsBranch(); |
| 546 UseVal* use = branch->value()->AsUse(); | 546 UseVal* use = branch->value()->AsUse(); |
| 547 if (instr == use->definition()) { | 547 if (instr == use->definition()) { |
| 548 comp->MarkFusedWithBranch(branch); | 548 comp->MarkFusedWithBranch(branch); |
| 549 branch->MarkFusedWithComparison(); | 549 branch->MarkFusedWithComparison(); |
| 550 return; | 550 return; |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 if ((next_instr != NULL) && next_instr->IsBind()) { | 553 if ((next_instr != NULL) && next_instr->IsBind()) { |
| 554 Computation* next_comp = next_instr->AsBind()->computation(); | 554 Computation* next_comp = next_instr->AsBind()->computation(); |
| 555 if (next_comp->IsBooleanNegate()) { | 555 if (next_comp->IsBooleanNegate()) { |
| 556 Instruction* next_next_instr = next_instr->successor(); | 556 Instruction* next_next_instr = next_instr->next(); |
| 557 if ((next_next_instr != NULL) && next_next_instr->IsBranch()) { | 557 if ((next_next_instr != NULL) && next_next_instr->IsBranch()) { |
| 558 BooleanNegateComp* negate = next_comp->AsBooleanNegate(); | 558 BooleanNegateComp* negate = next_comp->AsBooleanNegate(); |
| 559 BranchInstr* branch = next_next_instr->AsBranch(); | 559 BranchInstr* branch = next_next_instr->AsBranch(); |
| 560 if ((branch->value()->AsUse()->definition() == next_instr) && | 560 if ((branch->value()->AsUse()->definition() == next_instr) && |
| 561 (negate->value()->AsUse()->definition() == instr)) { | 561 (negate->value()->AsUse()->definition() == instr)) { |
| 562 comp->MarkFusedWithBranch(branch); | 562 comp->MarkFusedWithBranch(branch); |
| 563 branch->MarkFusedWithComparison(); | 563 branch->MarkFusedWithComparison(); |
| 564 branch->set_is_negated(true); | 564 branch->set_is_negated(true); |
| 565 instr->set_successor(next_next_instr); | 565 instr->set_next(next_next_instr); |
| 566 return; | 566 return; |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 | 572 |
| 573 | 573 |
| 574 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp, | 574 void FlowGraphOptimizer::VisitRelationalOp(RelationalOpComp* comp, |
| 575 BindInstr* instr) { | 575 BindInstr* instr) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 623 |
| 624 FlowGraphAnalyzer::FlowGraphAnalyzer( | 624 FlowGraphAnalyzer::FlowGraphAnalyzer( |
| 625 const GrowableArray<BlockEntryInstr*>& blocks) | 625 const GrowableArray<BlockEntryInstr*>& blocks) |
| 626 :blocks_(blocks), is_leaf_(false) {} | 626 :blocks_(blocks), is_leaf_(false) {} |
| 627 | 627 |
| 628 | 628 |
| 629 void FlowGraphAnalyzer::Analyze() { | 629 void FlowGraphAnalyzer::Analyze() { |
| 630 is_leaf_ = true; | 630 is_leaf_ = true; |
| 631 for (intptr_t i = 0; i < blocks_.length(); ++i) { | 631 for (intptr_t i = 0; i < blocks_.length(); ++i) { |
| 632 BlockEntryInstr* block_entry = blocks_[i]; | 632 BlockEntryInstr* block_entry = blocks_[i]; |
| 633 Instruction* instr = block_entry->successor(); | 633 Instruction* instr = block_entry->next(); |
| 634 while ((instr != NULL) && !instr->IsBlockEntry()) { | 634 while ((instr != NULL) && !instr->IsBlockEntry()) { |
| 635 LocationSummary* locs = instr->locs(); | 635 LocationSummary* locs = instr->locs(); |
| 636 if (locs != NULL) { | 636 if (locs != NULL) { |
| 637 if (locs->is_call()) { | 637 if (locs->is_call()) { |
| 638 is_leaf_ = false; | 638 is_leaf_ = false; |
| 639 return; | 639 return; |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 instr = instr->successor(); | 642 instr = instr->next(); |
| 643 } | 643 } |
| 644 } | 644 } |
| 645 } | 645 } |
| 646 | 646 |
| 647 } // namespace dart | 647 } // namespace dart |
| OLD | NEW |