| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 4137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4148 // Host CheckSmi instruction and make this phi smi one. | 4148 // Host CheckSmi instruction and make this phi smi one. |
| 4149 Hoist(it, pre_header, current); | 4149 Hoist(it, pre_header, current); |
| 4150 | 4150 |
| 4151 // Replace value we are checking with phi's input. | 4151 // Replace value we are checking with phi's input. |
| 4152 current->value()->BindTo(phi->InputAt(non_smi_input)->definition()); | 4152 current->value()->BindTo(phi->InputAt(non_smi_input)->definition()); |
| 4153 | 4153 |
| 4154 phi->UpdateType(CompileType::FromCid(kSmiCid)); | 4154 phi->UpdateType(CompileType::FromCid(kSmiCid)); |
| 4155 } | 4155 } |
| 4156 | 4156 |
| 4157 | 4157 |
| 4158 // Load instructions handled by load elimination. |
| 4159 static bool IsCandidateLoad(Instruction* instr) { |
| 4160 return instr->IsLoadField() |
| 4161 || instr->IsLoadIndexed() |
| 4162 || instr->IsLoadStaticField() |
| 4163 || instr->IsCurrentContext(); |
| 4164 } |
| 4165 |
| 4166 |
| 4158 static bool IsLoopInvariantLoad(ZoneGrowableArray<BitVector*>* sets, | 4167 static bool IsLoopInvariantLoad(ZoneGrowableArray<BitVector*>* sets, |
| 4159 intptr_t loop_header_index, | 4168 intptr_t loop_header_index, |
| 4160 Instruction* instr) { | 4169 Instruction* instr) { |
| 4161 return (sets != NULL) && | 4170 return IsCandidateLoad(instr) && |
| 4171 (sets != NULL) && |
| 4162 instr->HasPlaceId() && | 4172 instr->HasPlaceId() && |
| 4163 ((*sets)[loop_header_index] != NULL) && | 4173 ((*sets)[loop_header_index] != NULL) && |
| 4164 (*sets)[loop_header_index]->Contains(instr->place_id()); | 4174 (*sets)[loop_header_index]->Contains(instr->place_id()); |
| 4165 } | 4175 } |
| 4166 | 4176 |
| 4167 | 4177 |
| 4168 void LICM::Optimize() { | 4178 void LICM::Optimize() { |
| 4169 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers = | 4179 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers = |
| 4170 flow_graph()->loop_headers(); | 4180 flow_graph()->loop_headers(); |
| 4171 | 4181 |
| (...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6436 StoreInstanceFieldInstr* instr) { | 6446 StoreInstanceFieldInstr* instr) { |
| 6437 SetValue(instr, instr->value()->definition()->constant_value()); | 6447 SetValue(instr, instr->value()->definition()->constant_value()); |
| 6438 } | 6448 } |
| 6439 | 6449 |
| 6440 | 6450 |
| 6441 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) { | 6451 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) { |
| 6442 const Field& field = instr->StaticField(); | 6452 const Field& field = instr->StaticField(); |
| 6443 ASSERT(field.is_static()); | 6453 ASSERT(field.is_static()); |
| 6444 if (field.is_final()) { | 6454 if (field.is_final()) { |
| 6445 Instance& obj = Instance::Handle(field.value()); | 6455 Instance& obj = Instance::Handle(field.value()); |
| 6456 ASSERT(obj.raw() != Object::sentinel().raw()); |
| 6457 ASSERT(obj.raw() != Object::transition_sentinel().raw()); |
| 6446 if (obj.IsSmi() || obj.IsOld()) { | 6458 if (obj.IsSmi() || obj.IsOld()) { |
| 6447 SetValue(instr, obj); | 6459 SetValue(instr, obj); |
| 6448 return; | 6460 return; |
| 6449 } | 6461 } |
| 6450 } | 6462 } |
| 6451 SetValue(instr, non_constant_); | 6463 SetValue(instr, non_constant_); |
| 6452 } | 6464 } |
| 6453 | 6465 |
| 6454 | 6466 |
| 6455 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) { | 6467 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) { |
| (...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7872 } | 7884 } |
| 7873 | 7885 |
| 7874 // Insert materializations at environment uses. | 7886 // Insert materializations at environment uses. |
| 7875 for (intptr_t i = 0; i < exits.length(); i++) { | 7887 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7876 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7888 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7877 } | 7889 } |
| 7878 } | 7890 } |
| 7879 | 7891 |
| 7880 | 7892 |
| 7881 } // namespace dart | 7893 } // namespace dart |
| OLD | NEW |