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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 int field = FieldOf(instr->access()); | 196 int field = FieldOf(instr->access()); |
197 if (field < 0) return instr; | 197 if (field < 0) return instr; |
198 | 198 |
199 HValue* object = instr->object()->ActualValue(); | 199 HValue* object = instr->object()->ActualValue(); |
200 HFieldApproximation* approx = FindOrCreate(object, field); | 200 HFieldApproximation* approx = FindOrCreate(object, field); |
201 | 201 |
202 if (approx->last_value_ == NULL) { | 202 if (approx->last_value_ == NULL) { |
203 // Load is not redundant. Fill out a new entry. | 203 // Load is not redundant. Fill out a new entry. |
204 approx->last_value_ = instr; | 204 approx->last_value_ = instr; |
205 return instr; | 205 return instr; |
206 } else { | 206 } else if (approx->last_value_->block()->EqualToOrDominates( |
| 207 instr->block())) { |
207 // Eliminate the load. Reuse previously stored value or load instruction. | 208 // Eliminate the load. Reuse previously stored value or load instruction. |
208 return approx->last_value_; | 209 return approx->last_value_; |
| 210 } else { |
| 211 return instr; |
209 } | 212 } |
210 } | 213 } |
211 | 214 |
212 // Process a store instruction, updating internal table state. If a previous | 215 // Process a store instruction, updating internal table state. If a previous |
213 // store to the same object and field makes this store redundant (e.g. because | 216 // store to the same object and field makes this store redundant (e.g. because |
214 // the stored values are the same), return NULL indicating that this store | 217 // the stored values are the same), return NULL indicating that this store |
215 // instruction is redundant. Otherwise, return {instr}. | 218 // instruction is redundant. Otherwise, return {instr}. |
216 HValue* store(HStoreNamedField* instr) { | 219 HValue* store(HStoreNamedField* instr) { |
217 if (instr->store_mode() == PREINITIALIZING_STORE) { | 220 if (instr->store_mode() == PREINITIALIZING_STORE) { |
218 TRACE((" skipping preinitializing store\n")); | 221 TRACE((" skipping preinitializing store\n")); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 } else { | 511 } else { |
509 // Perform only local analysis. | 512 // Perform only local analysis. |
510 for (int i = 0; i < graph()->blocks()->length(); i++) { | 513 for (int i = 0; i < graph()->blocks()->length(); i++) { |
511 table->Kill(); | 514 table->Kill(); |
512 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); | 515 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); |
513 } | 516 } |
514 } | 517 } |
515 } | 518 } |
516 | 519 |
517 } } // namespace v8::internal | 520 } } // namespace v8::internal |
OLD | NEW |