Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: runtime/vm/cha.cc

Issue 24558002: VM: Fix CHA for Object. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 ASSERT(!cls.IsNull()); 66 ASSERT(!cls.IsNull());
67 ZoneGrowableArray<intptr_t>* ids = new ZoneGrowableArray<intptr_t>(); 67 ZoneGrowableArray<intptr_t>* ids = new ZoneGrowableArray<intptr_t>();
68 CollectSubclassIds(ids, cls); 68 CollectSubclassIds(ids, cls);
69 return ids; 69 return ids;
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
77 // exist.
78 if (cls.IsObjectClass()) return true;
79
76 if (cls_direct_subclasses.IsNull()) { 80 if (cls_direct_subclasses.IsNull()) {
77 return false; 81 return false;
78 } 82 }
79 Class& direct_subclass = Class::Handle(); 83 Class& direct_subclass = Class::Handle();
80 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { 84 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) {
81 direct_subclass ^= cls_direct_subclasses.At(i); 85 direct_subclass ^= cls_direct_subclasses.At(i);
82 if (direct_subclass.LookupDynamicFunction(function_name) != 86 if (direct_subclass.LookupDynamicFunction(function_name) !=
83 Function::null()) { 87 Function::null()) {
84 return true; 88 return true;
85 } 89 }
(...skipping 30 matching lines...) Expand all
116 ASSERT(!function.IsNull()); 120 ASSERT(!function.IsNull());
117 ASSERT(function.IsDynamicFunction()); 121 ASSERT(function.IsDynamicFunction());
118 const Class& function_owner = Class::Handle(function.Owner()); 122 const Class& function_owner = Class::Handle(function.Owner());
119 const String& function_name = String::Handle(function.name()); 123 const String& function_name = String::Handle(function.name());
120 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>(); 124 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>();
121 CollectSubclassIds(cids, function_owner); 125 CollectSubclassIds(cids, function_owner);
122 return GetNamedInstanceFunctionsOf(*cids, function_name); 126 return GetNamedInstanceFunctionsOf(*cids, function_name);
123 } 127 }
124 128
125 } // namespace dart 129 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698