OLD | NEW |
---|---|
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/constant_propagator.h" | 5 #include "vm/constant_propagator.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
10 #include "vm/flow_graph_range_analysis.h" | 10 #include "vm/flow_graph_range_analysis.h" |
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1541 ASSERT(branch->previous() != NULL); // Not already eliminated. | 1541 ASSERT(branch->previous() != NULL); // Not already eliminated. |
1542 BlockEntryInstr* if_true = | 1542 BlockEntryInstr* if_true = |
1543 FindFirstNonEmptySuccessor(branch->true_successor(), empty_blocks); | 1543 FindFirstNonEmptySuccessor(branch->true_successor(), empty_blocks); |
1544 BlockEntryInstr* if_false = | 1544 BlockEntryInstr* if_false = |
1545 FindFirstNonEmptySuccessor(branch->false_successor(), empty_blocks); | 1545 FindFirstNonEmptySuccessor(branch->false_successor(), empty_blocks); |
1546 if (if_true == if_false) { | 1546 if (if_true == if_false) { |
1547 // Replace the branch with a jump to the common successor. | 1547 // Replace the branch with a jump to the common successor. |
1548 // Drop the comparison, which does not have side effects | 1548 // Drop the comparison, which does not have side effects |
1549 JoinEntryInstr* join = if_true->AsJoinEntry(); | 1549 JoinEntryInstr* join = if_true->AsJoinEntry(); |
1550 if (join->phis() == NULL) { | 1550 if (join->phis() == NULL) { |
1551 GotoInstr* jump = new (Z) GotoInstr(if_true->AsJoinEntry()); | 1551 GotoInstr* jump = new (Z) GotoInstr( |
1552 if_true->AsJoinEntry(), Thread::Current()->GetNextDeoptId()); | |
Vyacheslav Egorov (Google)
2017/05/23 12:00:01
kNoDeoptId because InheritDeoptTarget.
| |
1552 jump->InheritDeoptTarget(Z, branch); | 1553 jump->InheritDeoptTarget(Z, branch); |
1553 | 1554 |
1554 Instruction* previous = branch->previous(); | 1555 Instruction* previous = branch->previous(); |
1555 branch->set_previous(NULL); | 1556 branch->set_previous(NULL); |
1556 previous->LinkTo(jump); | 1557 previous->LinkTo(jump); |
1557 | 1558 |
1558 // Remove uses from branch and all the empty blocks that | 1559 // Remove uses from branch and all the empty blocks that |
1559 // are now unreachable. | 1560 // are now unreachable. |
1560 branch->UnuseAllInputs(); | 1561 branch->UnuseAllInputs(); |
1561 for (BitVector::Iterator it(empty_blocks); !it.Done(); it.Advance()) { | 1562 for (BitVector::Iterator it(empty_blocks); !it.Done(); it.Advance()) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1685 TargetEntryInstr* if_true = branch->true_successor(); | 1686 TargetEntryInstr* if_true = branch->true_successor(); |
1686 TargetEntryInstr* if_false = branch->false_successor(); | 1687 TargetEntryInstr* if_false = branch->false_successor(); |
1687 JoinEntryInstr* join = NULL; | 1688 JoinEntryInstr* join = NULL; |
1688 Instruction* next = NULL; | 1689 Instruction* next = NULL; |
1689 | 1690 |
1690 if (!reachable_->Contains(if_true->preorder_number())) { | 1691 if (!reachable_->Contains(if_true->preorder_number())) { |
1691 ASSERT(reachable_->Contains(if_false->preorder_number())); | 1692 ASSERT(reachable_->Contains(if_false->preorder_number())); |
1692 ASSERT(if_false->parallel_move() == NULL); | 1693 ASSERT(if_false->parallel_move() == NULL); |
1693 ASSERT(if_false->loop_info() == NULL); | 1694 ASSERT(if_false->loop_info() == NULL); |
1694 join = | 1695 join = |
1695 new (Z) JoinEntryInstr(if_false->block_id(), if_false->try_index()); | 1696 new (Z) JoinEntryInstr(if_false->block_id(), if_false->try_index(), |
1697 Thread::Current()->GetNextDeoptId()); | |
Vyacheslav Egorov (Google)
2017/05/23 12:00:01
ditto
| |
1696 join->InheritDeoptTarget(Z, if_false); | 1698 join->InheritDeoptTarget(Z, if_false); |
1697 if_false->UnuseAllInputs(); | 1699 if_false->UnuseAllInputs(); |
1698 next = if_false->next(); | 1700 next = if_false->next(); |
1699 } else if (!reachable_->Contains(if_false->preorder_number())) { | 1701 } else if (!reachable_->Contains(if_false->preorder_number())) { |
1700 ASSERT(if_true->parallel_move() == NULL); | 1702 ASSERT(if_true->parallel_move() == NULL); |
1701 ASSERT(if_true->loop_info() == NULL); | 1703 ASSERT(if_true->loop_info() == NULL); |
1702 join = | 1704 join = new (Z) JoinEntryInstr(if_true->block_id(), if_true->try_index(), |
Vyacheslav Egorov (Google)
2017/05/23 12:00:01
ditto
| |
1703 new (Z) JoinEntryInstr(if_true->block_id(), if_true->try_index()); | 1705 Thread::Current()->GetNextDeoptId()); |
1704 join->InheritDeoptTarget(Z, if_true); | 1706 join->InheritDeoptTarget(Z, if_true); |
1705 if_true->UnuseAllInputs(); | 1707 if_true->UnuseAllInputs(); |
1706 next = if_true->next(); | 1708 next = if_true->next(); |
1707 } | 1709 } |
1708 | 1710 |
1709 if (join != NULL) { | 1711 if (join != NULL) { |
1710 // Replace the branch with a jump to the reachable successor. | 1712 // Replace the branch with a jump to the reachable successor. |
1711 // Drop the comparison, which does not have side effects as long | 1713 // Drop the comparison, which does not have side effects as long |
1712 // as it is a strict compare (the only one we can determine is | 1714 // as it is a strict compare (the only one we can determine is |
1713 // constant with the current analysis). | 1715 // constant with the current analysis). |
1714 GotoInstr* jump = new (Z) GotoInstr(join); | 1716 GotoInstr* jump = |
1717 new (Z) GotoInstr(join, Thread::Current()->GetNextDeoptId()); | |
Vyacheslav Egorov (Google)
2017/05/23 12:00:01
ditto
| |
1715 jump->InheritDeoptTarget(Z, branch); | 1718 jump->InheritDeoptTarget(Z, branch); |
1716 | 1719 |
1717 Instruction* previous = branch->previous(); | 1720 Instruction* previous = branch->previous(); |
1718 branch->set_previous(NULL); | 1721 branch->set_previous(NULL); |
1719 previous->LinkTo(jump); | 1722 previous->LinkTo(jump); |
1720 | 1723 |
1721 // Replace the false target entry with the new join entry. We will | 1724 // Replace the false target entry with the new join entry. We will |
1722 // recompute the dominators after this pass. | 1725 // recompute the dominators after this pass. |
1723 join->LinkTo(next); | 1726 join->LinkTo(next); |
1724 branch->UnuseAllInputs(); | 1727 branch->UnuseAllInputs(); |
1725 } | 1728 } |
1726 } | 1729 } |
1727 } | 1730 } |
1728 | 1731 |
1729 graph_->DiscoverBlocks(); | 1732 graph_->DiscoverBlocks(); |
1730 graph_->MergeBlocks(); | 1733 graph_->MergeBlocks(); |
1731 GrowableArray<BitVector*> dominance_frontier; | 1734 GrowableArray<BitVector*> dominance_frontier; |
1732 graph_->ComputeDominators(&dominance_frontier); | 1735 graph_->ComputeDominators(&dominance_frontier); |
1733 | 1736 |
1734 if (FLAG_trace_constant_propagation && | 1737 if (FLAG_trace_constant_propagation && |
1735 FlowGraphPrinter::ShouldPrint(graph_->function())) { | 1738 FlowGraphPrinter::ShouldPrint(graph_->function())) { |
1736 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1739 FlowGraphPrinter::PrintGraph("After CP", graph_); |
1737 } | 1740 } |
1738 } | 1741 } |
1739 | 1742 |
1740 } // namespace dart | 1743 } // namespace dart |
OLD | NEW |