| 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 "hydrogen-store-elimination.h" | 5 #include "hydrogen-store-elimination.h" |
| 6 #include "hydrogen-instructions.h" | 6 #include "hydrogen-instructions.h" |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 void HStoreEliminationPhase::ProcessStore(HStoreNamedField* store) { | 55 void HStoreEliminationPhase::ProcessStore(HStoreNamedField* store) { |
| 56 HValue* object = store->object()->ActualValue(); | 56 HValue* object = store->object()->ActualValue(); |
| 57 int i = 0; | 57 int i = 0; |
| 58 while (i < unobserved_.length()) { | 58 while (i < unobserved_.length()) { |
| 59 HStoreNamedField* prev = unobserved_.at(i); | 59 HStoreNamedField* prev = unobserved_.at(i); |
| 60 if (aliasing_->MustAlias(object, prev->object()->ActualValue()) && | 60 if (aliasing_->MustAlias(object, prev->object()->ActualValue()) && |
| 61 store->access().Equals(prev->access()) && | 61 store->access().Equals(prev->access())) { |
| 62 (!SmiValuesAre32Bits() || | |
| 63 !store->field_representation().IsSmi() || | |
| 64 store->store_mode() == STORE_TO_INITIALIZED_ENTRY || | |
| 65 prev->store_mode() == INITIALIZING_STORE)) { | |
| 66 // This store is guaranteed to overwrite the previous store. | 62 // This store is guaranteed to overwrite the previous store. |
| 67 prev->DeleteAndReplaceWith(NULL); | 63 prev->DeleteAndReplaceWith(NULL); |
| 68 TRACE(("++ Unobserved store S%d overwritten by S%d\n", | 64 TRACE(("++ Unobserved store S%d overwritten by S%d\n", |
| 69 prev->id(), store->id())); | 65 prev->id(), store->id())); |
| 70 unobserved_.Remove(i); | 66 unobserved_.Remove(i); |
| 71 } else { | 67 } else { |
| 72 // TODO(titzer): remove map word clearing from folded allocations. | 68 // TODO(titzer): remove map word clearing from folded allocations. |
| 73 i++; | 69 i++; |
| 74 } | 70 } |
| 75 } | 71 } |
| 76 TRACE(("-- Might remove store S%d\n", store->id())); | 72 // Only non-transitioning stores are removable. |
| 77 unobserved_.Add(store, zone()); | 73 if (!store->has_transition()) { |
| 74 TRACE(("-- Might remove store S%d\n", store->id())); |
| 75 unobserved_.Add(store, zone()); |
| 76 } |
| 78 } | 77 } |
| 79 | 78 |
| 80 | 79 |
| 81 void HStoreEliminationPhase::ProcessLoad(HLoadNamedField* load) { | 80 void HStoreEliminationPhase::ProcessLoad(HLoadNamedField* load) { |
| 82 HValue* object = load->object()->ActualValue(); | 81 HValue* object = load->object()->ActualValue(); |
| 83 int i = 0; | 82 int i = 0; |
| 84 while (i < unobserved_.length()) { | 83 while (i < unobserved_.length()) { |
| 85 HStoreNamedField* prev = unobserved_.at(i); | 84 HStoreNamedField* prev = unobserved_.at(i); |
| 86 if (aliasing_->MayAlias(object, prev->object()->ActualValue()) && | 85 if (aliasing_->MayAlias(object, prev->object()->ActualValue()) && |
| 87 load->access().Equals(prev->access())) { | 86 load->access().Equals(prev->access())) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 return; | 107 return; |
| 109 } | 108 } |
| 110 if (instr->DependsOnFlags().ContainsAnyOf(flags)) { | 109 if (instr->DependsOnFlags().ContainsAnyOf(flags)) { |
| 111 TRACE(("-- Observed stores at I%d (GVN flags)\n", instr->id())); | 110 TRACE(("-- Observed stores at I%d (GVN flags)\n", instr->id())); |
| 112 unobserved_.Rewind(0); | 111 unobserved_.Rewind(0); |
| 113 return; | 112 return; |
| 114 } | 113 } |
| 115 } | 114 } |
| 116 | 115 |
| 117 } } // namespace v8::internal | 116 } } // namespace v8::internal |
| OLD | NEW |