| 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/constant_propagator.h" | 5 #include "vm/constant_propagator.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
| 10 #include "vm/flow_graph_range_analysis.h" | 10 #include "vm/flow_graph_range_analysis.h" |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 Z, Smi::New(TypedData::Cast(constant->value()).Length()))); | 852 Z, Smi::New(TypedData::Cast(constant->value()).Length()))); |
| 853 return; | 853 return; |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 } | 856 } |
| 857 SetValue(instr, non_constant_); | 857 SetValue(instr, non_constant_); |
| 858 } | 858 } |
| 859 | 859 |
| 860 | 860 |
| 861 void ConstantPropagator::VisitInstantiateType(InstantiateTypeInstr* instr) { | 861 void ConstantPropagator::VisitInstantiateType(InstantiateTypeInstr* instr) { |
| 862 const Object& object = instr->instantiator()->definition()->constant_value(); | 862 const Object& object = |
| 863 instr->instantiator_type_arguments()->definition()->constant_value(); |
| 864 // TODO(regis): Check function type arguments. |
| 863 if (IsNonConstant(object)) { | 865 if (IsNonConstant(object)) { |
| 864 SetValue(instr, non_constant_); | 866 SetValue(instr, non_constant_); |
| 865 return; | 867 return; |
| 866 } | 868 } |
| 867 if (IsConstant(object)) { | 869 if (IsConstant(object)) { |
| 868 if (instr->type().IsTypeParameter()) { | 870 if (instr->type().IsTypeParameter()) { |
| 869 if (object.IsNull()) { | 871 if (object.IsNull()) { |
| 870 SetValue(instr, Object::dynamic_type()); | 872 SetValue(instr, Object::dynamic_type()); |
| 871 return; | 873 return; |
| 872 } | 874 } |
| 873 // We could try to instantiate the type parameter and return it if no | 875 // We could try to instantiate the type parameter and return it if no |
| 874 // malformed error is reported. | 876 // malformed error is reported. |
| 875 } | 877 } |
| 876 SetValue(instr, non_constant_); | 878 SetValue(instr, non_constant_); |
| 877 } | 879 } |
| 878 } | 880 } |
| 879 | 881 |
| 880 | 882 |
| 881 void ConstantPropagator::VisitInstantiateTypeArguments( | 883 void ConstantPropagator::VisitInstantiateTypeArguments( |
| 882 InstantiateTypeArgumentsInstr* instr) { | 884 InstantiateTypeArgumentsInstr* instr) { |
| 883 const Object& object = instr->instantiator()->definition()->constant_value(); | 885 const Object& object = |
| 886 instr->instantiator_type_arguments()->definition()->constant_value(); |
| 887 // TODO(regis): Check function type arguments. |
| 884 if (IsNonConstant(object)) { | 888 if (IsNonConstant(object)) { |
| 885 SetValue(instr, non_constant_); | 889 SetValue(instr, non_constant_); |
| 886 return; | 890 return; |
| 887 } | 891 } |
| 888 if (IsConstant(object)) { | 892 if (IsConstant(object)) { |
| 889 const intptr_t len = instr->type_arguments().Length(); | 893 const intptr_t len = instr->type_arguments().Length(); |
| 890 if (instr->type_arguments().IsRawInstantiatedRaw(len) && object.IsNull()) { | 894 if (instr->type_arguments().IsRawInstantiatedRaw(len) && object.IsNull()) { |
| 891 SetValue(instr, object); | 895 SetValue(instr, object); |
| 892 return; | 896 return; |
| 893 } | 897 } |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 GrowableArray<BitVector*> dominance_frontier; | 1716 GrowableArray<BitVector*> dominance_frontier; |
| 1713 graph_->ComputeDominators(&dominance_frontier); | 1717 graph_->ComputeDominators(&dominance_frontier); |
| 1714 | 1718 |
| 1715 if (FLAG_trace_constant_propagation && | 1719 if (FLAG_trace_constant_propagation && |
| 1716 FlowGraphPrinter::ShouldPrint(graph_->function())) { | 1720 FlowGraphPrinter::ShouldPrint(graph_->function())) { |
| 1717 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1721 FlowGraphPrinter::PrintGraph("After CP", graph_); |
| 1718 } | 1722 } |
| 1719 } | 1723 } |
| 1720 | 1724 |
| 1721 } // namespace dart | 1725 } // namespace dart |
| OLD | NEW |