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/crankshaft/hydrogen-store-elimination.h" | 5 #include "src/crankshaft/hydrogen-store-elimination.h" |
6 | 6 |
7 #include "src/crankshaft/hydrogen-instructions.h" | 7 #include "src/crankshaft/hydrogen-instructions.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 18 matching lines...) Expand all Loading... |
29 flags.Add(kTypedArrayElements); | 29 flags.Add(kTypedArrayElements); |
30 | 30 |
31 for (int i = 0; i < graph()->blocks()->length(); i++) { | 31 for (int i = 0; i < graph()->blocks()->length(); i++) { |
32 unobserved_.Rewind(0); | 32 unobserved_.Rewind(0); |
33 HBasicBlock* block = graph()->blocks()->at(i); | 33 HBasicBlock* block = graph()->blocks()->at(i); |
34 if (!block->IsReachable()) continue; | 34 if (!block->IsReachable()) continue; |
35 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | 35 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
36 HInstruction* instr = it.Current(); | 36 HInstruction* instr = it.Current(); |
37 if (instr->CheckFlag(HValue::kIsDead)) continue; | 37 if (instr->CheckFlag(HValue::kIsDead)) continue; |
38 | 38 |
39 // TODO(titzer): eliminate unobserved HStoreKeyed instructions too. | |
40 switch (instr->opcode()) { | 39 switch (instr->opcode()) { |
41 case HValue::kStoreNamedField: | 40 case HValue::kStoreNamedField: |
42 // Remove any unobserved stores overwritten by this store. | 41 // Remove any unobserved stores overwritten by this store. |
43 ProcessStore(HStoreNamedField::cast(instr)); | 42 ProcessStore(HStoreNamedField::cast(instr)); |
44 break; | 43 break; |
45 case HValue::kLoadNamedField: | 44 case HValue::kLoadNamedField: |
46 // Observe any unobserved stores on this object + field. | 45 // Observe any unobserved stores on this object + field. |
47 ProcessLoad(HLoadNamedField::cast(instr)); | 46 ProcessLoad(HLoadNamedField::cast(instr)); |
48 break; | 47 break; |
49 default: | 48 default: |
(...skipping 11 matching lines...) Expand all Loading... |
61 while (i < unobserved_.length()) { | 60 while (i < unobserved_.length()) { |
62 HStoreNamedField* prev = unobserved_.at(i); | 61 HStoreNamedField* prev = unobserved_.at(i); |
63 if (aliasing_->MustAlias(object, prev->object()->ActualValue()) && | 62 if (aliasing_->MustAlias(object, prev->object()->ActualValue()) && |
64 prev->CanBeReplacedWith(store)) { | 63 prev->CanBeReplacedWith(store)) { |
65 // This store is guaranteed to overwrite the previous store. | 64 // This store is guaranteed to overwrite the previous store. |
66 prev->DeleteAndReplaceWith(NULL); | 65 prev->DeleteAndReplaceWith(NULL); |
67 TRACE(("++ Unobserved store S%d overwritten by S%d\n", | 66 TRACE(("++ Unobserved store S%d overwritten by S%d\n", |
68 prev->id(), store->id())); | 67 prev->id(), store->id())); |
69 unobserved_.Remove(i); | 68 unobserved_.Remove(i); |
70 } else { | 69 } else { |
71 // TODO(titzer): remove map word clearing from folded allocations. | |
72 i++; | 70 i++; |
73 } | 71 } |
74 } | 72 } |
75 // Only non-transitioning stores are removable. | 73 // Only non-transitioning stores are removable. |
76 if (!store->has_transition()) { | 74 if (!store->has_transition()) { |
77 TRACE(("-- Might remove store S%d\n", store->id())); | 75 TRACE(("-- Might remove store S%d\n", store->id())); |
78 unobserved_.Add(store, zone()); | 76 unobserved_.Add(store, zone()); |
79 } | 77 } |
80 } | 78 } |
81 | 79 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (instr->DependsOnFlags().ContainsAnyOf(flags)) { | 112 if (instr->DependsOnFlags().ContainsAnyOf(flags)) { |
115 TRACE(("-- Observed stores at I%d (GVN flags of %s)\n", | 113 TRACE(("-- Observed stores at I%d (GVN flags of %s)\n", |
116 instr->id(), instr->Mnemonic())); | 114 instr->id(), instr->Mnemonic())); |
117 unobserved_.Rewind(0); | 115 unobserved_.Rewind(0); |
118 return; | 116 return; |
119 } | 117 } |
120 } | 118 } |
121 | 119 |
122 } // namespace internal | 120 } // namespace internal |
123 } // namespace v8 | 121 } // namespace v8 |
OLD | NEW |