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

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

Issue 1186113011: Some cleanup and be more conservative when guessing cids: use only current leaf classes; otherwise … (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: y Created 5 years, 6 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
« no previous file with comments | « runtime/vm/cha_test.cc ('k') | runtime/vm/flow_graph_type_propagator.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 157
158 // TODO(srdjan): Test/support other number types as well. 158 // TODO(srdjan): Test/support other number types as well.
159 static bool IsNumberCid(intptr_t cid) { 159 static bool IsNumberCid(intptr_t cid) {
160 return (cid == kSmiCid) || (cid == kDoubleCid); 160 return (cid == kSmiCid) || (cid == kDoubleCid);
161 } 161 }
162 162
163 163
164 // Attempt to build ICData for call using propagated class-ids. 164 // Attempt to build ICData for call using propagated class-ids.
165 bool FlowGraphOptimizer::TryCreateICData(InstanceCallInstr* call) { 165 bool FlowGraphOptimizer::TryCreateICData(InstanceCallInstr* call) {
166 return false;
167 ASSERT(call->HasICData()); 166 ASSERT(call->HasICData());
168 if (call->ic_data()->NumberOfChecks() > 0) { 167 if (call->ic_data()->NumberOfChecks() > 0) {
169 // This occurs when an instance call has too many checks, will be converted 168 // This occurs when an instance call has too many checks, will be converted
170 // to megamorphic call. 169 // to megamorphic call.
171 return false; 170 return false;
172 } 171 }
173 if (FLAG_warn_on_javascript_compatibility) { 172 if (FLAG_warn_on_javascript_compatibility) {
174 // Do not make the instance call megamorphic if the callee needs to decode 173 // Do not make the instance call megamorphic if the callee needs to decode
175 // the calling code sequence to lookup the ic data and verify if a warning 174 // the calling code sequence to lookup the ic data and verify if a warning
176 // has already been issued or not. 175 // has already been issued or not.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 ASSERT(class_ids.length() == 1); 234 ASSERT(class_ids.length() == 1);
236 call->ic_data()->AddReceiverCheck(class_ids[0], function); 235 call->ic_data()->AddReceiverCheck(class_ids[0], function);
237 } 236 }
238 return true; 237 return true;
239 } 238 }
240 239
241 // Check if getter or setter 240 // Check if getter or setter
242 if ((call->token_kind() == Token::kGET) || 241 if ((call->token_kind() == Token::kGET) ||
243 (call->token_kind() == Token::kSET)) { 242 (call->token_kind() == Token::kSET)) {
244 const Class& owner_class = Class::Handle(Z, function().Owner()); 243 const Class& owner_class = Class::Handle(Z, function().Owner());
245 if (!owner_class.is_abstract()) { 244 if (!owner_class.is_abstract() &&
245 !CHA::HasSubclasses(owner_class) &&
246 !CHA::IsImplemented(owner_class)) {
246 // Quite aggressive: if functions's owner has a a getter/setter of that 247 // Quite aggressive: if functions's owner has a a getter/setter of that
247 // name we add a check and call the setter directly. Considerable 248 // name we add a check and call the setter directly. Considerable
248 // performance improvement, some increase in code space. 249 // performance improvement, some increase in code space.
249 // TODO(srdjan): Make sure the getter/setters can be inlined. 250 // TODO(srdjan): Make sure the getter/setters can be inlined.
250 const Array& args_desc_array = Array::Handle(Z, 251 const Array& args_desc_array = Array::Handle(Z,
251 ArgumentsDescriptor::New(call->ArgumentCount(), 252 ArgumentsDescriptor::New(call->ArgumentCount(),
252 call->argument_names())); 253 call->argument_names()));
253 ArgumentsDescriptor args_desc(args_desc_array); 254 ArgumentsDescriptor args_desc(args_desc_array);
254 const Function& function = Function::Handle(Z, 255 const Function& function = Function::Handle(Z,
255 Resolver::ResolveDynamicForReceiverClass(owner_class, 256 Resolver::ResolveDynamicForReceiverClass(owner_class,
(...skipping 3745 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 4002
4002 // Returns true if checking against this type is a direct class id comparison. 4003 // Returns true if checking against this type is a direct class id comparison.
4003 bool FlowGraphOptimizer::TypeCheckAsClassEquality(const AbstractType& type) { 4004 bool FlowGraphOptimizer::TypeCheckAsClassEquality(const AbstractType& type) {
4004 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); 4005 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
4005 // Requires CHA. 4006 // Requires CHA.
4006 if (!type.IsInstantiated()) return false; 4007 if (!type.IsInstantiated()) return false;
4007 const Class& type_class = Class::Handle(type.type_class()); 4008 const Class& type_class = Class::Handle(type.type_class());
4008 // Signature classes have different type checking rules. 4009 // Signature classes have different type checking rules.
4009 if (type_class.IsSignatureClass()) return false; 4010 if (type_class.IsSignatureClass()) return false;
4010 // Could be an interface check? 4011 // Could be an interface check?
4011 if (thread()->cha()->IsImplemented(type_class)) return false; 4012 if (CHA::IsImplemented(type_class)) return false;
4012 // Check if there are subclasses. 4013 // Check if there are subclasses.
4013 if (thread()->cha()->HasSubclasses(type_class)) { 4014 if (CHA::HasSubclasses(type_class)) {
4014 return false; 4015 return false;
4015 } 4016 }
4016 4017
4017 // Private classes cannot be subclassed by later loaded libs. 4018 // Private classes cannot be subclassed by later loaded libs.
4018 if (!type_class.IsPrivate()) { 4019 if (!type_class.IsPrivate()) {
4019 if (FLAG_use_cha_deopt) { 4020 if (FLAG_use_cha_deopt) {
4020 thread()->cha()->AddToLeafClasses(type_class); 4021 thread()->cha()->AddToLeafClasses(type_class);
4021 } else { 4022 } else {
4022 return false; 4023 return false;
4023 } 4024 }
(...skipping 4696 matching lines...) Expand 10 before | Expand all | Expand 10 after
8720 8721
8721 // Insert materializations at environment uses. 8722 // Insert materializations at environment uses.
8722 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { 8723 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) {
8723 CreateMaterializationAt( 8724 CreateMaterializationAt(
8724 exits_collector_.exits()[i], alloc, *slots); 8725 exits_collector_.exits()[i], alloc, *slots);
8725 } 8726 }
8726 } 8727 }
8727 8728
8728 8729
8729 } // namespace dart 8730 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/cha_test.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698