| 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-alias-analysis.h" | 5 #include "src/hydrogen-alias-analysis.h" |
| 6 #include "src/hydrogen-flow-engine.h" | 6 #include "src/hydrogen-flow-engine.h" |
| 7 #include "src/hydrogen-instructions.h" | 7 #include "src/hydrogen-instructions.h" |
| 8 #include "src/hydrogen-load-elimination.h" | 8 #include "src/hydrogen-load-elimination.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 return this; | 115 return this; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Support for global analysis with HFlowEngine: Merge given state with | 118 // Support for global analysis with HFlowEngine: Merge given state with |
| 119 // the other incoming state. | 119 // the other incoming state. |
| 120 static HLoadEliminationTable* Merge(HLoadEliminationTable* succ_state, | 120 static HLoadEliminationTable* Merge(HLoadEliminationTable* succ_state, |
| 121 HBasicBlock* succ_block, | 121 HBasicBlock* succ_block, |
| 122 HLoadEliminationTable* pred_state, | 122 HLoadEliminationTable* pred_state, |
| 123 HBasicBlock* pred_block, | 123 HBasicBlock* pred_block, |
| 124 Zone* zone) { | 124 Zone* zone) { |
| 125 ASSERT(pred_state != NULL); | 125 DCHECK(pred_state != NULL); |
| 126 if (succ_state == NULL) { | 126 if (succ_state == NULL) { |
| 127 return pred_state->Copy(succ_block, pred_block, zone); | 127 return pred_state->Copy(succ_block, pred_block, zone); |
| 128 } else { | 128 } else { |
| 129 return succ_state->Merge(succ_block, pred_state, pred_block, zone); | 129 return succ_state->Merge(succ_block, pred_state, pred_block, zone); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Support for global analysis with HFlowEngine: Given state merged with all | 133 // Support for global analysis with HFlowEngine: Given state merged with all |
| 134 // the other incoming states, prepare it for use. | 134 // the other incoming states, prepare it for use. |
| 135 static HLoadEliminationTable* Finish(HLoadEliminationTable* state, | 135 static HLoadEliminationTable* Finish(HLoadEliminationTable* state, |
| 136 HBasicBlock* block, | 136 HBasicBlock* block, |
| 137 Zone* zone) { | 137 Zone* zone) { |
| 138 ASSERT(state != NULL); | 138 DCHECK(state != NULL); |
| 139 return state; | 139 return state; |
| 140 } | 140 } |
| 141 | 141 |
| 142 private: | 142 private: |
| 143 // Copy state to successor block. | 143 // Copy state to successor block. |
| 144 HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, | 144 HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, |
| 145 Zone* zone) { | 145 Zone* zone) { |
| 146 HLoadEliminationTable* copy = | 146 HLoadEliminationTable* copy = |
| 147 new(zone) HLoadEliminationTable(zone, aliasing_); | 147 new(zone) HLoadEliminationTable(zone, aliasing_); |
| 148 copy->EnsureFields(fields_.length()); | 148 copy->EnsureFields(fields_.length()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 friend class HLoadEliminationEffects; // Calls Kill() and others. | 194 friend class HLoadEliminationEffects; // Calls Kill() and others. |
| 195 friend class HLoadEliminationPhase; | 195 friend class HLoadEliminationPhase; |
| 196 | 196 |
| 197 private: | 197 private: |
| 198 // Process a load instruction, updating internal table state. If a previous | 198 // Process a load instruction, updating internal table state. If a previous |
| 199 // load or store for this object and field exists, return the new value with | 199 // load or store for this object and field exists, return the new value with |
| 200 // which the load should be replaced. Otherwise, return {instr}. | 200 // which the load should be replaced. Otherwise, return {instr}. |
| 201 HValue* load(HLoadNamedField* instr) { | 201 HValue* load(HLoadNamedField* instr) { |
| 202 // There must be no loads from non observable in-object properties. | 202 // There must be no loads from non observable in-object properties. |
| 203 ASSERT(!instr->access().IsInobject() || | 203 DCHECK(!instr->access().IsInobject() || |
| 204 instr->access().existing_inobject_property()); | 204 instr->access().existing_inobject_property()); |
| 205 | 205 |
| 206 int field = FieldOf(instr->access()); | 206 int field = FieldOf(instr->access()); |
| 207 if (field < 0) return instr; | 207 if (field < 0) return instr; |
| 208 | 208 |
| 209 HValue* object = instr->object()->ActualValue(); | 209 HValue* object = instr->object()->ActualValue(); |
| 210 HFieldApproximation* approx = FindOrCreate(object, field); | 210 HFieldApproximation* approx = FindOrCreate(object, field); |
| 211 | 211 |
| 212 if (approx->last_value_ == NULL) { | 212 if (approx->last_value_ == NULL) { |
| 213 // Load is not redundant. Fill out a new entry. | 213 // Load is not redundant. Fill out a new entry. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 return a->Equals(b); | 375 return a->Equals(b); |
| 376 } | 376 } |
| 377 return false; | 377 return false; |
| 378 } | 378 } |
| 379 | 379 |
| 380 // Remove the last approximation for a field so that it can be reused. | 380 // Remove the last approximation for a field so that it can be reused. |
| 381 // We reuse the last entry because it was the first inserted and is thus | 381 // We reuse the last entry because it was the first inserted and is thus |
| 382 // farthest away from the current instruction. | 382 // farthest away from the current instruction. |
| 383 HFieldApproximation* ReuseLastApproximation(int field) { | 383 HFieldApproximation* ReuseLastApproximation(int field) { |
| 384 HFieldApproximation* approx = fields_[field]; | 384 HFieldApproximation* approx = fields_[field]; |
| 385 ASSERT(approx != NULL); | 385 DCHECK(approx != NULL); |
| 386 | 386 |
| 387 HFieldApproximation* prev = NULL; | 387 HFieldApproximation* prev = NULL; |
| 388 while (approx->next_ != NULL) { | 388 while (approx->next_ != NULL) { |
| 389 prev = approx; | 389 prev = approx; |
| 390 approx = approx->next_; | 390 approx = approx->next_; |
| 391 } | 391 } |
| 392 if (prev != NULL) prev->next_ = NULL; | 392 if (prev != NULL) prev->next_ = NULL; |
| 393 return approx; | 393 return approx; |
| 394 } | 394 } |
| 395 | 395 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } else { | 502 } else { |
| 503 // Perform only local analysis. | 503 // Perform only local analysis. |
| 504 for (int i = 0; i < graph()->blocks()->length(); i++) { | 504 for (int i = 0; i < graph()->blocks()->length(); i++) { |
| 505 table->Kill(); | 505 table->Kill(); |
| 506 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); | 506 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 | 510 |
| 511 } } // namespace v8::internal | 511 } } // namespace v8::internal |
| OLD | NEW |