| 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
| 6 | 6 |
| 7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
| 8 | 8 |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 | 1015 |
| 1016 // Returns true if checking against this type is a direct class id comparison. | 1016 // Returns true if checking against this type is a direct class id comparison. |
| 1017 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) { | 1017 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) { |
| 1018 ASSERT(type.IsFinalized() && !type.IsMalformed()); | 1018 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
| 1019 // Requires CHA, which can be applied in optimized code only, | 1019 // Requires CHA, which can be applied in optimized code only, |
| 1020 if (!FLAG_use_cha || !is_optimizing()) return false; | 1020 if (!FLAG_use_cha || !is_optimizing()) return false; |
| 1021 if (!type.IsInstantiated()) return false; | 1021 if (!type.IsInstantiated()) return false; |
| 1022 const Class& type_class = Class::Handle(type.type_class()); | 1022 const Class& type_class = Class::Handle(type.type_class()); |
| 1023 // Signature classes have different type checking rules. |
| 1024 if (type_class.IsSignatureClass()) return false; |
| 1023 // Could be an interface check? | 1025 // Could be an interface check? |
| 1024 if (type_class.is_implemented()) return false; | 1026 if (type_class.is_implemented()) return false; |
| 1025 const intptr_t type_cid = type_class.id(); | 1027 const intptr_t type_cid = type_class.id(); |
| 1026 if (CHA::HasSubclasses(type_cid)) return false; | 1028 if (CHA::HasSubclasses(type_cid)) return false; |
| 1027 if (type_class.HasTypeArguments()) { | 1029 if (type_class.HasTypeArguments()) { |
| 1028 // Only raw types can be directly compared, thus disregarding type | 1030 // Only raw types can be directly compared, thus disregarding type |
| 1029 // arguments. | 1031 // arguments. |
| 1030 const AbstractTypeArguments& type_arguments = | 1032 const AbstractTypeArguments& type_arguments = |
| 1031 AbstractTypeArguments::Handle(type.arguments()); | 1033 AbstractTypeArguments::Handle(type.arguments()); |
| 1032 const bool is_raw_type = type_arguments.IsNull() || | 1034 const bool is_raw_type = type_arguments.IsNull() || |
| 1033 type_arguments.IsRaw(type_arguments.Length()); | 1035 type_arguments.IsRaw(type_arguments.Length()); |
| 1034 return is_raw_type; | 1036 return is_raw_type; |
| 1035 } | 1037 } |
| 1036 return true; | 1038 return true; |
| 1037 } | 1039 } |
| 1038 | 1040 |
| 1039 } // namespace dart | 1041 } // namespace dart |
| OLD | NEW |