Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/hydrogen-flow-engine.h

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-check-elimination.cc ('k') | src/hydrogen-gvn.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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->IsLoopHeader()) { 127 if (block->IsReachable()) {
128 // Apply loop effects before analyzing loop body. 128 ASSERT(state != NULL);
129 ComputeLoopEffects(block)->Apply(state); 129 if (block->IsLoopHeader()) {
130 } else { 130 // Apply loop effects before analyzing loop body.
131 // Must have visited all predecessors before this block. 131 ComputeLoopEffects(block)->Apply(state);
132 CheckPredecessorCount(block); 132 } else {
133 } 133 // Must have visited all predecessors before this block.
134 CheckPredecessorCount(block);
135 }
134 136
135 // Go through all instructions of the current block, updating the state. 137 // Go through all instructions of the current block, updating the state.
136 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { 138 for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
137 state = state->Process(it.Current(), zone_); 139 state = state->Process(it.Current(), zone_);
140 }
138 } 141 }
139 142
140 // Propagate the block state forward to all successor blocks. 143 // Propagate the block state forward to all successor blocks.
141 int max = block->end()->SuccessorCount(); 144 int max = block->end()->SuccessorCount();
142 for (int i = 0; i < max; i++) { 145 for (int i = 0; i < max; i++) {
143 HBasicBlock* succ = block->end()->SuccessorAt(i); 146 HBasicBlock* succ = block->end()->SuccessorAt(i);
144 IncrementPredecessorCount(succ); 147 IncrementPredecessorCount(succ);
145 if (StateAt(succ) == NULL) { 148
146 // This is the first state to reach the successor. 149 if (max == 1 && succ->predecessors()->length() == 1) {
147 if (max == 1 && succ->predecessors()->length() == 1) { 150 // Optimization: successor can inherit this state.
148 // Optimization: successor can inherit this state. 151 SetStateAt(succ, state);
149 SetStateAt(succ, state);
150 } else {
151 // Successor needs a copy of the state.
152 SetStateAt(succ, state->Copy(succ, zone_));
153 }
154 } else { 152 } else {
155 // Merge the current state with the state already at the successor. 153 // Merge the current state with the state already at the successor.
156 SetStateAt(succ, state->Merge(succ, StateAt(succ), zone_)); 154 SetStateAt(succ,
155 State::Merge(StateAt(succ), succ, state, block, zone_));
157 } 156 }
158 } 157 }
159 } 158 }
160 } 159 }
161 160
162 private: 161 private:
163 // 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
164 // block as its loop header. 163 // block as its loop header.
165 Effects* ComputeLoopEffects(HBasicBlock* block) { 164 Effects* ComputeLoopEffects(HBasicBlock* block) {
166 ASSERT(block->IsLoopHeader()); 165 ASSERT(block->IsLoopHeader());
(...skipping 11 matching lines...) Expand all
178 HBasicBlock* member = graph_->blocks()->at(i); 177 HBasicBlock* member = graph_->blocks()->at(i);
179 if (i != block->block_id() && member->IsLoopHeader()) { 178 if (i != block->block_id() && member->IsLoopHeader()) {
180 // Recursively compute and cache the effects of the nested loop. 179 // Recursively compute and cache the effects of the nested loop.
181 ASSERT(member->loop_information()->parent_loop() == loop); 180 ASSERT(member->loop_information()->parent_loop() == loop);
182 Effects* nested = ComputeLoopEffects(member); 181 Effects* nested = ComputeLoopEffects(member);
183 effects->Union(nested, zone_); 182 effects->Union(nested, zone_);
184 // Skip the nested loop's blocks. 183 // Skip the nested loop's blocks.
185 i = member->loop_information()->GetLastBackEdge()->block_id(); 184 i = member->loop_information()->GetLastBackEdge()->block_id();
186 } else { 185 } else {
187 // Process all the effects of the block. 186 // Process all the effects of the block.
187 if (member->IsUnreachable()) continue;
188 ASSERT(member->current_loop() == loop); 188 ASSERT(member->current_loop() == loop);
189 for (HInstructionIterator it(member); !it.Done(); it.Advance()) { 189 for (HInstructionIterator it(member); !it.Done(); it.Advance()) {
190 effects->Process(it.Current(), zone_); 190 effects->Process(it.Current(), zone_);
191 } 191 }
192 } 192 }
193 } 193 }
194 return effects; 194 return effects;
195 } 195 }
196 196
197 inline bool SkipNonDominatedBlock(HBasicBlock* root, HBasicBlock* other) { 197 inline bool SkipNonDominatedBlock(HBasicBlock* root, HBasicBlock* other) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 ZoneList<int> pred_counts_; // Finished predecessors (by block id). 233 ZoneList<int> pred_counts_; // Finished predecessors (by block id).
234 #endif 234 #endif
235 ZoneList<State*> block_states_; // Block states (by block id). 235 ZoneList<State*> block_states_; // Block states (by block id).
236 ZoneList<Effects*> loop_effects_; // Loop effects (by block id). 236 ZoneList<Effects*> loop_effects_; // Loop effects (by block id).
237 }; 237 };
238 238
239 239
240 } } // namespace v8::internal 240 } } // namespace v8::internal
241 241
242 #endif // V8_HYDROGEN_FLOW_ENGINE_H_ 242 #endif // V8_HYDROGEN_FLOW_ENGINE_H_
OLDNEW
« no previous file with comments | « src/hydrogen-check-elimination.cc ('k') | src/hydrogen-gvn.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698