| 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/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 4426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4437 } | 4437 } |
| 4438 return changed; | 4438 return changed; |
| 4439 } | 4439 } |
| 4440 | 4440 |
| 4441 | 4441 |
| 4442 ConstantPropagator::ConstantPropagator( | 4442 ConstantPropagator::ConstantPropagator( |
| 4443 FlowGraph* graph, | 4443 FlowGraph* graph, |
| 4444 const GrowableArray<BlockEntryInstr*>& ignored) | 4444 const GrowableArray<BlockEntryInstr*>& ignored) |
| 4445 : FlowGraphVisitor(ignored), | 4445 : FlowGraphVisitor(ignored), |
| 4446 graph_(graph), | 4446 graph_(graph), |
| 4447 unknown_(Object::transition_sentinel()), | 4447 unknown_(Object::unknown_constant()), |
| 4448 non_constant_(Object::sentinel()), | 4448 non_constant_(Object::non_constant()), |
| 4449 reachable_(new BitVector(graph->preorder().length())), | 4449 reachable_(new BitVector(graph->preorder().length())), |
| 4450 definition_marks_(new BitVector(graph->max_virtual_register_number())), | 4450 definition_marks_(new BitVector(graph->max_virtual_register_number())), |
| 4451 block_worklist_(), | 4451 block_worklist_(), |
| 4452 definition_worklist_() {} | 4452 definition_worklist_() {} |
| 4453 | 4453 |
| 4454 | 4454 |
| 4455 void ConstantPropagator::Optimize(FlowGraph* graph) { | 4455 void ConstantPropagator::Optimize(FlowGraph* graph) { |
| 4456 GrowableArray<BlockEntryInstr*> ignored; | 4456 GrowableArray<BlockEntryInstr*> ignored; |
| 4457 ConstantPropagator cp(graph, ignored); | 4457 ConstantPropagator cp(graph, ignored); |
| 4458 cp.Analyze(); | 4458 cp.Analyze(); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4875 } | 4875 } |
| 4876 | 4876 |
| 4877 | 4877 |
| 4878 void ConstantPropagator::VisitStoreInstanceField( | 4878 void ConstantPropagator::VisitStoreInstanceField( |
| 4879 StoreInstanceFieldInstr* instr) { | 4879 StoreInstanceFieldInstr* instr) { |
| 4880 SetValue(instr, instr->value()->definition()->constant_value()); | 4880 SetValue(instr, instr->value()->definition()->constant_value()); |
| 4881 } | 4881 } |
| 4882 | 4882 |
| 4883 | 4883 |
| 4884 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) { | 4884 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) { |
| 4885 const Field& field = instr->field(); |
| 4886 ASSERT(field.is_static()); |
| 4887 if (field.is_final()) { |
| 4888 Instance& obj = Instance::Handle(field.value()); |
| 4889 if (obj.IsSmi() || obj.IsOld()) { |
| 4890 SetValue(instr, obj); |
| 4891 return; |
| 4892 } |
| 4893 } |
| 4885 SetValue(instr, non_constant_); | 4894 SetValue(instr, non_constant_); |
| 4886 } | 4895 } |
| 4887 | 4896 |
| 4888 | 4897 |
| 4889 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) { | 4898 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) { |
| 4890 SetValue(instr, instr->value()->definition()->constant_value()); | 4899 SetValue(instr, instr->value()->definition()->constant_value()); |
| 4891 } | 4900 } |
| 4892 | 4901 |
| 4893 | 4902 |
| 4894 void ConstantPropagator::VisitBooleanNegate(BooleanNegateInstr* instr) { | 4903 void ConstantPropagator::VisitBooleanNegate(BooleanNegateInstr* instr) { |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6145 | 6154 |
| 6146 // Insert materializations at environment uses. | 6155 // Insert materializations at environment uses. |
| 6147 const Class& cls = Class::Handle(alloc->constructor().Owner()); | 6156 const Class& cls = Class::Handle(alloc->constructor().Owner()); |
| 6148 for (intptr_t i = 0; i < exits.length(); i++) { | 6157 for (intptr_t i = 0; i < exits.length(); i++) { |
| 6149 CreateMaterializationAt(exits[i], alloc, cls, *fields); | 6158 CreateMaterializationAt(exits[i], alloc, cls, *fields); |
| 6150 } | 6159 } |
| 6151 } | 6160 } |
| 6152 | 6161 |
| 6153 | 6162 |
| 6154 } // namespace dart | 6163 } // namespace dart |
| OLD | NEW |