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

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

Issue 2818273002: Remove parent_level field of function type parameters. (Closed)
Patch Set: Created 3 years, 8 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
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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 407 }
408 return; 408 return;
409 } 409 }
410 if (instance.IsSmi()) { 410 if (instance.IsSmi()) {
411 if (FLAG_trace_type_checks) { 411 if (FLAG_trace_type_checks) {
412 OS::Print("UpdateTypeTestCache: instance is Smi\n"); 412 OS::Print("UpdateTypeTestCache: instance is Smi\n");
413 } 413 }
414 return; 414 return;
415 } 415 }
416 // If the type is uninstantiated and refers to parent function type 416 // If the type is uninstantiated and refers to parent function type
417 // parameters, the context is required in the type test and the cache 417 // parameters, the function_type_arguments may not have been canonicalized
418 // therefore cannot be used. 418 // when concatenated. The optimization still works, but the cache could grow
419 if (!type.IsInstantiated(kParentFunctions)) { 419 // uncontrollably. For now, do not update the cache in this case.
420 // TODO(regis): Revisit.
421 if (!function_type_arguments.IsNull() &&
422 !function_type_arguments.IsCanonical()) {
420 if (FLAG_trace_type_checks) { 423 if (FLAG_trace_type_checks) {
421 OS::Print( 424 OS::Print(
422 "UpdateTypeTestCache: type refers to parent function's type " 425 "UpdateTypeTestCache: function_type_arguments is not canonical\n");
423 "parameters\n");
424 } 426 }
425 return; 427 return;
426 } 428 }
427 const Class& instance_class = Class::Handle(instance.clazz()); 429 const Class& instance_class = Class::Handle(instance.clazz());
428 Object& instance_class_id_or_function = Object::Handle(); 430 Object& instance_class_id_or_function = Object::Handle();
429 TypeArguments& instance_type_arguments = TypeArguments::Handle(); 431 TypeArguments& instance_type_arguments = TypeArguments::Handle();
430 if (instance_class.IsClosureClass()) { 432 if (instance_class.IsClosureClass()) {
433 // If the closure instance is generic, we cannot perform the optimization,
434 // because one more input (function_type_arguments) would need to be
435 // considered. For now, only perform the optimization if the closure's
436 // function_type_arguments is null, meaning the closure function is not
437 // generic.
438 // TODO(regis): In addition to null (non-generic closure), we should also
439 // accept Object::empty_type_arguments() (non-nested generic closure).
440 // In that case, update stubs and simulator_dbc accordingly.
441 if (Closure::Cast(instance).function_type_arguments() !=
442 TypeArguments::null()) {
443 if (FLAG_trace_type_checks) {
444 OS::Print(
445 "UpdateTypeTestCache: closure function_type_arguments is "
446 "not null\n");
447 }
448 return;
449 }
431 instance_class_id_or_function = Closure::Cast(instance).function(); 450 instance_class_id_or_function = Closure::Cast(instance).function();
432 instance_type_arguments = Closure::Cast(instance).instantiator(); 451 instance_type_arguments =
452 Closure::Cast(instance).instantiator_type_arguments();
433 } else { 453 } else {
434 instance_class_id_or_function = Smi::New(instance_class.id()); 454 instance_class_id_or_function = Smi::New(instance_class.id());
435 if (instance_class.NumTypeArguments() > 0) { 455 if (instance_class.NumTypeArguments() > 0) {
436 instance_type_arguments = instance.GetTypeArguments(); 456 instance_type_arguments = instance.GetTypeArguments();
437 } 457 }
438 } 458 }
439 const intptr_t len = new_cache.NumberOfChecks(); 459 const intptr_t len = new_cache.NumberOfChecks();
440 if (len >= FLAG_max_subtype_cache_entries) { 460 if (len >= FLAG_max_subtype_cache_entries) {
441 return; 461 return;
442 } 462 }
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 const intptr_t elm_size = old_data.ElementSizeInBytes(); 2292 const intptr_t elm_size = old_data.ElementSizeInBytes();
2273 const TypedData& new_data = 2293 const TypedData& new_data =
2274 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); 2294 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld));
2275 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); 2295 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size);
2276 typed_data_cell.SetAt(0, new_data); 2296 typed_data_cell.SetAt(0, new_data);
2277 arguments.SetReturn(new_data); 2297 arguments.SetReturn(new_data);
2278 } 2298 }
2279 2299
2280 2300
2281 } // namespace dart 2301 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698