OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HYDROGEN_H_ | 5 #ifndef V8_HYDROGEN_H_ |
6 #define V8_HYDROGEN_H_ | 6 #define V8_HYDROGEN_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 int argument_count() const { return argument_count_; } | 69 int argument_count() const { return argument_count_; } |
70 void set_argument_count(int count) { argument_count_ = count; } | 70 void set_argument_count(int count) { argument_count_ = count; } |
71 int first_instruction_index() const { return first_instruction_index_; } | 71 int first_instruction_index() const { return first_instruction_index_; } |
72 void set_first_instruction_index(int index) { | 72 void set_first_instruction_index(int index) { |
73 first_instruction_index_ = index; | 73 first_instruction_index_ = index; |
74 } | 74 } |
75 int last_instruction_index() const { return last_instruction_index_; } | 75 int last_instruction_index() const { return last_instruction_index_; } |
76 void set_last_instruction_index(int index) { | 76 void set_last_instruction_index(int index) { |
77 last_instruction_index_ = index; | 77 last_instruction_index_ = index; |
78 } | 78 } |
79 bool is_osr_entry() { return is_osr_entry_; } | 79 bool is_osr_entry() const { return IsOsrEntryField::decode(bit_field_); } |
80 void set_osr_entry() { is_osr_entry_ = true; } | 80 void set_osr_entry() { |
81 bit_field_ = IsOsrEntryField::update(bit_field_, true); | |
82 } | |
81 | 83 |
82 void AttachLoopInformation(); | 84 void AttachLoopInformation(); |
83 void DetachLoopInformation(); | 85 void DetachLoopInformation(); |
84 bool IsLoopHeader() const { return loop_information() != NULL; } | 86 bool IsLoopHeader() const { return loop_information() != NULL; } |
85 bool IsStartBlock() const { return block_id() == 0; } | 87 bool IsStartBlock() const { return block_id() == 0; } |
86 void PostProcessLoopHeader(IterationStatement* stmt); | 88 void PostProcessLoopHeader(IterationStatement* stmt); |
87 | 89 |
88 bool IsFinished() const { return end_ != NULL; } | 90 bool IsFinished() const { return end_ != NULL; } |
89 void AddPhi(HPhi* phi); | 91 void AddPhi(HPhi* phi); |
90 void RemovePhi(HPhi* phi); | 92 void RemovePhi(HPhi* phi); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 } | 125 } |
124 void AssignCommonDominator(HBasicBlock* other); | 126 void AssignCommonDominator(HBasicBlock* other); |
125 void AssignLoopSuccessorDominators(); | 127 void AssignLoopSuccessorDominators(); |
126 | 128 |
127 // If a target block is tagged as an inline function return, all | 129 // If a target block is tagged as an inline function return, all |
128 // predecessors should contain the inlined exit sequence: | 130 // predecessors should contain the inlined exit sequence: |
129 // | 131 // |
130 // LeaveInlined | 132 // LeaveInlined |
131 // Simulate (caller's environment) | 133 // Simulate (caller's environment) |
132 // Goto (target block) | 134 // Goto (target block) |
133 bool IsInlineReturnTarget() const { return is_inline_return_target_; } | 135 bool IsInlineReturnTarget() const { |
136 return IsInlineReturnTargetField::decode(bit_field_); | |
137 } | |
134 void MarkAsInlineReturnTarget(HBasicBlock* inlined_entry_block) { | 138 void MarkAsInlineReturnTarget(HBasicBlock* inlined_entry_block) { |
135 is_inline_return_target_ = true; | 139 bit_field_ = IsInlineReturnTargetField::update(bit_field_, true); |
136 inlined_entry_block_ = inlined_entry_block; | 140 inlined_entry_block_ = inlined_entry_block; |
137 } | 141 } |
138 HBasicBlock* inlined_entry_block() { return inlined_entry_block_; } | 142 HBasicBlock* inlined_entry_block() { return inlined_entry_block_; } |
139 | 143 |
140 bool IsDeoptimizing() const { | 144 bool IsDeoptimizing() const { |
141 return end() != NULL && end()->IsDeoptimize(); | 145 return end() != NULL && end()->IsDeoptimize(); |
142 } | 146 } |
143 | 147 |
144 void MarkUnreachable(); | 148 void MarkUnreachable(); |
145 bool IsUnreachable() const { return !is_reachable_; } | 149 bool IsUnreachable() const { return !IsReachable(); } |
146 bool IsReachable() const { return is_reachable_; } | 150 bool IsReachable() const { return IsReachableField::decode(bit_field_); } |
147 | 151 |
148 bool IsLoopSuccessorDominator() const { | 152 bool IsLoopSuccessorDominator() const { |
149 return dominates_loop_successors_; | 153 return DominatesLoopSuccessorsField::decode(bit_field_); |
150 } | 154 } |
151 void MarkAsLoopSuccessorDominator() { | 155 void MarkAsLoopSuccessorDominator() { |
152 dominates_loop_successors_ = true; | 156 bit_field_ = DominatesLoopSuccessorsField::update(bit_field_, true); |
153 } | 157 } |
154 | 158 |
155 bool IsOrdered() const { return is_ordered_; } | 159 bool IsOrdered() const { return IsOrderedField::decode(bit_field_); } |
156 void MarkAsOrdered() { is_ordered_ = true; } | 160 void MarkAsOrdered() { |
161 bit_field_ = IsOrderedField::update(bit_field_, true); | |
162 } | |
157 | 163 |
158 void MarkSuccEdgeUnreachable(int succ); | 164 void MarkSuccEdgeUnreachable(int succ); |
159 | 165 |
160 inline Zone* zone() const; | 166 inline Zone* zone() const; |
161 | 167 |
162 #ifdef DEBUG | 168 #ifdef DEBUG |
163 void Verify(); | 169 void Verify(); |
164 #endif | 170 #endif |
165 | 171 |
166 protected: | 172 protected: |
(...skipping 13 matching lines...) Expand all Loading... | |
180 // Add the inlined function exit sequence, adding an HLeaveInlined | 186 // Add the inlined function exit sequence, adding an HLeaveInlined |
181 // instruction and updating the bailout environment. | 187 // instruction and updating the bailout environment. |
182 void AddLeaveInlined(HValue* return_value, | 188 void AddLeaveInlined(HValue* return_value, |
183 FunctionState* state, | 189 FunctionState* state, |
184 HSourcePosition position); | 190 HSourcePosition position); |
185 | 191 |
186 private: | 192 private: |
187 void RegisterPredecessor(HBasicBlock* pred); | 193 void RegisterPredecessor(HBasicBlock* pred); |
188 void AddDominatedBlock(HBasicBlock* block); | 194 void AddDominatedBlock(HBasicBlock* block); |
189 | 195 |
196 class IsInlineReturnTargetField : public BitField<bool, 0, 1> {}; | |
197 class IsReachableField : public BitField<bool, 1, 1> {}; | |
198 class DominatesLoopSuccessorsField : public BitField<bool, 2, 1> {}; | |
199 class IsOsrEntryField : public BitField<bool, 3, 1> {}; | |
200 class IsOrderedField : public BitField<bool, 4, 1> {}; | |
201 | |
190 int block_id_; | 202 int block_id_; |
191 HGraph* graph_; | 203 HGraph* graph_; |
192 ZoneList<HPhi*> phis_; | 204 ZoneList<HPhi*> phis_; |
193 HInstruction* first_; | 205 HInstruction* first_; |
194 HInstruction* last_; | 206 HInstruction* last_; |
195 HControlInstruction* end_; | 207 HControlInstruction* end_; |
196 HLoopInformation* loop_information_; | 208 HLoopInformation* loop_information_; |
197 ZoneList<HBasicBlock*> predecessors_; | 209 ZoneList<HBasicBlock*> predecessors_; |
198 HBasicBlock* dominator_; | 210 HBasicBlock* dominator_; |
199 ZoneList<HBasicBlock*> dominated_blocks_; | 211 ZoneList<HBasicBlock*> dominated_blocks_; |
200 HEnvironment* last_environment_; | 212 HEnvironment* last_environment_; |
201 // Outgoing parameter count at block exit, set during lithium translation. | 213 // Outgoing parameter count at block exit, set during lithium translation. |
202 int argument_count_; | 214 int argument_count_; |
203 // Instruction indices into the lithium code stream. | 215 // Instruction indices into the lithium code stream. |
204 int first_instruction_index_; | 216 int first_instruction_index_; |
205 int last_instruction_index_; | 217 int last_instruction_index_; |
206 ZoneList<int> deleted_phis_; | 218 ZoneList<int> deleted_phis_; |
207 HBasicBlock* parent_loop_header_; | 219 HBasicBlock* parent_loop_header_; |
208 // For blocks marked as inline return target: the block with HEnterInlined. | 220 // For blocks marked as inline return target: the block with HEnterInlined. |
209 HBasicBlock* inlined_entry_block_; | 221 HBasicBlock* inlined_entry_block_; |
210 bool is_inline_return_target_ : 1; | 222 uint32_t bit_field_; |
Sven Panne
2014/11/05 09:11:49
Can we leave this as it is? It's only a sequence o
Jakob Kummerow
2014/11/05 12:13:46
Done. (Though I don't agree with the term "obfusca
| |
211 bool is_reachable_ : 1; | |
212 bool dominates_loop_successors_ : 1; | |
213 bool is_osr_entry_ : 1; | |
214 bool is_ordered_ : 1; | |
215 }; | 223 }; |
216 | 224 |
217 | 225 |
218 std::ostream& operator<<(std::ostream& os, const HBasicBlock& b); | 226 std::ostream& operator<<(std::ostream& os, const HBasicBlock& b); |
219 | 227 |
220 | 228 |
221 class HPredecessorIterator FINAL BASE_EMBEDDED { | 229 class HPredecessorIterator FINAL BASE_EMBEDDED { |
222 public: | 230 public: |
223 explicit HPredecessorIterator(HBasicBlock* block) | 231 explicit HPredecessorIterator(HBasicBlock* block) |
224 : predecessor_list_(block->predecessors()), current_(0) { } | 232 : predecessor_list_(block->predecessors()), current_(0) { } |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1475 class IfBuilder FINAL { | 1483 class IfBuilder FINAL { |
1476 public: | 1484 public: |
1477 // If using this constructor, Initialize() must be called explicitly! | 1485 // If using this constructor, Initialize() must be called explicitly! |
1478 IfBuilder(); | 1486 IfBuilder(); |
1479 | 1487 |
1480 explicit IfBuilder(HGraphBuilder* builder); | 1488 explicit IfBuilder(HGraphBuilder* builder); |
1481 IfBuilder(HGraphBuilder* builder, | 1489 IfBuilder(HGraphBuilder* builder, |
1482 HIfContinuation* continuation); | 1490 HIfContinuation* continuation); |
1483 | 1491 |
1484 ~IfBuilder() { | 1492 ~IfBuilder() { |
1485 if (!finished_) End(); | 1493 if (!finished()) End(); |
1486 } | 1494 } |
1487 | 1495 |
1488 void Initialize(HGraphBuilder* builder); | 1496 void Initialize(HGraphBuilder* builder); |
1489 | 1497 |
1490 template<class Condition> | 1498 template<class Condition> |
1491 Condition* If(HValue *p) { | 1499 Condition* If(HValue *p) { |
1492 Condition* compare = builder()->New<Condition>(p); | 1500 Condition* compare = builder()->New<Condition>(p); |
1493 AddCompare(compare); | 1501 AddCompare(compare); |
1494 return compare; | 1502 return compare; |
1495 } | 1503 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1650 bool deopt, | 1658 bool deopt, |
1651 MergeAtJoinBlock* next) | 1659 MergeAtJoinBlock* next) |
1652 : block_(block), | 1660 : block_(block), |
1653 deopt_(deopt), | 1661 deopt_(deopt), |
1654 next_(next) {} | 1662 next_(next) {} |
1655 HBasicBlock* block_; | 1663 HBasicBlock* block_; |
1656 bool deopt_; | 1664 bool deopt_; |
1657 MergeAtJoinBlock* next_; | 1665 MergeAtJoinBlock* next_; |
1658 }; | 1666 }; |
1659 | 1667 |
1668 class FinishedField : public BitField<bool, 0, 1> {}; | |
1669 class DidThenField : public BitField<bool, 1, 1> {}; | |
1670 class DidElseField : public BitField<bool, 2, 1> {}; | |
1671 class DidElseIfField : public BitField<bool, 3, 1> {}; | |
1672 class DidAndField : public BitField<bool, 4, 1> {}; | |
1673 class DidOrField : public BitField<bool, 5, 1> {}; | |
1674 class CapturedField : public BitField<bool, 6, 1> {}; | |
1675 class NeedsCompareField : public BitField<bool, 7, 1> {}; | |
1676 class PendingMergeBlockField : public BitField<bool, 8, 1> {}; | |
1677 | |
1678 bool finished() const { return FinishedField::decode(bit_field_); } | |
1679 void set_finished() { | |
1680 bit_field_ = FinishedField::update(bit_field_, true); | |
1681 } | |
1682 bool did_then() const { return DidThenField::decode(bit_field_); } | |
1683 void set_did_then(bool b) { | |
1684 bit_field_ = DidThenField::update(bit_field_, b); | |
1685 } | |
1686 bool did_else() const { return DidElseField::decode(bit_field_); } | |
1687 void set_did_else(bool b) { | |
1688 bit_field_ = DidElseField::update(bit_field_, b); | |
1689 } | |
1690 bool did_else_if() const { return DidElseIfField::decode(bit_field_); } | |
1691 void set_did_else_if(bool b) { | |
1692 bit_field_ = DidElseIfField::update(bit_field_, b); | |
1693 } | |
1694 bool did_and() const { return DidAndField::decode(bit_field_); } | |
1695 void set_did_and(bool b) { | |
1696 bit_field_ = DidAndField::update(bit_field_, b); | |
1697 } | |
1698 bool did_or() const { return DidOrField::decode(bit_field_); } | |
1699 void set_did_or(bool b) { bit_field_ = DidOrField::update(bit_field_, b); } | |
1700 bool captured() const { return CapturedField::decode(bit_field_); } | |
1701 void set_captured() { | |
1702 bit_field_ = CapturedField::update(bit_field_, true); | |
1703 } | |
1704 bool needs_compare() const { return NeedsCompareField::decode(bit_field_); } | |
1705 void set_needs_compare(bool b) { | |
1706 bit_field_ = NeedsCompareField::update(bit_field_, b); | |
1707 } | |
1708 bool pending_merge_block() const { | |
1709 return PendingMergeBlockField::decode(bit_field_); | |
1710 } | |
1711 void set_pending_merge_block(bool b) { | |
1712 bit_field_ = PendingMergeBlockField::update(bit_field_, b); | |
1713 } | |
1714 | |
1660 HGraphBuilder* builder_; | 1715 HGraphBuilder* builder_; |
1661 bool finished_ : 1; | 1716 uint32_t bit_field_; |
Sven Panne
2014/11/05 09:11:49
Same here: This is obfuscating things, and IfBuild
Jakob Kummerow
2014/11/05 12:13:46
Done.
| |
1662 bool did_then_ : 1; | |
1663 bool did_else_ : 1; | |
1664 bool did_else_if_ : 1; | |
1665 bool did_and_ : 1; | |
1666 bool did_or_ : 1; | |
1667 bool captured_ : 1; | |
1668 bool needs_compare_ : 1; | |
1669 bool pending_merge_block_ : 1; | |
1670 HBasicBlock* first_true_block_; | 1717 HBasicBlock* first_true_block_; |
1671 HBasicBlock* first_false_block_; | 1718 HBasicBlock* first_false_block_; |
1672 HBasicBlock* split_edge_merge_block_; | 1719 HBasicBlock* split_edge_merge_block_; |
1673 MergeAtJoinBlock* merge_at_join_blocks_; | 1720 MergeAtJoinBlock* merge_at_join_blocks_; |
1674 int normal_merge_at_join_block_count_; | 1721 int normal_merge_at_join_block_count_; |
1675 int deopt_merge_at_join_block_count_; | 1722 int deopt_merge_at_join_block_count_; |
1676 }; | 1723 }; |
1677 | 1724 |
1678 class LoopBuilder FINAL { | 1725 class LoopBuilder FINAL { |
1679 public: | 1726 public: |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2910 } | 2957 } |
2911 | 2958 |
2912 private: | 2959 private: |
2913 HGraphBuilder* builder_; | 2960 HGraphBuilder* builder_; |
2914 }; | 2961 }; |
2915 | 2962 |
2916 | 2963 |
2917 } } // namespace v8::internal | 2964 } } // namespace v8::internal |
2918 | 2965 |
2919 #endif // V8_HYDROGEN_H_ | 2966 #endif // V8_HYDROGEN_H_ |
OLD | NEW |