| 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 3080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3091 // Returns a Boolean constant if all classes in ic_data yield the same type-test | 3091 // Returns a Boolean constant if all classes in ic_data yield the same type-test |
| 3092 // result and the type tests do not depend on type arguments. Otherwise return | 3092 // result and the type tests do not depend on type arguments. Otherwise return |
| 3093 // Bool::null(). | 3093 // Bool::null(). |
| 3094 RawBool* FlowGraphOptimizer::InstanceOfAsBool(const ICData& ic_data, | 3094 RawBool* FlowGraphOptimizer::InstanceOfAsBool(const ICData& ic_data, |
| 3095 const AbstractType& type) const { | 3095 const AbstractType& type) const { |
| 3096 ASSERT(ic_data.num_args_tested() == 1); // Unary checks only. | 3096 ASSERT(ic_data.num_args_tested() == 1); // Unary checks only. |
| 3097 if (!type.IsInstantiated() || type.IsMalformedOrMalbounded()) { | 3097 if (!type.IsInstantiated() || type.IsMalformedOrMalbounded()) { |
| 3098 return Bool::null(); | 3098 return Bool::null(); |
| 3099 } | 3099 } |
| 3100 const Class& type_class = Class::Handle(type.type_class()); | 3100 const Class& type_class = Class::Handle(type.type_class()); |
| 3101 if (type_class.NumTypeArguments() > 0) { | 3101 const intptr_t num_type_args = type_class.NumTypeArguments(); |
| 3102 if (num_type_args > 0) { |
| 3102 // Only raw types can be directly compared, thus disregarding type | 3103 // Only raw types can be directly compared, thus disregarding type |
| 3103 // arguments. | 3104 // arguments. |
| 3105 const intptr_t num_type_params = type_class.NumTypeParameters(); |
| 3106 const intptr_t from_index = num_type_args - num_type_params; |
| 3104 const AbstractTypeArguments& type_arguments = | 3107 const AbstractTypeArguments& type_arguments = |
| 3105 AbstractTypeArguments::Handle(type.arguments()); | 3108 AbstractTypeArguments::Handle(type.arguments()); |
| 3106 const bool is_raw_type = type_arguments.IsNull() || | 3109 const bool is_raw_type = type_arguments.IsNull() || |
| 3107 type_arguments.IsRaw(type_arguments.Length()); | 3110 type_arguments.IsRaw(from_index, num_type_params); |
| 3108 if (!is_raw_type) { | 3111 if (!is_raw_type) { |
| 3109 // Unknown result. | 3112 // Unknown result. |
| 3110 return Bool::null(); | 3113 return Bool::null(); |
| 3111 } | 3114 } |
| 3112 } | 3115 } |
| 3113 const ClassTable& class_table = *Isolate::Current()->class_table(); | 3116 const ClassTable& class_table = *Isolate::Current()->class_table(); |
| 3114 Bool& prev = Bool::Handle(); | 3117 Bool& prev = Bool::Handle(); |
| 3115 Class& cls = Class::Handle(); | 3118 Class& cls = Class::Handle(); |
| 3116 for (int i = 0; i < ic_data.NumberOfChecks(); i++) { | 3119 for (int i = 0; i < ic_data.NumberOfChecks(); i++) { |
| 3117 cls = class_table.At(ic_data.GetReceiverClassIdAt(i)); | 3120 cls = class_table.At(ic_data.GetReceiverClassIdAt(i)); |
| (...skipping 4895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8013 } | 8016 } |
| 8014 | 8017 |
| 8015 // Insert materializations at environment uses. | 8018 // Insert materializations at environment uses. |
| 8016 for (intptr_t i = 0; i < exits.length(); i++) { | 8019 for (intptr_t i = 0; i < exits.length(); i++) { |
| 8017 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 8020 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 8018 } | 8021 } |
| 8019 } | 8022 } |
| 8020 | 8023 |
| 8021 | 8024 |
| 8022 } // namespace dart | 8025 } // namespace dart |
| OLD | NEW |