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/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
11 #include "vm/longjump.h" | 11 #include "vm/longjump.h" |
12 #include "vm/log.h" | 12 #include "vm/log.h" |
13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
14 #include "vm/report.h" | 14 #include "vm/report.h" |
15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
19 DEFINE_FLAG(bool, print_classes, false, "Prints details about loaded classes."); | 19 DEFINE_FLAG(bool, print_classes, false, "Prints details about loaded classes."); |
20 DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization."); | 20 DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization."); |
21 DEFINE_FLAG(bool, trace_type_finalization, false, "Trace type finalization."); | 21 DEFINE_FLAG(bool, trace_type_finalization, false, "Trace type finalization."); |
22 DECLARE_FLAG(bool, supermixin); | |
23 DECLARE_FLAG(bool, use_cha_deopt); | 22 DECLARE_FLAG(bool, use_cha_deopt); |
24 | 23 |
25 | 24 |
26 bool ClassFinalizer::AllClassesFinalized() { | 25 bool ClassFinalizer::AllClassesFinalized() { |
27 ObjectStore* object_store = Isolate::Current()->object_store(); | 26 ObjectStore* object_store = Isolate::Current()->object_store(); |
28 const GrowableObjectArray& classes = | 27 const GrowableObjectArray& classes = |
29 GrowableObjectArray::Handle(object_store->pending_classes()); | 28 GrowableObjectArray::Handle(object_store->pending_classes()); |
30 return classes.Length() == 0; | 29 return classes.Length() == 0; |
31 } | 30 } |
32 | 31 |
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 | 2024 |
2026 // Check for illegal self references. | 2025 // Check for illegal self references. |
2027 GrowableArray<intptr_t> visited_mixins; | 2026 GrowableArray<intptr_t> visited_mixins; |
2028 if (!IsMixinCycleFree(mixin_class, &visited_mixins)) { | 2027 if (!IsMixinCycleFree(mixin_class, &visited_mixins)) { |
2029 const String& class_name = String::Handle(mixin_class.Name()); | 2028 const String& class_name = String::Handle(mixin_class.Name()); |
2030 ReportError(mixin_class, mixin_class.token_pos(), | 2029 ReportError(mixin_class, mixin_class.token_pos(), |
2031 "mixin class '%s' illegally refers to itself", | 2030 "mixin class '%s' illegally refers to itself", |
2032 class_name.ToCString()); | 2031 class_name.ToCString()); |
2033 } | 2032 } |
2034 | 2033 |
2035 if (!FLAG_supermixin) { | |
2036 // Check that the super class of the mixin class is class Object. | |
2037 Class& mixin_super_class = Class::Handle(mixin_class.SuperClass()); | |
2038 // Skip over mixin application alias classes, which are implemented as | |
2039 // subclasses of the mixin application classes they name. | |
2040 if (!mixin_super_class.IsNull() && mixin_class.is_mixin_app_alias()) { | |
2041 while (mixin_super_class.is_mixin_app_alias()) { | |
2042 mixin_super_class = mixin_super_class.SuperClass(); | |
2043 } | |
2044 mixin_super_class = mixin_super_class.SuperClass(); | |
2045 } | |
2046 if (mixin_super_class.IsNull() || !mixin_super_class.IsObjectClass()) { | |
2047 const String& class_name = String::Handle(mixin_class.Name()); | |
2048 ReportError(mixin_app_class, mixin_app_class.token_pos(), | |
2049 "mixin class '%s' must extend class 'Object'", | |
2050 class_name.ToCString()); | |
2051 } | |
2052 } | |
2053 | |
2054 // Copy type parameters to mixin application class. | 2034 // Copy type parameters to mixin application class. |
2055 CloneMixinAppTypeParameters(mixin_app_class); | 2035 CloneMixinAppTypeParameters(mixin_app_class); |
2056 | 2036 |
2057 // Verify that no restricted class is used as a mixin by checking the | 2037 // Verify that no restricted class is used as a mixin by checking the |
2058 // interfaces of the mixin application class, which implements its mixin. | 2038 // interfaces of the mixin application class, which implements its mixin. |
2059 GrowableArray<intptr_t> visited_interfaces; | 2039 GrowableArray<intptr_t> visited_interfaces; |
2060 ResolveSuperTypeAndInterfaces(mixin_app_class, &visited_interfaces); | 2040 ResolveSuperTypeAndInterfaces(mixin_app_class, &visited_interfaces); |
2061 | 2041 |
2062 if (FLAG_trace_class_finalization) { | 2042 if (FLAG_trace_class_finalization) { |
2063 THR_Print("Done applying mixin type '%s' to class '%s' %s extending '%s'\n", | 2043 THR_Print("Done applying mixin type '%s' to class '%s' %s extending '%s'\n", |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3220 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3200 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3221 field ^= fields_array.At(0); | 3201 field ^= fields_array.At(0); |
3222 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3202 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3223 name ^= field.name(); | 3203 name ^= field.name(); |
3224 expected_name ^= String::New("_data"); | 3204 expected_name ^= String::New("_data"); |
3225 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3205 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3226 #endif | 3206 #endif |
3227 } | 3207 } |
3228 | 3208 |
3229 } // namespace dart | 3209 } // namespace dart |
OLD | NEW |