28 #ifndef V8_HYDROGEN_FLOW_ENGINE_H_
29 #define V8_HYDROGEN_FLOW_ENGINE_H_
46 template <
class State>
47 inline void Apply(State* state) {
90 template <
class State,
class Effects>
97 pred_counts_(graph->blocks()->length(), zone),
99 block_states_(graph->blocks()->length(), zone),
100 loop_effects_(graph->blocks()->length(), zone) {
101 loop_effects_.AddBlock(
NULL, graph_->blocks()->length(), zone);
107 for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
108 state = state->Process(it.Current(), zone_);
117 SetStateAt(root, initial);
120 for (
int i = root->block_id(); i < graph_->blocks()->length(); i++) {
121 HBasicBlock* block = graph_->blocks()->at(i);
124 if (SkipNonDominatedBlock(root, block))
continue;
125 State* state = State::Finish(StateAt(block), block, zone_);
127 if (block->IsReachable()) {
129 if (block->IsLoopHeader()) {
131 ComputeLoopEffects(block)->Apply(state);
134 CheckPredecessorCount(block);
138 for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
139 state = state->Process(it.Current(), zone_);
144 int max = block->end()->SuccessorCount();
145 for (
int i = 0; i < max; i++) {
146 HBasicBlock* succ = block->end()->SuccessorAt(i);
147 IncrementPredecessorCount(succ);
149 if (max == 1 && succ->predecessors()->length() == 1) {
151 SetStateAt(succ, state);
155 State::Merge(StateAt(succ), succ, state, block, zone_));
164 Effects* ComputeLoopEffects(HBasicBlock* block) {
165 ASSERT(block->IsLoopHeader());
166 Effects* effects = loop_effects_[block->block_id()];
167 if (effects !=
NULL)
return effects;
169 effects =
new(zone_)
Effects(zone_);
170 loop_effects_[block->block_id()] = effects;
171 if (effects->Disabled())
return effects;
173 HLoopInformation* loop = block->loop_information();
174 int end = loop->GetLastBackEdge()->block_id();
176 for (
int i = block->block_id(); i <= end; i++) {
177 HBasicBlock* member = graph_->blocks()->at(i);
178 if (i != block->block_id() && member->IsLoopHeader()) {
180 ASSERT(member->loop_information()->parent_loop() == loop);
181 Effects* nested = ComputeLoopEffects(member);
182 effects->Union(nested, zone_);
184 i = member->loop_information()->GetLastBackEdge()->block_id();
187 if (member->IsUnreachable())
continue;
188 ASSERT(member->current_loop() == loop);
189 for (HInstructionIterator it(member); !it.Done(); it.Advance()) {
190 effects->Process(it.Current(), zone_);
197 inline bool SkipNonDominatedBlock(HBasicBlock* root, HBasicBlock* other) {
198 if (root->block_id() == 0)
return false;
199 if (root == other)
return false;
200 return !root->Dominates(other);
203 inline State* StateAt(HBasicBlock* block) {
204 return block_states_.
at(block->block_id());
207 inline void SetStateAt(HBasicBlock* block, State* state) {
208 block_states_.
Set(block->block_id(), state);
211 inline void InitializeStates() {
213 pred_counts_.Rewind(0);
214 pred_counts_.AddBlock(0, graph_->blocks()->length(), zone_);
216 block_states_.Rewind(0);
217 block_states_.
AddBlock(
NULL, graph_->blocks()->length(), zone_);
220 inline void CheckPredecessorCount(HBasicBlock* block) {
221 ASSERT(block->predecessors()->length() == pred_counts_[block->block_id()]);
224 inline void IncrementPredecessorCount(HBasicBlock* block) {
226 pred_counts_[block->block_id()]++;
233 ZoneList<int> pred_counts_;
235 ZoneList<State*> block_states_;
236 ZoneList<Effects*> loop_effects_;
242 #endif // V8_HYDROGEN_FLOW_ENGINE_H_
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void Process(HInstruction *value, Zone *zone)
NoState * Process(HInstruction *value, Zone *zone)
void AnalyzeDominatedBlocks(HBasicBlock *root, State *initial)
#define ASSERT(condition)
NoState * Merge(HBasicBlock *succ, NoState *other, Zone *zone)
void Union(NoEffects *other, Zone *zone)
void Set(int index, const T &element)
State * AnalyzeOneBlock(HBasicBlock *block, State *state)
NoState * Copy(HBasicBlock *succ, Zone *zone)
HFlowEngine(HGraph *graph, Zone *zone)
Vector< T > AddBlock(T value, int count, AllocationPolicy allocator=AllocationPolicy())