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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Improvements possible: | 125 // Improvements possible: |
126 // - learn from HCheckMaps for field 0 | 126 // - learn from HCheckMaps for field 0 |
127 // - remove unobservable stores (write-after-write) | 127 // - remove unobservable stores (write-after-write) |
128 // - track cells | 128 // - track cells |
129 // - track globals | 129 // - track globals |
130 // - track roots | 130 // - track roots |
131 } | 131 } |
132 return this; | 132 return this; |
133 } | 133 } |
134 | 134 |
135 // Support for global analysis with HFlowEngine: Copy state to sucessor block. | 135 // Support for global analysis with HFlowEngine: Copy state to successor |
136 HLoadEliminationTable* Copy(HBasicBlock* succ, Zone* zone) { | 136 // block. |
| 137 HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, |
| 138 Zone* zone) { |
137 HLoadEliminationTable* copy = | 139 HLoadEliminationTable* copy = |
138 new(zone) HLoadEliminationTable(zone, aliasing_); | 140 new(zone) HLoadEliminationTable(zone, aliasing_); |
139 copy->EnsureFields(fields_.length()); | 141 copy->EnsureFields(fields_.length()); |
140 for (int i = 0; i < fields_.length(); i++) { | 142 for (int i = 0; i < fields_.length(); i++) { |
141 copy->fields_[i] = fields_[i]->Copy(zone); | 143 copy->fields_[i] = fields_[i]->Copy(zone); |
142 } | 144 } |
143 if (FLAG_trace_load_elimination) { | 145 if (FLAG_trace_load_elimination) { |
144 TRACE((" copy-to B%d\n", succ->block_id())); | 146 TRACE((" copy-to B%d\n", succ->block_id())); |
145 copy->Print(); | 147 copy->Print(); |
146 } | 148 } |
147 return copy; | 149 return copy; |
148 } | 150 } |
149 | 151 |
150 // Support for global analysis with HFlowEngine: Merge this state with | 152 // Support for global analysis with HFlowEngine: Merge this state with |
151 // the other incoming state. | 153 // the other incoming state. |
152 HLoadEliminationTable* Merge(HBasicBlock* succ, | 154 void Merge(HBasicBlock* succ, HLoadEliminationTable* that, |
153 HLoadEliminationTable* that, Zone* zone) { | 155 HBasicBlock* that_block, Zone* zone) { |
154 if (that->fields_.length() < fields_.length()) { | 156 if (that->fields_.length() < fields_.length()) { |
155 // Drop fields not in the other table. | 157 // Drop fields not in the other table. |
156 fields_.Rewind(that->fields_.length()); | 158 fields_.Rewind(that->fields_.length()); |
157 } | 159 } |
158 for (int i = 0; i < fields_.length(); i++) { | 160 for (int i = 0; i < fields_.length(); i++) { |
159 // Merge the field approximations for like fields. | 161 // Merge the field approximations for like fields. |
160 HFieldApproximation* approx = fields_[i]; | 162 HFieldApproximation* approx = fields_[i]; |
161 HFieldApproximation* prev = NULL; | 163 HFieldApproximation* prev = NULL; |
162 while (approx != NULL) { | 164 while (approx != NULL) { |
163 // TODO(titzer): Merging is O(N * M); sort? | 165 // TODO(titzer): Merging is O(N * M); sort? |
164 HFieldApproximation* other = that->Find(approx->object_, i); | 166 HFieldApproximation* other = that->Find(approx->object_, i); |
165 if (other == NULL || !Equal(approx->last_value_, other->last_value_)) { | 167 if (other == NULL || !Equal(approx->last_value_, other->last_value_)) { |
166 // Kill an entry that doesn't agree with the other value. | 168 // Kill an entry that doesn't agree with the other value. |
167 if (prev != NULL) { | 169 if (prev != NULL) { |
168 prev->next_ = approx->next_; | 170 prev->next_ = approx->next_; |
169 } else { | 171 } else { |
170 fields_[i] = approx->next_; | 172 fields_[i] = approx->next_; |
171 } | 173 } |
172 approx = approx->next_; | 174 approx = approx->next_; |
173 continue; | 175 continue; |
174 } | 176 } |
175 prev = approx; | 177 prev = approx; |
176 approx = approx->next_; | 178 approx = approx->next_; |
177 } | 179 } |
178 } | 180 } |
179 return this; | |
180 } | 181 } |
181 | 182 |
182 friend class HLoadEliminationEffects; // Calls Kill() and others. | 183 friend class HLoadEliminationEffects; // Calls Kill() and others. |
183 friend class HLoadEliminationPhase; | 184 friend class HLoadEliminationPhase; |
184 | 185 |
185 private: | 186 private: |
186 // Process a load instruction, updating internal table state. If a previous | 187 // Process a load instruction, updating internal table state. If a previous |
187 // load or store for this object and field exists, return the new value with | 188 // load or store for this object and field exists, return the new value with |
188 // which the load should be replaced. Otherwise, return {instr}. | 189 // which the load should be replaced. Otherwise, return {instr}. |
189 HValue* load(HLoadNamedField* instr) { | 190 HValue* load(HLoadNamedField* instr) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 } else { | 498 } else { |
498 // Perform only local analysis. | 499 // Perform only local analysis. |
499 for (int i = 0; i < graph()->blocks()->length(); i++) { | 500 for (int i = 0; i < graph()->blocks()->length(); i++) { |
500 table->Kill(); | 501 table->Kill(); |
501 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); | 502 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); |
502 } | 503 } |
503 } | 504 } |
504 } | 505 } |
505 | 506 |
506 } } // namespace v8::internal | 507 } } // namespace v8::internal |
OLD | NEW |