Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/cha.h" | 7 #include "vm/cha.h" |
| 8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/hash_map.h" | 9 #include "vm/hash_map.h" |
| 10 #include "vm/il_printer.h" | 10 #include "vm/il_printer.h" |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 // Current bind was not removed. | 916 // Current bind was not removed. |
| 917 // Cache propagated computation type. | 917 // Cache propagated computation type. |
| 918 AbstractType& computation_type = | 918 AbstractType& computation_type = |
| 919 AbstractType::Handle(bind->computation()->CompileType()); | 919 AbstractType::Handle(bind->computation()->CompileType()); |
| 920 bool changed = bind->SetPropagatedType(computation_type); | 920 bool changed = bind->SetPropagatedType(computation_type); |
| 921 if (changed) { | 921 if (changed) { |
| 922 still_changing_ = true; | 922 still_changing_ = true; |
| 923 } | 923 } |
| 924 // Propagate class ids. | 924 // Propagate class ids. |
| 925 intptr_t cid = bind->computation()->ResultCid(); | 925 intptr_t cid = bind->computation()->ResultCid(); |
| 926 changed = bind->SetPropagatedCid(cid); | 926 if (cid != kIllegalCid) { |
|
regis
2012/08/24 21:30:46
The equivalent of this test for propagated types i
srdjan
2012/08/24 21:39:20
Done.
| |
| 927 if (changed) { | 927 // The definition may produce result. |
| 928 still_changing_ = true; | 928 changed = bind->SetPropagatedCid(cid); |
| 929 if (changed) { | |
| 930 still_changing_ = true; | |
| 931 } | |
| 929 } | 932 } |
| 930 } | 933 } |
| 931 } | 934 } |
| 932 | 935 |
| 933 | 936 |
| 934 void FlowGraphTypePropagator::VisitPhi(PhiInstr* phi) { | 937 void FlowGraphTypePropagator::VisitPhi(PhiInstr* phi) { |
| 935 // We could set the propagated type of the phi to the least upper bound of its | 938 // We could set the propagated type of the phi to the least upper bound of its |
| 936 // input propagated types. However, keeping all propagated types allows us to | 939 // input propagated types. However, keeping all propagated types allows us to |
| 937 // optimize method dispatch. | 940 // optimize method dispatch. |
| 938 // TODO(regis): Support a set of propagated types. For now, we compute the | 941 // TODO(regis): Support a set of propagated types. For now, we compute the |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 962 } | 965 } |
| 963 } | 966 } |
| 964 if (merged_cid == kIllegalCid) { | 967 if (merged_cid == kIllegalCid) { |
| 965 merged_cid = kDynamicCid; | 968 merged_cid = kDynamicCid; |
| 966 } | 969 } |
| 967 changed = phi->SetPropagatedCid(merged_cid); | 970 changed = phi->SetPropagatedCid(merged_cid); |
| 968 if (changed) { | 971 if (changed) { |
| 969 still_changing_ = true; | 972 still_changing_ = true; |
| 970 } | 973 } |
| 971 } | 974 } |
| 972 | 975 |
|
regis
2012/08/24 21:30:46
Accidental remove?
srdjan
2012/08/24 21:39:20
Yes, reinstated the line.
| |
| 973 | |
| 974 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) { | 976 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) { |
| 975 // TODO(regis): Once we inline functions, the propagated type of the formal | 977 // TODO(regis): Once we inline functions, the propagated type of the formal |
| 976 // parameter will reflect the compile type of the passed-in argument. | 978 // parameter will reflect the compile type of the passed-in argument. |
| 977 // For now, we do not know anything about the argument type and therefore set | 979 // For now, we do not know anything about the argument type and therefore set |
| 978 // it to the DynamicType, unless the argument is a compiler generated value, | 980 // it to the DynamicType, unless the argument is a compiler generated value, |
| 979 // i.e. the receiver argument or the constructor phase argument. | 981 // i.e. the receiver argument or the constructor phase argument. |
| 980 AbstractType& param_type = AbstractType::Handle(Type::DynamicType()); | 982 AbstractType& param_type = AbstractType::Handle(Type::DynamicType()); |
| 981 param->SetPropagatedCid(kDynamicCid); | 983 param->SetPropagatedCid(kDynamicCid); |
| 982 if (param->index() < 2) { | 984 if (param->index() < 2) { |
| 983 const Function& function = parsed_function().function(); | 985 const Function& function = parsed_function().function(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. | 1065 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. |
| 1064 OptimizeRecursive(child, &child_map); | 1066 OptimizeRecursive(child, &child_map); |
| 1065 } else { | 1067 } else { |
| 1066 OptimizeRecursive(child, map); // Reuse map for the last child. | 1068 OptimizeRecursive(child, map); // Reuse map for the last child. |
| 1067 } | 1069 } |
| 1068 } | 1070 } |
| 1069 } | 1071 } |
| 1070 | 1072 |
| 1071 | 1073 |
| 1072 } // namespace dart | 1074 } // namespace dart |
| OLD | NEW |