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 12 matching lines...) Expand all Loading... |
23 flags.Add(kDoubleFields); | 23 flags.Add(kDoubleFields); |
24 flags.Add(kElementsPointer); | 24 flags.Add(kElementsPointer); |
25 flags.Add(kInobjectFields); | 25 flags.Add(kInobjectFields); |
26 flags.Add(kExternalMemory); | 26 flags.Add(kExternalMemory); |
27 flags.Add(kStringChars); | 27 flags.Add(kStringChars); |
28 flags.Add(kTypedArrayElements); | 28 flags.Add(kTypedArrayElements); |
29 | 29 |
30 for (int i = 0; i < graph()->blocks()->length(); i++) { | 30 for (int i = 0; i < graph()->blocks()->length(); i++) { |
31 unobserved_.Rewind(0); | 31 unobserved_.Rewind(0); |
32 HBasicBlock* block = graph()->blocks()->at(i); | 32 HBasicBlock* block = graph()->blocks()->at(i); |
| 33 if (!block->IsReachable()) continue; |
33 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { | 34 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
34 HInstruction* instr = it.Current(); | 35 HInstruction* instr = it.Current(); |
| 36 if (instr->CheckFlag(HValue::kIsDead)) continue; |
35 | 37 |
36 // TODO(titzer): eliminate unobserved HStoreKeyed instructions too. | 38 // TODO(titzer): eliminate unobserved HStoreKeyed instructions too. |
37 switch (instr->opcode()) { | 39 switch (instr->opcode()) { |
38 case HValue::kStoreNamedField: | 40 case HValue::kStoreNamedField: |
39 // Remove any unobserved stores overwritten by this store. | 41 // Remove any unobserved stores overwritten by this store. |
40 ProcessStore(HStoreNamedField::cast(instr)); | 42 ProcessStore(HStoreNamedField::cast(instr)); |
41 break; | 43 break; |
42 case HValue::kLoadNamedField: | 44 case HValue::kLoadNamedField: |
43 // Observe any unobserved stores on this object + field. | 45 // Observe any unobserved stores on this object + field. |
44 ProcessLoad(HLoadNamedField::cast(instr)); | 46 ProcessLoad(HLoadNamedField::cast(instr)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 i++; | 92 i++; |
91 } | 93 } |
92 } | 94 } |
93 } | 95 } |
94 | 96 |
95 | 97 |
96 void HStoreEliminationPhase::ProcessInstr(HInstruction* instr, | 98 void HStoreEliminationPhase::ProcessInstr(HInstruction* instr, |
97 GVNFlagSet flags) { | 99 GVNFlagSet flags) { |
98 if (unobserved_.length() == 0) return; // Nothing to do. | 100 if (unobserved_.length() == 0) return; // Nothing to do. |
99 if (instr->CanDeoptimize()) { | 101 if (instr->CanDeoptimize()) { |
100 TRACE(("-- Observed stores at I%d (might deoptimize)\n", instr->id())); | 102 TRACE(("-- Observed stores at I%d (%s might deoptimize)\n", |
| 103 instr->id(), instr->Mnemonic())); |
101 unobserved_.Rewind(0); | 104 unobserved_.Rewind(0); |
102 return; | 105 return; |
103 } | 106 } |
104 if (instr->CheckChangesFlag(kNewSpacePromotion)) { | 107 if (instr->CheckChangesFlag(kNewSpacePromotion)) { |
105 TRACE(("-- Observed stores at I%d (might GC)\n", instr->id())); | 108 TRACE(("-- Observed stores at I%d (%s might GC)\n", |
| 109 instr->id(), instr->Mnemonic())); |
106 unobserved_.Rewind(0); | 110 unobserved_.Rewind(0); |
107 return; | 111 return; |
108 } | 112 } |
109 if (instr->DependsOnFlags().ContainsAnyOf(flags)) { | 113 if (instr->DependsOnFlags().ContainsAnyOf(flags)) { |
110 TRACE(("-- Observed stores at I%d (GVN flags)\n", instr->id())); | 114 TRACE(("-- Observed stores at I%d (GVN flags of %s)\n", |
| 115 instr->id(), instr->Mnemonic())); |
111 unobserved_.Rewind(0); | 116 unobserved_.Rewind(0); |
112 return; | 117 return; |
113 } | 118 } |
114 } | 119 } |
115 | 120 |
116 } } // namespace v8::internal | 121 } } // namespace v8::internal |
OLD | NEW |