| 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" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // read-only. | 55 // read-only. |
| 56 // TODO(fschneider): Enable tracking of CHA dependent code for VM heap | 56 // TODO(fschneider): Enable tracking of CHA dependent code for VM heap |
| 57 // classes. | 57 // classes. |
| 58 if (cls.InVMHeap()) return true; | 58 if (cls.InVMHeap()) return true; |
| 59 | 59 |
| 60 return cls.is_implemented(); | 60 return cls.is_implemented(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 bool CHA::HasOverride(const Class& cls, const String& function_name) { | 64 bool CHA::HasOverride(const Class& cls, const String& function_name) { |
| 65 const GrowableObjectArray& cls_direct_subclasses = | 65 // Can't track dependencies for classes on the VM heap since those are |
| 66 GrowableObjectArray::Handle(thread_->zone(), cls.direct_subclasses()); | 66 // read-only. |
| 67 // TODO(fschneider): Enable tracking of CHA dependent code for VM heap |
| 68 // classes. |
| 69 if (cls.InVMHeap()) return true; |
| 70 |
| 67 // Subclasses of Object are not tracked by CHA. Safely assume that overrides | 71 // Subclasses of Object are not tracked by CHA. Safely assume that overrides |
| 68 // exist. | 72 // exist. |
| 69 if (cls.IsObjectClass()) { | 73 if (cls.IsObjectClass()) { |
| 70 return true; | 74 return true; |
| 71 } | 75 } |
| 72 | 76 |
| 77 const GrowableObjectArray& cls_direct_subclasses = |
| 78 GrowableObjectArray::Handle(thread_->zone(), cls.direct_subclasses()); |
| 73 if (cls_direct_subclasses.IsNull()) { | 79 if (cls_direct_subclasses.IsNull()) { |
| 74 return false; | 80 return false; |
| 75 } | 81 } |
| 76 Class& direct_subclass = Class::Handle(thread_->zone()); | 82 Class& direct_subclass = Class::Handle(thread_->zone()); |
| 77 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { | 83 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { |
| 78 direct_subclass ^= cls_direct_subclasses.At(i); | 84 direct_subclass ^= cls_direct_subclasses.At(i); |
| 79 // Unfinalized classes are treated as non-existent for CHA purposes, | 85 // Unfinalized classes are treated as non-existent for CHA purposes, |
| 80 // as that means that no instance of that class exists at runtime. | 86 // as that means that no instance of that class exists at runtime. |
| 81 if (direct_subclass.is_finalized() && | 87 if (direct_subclass.is_finalized() && |
| 82 (direct_subclass.LookupDynamicFunction(function_name) != | 88 (direct_subclass.LookupDynamicFunction(function_name) != |
| 83 Function::null())) { | 89 Function::null())) { |
| 84 return true; | 90 return true; |
| 85 } | 91 } |
| 86 if (HasOverride(direct_subclass, function_name)) { | 92 if (HasOverride(direct_subclass, function_name)) { |
| 87 return true; | 93 return true; |
| 88 } | 94 } |
| 89 } | 95 } |
| 90 return false; | 96 return false; |
| 91 } | 97 } |
| 92 | 98 |
| 93 } // namespace dart | 99 } // namespace dart |
| OLD | NEW |