| 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/object_store.h" | 12 #include "vm/object_store.h" |
| 13 #include "vm/report.h" | 13 #include "vm/report.h" |
| 14 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 DEFINE_FLAG(bool, error_on_bad_override, false, | 18 DEFINE_FLAG(bool, error_on_bad_override, false, |
| 19 "Report error for bad overrides."); | 19 "Report error for bad overrides."); |
| 20 DEFINE_FLAG(bool, error_on_bad_type, false, | 20 DEFINE_FLAG(bool, error_on_bad_type, false, |
| 21 "Report error for malformed types."); | 21 "Report error for malformed types."); |
| 22 DEFINE_FLAG(bool, print_classes, false, "Prints details about loaded classes."); | 22 DEFINE_FLAG(bool, print_classes, false, "Prints details about loaded classes."); |
| 23 DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization."); | 23 DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization."); |
| 24 DEFINE_FLAG(bool, trace_type_finalization, false, "Trace type finalization."); | 24 DEFINE_FLAG(bool, trace_type_finalization, false, "Trace type finalization."); |
| 25 DECLARE_FLAG(bool, use_cha); | 25 DECLARE_FLAG(bool, use_cha_deopt); |
| 26 | 26 |
| 27 | 27 |
| 28 bool ClassFinalizer::AllClassesFinalized() { | 28 bool ClassFinalizer::AllClassesFinalized() { |
| 29 ObjectStore* object_store = Isolate::Current()->object_store(); | 29 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 30 const GrowableObjectArray& classes = | 30 const GrowableObjectArray& classes = |
| 31 GrowableObjectArray::Handle(object_store->pending_classes()); | 31 GrowableObjectArray::Handle(object_store->pending_classes()); |
| 32 return classes.Length() == 0; | 32 return classes.Length() == 0; |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 // Removes optimized code once we load more classes, since --use_cha based | 36 // Removes optimized code once we load more classes, since CHA based |
| 37 // optimizations may have become invalid. | 37 // optimizations may have become invalid. |
| 38 // Only methods which owner classes where subclasses can be invalid. | 38 // Only methods which owner classes where subclasses can be invalid. |
| 39 // TODO(srdjan): Be even more precise by recording the exact CHA optimization. | 39 // TODO(srdjan): Be even more precise by recording the exact CHA optimization. |
| 40 static void RemoveCHAOptimizedCode( | 40 static void RemoveCHAOptimizedCode( |
| 41 const GrowableArray<intptr_t>& added_subclass_to_cids) { | 41 const GrowableArray<intptr_t>& added_subclass_to_cids) { |
| 42 ASSERT(FLAG_use_cha); | 42 ASSERT(FLAG_use_cha_deopt); |
| 43 if (added_subclass_to_cids.is_empty()) return; | 43 if (added_subclass_to_cids.is_empty()) return; |
| 44 // Switch all functions' code to unoptimized. | 44 // Switch all functions' code to unoptimized. |
| 45 const ClassTable& class_table = *Isolate::Current()->class_table(); | 45 const ClassTable& class_table = *Isolate::Current()->class_table(); |
| 46 Class& cls = Class::Handle(); | 46 Class& cls = Class::Handle(); |
| 47 for (intptr_t i = 0; i < added_subclass_to_cids.length(); i++) { | 47 for (intptr_t i = 0; i < added_subclass_to_cids.length(); i++) { |
| 48 intptr_t cid = added_subclass_to_cids[i]; | 48 intptr_t cid = added_subclass_to_cids[i]; |
| 49 cls = class_table.At(cid); | 49 cls = class_table.At(cid); |
| 50 ASSERT(!cls.IsNull()); | 50 ASSERT(!cls.IsNull()); |
| 51 cls.DisableCHAOptimizedCode(); | 51 cls.DisableCHAOptimizedCode(); |
| 52 } | 52 } |
| (...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2367 // class or a signature class. | 2367 // class or a signature class. |
| 2368 ASSERT(cls.IsTopLevel() || | 2368 ASSERT(cls.IsTopLevel() || |
| 2369 cls.IsSignatureClass() || | 2369 cls.IsSignatureClass() || |
| 2370 (Array::Handle(cls.functions()).Length() > 0)); | 2370 (Array::Handle(cls.functions()).Length() > 0)); |
| 2371 // Resolve and finalize all member types. | 2371 // Resolve and finalize all member types. |
| 2372 ResolveAndFinalizeMemberTypes(cls); | 2372 ResolveAndFinalizeMemberTypes(cls); |
| 2373 // Run additional checks after all types are finalized. | 2373 // Run additional checks after all types are finalized. |
| 2374 if (cls.is_const()) { | 2374 if (cls.is_const()) { |
| 2375 CheckForLegalConstClass(cls); | 2375 CheckForLegalConstClass(cls); |
| 2376 } | 2376 } |
| 2377 if (FLAG_use_cha) { | 2377 if (FLAG_use_cha_deopt) { |
| 2378 GrowableArray<intptr_t> cids; | 2378 GrowableArray<intptr_t> cids; |
| 2379 CollectFinalizedSuperClasses(cls, &cids); | 2379 CollectFinalizedSuperClasses(cls, &cids); |
| 2380 CollectImmediateSuperInterfaces(cls, &cids); | 2380 CollectImmediateSuperInterfaces(cls, &cids); |
| 2381 RemoveCHAOptimizedCode(cids); | 2381 RemoveCHAOptimizedCode(cids); |
| 2382 } | 2382 } |
| 2383 if (cls.is_enum_class()) { | 2383 if (cls.is_enum_class()) { |
| 2384 AllocateEnumValues(cls); | 2384 AllocateEnumValues(cls); |
| 2385 } | 2385 } |
| 2386 } | 2386 } |
| 2387 | 2387 |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3182 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3182 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
| 3183 field ^= fields_array.At(0); | 3183 field ^= fields_array.At(0); |
| 3184 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3184 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
| 3185 name ^= field.name(); | 3185 name ^= field.name(); |
| 3186 expected_name ^= String::New("_data"); | 3186 expected_name ^= String::New("_data"); |
| 3187 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3187 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 3188 #endif | 3188 #endif |
| 3189 } | 3189 } |
| 3190 | 3190 |
| 3191 } // namespace dart | 3191 } // namespace dart |
| OLD | NEW |