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/class_finalizer.h" | 5 #include "vm/class_finalizer.h" |
6 | 6 |
7 #include "vm/code_generator.h" | 7 #include "vm/code_generator.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/hash_table.h" | 9 #include "vm/hash_table.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 if (FLAG_trace_type_finalization) { | 1156 if (FLAG_trace_type_finalization) { |
1157 THR_Print("Finalizing type '%s' for class '%s'\n", | 1157 THR_Print("Finalizing type '%s' for class '%s'\n", |
1158 String::Handle(zone, type.Name()).ToCString(), | 1158 String::Handle(zone, type.Name()).ToCString(), |
1159 String::Handle(zone, cls.Name()).ToCString()); | 1159 String::Handle(zone, cls.Name()).ToCString()); |
1160 } | 1160 } |
1161 | 1161 |
1162 if (type.IsTypeParameter()) { | 1162 if (type.IsTypeParameter()) { |
1163 const TypeParameter& type_parameter = TypeParameter::Cast(type); | 1163 const TypeParameter& type_parameter = TypeParameter::Cast(type); |
1164 const Class& parameterized_class = | 1164 const Class& parameterized_class = |
1165 Class::Handle(zone, type_parameter.parameterized_class()); | 1165 Class::Handle(zone, type_parameter.parameterized_class()); |
1166 ASSERT(!parameterized_class.IsNull()); | 1166 if (!parameterized_class.IsNull()) { |
1167 // The index must reflect the position of this type parameter in the type | 1167 // The index must reflect the position of this type parameter in the type |
1168 // arguments vector of its parameterized class. The offset to add is the | 1168 // arguments vector of its parameterized class. The offset to add is the |
1169 // number of type arguments in the super type, which is equal to the | 1169 // number of type arguments in the super type, which is equal to the |
1170 // difference in number of type arguments and type parameters of the | 1170 // difference in number of type arguments and type parameters of the |
1171 // parameterized class. | 1171 // parameterized class. |
1172 const intptr_t offset = parameterized_class.NumTypeArguments() - | 1172 const intptr_t offset = parameterized_class.NumTypeArguments() - |
1173 parameterized_class.NumTypeParameters(); | 1173 parameterized_class.NumTypeParameters(); |
1174 // Calling NumTypeParameters() may finalize this type parameter if it | 1174 // Calling NumTypeParameters() may finalize this type parameter if it |
1175 // belongs to a mixin application class. | 1175 // belongs to a mixin application class. |
1176 if (!type_parameter.IsFinalized()) { | 1176 if (!type_parameter.IsFinalized()) { |
1177 type_parameter.set_index(type_parameter.index() + offset); | 1177 type_parameter.set_index(type_parameter.index() + offset); |
1178 type_parameter.SetIsFinalized(); | 1178 type_parameter.SetIsFinalized(); |
| 1179 } else { |
| 1180 ASSERT(cls.IsMixinApplication()); |
| 1181 } |
1179 } else { | 1182 } else { |
1180 ASSERT(cls.IsMixinApplication()); | 1183 // A function type parameter is always finalized. |
| 1184 ASSERT(type_parameter.IsFinalized()); |
1181 } | 1185 } |
1182 | 1186 |
1183 if (FLAG_trace_type_finalization) { | 1187 if (FLAG_trace_type_finalization) { |
1184 THR_Print("Done finalizing type parameter '%s' with index %" Pd "\n", | 1188 THR_Print("Done finalizing type parameter '%s' with index %" Pd "\n", |
1185 String::Handle(zone, type_parameter.name()).ToCString(), | 1189 String::Handle(zone, type_parameter.name()).ToCString(), |
1186 type_parameter.index()); | 1190 type_parameter.index()); |
1187 } | 1191 } |
1188 | 1192 |
1189 // We do not canonicalize type parameters. | 1193 // We do not canonicalize type parameters. |
1190 return type_parameter.raw(); | 1194 return type_parameter.raw(); |
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3704 ProgramVisitor::VisitFunctions(&function_visitor); | 3708 ProgramVisitor::VisitFunctions(&function_visitor); |
3705 | 3709 |
3706 class ClearCodeClassVisitor : public ClassVisitor { | 3710 class ClearCodeClassVisitor : public ClassVisitor { |
3707 void Visit(const Class& cls) { cls.DisableAllocationStub(); } | 3711 void Visit(const Class& cls) { cls.DisableAllocationStub(); } |
3708 }; | 3712 }; |
3709 ClearCodeClassVisitor class_visitor; | 3713 ClearCodeClassVisitor class_visitor; |
3710 ProgramVisitor::VisitClasses(&class_visitor); | 3714 ProgramVisitor::VisitClasses(&class_visitor); |
3711 } | 3715 } |
3712 | 3716 |
3713 } // namespace dart | 3717 } // namespace dart |
OLD | NEW |