| 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 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 // predecessors. Targets are all other basic block entries. The types | 1526 // predecessors. Targets are all other basic block entries. The types |
| 1527 // enforce edge-split form---joins are forbidden as the successors of | 1527 // enforce edge-split form---joins are forbidden as the successors of |
| 1528 // branches. | 1528 // branches. |
| 1529 class BlockEntryInstr : public Instruction { | 1529 class BlockEntryInstr : public Instruction { |
| 1530 public: | 1530 public: |
| 1531 virtual bool IsBlockEntry() const { return true; } | 1531 virtual bool IsBlockEntry() const { return true; } |
| 1532 | 1532 |
| 1533 virtual intptr_t PredecessorCount() const = 0; | 1533 virtual intptr_t PredecessorCount() const = 0; |
| 1534 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0; | 1534 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0; |
| 1535 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; | 1535 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; |
| 1536 virtual void PrepareEntry(FlowGraphCompiler* compiler) = 0; |
| 1536 | 1537 |
| 1537 intptr_t preorder_number() const { return preorder_number_; } | 1538 intptr_t preorder_number() const { return preorder_number_; } |
| 1538 void set_preorder_number(intptr_t number) { preorder_number_ = number; } | 1539 void set_preorder_number(intptr_t number) { preorder_number_ = number; } |
| 1539 | 1540 |
| 1540 intptr_t postorder_number() const { return postorder_number_; } | 1541 intptr_t postorder_number() const { return postorder_number_; } |
| 1541 void set_postorder_number(intptr_t number) { postorder_number_ = number; } | 1542 void set_postorder_number(intptr_t number) { postorder_number_ = number; } |
| 1542 | 1543 |
| 1543 intptr_t block_id() const { return block_id_; } | 1544 intptr_t block_id() const { return block_id_; } |
| 1544 void set_block_id(intptr_t value) { block_id_ = value; } | 1545 void set_block_id(intptr_t value) { block_id_ = value; } |
| 1545 | 1546 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 virtual void DiscoverBlocks( | 1597 virtual void DiscoverBlocks( |
| 1597 BlockEntryInstr* current_block, | 1598 BlockEntryInstr* current_block, |
| 1598 GrowableArray<BlockEntryInstr*>* preorder, | 1599 GrowableArray<BlockEntryInstr*>* preorder, |
| 1599 GrowableArray<BlockEntryInstr*>* postorder, | 1600 GrowableArray<BlockEntryInstr*>* postorder, |
| 1600 GrowableArray<intptr_t>* parent, | 1601 GrowableArray<intptr_t>* parent, |
| 1601 GrowableArray<BitVector*>* assigned_vars, | 1602 GrowableArray<BitVector*>* assigned_vars, |
| 1602 intptr_t variable_count); | 1603 intptr_t variable_count); |
| 1603 | 1604 |
| 1604 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } | 1605 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } |
| 1605 | 1606 |
| 1607 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 1608 |
| 1606 private: | 1609 private: |
| 1607 TargetEntryInstr* normal_entry_; | 1610 TargetEntryInstr* normal_entry_; |
| 1608 GrowableArray<TargetEntryInstr*> catch_entries_; | 1611 GrowableArray<TargetEntryInstr*> catch_entries_; |
| 1609 | 1612 |
| 1610 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); | 1613 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); |
| 1611 }; | 1614 }; |
| 1612 | 1615 |
| 1613 | 1616 |
| 1614 class JoinEntryInstr : public BlockEntryInstr { | 1617 class JoinEntryInstr : public BlockEntryInstr { |
| 1615 public: | 1618 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1629 } | 1632 } |
| 1630 | 1633 |
| 1631 virtual Instruction* StraightLineSuccessor() const { | 1634 virtual Instruction* StraightLineSuccessor() const { |
| 1632 return successor_; | 1635 return successor_; |
| 1633 } | 1636 } |
| 1634 virtual void SetSuccessor(Instruction* instr) { | 1637 virtual void SetSuccessor(Instruction* instr) { |
| 1635 ASSERT(successor_ == NULL); | 1638 ASSERT(successor_ == NULL); |
| 1636 successor_ = instr; | 1639 successor_ = instr; |
| 1637 } | 1640 } |
| 1638 | 1641 |
| 1642 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 1643 |
| 1639 private: | 1644 private: |
| 1640 ZoneGrowableArray<BlockEntryInstr*> predecessors_; | 1645 ZoneGrowableArray<BlockEntryInstr*> predecessors_; |
| 1641 Instruction* successor_; | 1646 Instruction* successor_; |
| 1642 | 1647 |
| 1643 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); | 1648 DISALLOW_COPY_AND_ASSIGN(JoinEntryInstr); |
| 1644 }; | 1649 }; |
| 1645 | 1650 |
| 1646 | 1651 |
| 1647 class TargetEntryInstr : public BlockEntryInstr { | 1652 class TargetEntryInstr : public BlockEntryInstr { |
| 1648 public: | 1653 public: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 | 1688 |
| 1684 bool HasTryIndex() const { | 1689 bool HasTryIndex() const { |
| 1685 return try_index_ != CatchClauseNode::kInvalidTryIndex; | 1690 return try_index_ != CatchClauseNode::kInvalidTryIndex; |
| 1686 } | 1691 } |
| 1687 | 1692 |
| 1688 intptr_t try_index() const { | 1693 intptr_t try_index() const { |
| 1689 ASSERT(HasTryIndex()); | 1694 ASSERT(HasTryIndex()); |
| 1690 return try_index_; | 1695 return try_index_; |
| 1691 } | 1696 } |
| 1692 | 1697 |
| 1698 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 1699 |
| 1693 private: | 1700 private: |
| 1694 BlockEntryInstr* predecessor_; | 1701 BlockEntryInstr* predecessor_; |
| 1695 Instruction* successor_; | 1702 Instruction* successor_; |
| 1696 const intptr_t try_index_; | 1703 const intptr_t try_index_; |
| 1697 | 1704 |
| 1698 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); | 1705 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); |
| 1699 }; | 1706 }; |
| 1700 | 1707 |
| 1701 | 1708 |
| 1702 class DoInstr : public Instruction { | 1709 class DoInstr : public Instruction { |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ | 1973 #define DECLARE_VISIT_INSTRUCTION(ShortName) \ |
| 1967 virtual void Visit##ShortName(ShortName##Instr* instr) { } | 1974 virtual void Visit##ShortName(ShortName##Instr* instr) { } |
| 1968 | 1975 |
| 1969 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) | 1976 FOR_EACH_COMPUTATION(DECLARE_VISIT_COMPUTATION) |
| 1970 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) | 1977 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 1971 | 1978 |
| 1972 #undef DECLARE_VISIT_COMPUTATION | 1979 #undef DECLARE_VISIT_COMPUTATION |
| 1973 #undef DECLARE_VISIT_INSTRUCTION | 1980 #undef DECLARE_VISIT_INSTRUCTION |
| 1974 | 1981 |
| 1975 protected: | 1982 protected: |
| 1976 // Map a block number in a forward iteration into the block number in the | |
| 1977 // corresponding reverse iteration. Used to obtain an index into | |
| 1978 // block_order for reverse iterations. | |
| 1979 intptr_t reverse_index(intptr_t index) const { | |
| 1980 return block_order_.length() - index - 1; | |
| 1981 } | |
| 1982 | |
| 1983 const GrowableArray<BlockEntryInstr*>& block_order_; | 1983 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 1984 | 1984 |
| 1985 private: | 1985 private: |
| 1986 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1986 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1987 }; | 1987 }; |
| 1988 | 1988 |
| 1989 | 1989 |
| 1990 } // namespace dart | 1990 } // namespace dart |
| 1991 | 1991 |
| 1992 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1992 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |