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 successor | 135 // Support for global analysis with HFlowEngine: Merge given state with |
136 // block. | 136 // the other incoming state. |
| 137 static HLoadEliminationTable* Merge(HLoadEliminationTable* succ_state, |
| 138 HBasicBlock* succ_block, |
| 139 HLoadEliminationTable* pred_state, |
| 140 HBasicBlock* pred_block, |
| 141 Zone* zone) { |
| 142 ASSERT(pred_state != NULL); |
| 143 if (succ_state == NULL) { |
| 144 return pred_state->Copy(succ_block, pred_block, zone); |
| 145 } else { |
| 146 return succ_state->Merge(succ_block, pred_state, pred_block, zone); |
| 147 } |
| 148 } |
| 149 |
| 150 // Support for global analysis with HFlowEngine: Given state merged with all |
| 151 // the other incoming states, prepare it for use. |
| 152 static HLoadEliminationTable* Finish(HLoadEliminationTable* state, |
| 153 HBasicBlock* block, |
| 154 Zone* zone) { |
| 155 ASSERT(state != NULL); |
| 156 return state; |
| 157 } |
| 158 |
| 159 private: |
| 160 // Copy state to successor block. |
137 HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, | 161 HLoadEliminationTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, |
138 Zone* zone) { | 162 Zone* zone) { |
139 HLoadEliminationTable* copy = | 163 HLoadEliminationTable* copy = |
140 new(zone) HLoadEliminationTable(zone, aliasing_); | 164 new(zone) HLoadEliminationTable(zone, aliasing_); |
141 copy->EnsureFields(fields_.length()); | 165 copy->EnsureFields(fields_.length()); |
142 for (int i = 0; i < fields_.length(); i++) { | 166 for (int i = 0; i < fields_.length(); i++) { |
143 copy->fields_[i] = fields_[i]->Copy(zone); | 167 copy->fields_[i] = fields_[i]->Copy(zone); |
144 } | 168 } |
145 if (FLAG_trace_load_elimination) { | 169 if (FLAG_trace_load_elimination) { |
146 TRACE((" copy-to B%d\n", succ->block_id())); | 170 TRACE((" copy-to B%d\n", succ->block_id())); |
147 copy->Print(); | 171 copy->Print(); |
148 } | 172 } |
149 return copy; | 173 return copy; |
150 } | 174 } |
151 | 175 |
152 // Support for global analysis with HFlowEngine: Merge this state with | 176 // Merge this state with the other incoming state. |
153 // the other incoming state. | |
154 HLoadEliminationTable* Merge(HBasicBlock* succ, HLoadEliminationTable* that, | 177 HLoadEliminationTable* Merge(HBasicBlock* succ, HLoadEliminationTable* that, |
155 HBasicBlock* that_block, Zone* zone) { | 178 HBasicBlock* that_block, Zone* zone) { |
156 if (that->fields_.length() < fields_.length()) { | 179 if (that->fields_.length() < fields_.length()) { |
157 // Drop fields not in the other table. | 180 // Drop fields not in the other table. |
158 fields_.Rewind(that->fields_.length()); | 181 fields_.Rewind(that->fields_.length()); |
159 } | 182 } |
160 for (int i = 0; i < fields_.length(); i++) { | 183 for (int i = 0; i < fields_.length(); i++) { |
161 // Merge the field approximations for like fields. | 184 // Merge the field approximations for like fields. |
162 HFieldApproximation* approx = fields_[i]; | 185 HFieldApproximation* approx = fields_[i]; |
163 HFieldApproximation* prev = NULL; | 186 HFieldApproximation* prev = NULL; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } else { | 539 } else { |
517 // Perform only local analysis. | 540 // Perform only local analysis. |
518 for (int i = 0; i < graph()->blocks()->length(); i++) { | 541 for (int i = 0; i < graph()->blocks()->length(); i++) { |
519 table->Kill(); | 542 table->Kill(); |
520 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); | 543 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); |
521 } | 544 } |
522 } | 545 } |
523 } | 546 } |
524 | 547 |
525 } } // namespace v8::internal | 548 } } // namespace v8::internal |
OLD | NEW |