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

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

Issue 137983006: Leave uninitialized type arguments of a type being finalized as null instead of (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/object.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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 const intptr_t super_offset = num_super_type_args - num_super_type_params; 570 const intptr_t super_offset = num_super_type_args - num_super_type_params;
571 AbstractType& super_type_arg = AbstractType::Handle(Type::DynamicType()); 571 AbstractType& super_type_arg = AbstractType::Handle(Type::DynamicType());
572 for (intptr_t i = super_offset; i < num_uninitialized_arguments; i++) { 572 for (intptr_t i = super_offset; i < num_uninitialized_arguments; i++) {
573 if (!super_type_args.IsNull()) { 573 if (!super_type_args.IsNull()) {
574 super_type_arg = super_type_args.TypeAt(i); 574 super_type_arg = super_type_args.TypeAt(i);
575 if (!super_type_arg.IsFinalized()) { 575 if (!super_type_arg.IsFinalized()) {
576 super_type_arg ^= FinalizeType( 576 super_type_arg ^= FinalizeType(
577 cls, super_type_arg, kFinalize, pending_types); 577 cls, super_type_arg, kFinalize, pending_types);
578 super_type_args.SetTypeAt(i, super_type_arg); 578 super_type_args.SetTypeAt(i, super_type_arg);
579 } 579 }
580 if (!super_type_arg.IsInstantiated()) { 580 if (!super_type_arg.IsBeingFinalized() &&
581 !super_type_arg.IsInstantiated()) {
581 Error& error = Error::Handle(); 582 Error& error = Error::Handle();
582 super_type_arg = super_type_arg.InstantiateFrom(arguments, &error); 583 super_type_arg = super_type_arg.InstantiateFrom(arguments, &error);
583 if (!error.IsNull()) { 584 if (!error.IsNull()) {
584 // InstantiateFrom does not report an error if the type is still 585 // InstantiateFrom does not report an error if the type is still
585 // uninstantiated. Instead, it will return a new BoundedType so that 586 // uninstantiated. Instead, it will return a new BoundedType so that
586 // the check is postponed to run time. 587 // the check is postponed to run time.
587 ASSERT(super_type_arg.IsInstantiated()); 588 ASSERT(super_type_arg.IsInstantiated());
588 // Keep only the first bound error. 589 // Keep only the first bound error.
589 if (bound_error->IsNull()) { 590 if (bound_error->IsNull()) {
590 *bound_error = error.raw(); 591 *bound_error = error.raw();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 // types have been bound checked. 739 // types have been bound checked.
739 ASSERT((pending_types == NULL) || (finalization < kCanonicalize)); 740 ASSERT((pending_types == NULL) || (finalization < kCanonicalize));
740 if (type.IsFinalized()) { 741 if (type.IsFinalized()) {
741 // Ensure type is canonical if canonicalization is requested, unless type is 742 // Ensure type is canonical if canonicalization is requested, unless type is
742 // malformed. 743 // malformed.
743 if ((finalization >= kCanonicalize) && !type.IsMalformed()) { 744 if ((finalization >= kCanonicalize) && !type.IsMalformed()) {
744 return type.Canonicalize(); 745 return type.Canonicalize();
745 } 746 }
746 return type.raw(); 747 return type.raw();
747 } 748 }
748 ASSERT(type.IsResolved());
749 ASSERT(finalization >= kFinalize); 749 ASSERT(finalization >= kFinalize);
750 750
751 if (type.IsTypeRef()) { 751 if (type.IsTypeRef()) {
752 // The referenced type will be finalized later by the code that set the 752 // The referenced type will be finalized later by the code that set the
753 // is_being_finalized mark bit. 753 // is_being_finalized mark bit.
754 return type.raw(); 754 return type.raw();
755 } 755 }
756 756
757 if (type.IsBeingFinalized()) { 757 if (type.IsBeingFinalized()) {
758 if (FLAG_trace_type_finalization) { 758 if (FLAG_trace_type_finalization) {
759 OS::Print("Creating TypeRef '%s' for class '%s'\n", 759 OS::Print("Creating TypeRef '%s' for class '%s'\n",
760 String::Handle(type.Name()).ToCString(), 760 String::Handle(type.Name()).ToCString(),
761 cls.ToCString()); 761 cls.ToCString());
762 } 762 }
763 return TypeRef::New(type); 763 return TypeRef::New(type);
764 } 764 }
765 765
766 ASSERT(type.IsResolved());
766 if (FLAG_trace_type_finalization) { 767 if (FLAG_trace_type_finalization) {
767 OS::Print("Finalizing type '%s' for class '%s'\n", 768 OS::Print("Finalizing type '%s' for class '%s'\n",
768 String::Handle(type.Name()).ToCString(), 769 String::Handle(type.Name()).ToCString(),
769 cls.ToCString()); 770 cls.ToCString());
770 } 771 }
771 772
772 if (type.IsTypeParameter()) { 773 if (type.IsTypeParameter()) {
773 const TypeParameter& type_parameter = TypeParameter::Cast(type); 774 const TypeParameter& type_parameter = TypeParameter::Cast(type);
774 const Class& parameterized_class = 775 const Class& parameterized_class =
775 Class::Handle(type_parameter.parameterized_class()); 776 Class::Handle(type_parameter.parameterized_class());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 Error& bound_error = Error::Handle(); 858 Error& bound_error = Error::Handle();
858 if (num_type_arguments > 0) { 859 if (num_type_arguments > 0) {
859 // If no type arguments were parsed and if the super types do not prepend 860 // If no type arguments were parsed and if the super types do not prepend
860 // type arguments to the vector, we can leave the vector as null. 861 // type arguments to the vector, we can leave the vector as null.
861 if (!arguments.IsNull() || (num_type_arguments > num_type_parameters)) { 862 if (!arguments.IsNull() || (num_type_arguments > num_type_parameters)) {
862 full_arguments = TypeArguments::New(num_type_arguments); 863 full_arguments = TypeArguments::New(num_type_arguments);
863 // Copy the parsed type arguments at the correct offset in the full type 864 // Copy the parsed type arguments at the correct offset in the full type
864 // argument vector. 865 // argument vector.
865 const intptr_t offset = num_type_arguments - num_type_parameters; 866 const intptr_t offset = num_type_arguments - num_type_parameters;
866 AbstractType& type_arg = AbstractType::Handle(Type::DynamicType()); 867 AbstractType& type_arg = AbstractType::Handle(Type::DynamicType());
867 // TODO(regis): Leave the temporary type argument values as null. 868 // Leave the temporary type arguments at indices [0..offset[ as null.
868 for (intptr_t i = 0; i < offset; i++) {
869 // Temporarily set the type arguments of the super classes to dynamic.
870 full_arguments.SetTypeAt(i, type_arg);
871 }
872 for (intptr_t i = 0; i < num_type_parameters; i++) { 869 for (intptr_t i = 0; i < num_type_parameters; i++) {
873 // If no type parameters were provided, a raw type is desired, so we 870 // If no type parameters were provided, a raw type is desired, so we
874 // create a vector of dynamic. 871 // create a vector of dynamic.
875 if (!arguments.IsNull()) { 872 if (!arguments.IsNull()) {
876 type_arg = arguments.TypeAt(i); 873 type_arg = arguments.TypeAt(i);
877 // The parsed type_arg may or may not be finalized. 874 // The parsed type_arg may or may not be finalized.
878 } 875 }
879 full_arguments.SetTypeAt(offset + i, type_arg); 876 full_arguments.SetTypeAt(offset + i, type_arg);
880 } 877 }
881 // Replace the compile-time argument vector (of length zero or 878 // Replace the compile-time argument vector (of length zero or
(...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after
2849 expected_name ^= String::New("_offset"); 2846 expected_name ^= String::New("_offset");
2850 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 2847 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2851 field ^= fields_array.At(2); 2848 field ^= fields_array.At(2);
2852 ASSERT(field.Offset() == TypedDataView::length_offset()); 2849 ASSERT(field.Offset() == TypedDataView::length_offset());
2853 name ^= field.name(); 2850 name ^= field.name();
2854 ASSERT(name.Equals("length")); 2851 ASSERT(name.Equals("length"));
2855 #endif 2852 #endif
2856 } 2853 }
2857 2854
2858 } // namespace dart 2855 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698