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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/cha.h ('k') | runtime/vm/cha_test.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"
11 #include "vm/visitor.h" 11 #include "vm/visitor.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 void CHA::AddToGuardedClasses(const Class& cls, intptr_t subclass_count) { 15 void CHA::AddToGuardedClasses(const Class& cls, intptr_t subclass_count) {
16 for (intptr_t i = 0; i < guarded_classes_.length(); i++) { 16 for (intptr_t i = 0; i < guarded_classes_.length(); i++) {
17 if (guarded_classes_[i].cls->raw() == cls.raw()) { 17 if (guarded_classes_[i].cls->raw() == cls.raw()) {
18 return; 18 return;
19 } 19 }
20 } 20 }
21 GuardedClassInfo info = { 21 GuardedClassInfo info = {&Class::ZoneHandle(thread_->zone(), cls.raw()),
22 &Class::ZoneHandle(thread_->zone(), cls.raw()), 22 subclass_count};
23 subclass_count
24 };
25 guarded_classes_.Add(info); 23 guarded_classes_.Add(info);
26 return; 24 return;
27 } 25 }
28 26
29 27
30 bool CHA::IsGuardedClass(intptr_t cid) const { 28 bool CHA::IsGuardedClass(intptr_t cid) const {
31 for (intptr_t i = 0; i < guarded_classes_.length(); ++i) { 29 for (intptr_t i = 0; i < guarded_classes_.length(); ++i) {
32 if (guarded_classes_[i].cls->id() == cid) return true; 30 if (guarded_classes_[i].cls->id() == cid) return true;
33 } 31 }
34 return false; 32 return false;
(...skipping 20 matching lines...) Expand all
55 53
56 54
57 bool CHA::HasSubclasses(intptr_t cid) const { 55 bool CHA::HasSubclasses(intptr_t cid) const {
58 const ClassTable& class_table = *thread_->isolate()->class_table(); 56 const ClassTable& class_table = *thread_->isolate()->class_table();
59 Class& cls = Class::Handle(thread_->zone(), class_table.At(cid)); 57 Class& cls = Class::Handle(thread_->zone(), class_table.At(cid));
60 return HasSubclasses(cls); 58 return HasSubclasses(cls);
61 } 59 }
62 60
63 61
64 bool CHA::ConcreteSubclasses(const Class& cls, 62 bool CHA::ConcreteSubclasses(const Class& cls,
65 GrowableArray<intptr_t> *class_ids) { 63 GrowableArray<intptr_t>* class_ids) {
66 if (cls.InVMHeap()) return false; 64 if (cls.InVMHeap()) return false;
67 if (cls.IsObjectClass()) return false; 65 if (cls.IsObjectClass()) return false;
68 66
69 if (!cls.is_abstract()) { 67 if (!cls.is_abstract()) {
70 class_ids->Add(cls.id()); 68 class_ids->Add(cls.id());
71 } 69 }
72 70
73 const GrowableObjectArray& direct_subclasses = 71 const GrowableObjectArray& direct_subclasses =
74 GrowableObjectArray::Handle(cls.direct_subclasses()); 72 GrowableObjectArray::Handle(cls.direct_subclasses());
75 if (direct_subclasses.IsNull()) { 73 if (direct_subclasses.IsNull()) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 Class& direct_subclass = Class::Handle(thread_->zone()); 152 Class& direct_subclass = Class::Handle(thread_->zone());
155 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) { 153 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) {
156 direct_subclass ^= cls_direct_subclasses.At(i); 154 direct_subclass ^= cls_direct_subclasses.At(i);
157 // Unfinalized classes are treated as non-existent for CHA purposes, 155 // Unfinalized classes are treated as non-existent for CHA purposes,
158 // as that means that no instance of that class exists at runtime. 156 // as that means that no instance of that class exists at runtime.
159 if (!direct_subclass.is_finalized()) { 157 if (!direct_subclass.is_finalized()) {
160 continue; 158 continue;
161 } 159 }
162 160
163 if (direct_subclass.LookupDynamicFunction(function_name) != 161 if (direct_subclass.LookupDynamicFunction(function_name) !=
164 Function::null()) { 162 Function::null()) {
165 return true; 163 return true;
166 } 164 }
167 165
168 if (HasOverride(direct_subclass, function_name, subclasses_count)) { 166 if (HasOverride(direct_subclass, function_name, subclasses_count)) {
169 return true; 167 return true;
170 } 168 }
171 169
172 (*subclasses_count)++; 170 (*subclasses_count)++;
173 } 171 }
174 172
175 return false; 173 return false;
176 } 174 }
177 175
178 176
179 void CHA::RegisterDependencies(const Code& code) const { 177 void CHA::RegisterDependencies(const Code& code) const {
180 for (intptr_t i = 0; i < guarded_classes_.length(); ++i) { 178 for (intptr_t i = 0; i < guarded_classes_.length(); ++i) {
181 guarded_classes_[i].cls->RegisterCHACode(code); 179 guarded_classes_[i].cls->RegisterCHACode(code);
182 } 180 }
183 } 181 }
184 182
185 183
186 } // namespace dart 184 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/cha.h ('k') | runtime/vm/cha_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698