| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 void AnalyzeDominatedBlocks(HBasicBlock* root, State* initial) { | 115 void AnalyzeDominatedBlocks(HBasicBlock* root, State* initial) { |
| 116 InitializeStates(); | 116 InitializeStates(); |
| 117 SetStateAt(root, initial); | 117 SetStateAt(root, initial); |
| 118 | 118 |
| 119 // Iterate all dominated blocks starting from the given start block. | 119 // Iterate all dominated blocks starting from the given start block. |
| 120 for (int i = root->block_id(); i < graph_->blocks()->length(); i++) { | 120 for (int i = root->block_id(); i < graph_->blocks()->length(); i++) { |
| 121 HBasicBlock* block = graph_->blocks()->at(i); | 121 HBasicBlock* block = graph_->blocks()->at(i); |
| 122 | 122 |
| 123 // Skip blocks not dominated by the root node. | 123 // Skip blocks not dominated by the root node. |
| 124 if (SkipNonDominatedBlock(root, block)) continue; | 124 if (SkipNonDominatedBlock(root, block)) continue; |
| 125 State* state = StateAt(block); | 125 State* state = State::Finish(StateAt(block), block, zone_); |
| 126 | 126 |
| 127 if (block->IsReachable()) { | 127 if (block->IsReachable()) { |
| 128 ASSERT(state != NULL); |
| 128 if (block->IsLoopHeader()) { | 129 if (block->IsLoopHeader()) { |
| 129 // Apply loop effects before analyzing loop body. | 130 // Apply loop effects before analyzing loop body. |
| 130 ComputeLoopEffects(block)->Apply(state); | 131 ComputeLoopEffects(block)->Apply(state); |
| 131 } else { | 132 } else { |
| 132 // Must have visited all predecessors before this block. | 133 // Must have visited all predecessors before this block. |
| 133 CheckPredecessorCount(block); | 134 CheckPredecessorCount(block); |
| 134 } | 135 } |
| 135 | 136 |
| 136 // Go through all instructions of the current block, updating the state. | 137 // Go through all instructions of the current block, updating the state. |
| 137 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | 138 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 138 state = state->Process(it.Current(), zone_); | 139 state = state->Process(it.Current(), zone_); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 // Propagate the block state forward to all successor blocks. | 143 // Propagate the block state forward to all successor blocks. |
| 143 int max = block->end()->SuccessorCount(); | 144 int max = block->end()->SuccessorCount(); |
| 144 for (int i = 0; i < max; i++) { | 145 for (int i = 0; i < max; i++) { |
| 145 HBasicBlock* succ = block->end()->SuccessorAt(i); | 146 HBasicBlock* succ = block->end()->SuccessorAt(i); |
| 146 IncrementPredecessorCount(succ); | 147 IncrementPredecessorCount(succ); |
| 147 if (StateAt(succ) == NULL) { | 148 |
| 148 // This is the first state to reach the successor. | 149 if (max == 1 && succ->predecessors()->length() == 1) { |
| 149 if (max == 1 && succ->predecessors()->length() == 1) { | 150 // Optimization: successor can inherit this state. |
| 150 // Optimization: successor can inherit this state. | 151 SetStateAt(succ, state); |
| 151 SetStateAt(succ, state); | |
| 152 } else { | |
| 153 // Successor needs a copy of the state. | |
| 154 SetStateAt(succ, state->Copy(succ, block, zone_)); | |
| 155 } | |
| 156 } else { | 152 } else { |
| 157 // Merge the current state with the state already at the successor. | 153 // Merge the current state with the state already at the successor. |
| 158 SetStateAt(succ, StateAt(succ)->Merge(succ, state, block, zone_)); | 154 SetStateAt(succ, |
| 155 State::Merge(StateAt(succ), succ, state, block, zone_)); |
| 159 } | 156 } |
| 160 } | 157 } |
| 161 } | 158 } |
| 162 } | 159 } |
| 163 | 160 |
| 164 private: | 161 private: |
| 165 // Computes and caches the loop effects for the loop which has the given | 162 // Computes and caches the loop effects for the loop which has the given |
| 166 // block as its loop header. | 163 // block as its loop header. |
| 167 Effects* ComputeLoopEffects(HBasicBlock* block) { | 164 Effects* ComputeLoopEffects(HBasicBlock* block) { |
| 168 ASSERT(block->IsLoopHeader()); | 165 ASSERT(block->IsLoopHeader()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 ZoneList<int> pred_counts_; // Finished predecessors (by block id). | 233 ZoneList<int> pred_counts_; // Finished predecessors (by block id). |
| 237 #endif | 234 #endif |
| 238 ZoneList<State*> block_states_; // Block states (by block id). | 235 ZoneList<State*> block_states_; // Block states (by block id). |
| 239 ZoneList<Effects*> loop_effects_; // Loop effects (by block id). | 236 ZoneList<Effects*> loop_effects_; // Loop effects (by block id). |
| 240 }; | 237 }; |
| 241 | 238 |
| 242 | 239 |
| 243 } } // namespace v8::internal | 240 } } // namespace v8::internal |
| 244 | 241 |
| 245 #endif // V8_HYDROGEN_FLOW_ENGINE_H_ | 242 #endif // V8_HYDROGEN_FLOW_ENGINE_H_ |
| OLD | NEW |