OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/hydrogen-bch.h" | 5 #include "src/hydrogen-bch.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 | 9 |
10 /* | 10 /* |
(...skipping 26 matching lines...) Expand all Loading... |
37 void set_has_check() { has_check_ = true; } | 37 void set_has_check() { has_check_ = true; } |
38 InductionVariableLimitUpdate* additional_limit() { | 38 InductionVariableLimitUpdate* additional_limit() { |
39 return &additional_limit_; | 39 return &additional_limit_; |
40 } | 40 } |
41 | 41 |
42 /* | 42 /* |
43 * Initializes the table element for a given loop (identified by its | 43 * Initializes the table element for a given loop (identified by its |
44 * induction variable). | 44 * induction variable). |
45 */ | 45 */ |
46 void InitializeLoop(InductionVariableData* data) { | 46 void InitializeLoop(InductionVariableData* data) { |
47 ASSERT(data->limit() != NULL); | 47 DCHECK(data->limit() != NULL); |
48 HLoopInformation* loop = data->phi()->block()->current_loop(); | 48 HLoopInformation* loop = data->phi()->block()->current_loop(); |
49 is_start_ = (block() == loop->loop_header()); | 49 is_start_ = (block() == loop->loop_header()); |
50 is_proper_exit_ = (block() == data->induction_exit_target()); | 50 is_proper_exit_ = (block() == data->induction_exit_target()); |
51 is_in_loop_ = loop->IsNestedInThisLoop(block()->current_loop()); | 51 is_in_loop_ = loop->IsNestedInThisLoop(block()->current_loop()); |
52 has_check_ = false; | 52 has_check_ = false; |
53 } | 53 } |
54 | 54 |
55 // Utility methods to iterate over dominated blocks. | 55 // Utility methods to iterate over dominated blocks. |
56 void ResetCurrentDominatedBlock() { current_dominated_block_ = kNoBlock; } | 56 void ResetCurrentDominatedBlock() { current_dominated_block_ = kNoBlock; } |
57 HBasicBlock* CurrentDominatedBlock() { | 57 HBasicBlock* CurrentDominatedBlock() { |
58 ASSERT(current_dominated_block_ != kNoBlock); | 58 DCHECK(current_dominated_block_ != kNoBlock); |
59 return current_dominated_block_ < block()->dominated_blocks()->length() ? | 59 return current_dominated_block_ < block()->dominated_blocks()->length() ? |
60 block()->dominated_blocks()->at(current_dominated_block_) : NULL; | 60 block()->dominated_blocks()->at(current_dominated_block_) : NULL; |
61 } | 61 } |
62 HBasicBlock* NextDominatedBlock() { | 62 HBasicBlock* NextDominatedBlock() { |
63 current_dominated_block_++; | 63 current_dominated_block_++; |
64 return CurrentDominatedBlock(); | 64 return CurrentDominatedBlock(); |
65 } | 65 } |
66 | 66 |
67 Element() | 67 Element() |
68 : block_(NULL), is_start_(false), is_proper_exit_(false), | 68 : block_(NULL), is_start_(false), is_proper_exit_(false), |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return unsafe ? OPTIMISTICALLY_HOISTABLE : HOISTABLE; | 174 return unsafe ? OPTIMISTICALLY_HOISTABLE : HOISTABLE; |
175 } | 175 } |
176 | 176 |
177 explicit InductionVariableBlocksTable(HGraph* graph) | 177 explicit InductionVariableBlocksTable(HGraph* graph) |
178 : graph_(graph), loop_header_(NULL), | 178 : graph_(graph), loop_header_(NULL), |
179 elements_(graph->blocks()->length(), graph->zone()) { | 179 elements_(graph->blocks()->length(), graph->zone()) { |
180 for (int i = 0; i < graph->blocks()->length(); i++) { | 180 for (int i = 0; i < graph->blocks()->length(); i++) { |
181 Element element; | 181 Element element; |
182 element.set_block(graph->blocks()->at(i)); | 182 element.set_block(graph->blocks()->at(i)); |
183 elements_.Add(element, graph->zone()); | 183 elements_.Add(element, graph->zone()); |
184 ASSERT(at(i)->block()->block_id() == i); | 184 DCHECK(at(i)->block()->block_id() == i); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 // Tries to hoist a check out of its induction loop. | 188 // Tries to hoist a check out of its induction loop. |
189 void ProcessRelatedChecks( | 189 void ProcessRelatedChecks( |
190 InductionVariableData::InductionVariableCheck* check, | 190 InductionVariableData::InductionVariableCheck* check, |
191 InductionVariableData* data) { | 191 InductionVariableData* data) { |
192 HValue* length = check->check()->length(); | 192 HValue* length = check->check()->length(); |
193 check->set_processed(); | 193 check->set_processed(); |
194 HBasicBlock* header = | 194 HBasicBlock* header = |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 void HBoundsCheckHoistingPhase::HoistRedundantBoundsChecks() { | 371 void HBoundsCheckHoistingPhase::HoistRedundantBoundsChecks() { |
372 InductionVariableBlocksTable table(graph()); | 372 InductionVariableBlocksTable table(graph()); |
373 table.CollectInductionVariableData(graph()->entry_block()); | 373 table.CollectInductionVariableData(graph()->entry_block()); |
374 for (int i = 0; i < graph()->blocks()->length(); i++) { | 374 for (int i = 0; i < graph()->blocks()->length(); i++) { |
375 table.EliminateRedundantBoundsChecks(graph()->blocks()->at(i)); | 375 table.EliminateRedundantBoundsChecks(graph()->blocks()->at(i)); |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 } } // namespace v8::internal | 379 } } // namespace v8::internal |
OLD | NEW |