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

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

Issue 11275110: Do not recompute unary_checks repeatedly. Add special (and quicker) way to check for method overrid… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/cha.h ('k') | runtime/vm/flow_graph_optimizer.h » ('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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
74 const GrowableObjectArray& cls_direct_subclasses =
75 GrowableObjectArray::Handle(cls.direct_subclasses());
76 if (cls_direct_subclasses.IsNull()) {
77 return false;
78 }
79 Class& direct_subclass = Class::Handle();
80 for (intptr_t i = 0; i < cls_direct_subclasses.Length(); i++) {
81 direct_subclass ^= cls_direct_subclasses.At(i);
82 if (direct_subclass.LookupDynamicFunction(function_name) !=
83 Function::null()) {
84 return true;
85 }
86 if (HasOverride(direct_subclass, function_name)) {
87 return true;
88 }
89 }
90 return false;
91 }
92
93
73 ZoneGrowableArray<Function*>* CHA::GetNamedInstanceFunctionsOf( 94 ZoneGrowableArray<Function*>* CHA::GetNamedInstanceFunctionsOf(
74 const ZoneGrowableArray<intptr_t>& cids, 95 const ZoneGrowableArray<intptr_t>& cids,
75 const String& function_name) { 96 const String& function_name) {
76 ASSERT(!function_name.IsNull()); 97 ASSERT(!function_name.IsNull());
77 const ClassTable& class_table = *Isolate::Current()->class_table(); 98 const ClassTable& class_table = *Isolate::Current()->class_table();
78 ZoneGrowableArray<Function*>* functions = new ZoneGrowableArray<Function*>(); 99 ZoneGrowableArray<Function*>* functions = new ZoneGrowableArray<Function*>();
79 Class& cls = Class::Handle(); 100 Class& cls = Class::Handle();
80 Function& cls_function = Function::Handle(); 101 Function& cls_function = Function::Handle();
81 for (intptr_t i = 0; i < cids.length(); i++) { 102 for (intptr_t i = 0; i < cids.length(); i++) {
82 const intptr_t cid = cids[i]; 103 const intptr_t cid = cids[i];
(...skipping 12 matching lines...) Expand all
95 ASSERT(!function.IsNull()); 116 ASSERT(!function.IsNull());
96 ASSERT(function.IsDynamicFunction()); 117 ASSERT(function.IsDynamicFunction());
97 const Class& function_owner = Class::Handle(function.Owner()); 118 const Class& function_owner = Class::Handle(function.Owner());
98 const String& function_name = String::Handle(function.name()); 119 const String& function_name = String::Handle(function.name());
99 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>(); 120 ZoneGrowableArray<intptr_t>* cids = new ZoneGrowableArray<intptr_t>();
100 CollectSubclassIds(cids, function_owner); 121 CollectSubclassIds(cids, function_owner);
101 return GetNamedInstanceFunctionsOf(*cids, function_name); 122 return GetNamedInstanceFunctionsOf(*cids, function_name);
102 } 123 }
103 124
104 } // namespace dart 125 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/cha.h ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698