Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 bool CHA::HasOverride(const Class& cls, const String& function_name) { | 73 bool CHA::HasOverride(const Class& cls, const String& function_name) { |
| 74 const GrowableObjectArray& cls_direct_subclasses = | 74 const GrowableObjectArray& cls_direct_subclasses = |
| 75 GrowableObjectArray::Handle(cls.direct_subclasses()); | 75 GrowableObjectArray::Handle(cls.direct_subclasses()); |
| 76 // Subclasses of Object are not tracked by CHA. Safely assume that overrides | 76 // Subclasses of Object are not tracked by CHA. Safely assume that overrides |
| 77 // exist. | 77 // exist. |
| 78 if (cls.IsObjectClass()) return true; | 78 if (cls.IsObjectClass()) return true; |
| 79 | 79 |
| 80 if (cls_direct_subclasses.IsNull()) { | 80 if (cls_direct_subclasses.IsNull()) { |
|
Ivan Posva
2013/11/21 23:04:09
We should initialize this with an empty array if n
srdjan
2013/11/22 00:08:14
direct_subclasses_ is of type GrowablObjectArray.
| |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 Class& direct_subclass = Class::Handle(); | 83 Class& direct_subclass = Class::Handle(); |
| 84 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { | 84 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { |
| 85 direct_subclass ^= cls_direct_subclasses.At(i); | 85 direct_subclass ^= cls_direct_subclasses.At(i); |
| 86 if (direct_subclass.LookupDynamicFunction(function_name) != | 86 // Unfinalized classes are treated as non-existent for CHA purposes, |
| 87 // as that means that no instance of that class exists at runtime. | |
| 88 if (direct_subclass.is_finalized() && | |
| 89 direct_subclass.LookupDynamicFunction(function_name) != | |
|
regis
2013/11/21 21:48:18
missing parenthesis
srdjan
2013/11/21 22:25:00
Done.
| |
| 87 Function::null()) { | 90 Function::null()) { |
| 88 return true; | 91 return true; |
| 89 } | 92 } |
| 90 if (HasOverride(direct_subclass, function_name)) { | 93 if (HasOverride(direct_subclass, function_name)) { |
| 91 return true; | 94 return true; |
| 92 } | 95 } |
| 93 } | 96 } |
| 94 return false; | 97 return false; |
| 95 } | 98 } |
| 96 | 99 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 120 ASSERT(!function.IsNull()); | 123 ASSERT(!function.IsNull()); |
| 121 ASSERT(function.IsDynamicFunction()); | 124 ASSERT(function.IsDynamicFunction()); |
| 122 const Class& function_owner = Class::Handle(function.Owner()); | 125 const Class& function_owner = Class::Handle(function.Owner()); |
| 123 const String& function_name = String::Handle(function.name()); | 126 const String& function_name = String::Handle(function.name()); |
| 124 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>(); | 127 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>(); |
| 125 CollectSubclassIds(cids, function_owner); | 128 CollectSubclassIds(cids, function_owner); |
| 126 return GetNamedInstanceFunctionsOf(*cids, function_name); | 129 return GetNamedInstanceFunctionsOf(*cids, function_name); |
| 127 } | 130 } |
| 128 | 131 |
| 129 } // namespace dart | 132 } // namespace dart |
| OLD | NEW |