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

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

Issue 2941643002: Check for a passed-in type argument vector in the prolog of generic functions. (Closed)
Patch Set: address review comments Created 3 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/parser.cc ('k') | runtime/vm/scopes.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/runtime_entry.h" 5 #include "vm/runtime_entry.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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 for (intptr_t i = 0; i < len; ++i) { 511 for (intptr_t i = 0; i < len; ++i) {
512 new_cache.GetCheck(i, &last_instance_class_id_or_function, 512 new_cache.GetCheck(i, &last_instance_class_id_or_function,
513 &last_instance_type_arguments, 513 &last_instance_type_arguments,
514 &last_instantiator_type_arguments, 514 &last_instantiator_type_arguments,
515 &last_function_type_arguments, &last_result); 515 &last_function_type_arguments, &last_result);
516 if ((last_instance_class_id_or_function.raw() == 516 if ((last_instance_class_id_or_function.raw() ==
517 instance_class_id_or_function.raw()) && 517 instance_class_id_or_function.raw()) &&
518 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) && 518 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) &&
519 (last_instantiator_type_arguments.raw() == 519 (last_instantiator_type_arguments.raw() ==
520 instantiator_type_arguments.raw()) && 520 instantiator_type_arguments.raw()) &&
521 (last_function_type_arguments.raw() == 521 (last_function_type_arguments.raw() == function_type_arguments.raw())) {
522 last_function_type_arguments.raw())) {
523 OS::PrintErr(" Error in test cache %p ix: %" Pd ",", new_cache.raw(), i); 522 OS::PrintErr(" Error in test cache %p ix: %" Pd ",", new_cache.raw(), i);
524 PrintTypeCheck(" duplicate cache entry", instance, type, 523 PrintTypeCheck(" duplicate cache entry", instance, type,
525 instantiator_type_arguments, function_type_arguments, 524 instantiator_type_arguments, function_type_arguments,
526 result); 525 result);
527 UNREACHABLE(); 526 UNREACHABLE();
528 return; 527 return;
529 } 528 }
530 } 529 }
531 #endif 530 #endif
532 new_cache.AddCheck(instance_class_id_or_function, instance_type_arguments, 531 new_cache.AddCheck(instance_class_id_or_function, instance_type_arguments,
533 instantiator_type_arguments, function_type_arguments, 532 instantiator_type_arguments, function_type_arguments,
534 result); 533 result);
535 if (FLAG_trace_type_checks) { 534 if (FLAG_trace_type_checks) {
536 AbstractType& test_type = AbstractType::Handle(type.raw()); 535 AbstractType& test_type = AbstractType::Handle(type.raw());
537 if (!test_type.IsInstantiated()) { 536 if (!test_type.IsInstantiated()) {
538 Error& bound_error = Error::Handle(); 537 Error& bound_error = Error::Handle();
539 test_type = type.InstantiateFrom(instantiator_type_arguments, 538 test_type = type.InstantiateFrom(instantiator_type_arguments,
540 function_type_arguments, &bound_error, 539 function_type_arguments, &bound_error,
541 NULL, NULL, Heap::kNew); 540 NULL, NULL, Heap::kNew);
542 ASSERT(bound_error.IsNull()); // Malbounded types are not optimized. 541 ASSERT(bound_error.IsNull()); // Malbounded types are not optimized.
543 } 542 }
544 OS::PrintErr( 543 OS::PrintErr(
545 " Updated test cache %p ix: %" Pd 544 " Updated test cache %p ix: %" Pd
546 " with " 545 " with "
547 "(cid-or-fun: %p, type-args: %p, i-type-args: %p, f-type-args: %p, " 546 "(cid-or-fun: %p, type-args: %p, i-type-args: %p, f-type-args: %p, "
548 "result: %s)\n" 547 "result: %s)\n"
549 " instance [class: (%p '%s' cid: %" Pd 548 " instance [class: (%p '%s' cid: %" Pd
550 "), type-args: %p %s]\n" 549 "), type-args: %p %s]\n"
551 " test-type [class: (%p '%s' cid: %" Pd 550 " test-type [class: (%p '%s' cid: %" Pd
552 "), i-type-args: %p %s, " 551 "), i-type-args: %p %s, f-type-args: %p %s]\n",
553 ", f-type-args: %p %s]\n",
554 new_cache.raw(), len, 552 new_cache.raw(), len,
555 553
556 instance_class_id_or_function.raw(), instance_type_arguments.raw(), 554 instance_class_id_or_function.raw(), instance_type_arguments.raw(),
557 instantiator_type_arguments.raw(), instantiator_type_arguments.raw(), 555 instantiator_type_arguments.raw(), instantiator_type_arguments.raw(),
558 result.ToCString(), 556 result.ToCString(),
559 557
560 instance_class.raw(), String::Handle(instance_class.Name()).ToCString(), 558 instance_class.raw(), String::Handle(instance_class.Name()).ToCString(),
561 instance_class.id(), instance_type_arguments.raw(), 559 instance_class.id(), instance_type_arguments.raw(),
562 instance_type_arguments.ToCString(), 560 instance_type_arguments.ToCString(),
563 561
564 test_type.type_class(), 562 test_type.type_class(),
565 String::Handle(Class::Handle(test_type.type_class()).Name()) 563 String::Handle(Class::Handle(test_type.type_class()).Name())
566 .ToCString(), 564 .ToCString(),
567 Class::Handle(test_type.type_class()).id(), 565 Class::Handle(test_type.type_class()).id(),
568 instantiator_type_arguments.raw(), 566 instantiator_type_arguments.raw(),
569 instantiator_type_arguments.ToCString(), 567 instantiator_type_arguments.ToCString(), function_type_arguments.raw(),
570 instantiator_type_arguments.raw(), 568 function_type_arguments.ToCString());
571 instantiator_type_arguments.ToCString());
572 } 569 }
573 } 570 }
574 571
575 572
576 // Check that the given instance is an instance of the given type. 573 // Check that the given instance is an instance of the given type.
577 // Tested instance may not be null, because the null test is inlined. 574 // Tested instance may not be null, because the null test is inlined.
578 // Arg0: instance being checked. 575 // Arg0: instance being checked.
579 // Arg1: type. 576 // Arg1: type.
580 // Arg2: type arguments of the instantiator of the type. 577 // Arg2: type arguments of the instantiator of the type.
581 // Arg3: type arguments of the function of the type. 578 // Arg3: type arguments of the function of the type.
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 const intptr_t new_size = 2 * old_size; 2351 const intptr_t new_size = 2 * old_size;
2355 const intptr_t elm_size = old_data.ElementSizeInBytes(); 2352 const intptr_t elm_size = old_data.ElementSizeInBytes();
2356 const TypedData& new_data = 2353 const TypedData& new_data =
2357 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); 2354 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld));
2358 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); 2355 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size);
2359 typed_data_cell.SetAt(0, new_data); 2356 typed_data_cell.SetAt(0, new_data);
2360 arguments.SetReturn(new_data); 2357 arguments.SetReturn(new_data);
2361 } 2358 }
2362 2359
2363 } // namespace dart 2360 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698