| 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/cha.h" | 5 #include "vm/cha.h" |
| 6 #include "vm/class_table.h" | 6 #include "vm/class_table.h" |
| 7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/freelist.h" | 8 #include "vm/freelist.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/raw_object.h" | 10 #include "vm/raw_object.h" |
| 11 #include "vm/visitor.h" | 11 #include "vm/visitor.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 // Return true if the class is private to our internal libraries (not extendable | |
| 16 // or implementable after startup). Therefore, we don't need to register | |
| 17 // optimized code for invalidation for those classes. | |
| 18 // TODO(fschneider): Allow more libraries. | |
| 19 static bool IsKnownPrivateClass(const Class& type_class) { | |
| 20 if (!Library::IsPrivate(String::Handle(type_class.Name()))) return false; | |
| 21 const Library& library = Library::Handle(type_class.library()); | |
| 22 if (library.raw() == Library::CoreLibrary()) return true; | |
| 23 if (library.raw() == Library::CollectionLibrary()) return true; | |
| 24 if (library.raw() == Library::TypedDataLibrary()) return true; | |
| 25 if (library.raw() == Library::MathLibrary()) return true; | |
| 26 return false; | |
| 27 } | |
| 28 | |
| 29 | |
| 30 void CHA::AddToLeafClasses(const Class& cls) { | 15 void CHA::AddToLeafClasses(const Class& cls) { |
| 31 if (IsKnownPrivateClass(cls)) return; | |
| 32 | |
| 33 for (intptr_t i = 0; i < leaf_classes_.length(); i++) { | 16 for (intptr_t i = 0; i < leaf_classes_.length(); i++) { |
| 34 if (leaf_classes_[i]->raw() == cls.raw()) { | 17 if (leaf_classes_[i]->raw() == cls.raw()) { |
| 35 return; | 18 return; |
| 36 } | 19 } |
| 37 } | 20 } |
| 38 leaf_classes_.Add(&Class::ZoneHandle(isolate_, cls.raw())); | 21 leaf_classes_.Add(&Class::ZoneHandle(isolate_, cls.raw())); |
| 39 } | 22 } |
| 40 | 23 |
| 41 | 24 |
| 42 bool CHA::HasSubclasses(const Class& cls) { | 25 bool CHA::HasSubclasses(const Class& cls) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 95 } |
| 113 if (HasOverride(direct_subclass, function_name)) { | 96 if (HasOverride(direct_subclass, function_name)) { |
| 114 return true; | 97 return true; |
| 115 } | 98 } |
| 116 } | 99 } |
| 117 AddToLeafClasses(cls); | 100 AddToLeafClasses(cls); |
| 118 return false; | 101 return false; |
| 119 } | 102 } |
| 120 | 103 |
| 121 } // namespace dart | 104 } // namespace dart |
| OLD | NEW |