| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 3221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3232 if (IsInterferingStore(instr, &offset_in_words)) { | 3232 if (IsInterferingStore(instr, &offset_in_words)) { |
| 3233 // Interfering stores kill only loads from the same offset. | 3233 // Interfering stores kill only loads from the same offset. |
| 3234 if ((offset_in_words < kill_by_offset_.length()) && | 3234 if ((offset_in_words < kill_by_offset_.length()) && |
| 3235 (kill_by_offset_[offset_in_words] != NULL)) { | 3235 (kill_by_offset_[offset_in_words] != NULL)) { |
| 3236 kill->AddAll(kill_by_offset_[offset_in_words]); | 3236 kill->AddAll(kill_by_offset_[offset_in_words]); |
| 3237 // There is no need to clear out_values when clearing GEN set | 3237 // There is no need to clear out_values when clearing GEN set |
| 3238 // because only those values that are in the GEN set | 3238 // because only those values that are in the GEN set |
| 3239 // will ever be used. | 3239 // will ever be used. |
| 3240 gen->RemoveAll(kill_by_offset_[offset_in_words]); | 3240 gen->RemoveAll(kill_by_offset_[offset_in_words]); |
| 3241 | 3241 |
| 3242 Definition* load = map_->Lookup(instr->AsDefinition()); | 3242 // Only forward stores to normal arrays and float64 arrays |
| 3243 if (load != NULL) { | 3243 // to loads because other array stores (intXX/uintXX/float32) |
| 3244 // Store has a corresponding numbered load. Try forwarding | 3244 // may implicitly convert the value stored. |
| 3245 // stored value to it. | 3245 StoreIndexedInstr* array_store = instr->AsStoreIndexed(); |
| 3246 gen->Add(load->expr_id()); | 3246 if (array_store == NULL || |
| 3247 if (out_values == NULL) out_values = CreateBlockOutValues(); | 3247 array_store->class_id() == kArrayCid || |
| 3248 (*out_values)[load->expr_id()] = GetStoredValue(instr); | 3248 array_store->class_id() == kFloat64ArrayCid) { |
| 3249 Definition* load = map_->Lookup(instr->AsDefinition()); |
| 3250 if (load != NULL) { |
| 3251 // Store has a corresponding numbered load. Try forwarding |
| 3252 // stored value to it. |
| 3253 gen->Add(load->expr_id()); |
| 3254 if (out_values == NULL) out_values = CreateBlockOutValues(); |
| 3255 (*out_values)[load->expr_id()] = GetStoredValue(instr); |
| 3256 } |
| 3249 } | 3257 } |
| 3250 } | 3258 } |
| 3251 ASSERT(instr->IsDefinition() && | 3259 ASSERT(instr->IsDefinition() && |
| 3252 !IsLoadEliminationCandidate(instr->AsDefinition())); | 3260 !IsLoadEliminationCandidate(instr->AsDefinition())); |
| 3253 continue; | 3261 continue; |
| 3254 } | 3262 } |
| 3255 | 3263 |
| 3256 // Other instructions with side effects kill all loads. | 3264 // Other instructions with side effects kill all loads. |
| 3257 if (instr->HasSideEffect()) { | 3265 if (instr->HasSideEffect()) { |
| 3258 kill->SetAll(); | 3266 kill->SetAll(); |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4511 | 4519 |
| 4512 if (FLAG_trace_constant_propagation) { | 4520 if (FLAG_trace_constant_propagation) { |
| 4513 OS::Print("\n==== After constant propagation ====\n"); | 4521 OS::Print("\n==== After constant propagation ====\n"); |
| 4514 FlowGraphPrinter printer(*graph_); | 4522 FlowGraphPrinter printer(*graph_); |
| 4515 printer.PrintBlocks(); | 4523 printer.PrintBlocks(); |
| 4516 } | 4524 } |
| 4517 } | 4525 } |
| 4518 | 4526 |
| 4519 | 4527 |
| 4520 } // namespace dart | 4528 } // namespace dart |
| OLD | NEW |