| 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 740 |
| 741 virtual bool HasSideEffect() const { return false; } | 741 virtual bool HasSideEffect() const { return false; } |
| 742 | 742 |
| 743 intptr_t try_index() const { return try_index_; } | 743 intptr_t try_index() const { return try_index_; } |
| 744 | 744 |
| 745 BitVector* loop_info() const { return loop_info_; } | 745 BitVector* loop_info() const { return loop_info_; } |
| 746 void set_loop_info(BitVector* loop_info) { | 746 void set_loop_info(BitVector* loop_info) { |
| 747 loop_info_ = loop_info; | 747 loop_info_ = loop_info; |
| 748 } | 748 } |
| 749 | 749 |
| 750 intptr_t loop_depth() const { return loop_depth_; } |
| 751 |
| 750 virtual BlockEntryInstr* GetBlock() const { | 752 virtual BlockEntryInstr* GetBlock() const { |
| 751 return const_cast<BlockEntryInstr*>(this); | 753 return const_cast<BlockEntryInstr*>(this); |
| 752 } | 754 } |
| 753 | 755 |
| 754 protected: | 756 protected: |
| 755 BlockEntryInstr(intptr_t block_id, intptr_t try_index) | 757 BlockEntryInstr(intptr_t block_id, intptr_t try_index, intptr_t loop_depth) |
| 756 : block_id_(block_id), | 758 : block_id_(block_id), |
| 757 try_index_(try_index), | 759 try_index_(try_index), |
| 758 preorder_number_(-1), | 760 preorder_number_(-1), |
| 759 postorder_number_(-1), | 761 postorder_number_(-1), |
| 760 dominator_(NULL), | 762 dominator_(NULL), |
| 761 dominated_blocks_(1), | 763 dominated_blocks_(1), |
| 762 last_instruction_(NULL), | 764 last_instruction_(NULL), |
| 763 parallel_move_(NULL), | 765 parallel_move_(NULL), |
| 764 loop_info_(NULL) { } | 766 loop_info_(NULL), |
| 767 loop_depth_(loop_depth) { } |
| 765 | 768 |
| 766 private: | 769 private: |
| 767 virtual void ClearPredecessors() = 0; | 770 virtual void ClearPredecessors() = 0; |
| 768 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; | 771 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; |
| 769 | 772 |
| 770 const intptr_t block_id_; | 773 const intptr_t block_id_; |
| 771 const intptr_t try_index_; | 774 const intptr_t try_index_; |
| 772 intptr_t preorder_number_; | 775 intptr_t preorder_number_; |
| 773 intptr_t postorder_number_; | 776 intptr_t postorder_number_; |
| 774 // Starting and ending lifetime positions for this block. Used by | 777 // Starting and ending lifetime positions for this block. Used by |
| 775 // the linear scan register allocator. | 778 // the linear scan register allocator. |
| 776 intptr_t start_pos_; | 779 intptr_t start_pos_; |
| 777 intptr_t end_pos_; | 780 intptr_t end_pos_; |
| 778 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. | 781 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. |
| 779 // TODO(fschneider): Optimize the case of one child to save space. | 782 // TODO(fschneider): Optimize the case of one child to save space. |
| 780 GrowableArray<BlockEntryInstr*> dominated_blocks_; | 783 GrowableArray<BlockEntryInstr*> dominated_blocks_; |
| 781 Instruction* last_instruction_; | 784 Instruction* last_instruction_; |
| 782 | 785 |
| 783 // Parallel move that will be used by linear scan register allocator to | 786 // Parallel move that will be used by linear scan register allocator to |
| 784 // connect live ranges at the start of the block. | 787 // connect live ranges at the start of the block. |
| 785 ParallelMoveInstr* parallel_move_; | 788 ParallelMoveInstr* parallel_move_; |
| 786 | 789 |
| 787 // Bit vector containg loop blocks for a loop header indexed by block | 790 // Bit vector containg loop blocks for a loop header indexed by block |
| 788 // preorder number. | 791 // preorder number. |
| 789 BitVector* loop_info_; | 792 BitVector* loop_info_; |
| 790 | 793 |
| 794 // Syntactic loop depth of the block. |
| 795 intptr_t loop_depth_; |
| 796 |
| 791 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); | 797 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); |
| 792 }; | 798 }; |
| 793 | 799 |
| 794 | 800 |
| 795 class ForwardInstructionIterator : public ValueObject { | 801 class ForwardInstructionIterator : public ValueObject { |
| 796 public: | 802 public: |
| 797 explicit ForwardInstructionIterator(BlockEntryInstr* block_entry) | 803 explicit ForwardInstructionIterator(BlockEntryInstr* block_entry) |
| 798 : block_entry_(block_entry), current_(block_entry) { | 804 : block_entry_(block_entry), current_(block_entry) { |
| 799 ASSERT(block_entry_->last_instruction()->next() == NULL); | 805 ASSERT(block_entry_->last_instruction()->next() == NULL); |
| 800 Advance(); | 806 Advance(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 GrowableArray<TargetEntryInstr*> catch_entries_; | 900 GrowableArray<TargetEntryInstr*> catch_entries_; |
| 895 GrowableArray<Definition*> initial_definitions_; | 901 GrowableArray<Definition*> initial_definitions_; |
| 896 intptr_t spill_slot_count_; | 902 intptr_t spill_slot_count_; |
| 897 | 903 |
| 898 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); | 904 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); |
| 899 }; | 905 }; |
| 900 | 906 |
| 901 | 907 |
| 902 class JoinEntryInstr : public BlockEntryInstr { | 908 class JoinEntryInstr : public BlockEntryInstr { |
| 903 public: | 909 public: |
| 904 JoinEntryInstr(intptr_t block_id, intptr_t try_index) | 910 JoinEntryInstr(intptr_t block_id, intptr_t try_index, intptr_t loop_depth) |
| 905 : BlockEntryInstr(block_id, try_index), | 911 : BlockEntryInstr(block_id, try_index, loop_depth), |
| 906 predecessors_(2), // Two is the assumed to be the common case. | 912 predecessors_(2), // Two is the assumed to be the common case. |
| 907 phis_(NULL), | 913 phis_(NULL), |
| 908 phi_count_(0) { } | 914 phi_count_(0) { } |
| 909 | 915 |
| 910 DECLARE_INSTRUCTION(JoinEntry) | 916 DECLARE_INSTRUCTION(JoinEntry) |
| 911 | 917 |
| 912 virtual intptr_t PredecessorCount() const { return predecessors_.length(); } | 918 virtual intptr_t PredecessorCount() const { return predecessors_.length(); } |
| 913 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 919 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 914 return predecessors_[index]; | 920 return predecessors_[index]; |
| 915 } | 921 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 } | 970 } |
| 965 | 971 |
| 966 private: | 972 private: |
| 967 ZoneGrowableArray<PhiInstr*>* phis_; | 973 ZoneGrowableArray<PhiInstr*>* phis_; |
| 968 intptr_t index_; | 974 intptr_t index_; |
| 969 }; | 975 }; |
| 970 | 976 |
| 971 | 977 |
| 972 class TargetEntryInstr : public BlockEntryInstr { | 978 class TargetEntryInstr : public BlockEntryInstr { |
| 973 public: | 979 public: |
| 974 TargetEntryInstr(intptr_t block_id, intptr_t try_index) | 980 TargetEntryInstr(intptr_t block_id, intptr_t try_index, intptr_t loop_depth) |
| 975 : BlockEntryInstr(block_id, try_index), | 981 : BlockEntryInstr(block_id, try_index, loop_depth), |
| 976 predecessor_(NULL), | 982 predecessor_(NULL), |
| 977 catch_try_index_(CatchClauseNode::kInvalidTryIndex) { } | 983 catch_try_index_(CatchClauseNode::kInvalidTryIndex) { } |
| 978 | 984 |
| 979 DECLARE_INSTRUCTION(TargetEntry) | 985 DECLARE_INSTRUCTION(TargetEntry) |
| 980 | 986 |
| 981 virtual intptr_t PredecessorCount() const { | 987 virtual intptr_t PredecessorCount() const { |
| 982 return (predecessor_ == NULL) ? 0 : 1; | 988 return (predecessor_ == NULL) ? 0 : 1; |
| 983 } | 989 } |
| 984 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 990 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 985 ASSERT((index == 0) && (predecessor_ != NULL)); | 991 ASSERT((index == 0) && (predecessor_ != NULL)); |
| (...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4254 ForwardInstructionIterator* current_iterator_; | 4260 ForwardInstructionIterator* current_iterator_; |
| 4255 | 4261 |
| 4256 private: | 4262 private: |
| 4257 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4263 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4258 }; | 4264 }; |
| 4259 | 4265 |
| 4260 | 4266 |
| 4261 } // namespace dart | 4267 } // namespace dart |
| 4262 | 4268 |
| 4263 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4269 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |