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

Side by Side Diff: vm/cha.cc

Issue 12052033: Added macros OBJECT_IMPLEMENTATION and FINAL_OBJECT_IMPLEMENTATION (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 | « vm/bigint_operations.cc ('k') | vm/class_finalizer.cc » ('j') | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Recursively collect direct and indirect subclass ids of cls. 42 // Recursively collect direct and indirect subclass ids of cls.
43 static void CollectSubclassIds(ZoneGrowableArray<intptr_t>* cids, 43 static void CollectSubclassIds(ZoneGrowableArray<intptr_t>* cids,
44 const Class& cls) { 44 const Class& cls) {
45 const GrowableObjectArray& cls_direct_subclasses = 45 const GrowableObjectArray& cls_direct_subclasses =
46 GrowableObjectArray::Handle(cls.direct_subclasses()); 46 GrowableObjectArray::Handle(cls.direct_subclasses());
47 if (cls_direct_subclasses.IsNull()) { 47 if (cls_direct_subclasses.IsNull()) {
48 return; 48 return;
49 } 49 }
50 Class& direct_subclass = Class::Handle(); 50 Class& direct_subclass = Class::Handle();
51 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { 51 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) {
52 direct_subclass |= cls_direct_subclasses.At(i); 52 direct_subclass ^= cls_direct_subclasses.At(i);
53 intptr_t direct_subclass_id = direct_subclass.id(); 53 intptr_t direct_subclass_id = direct_subclass.id();
54 if (!ContainsCid(cids, direct_subclass_id)) { 54 if (!ContainsCid(cids, direct_subclass_id)) {
55 cids->Add(direct_subclass_id); 55 cids->Add(direct_subclass_id);
56 CollectSubclassIds(cids, direct_subclass); 56 CollectSubclassIds(cids, direct_subclass);
57 } 57 }
58 } 58 }
59 } 59 }
60 60
61 61
62 ZoneGrowableArray<intptr_t>* CHA::GetSubclassIdsOf(intptr_t cid) { 62 ZoneGrowableArray<intptr_t>* CHA::GetSubclassIdsOf(intptr_t cid) {
63 ASSERT(cid > kInstanceCid); 63 ASSERT(cid > kInstanceCid);
64 const ClassTable& class_table = *Isolate::Current()->class_table(); 64 const ClassTable& class_table = *Isolate::Current()->class_table();
65 const Class& cls = Class::Handle(class_table.At(cid)); 65 const Class& cls = Class::Handle(class_table.At(cid));
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 if (cls_direct_subclasses.IsNull()) { 76 if (cls_direct_subclasses.IsNull()) {
77 return false; 77 return false;
78 } 78 }
79 Class& direct_subclass = Class::Handle(); 79 Class& direct_subclass = Class::Handle();
80 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { 80 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) {
81 direct_subclass |= cls_direct_subclasses.At(i); 81 direct_subclass ^= cls_direct_subclasses.At(i);
82 if (direct_subclass.LookupDynamicFunction(function_name) != 82 if (direct_subclass.LookupDynamicFunction(function_name) !=
83 Function::null()) { 83 Function::null()) {
84 return true; 84 return true;
85 } 85 }
86 if (HasOverride(direct_subclass, function_name)) { 86 if (HasOverride(direct_subclass, function_name)) {
87 return true; 87 return true;
88 } 88 }
89 } 89 }
90 return false; 90 return false;
91 } 91 }
(...skipping 24 matching lines...) Expand all
116 ASSERT(!function.IsNull()); 116 ASSERT(!function.IsNull());
117 ASSERT(function.IsDynamicFunction()); 117 ASSERT(function.IsDynamicFunction());
118 const Class& function_owner = Class::Handle(function.Owner()); 118 const Class& function_owner = Class::Handle(function.Owner());
119 const String& function_name = String::Handle(function.name()); 119 const String& function_name = String::Handle(function.name());
120 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>(); 120 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>();
121 CollectSubclassIds(cids, function_owner); 121 CollectSubclassIds(cids, function_owner);
122 return GetNamedInstanceFunctionsOf(*cids, function_name); 122 return GetNamedInstanceFunctionsOf(*cids, function_name);
123 } 123 }
124 124
125 } // namespace dart 125 } // namespace dart
OLDNEW
« no previous file with comments | « vm/bigint_operations.cc ('k') | vm/class_finalizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698