OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // Must have visited all predecessors before this block. | 131 // Must have visited all predecessors before this block. |
132 CheckPredecessorCount(block); | 132 CheckPredecessorCount(block); |
133 } | 133 } |
134 | 134 |
135 // Go through all instructions of the current block, updating the state. | 135 // Go through all instructions of the current block, updating the state. |
136 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | 136 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
137 state = state->Process(it.Current(), zone_); | 137 state = state->Process(it.Current(), zone_); |
138 } | 138 } |
139 | 139 |
140 // Propagate the block state forward to all successor blocks. | 140 // Propagate the block state forward to all successor blocks. |
141 for (int i = 0; i < block->end()->SuccessorCount(); i++) { | 141 int max = block->end()->SuccessorCount(); |
| 142 for (int i = 0; i < max; i++) { |
142 HBasicBlock* succ = block->end()->SuccessorAt(i); | 143 HBasicBlock* succ = block->end()->SuccessorAt(i); |
143 IncrementPredecessorCount(succ); | 144 IncrementPredecessorCount(succ); |
144 if (StateAt(succ) == NULL) { | 145 if (StateAt(succ) == NULL) { |
145 // This is the first state to reach the successor. | 146 // This is the first state to reach the successor. |
146 SetStateAt(succ, state->Copy(succ, zone_)); | 147 if (max == 1 && succ->predecessors()->length() == 1) { |
| 148 // Optimization: successor can inherit this state. |
| 149 SetStateAt(succ, state); |
| 150 } else { |
| 151 // Successor needs a copy of the state. |
| 152 SetStateAt(succ, state->Copy(succ, zone_)); |
| 153 } |
147 } else { | 154 } else { |
148 // Merge the current state with the state already at the successor. | 155 // Merge the current state with the state already at the successor. |
149 SetStateAt(succ, state->Merge(succ, StateAt(succ), zone_)); | 156 SetStateAt(succ, state->Merge(succ, StateAt(succ), zone_)); |
150 } | 157 } |
151 } | 158 } |
152 } | 159 } |
153 } | 160 } |
154 | 161 |
155 private: | 162 private: |
156 // Computes and caches the loop effects for the loop which has the given | 163 // Computes and caches the loop effects for the loop which has the given |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ZoneList<int> pred_counts_; // Finished predecessors (by block id). | 233 ZoneList<int> pred_counts_; // Finished predecessors (by block id). |
227 #endif | 234 #endif |
228 ZoneList<State*> block_states_; // Block states (by block id). | 235 ZoneList<State*> block_states_; // Block states (by block id). |
229 ZoneList<Effects*> loop_effects_; // Loop effects (by block id). | 236 ZoneList<Effects*> loop_effects_; // Loop effects (by block id). |
230 }; | 237 }; |
231 | 238 |
232 | 239 |
233 } } // namespace v8::internal | 240 } } // namespace v8::internal |
234 | 241 |
235 #endif // V8_HYDROGEN_FLOW_ENGINE_H_ | 242 #endif // V8_HYDROGEN_FLOW_ENGINE_H_ |
OLD | NEW |