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

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

Issue 26682003: Cache number of type arguments in class object instead of recalculating it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | « runtime/vm/object.h ('k') | runtime/vm/raw_object.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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 474
475 Class fake; 475 Class fake;
476 // Initialization from Class::New<Class>. 476 // Initialization from Class::New<Class>.
477 // Directly set raw_ to break a circular dependency: SetRaw will attempt 477 // Directly set raw_ to break a circular dependency: SetRaw will attempt
478 // to lookup class class in the class table where it is not registered yet. 478 // to lookup class class in the class table where it is not registered yet.
479 cls.raw_ = class_class_; 479 cls.raw_ = class_class_;
480 cls.set_handle_vtable(fake.vtable()); 480 cls.set_handle_vtable(fake.vtable());
481 cls.set_instance_size(Class::InstanceSize()); 481 cls.set_instance_size(Class::InstanceSize());
482 cls.set_next_field_offset(Class::InstanceSize()); 482 cls.set_next_field_offset(Class::InstanceSize());
483 cls.set_id(Class::kClassId); 483 cls.set_id(Class::kClassId);
484 cls.raw_ptr()->state_bits_ = 0; 484 cls.set_state_bits(0);
485 cls.set_is_finalized(); 485 cls.set_is_finalized();
486 cls.set_is_type_finalized(); 486 cls.set_is_type_finalized();
487 cls.raw_ptr()->type_arguments_field_offset_in_words_ = 487 cls.set_type_arguments_field_offset_in_words(Class::kNoTypeArguments);
488 Class::kNoTypeArguments; 488 cls.set_num_type_arguments(0);
489 cls.raw_ptr()->num_native_fields_ = 0; 489 cls.set_num_own_type_arguments(0);
490 cls.set_num_native_fields(0);
490 cls.InitEmptyFields(); 491 cls.InitEmptyFields();
491 isolate->RegisterClass(cls); 492 isolate->RegisterClass(cls);
492 } 493 }
493 494
494 // Allocate and initialize the null class. 495 // Allocate and initialize the null class.
495 cls = Class::New<Instance>(kNullCid); 496 cls = Class::New<Instance>(kNullCid);
497 cls.set_num_type_arguments(0);
498 cls.set_num_own_type_arguments(0);
496 isolate->object_store()->set_null_class(cls); 499 isolate->object_store()->set_null_class(cls);
497 500
498 // Allocate and initialize the free list element class. 501 // Allocate and initialize the free list element class.
499 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); 502 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement);
503 cls.set_num_type_arguments(0);
504 cls.set_num_own_type_arguments(0);
500 cls.set_is_finalized(); 505 cls.set_is_finalized();
501 cls.set_is_type_finalized(); 506 cls.set_is_type_finalized();
502 507
503 // Allocate and initialize the sentinel values of Null class. 508 // Allocate and initialize the sentinel values of Null class.
504 { 509 {
505 *sentinel_ ^= 510 *sentinel_ ^=
506 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); 511 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
507 512
508 *transition_sentinel_ ^= 513 *transition_sentinel_ ^=
509 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld); 514 Object::Allocate(kNullCid, Instance::InstanceSize(), Heap::kOld);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 cls = Class::New<UnwindError>(); 613 cls = Class::New<UnwindError>();
609 unwind_error_class_ = cls.raw(); 614 unwind_error_class_ = cls.raw();
610 615
611 ASSERT(class_class() != null_); 616 ASSERT(class_class() != null_);
612 617
613 // Pre-allocate classes in the vm isolate so that we can for example create a 618 // Pre-allocate classes in the vm isolate so that we can for example create a
614 // symbol table and populate it with some frequently used strings as symbols. 619 // symbol table and populate it with some frequently used strings as symbols.
615 cls = Class::New<Array>(); 620 cls = Class::New<Array>();
616 isolate->object_store()->set_array_class(cls); 621 isolate->object_store()->set_array_class(cls);
617 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); 622 cls.set_type_arguments_field_offset(Array::type_arguments_offset());
623 cls.set_num_type_arguments(1);
624 cls.set_num_own_type_arguments(1);
618 cls = Class::New<Array>(kImmutableArrayCid); 625 cls = Class::New<Array>(kImmutableArrayCid);
619 isolate->object_store()->set_immutable_array_class(cls); 626 isolate->object_store()->set_immutable_array_class(cls);
620 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); 627 cls.set_type_arguments_field_offset(Array::type_arguments_offset());
628 cls.set_num_type_arguments(1);
629 cls.set_num_own_type_arguments(1);
621 cls = Class::NewStringClass(kOneByteStringCid); 630 cls = Class::NewStringClass(kOneByteStringCid);
622 isolate->object_store()->set_one_byte_string_class(cls); 631 isolate->object_store()->set_one_byte_string_class(cls);
623 cls = Class::NewStringClass(kTwoByteStringCid); 632 cls = Class::NewStringClass(kTwoByteStringCid);
624 isolate->object_store()->set_two_byte_string_class(cls); 633 isolate->object_store()->set_two_byte_string_class(cls);
625 634
626 // Allocate and initialize the empty_array instance. 635 // Allocate and initialize the empty_array instance.
627 { 636 {
628 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld); 637 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld);
629 InitializeObject(address, kArrayCid, Array::InstanceSize(0)); 638 InitializeObject(address, kArrayCid, Array::InstanceSize(0));
630 Array::initializeHandle( 639 Array::initializeHandle(
631 empty_array_, 640 empty_array_,
632 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); 641 reinterpret_cast<RawArray*>(address + kHeapObjectTag));
633 empty_array_->raw()->ptr()->length_ = Smi::New(0); 642 empty_array_->raw()->ptr()->length_ = Smi::New(0);
634 } 643 }
635 644
636 cls = Class::New<Instance>(kDynamicCid); 645 cls = Class::New<Instance>(kDynamicCid);
646 cls.set_is_abstract();
647 cls.set_num_type_arguments(0);
648 cls.set_num_own_type_arguments(0);
649 cls.set_is_type_finalized();
637 cls.set_is_finalized(); 650 cls.set_is_finalized();
638 cls.set_is_type_finalized();
639 cls.set_is_abstract();
640 dynamic_class_ = cls.raw(); 651 dynamic_class_ = cls.raw();
641 652
642 cls = Class::New<Instance>(kVoidCid); 653 cls = Class::New<Instance>(kVoidCid);
654 cls.set_num_type_arguments(0);
655 cls.set_num_own_type_arguments(0);
656 cls.set_is_type_finalized();
643 cls.set_is_finalized(); 657 cls.set_is_finalized();
644 cls.set_is_type_finalized();
645 void_class_ = cls.raw(); 658 void_class_ = cls.raw();
646 659
647 cls = Class::New<Type>(); 660 cls = Class::New<Type>();
661 cls.set_is_type_finalized();
648 cls.set_is_finalized(); 662 cls.set_is_finalized();
649 cls.set_is_type_finalized();
650 isolate->object_store()->set_type_class(cls); 663 isolate->object_store()->set_type_class(cls);
651 664
652 cls = dynamic_class_; 665 cls = dynamic_class_;
653 dynamic_type_ = Type::NewNonParameterizedType(cls); 666 dynamic_type_ = Type::NewNonParameterizedType(cls);
654 667
655 cls = void_class_; 668 cls = void_class_;
656 void_type_ = Type::NewNonParameterizedType(cls); 669 void_type_ = Type::NewNonParameterizedType(cls);
657 670
658 // Allocate and initialize singleton true and false boolean objects. 671 // Allocate and initialize singleton true and false boolean objects.
659 cls = Class::New<Bool>(); 672 cls = Class::New<Bool>();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 // All RawArray fields will be initialized to an empty array, therefore 868 // All RawArray fields will be initialized to an empty array, therefore
856 // initialize array class first. 869 // initialize array class first.
857 cls = Class::New<Array>(); 870 cls = Class::New<Array>();
858 object_store->set_array_class(cls); 871 object_store->set_array_class(cls);
859 872
860 // Array and ImmutableArray are the only VM classes that are parameterized. 873 // Array and ImmutableArray are the only VM classes that are parameterized.
861 // Since they are pre-finalized, CalculateFieldOffsets() is not called, so we 874 // Since they are pre-finalized, CalculateFieldOffsets() is not called, so we
862 // need to set the offset of their type_arguments_ field, which is explicitly 875 // need to set the offset of their type_arguments_ field, which is explicitly
863 // declared in RawArray. 876 // declared in RawArray.
864 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); 877 cls.set_type_arguments_field_offset(Array::type_arguments_offset());
878 cls.set_num_type_arguments(1);
879 cls.set_num_own_type_arguments(1);
865 880
866 // Set up the growable object array class (Has to be done after the array 881 // Set up the growable object array class (Has to be done after the array
867 // class is setup as one of its field is an array object). 882 // class is setup as one of its field is an array object).
868 cls = Class::New<GrowableObjectArray>(); 883 cls = Class::New<GrowableObjectArray>();
869 object_store->set_growable_object_array_class(cls); 884 object_store->set_growable_object_array_class(cls);
870 cls.set_type_arguments_field_offset( 885 cls.set_type_arguments_field_offset(
871 GrowableObjectArray::type_arguments_offset()); 886 GrowableObjectArray::type_arguments_offset());
887 cls.set_num_type_arguments(1);
888 cls.set_num_own_type_arguments(1);
872 889
873 // canonical_type_arguments_ are Smi terminated. 890 // canonical_type_arguments_ are Smi terminated.
874 // Last element contains the count of used slots. 891 // Last element contains the count of used slots.
875 const intptr_t kInitialCanonicalTypeArgumentsSize = 4; 892 const intptr_t kInitialCanonicalTypeArgumentsSize = 4;
876 array = Array::New(kInitialCanonicalTypeArgumentsSize + 1); 893 array = Array::New(kInitialCanonicalTypeArgumentsSize + 1);
877 array.SetAt(kInitialCanonicalTypeArgumentsSize, Smi::Handle(Smi::New(0))); 894 array.SetAt(kInitialCanonicalTypeArgumentsSize, Smi::Handle(Smi::New(0)));
878 object_store->set_canonical_type_arguments(array); 895 object_store->set_canonical_type_arguments(array);
879 896
880 // Setup type class early in the process. 897 // Setup type class early in the process.
881 cls = Class::New<Type>(); 898 cls = Class::New<Type>();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 type ^= type.Canonicalize(); 952 type ^= type.Canonicalize();
936 object_store->set_array_type(type); 953 object_store->set_array_type(type);
937 954
938 cls = object_store->growable_object_array_class(); // Was allocated above. 955 cls = object_store->growable_object_array_class(); // Was allocated above.
939 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); 956 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib);
940 pending_classes.Add(cls); 957 pending_classes.Add(cls);
941 958
942 cls = Class::New<Array>(kImmutableArrayCid); 959 cls = Class::New<Array>(kImmutableArrayCid);
943 object_store->set_immutable_array_class(cls); 960 object_store->set_immutable_array_class(cls);
944 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); 961 cls.set_type_arguments_field_offset(Array::type_arguments_offset());
962 cls.set_num_type_arguments(1);
963 cls.set_num_own_type_arguments(1);
945 ASSERT(object_store->immutable_array_class() != object_store->array_class()); 964 ASSERT(object_store->immutable_array_class() != object_store->array_class());
946 cls.set_is_prefinalized(); 965 cls.set_is_prefinalized();
947 RegisterPrivateClass(cls, Symbols::_ImmutableList(), core_lib); 966 RegisterPrivateClass(cls, Symbols::_ImmutableList(), core_lib);
948 pending_classes.Add(cls); 967 pending_classes.Add(cls);
949 968
950 cls = object_store->one_byte_string_class(); // Was allocated above. 969 cls = object_store->one_byte_string_class(); // Was allocated above.
951 RegisterPrivateClass(cls, Symbols::OneByteString(), core_lib); 970 RegisterPrivateClass(cls, Symbols::OneByteString(), core_lib);
952 pending_classes.Add(cls); 971 pending_classes.Add(cls);
953 972
954 cls = object_store->two_byte_string_class(); // Was allocated above. 973 cls = object_store->two_byte_string_class(); // Was allocated above.
(...skipping 23 matching lines...) Expand all
978 997
979 // Initialize the base interfaces used by the core VM classes. 998 // Initialize the base interfaces used by the core VM classes.
980 999
981 // Allocate and initialize the pre-allocated classes in the core library. 1000 // Allocate and initialize the pre-allocated classes in the core library.
982 // The script and token index of these pre-allocated classes is set up in 1001 // The script and token index of these pre-allocated classes is set up in
983 // the parser when the corelib script is compiled (see 1002 // the parser when the corelib script is compiled (see
984 // Parser::ParseClassDefinition). 1003 // Parser::ParseClassDefinition).
985 cls = Class::New<Instance>(kInstanceCid); 1004 cls = Class::New<Instance>(kInstanceCid);
986 object_store->set_object_class(cls); 1005 object_store->set_object_class(cls);
987 cls.set_name(Symbols::Object()); 1006 cls.set_name(Symbols::Object());
1007 cls.set_num_type_arguments(0);
1008 cls.set_num_own_type_arguments(0);
988 cls.set_is_prefinalized(); 1009 cls.set_is_prefinalized();
989 core_lib.AddClass(cls); 1010 core_lib.AddClass(cls);
990 pending_classes.Add(cls); 1011 pending_classes.Add(cls);
991 type = Type::NewNonParameterizedType(cls); 1012 type = Type::NewNonParameterizedType(cls);
992 object_store->set_object_type(type); 1013 object_store->set_object_type(type);
993 1014
994 cls = Class::New<Bool>(); 1015 cls = Class::New<Bool>();
995 object_store->set_bool_class(cls); 1016 object_store->set_bool_class(cls);
996 RegisterClass(cls, Symbols::Bool(), core_lib); 1017 RegisterClass(cls, Symbols::Bool(), core_lib);
997 pending_classes.Add(cls); 1018 pending_classes.Add(cls);
998 1019
999 cls = Class::New<Instance>(kNullCid); 1020 cls = Class::New<Instance>(kNullCid);
1021 object_store->set_null_class(cls);
1022 cls.set_num_type_arguments(0);
1023 cls.set_num_own_type_arguments(0);
1000 cls.set_is_prefinalized(); 1024 cls.set_is_prefinalized();
1001 object_store->set_null_class(cls);
1002 RegisterClass(cls, Symbols::Null(), core_lib); 1025 RegisterClass(cls, Symbols::Null(), core_lib);
1003 pending_classes.Add(cls); 1026 pending_classes.Add(cls);
1004 1027
1005 cls = object_store->type_class(); 1028 cls = object_store->type_class();
1006 RegisterPrivateClass(cls, Symbols::Type(), core_lib); 1029 RegisterPrivateClass(cls, Symbols::Type(), core_lib);
1007 pending_classes.Add(cls); 1030 pending_classes.Add(cls);
1008 1031
1009 cls = object_store->type_parameter_class(); 1032 cls = object_store->type_parameter_class();
1010 RegisterPrivateClass(cls, Symbols::TypeParameter(), core_lib); 1033 RegisterPrivateClass(cls, Symbols::TypeParameter(), core_lib);
1011 pending_classes.Add(cls); 1034 pending_classes.Add(cls);
(...skipping 26 matching lines...) Expand all
1038 RegisterPrivateClass(cls, Symbols::_Bigint(), core_lib); 1061 RegisterPrivateClass(cls, Symbols::_Bigint(), core_lib);
1039 pending_classes.Add(cls); 1062 pending_classes.Add(cls);
1040 1063
1041 cls = Class::New<Double>(); 1064 cls = Class::New<Double>();
1042 object_store->set_double_class(cls); 1065 object_store->set_double_class(cls);
1043 RegisterPrivateClass(cls, Symbols::_Double(), core_lib); 1066 RegisterPrivateClass(cls, Symbols::_Double(), core_lib);
1044 pending_classes.Add(cls); 1067 pending_classes.Add(cls);
1045 1068
1046 // Abstract super class for all signature classes. 1069 // Abstract super class for all signature classes.
1047 cls = Class::New<Instance>(kIllegalCid); 1070 cls = Class::New<Instance>(kIllegalCid);
1071 cls.set_num_type_arguments(0);
1072 cls.set_num_own_type_arguments(0);
1048 cls.set_is_prefinalized(); 1073 cls.set_is_prefinalized();
1049 RegisterPrivateClass(cls, Symbols::FunctionImpl(), core_lib); 1074 RegisterPrivateClass(cls, Symbols::FunctionImpl(), core_lib);
1050 pending_classes.Add(cls); 1075 pending_classes.Add(cls);
1051 type = Type::NewNonParameterizedType(cls); 1076 type = Type::NewNonParameterizedType(cls);
1052 object_store->set_function_impl_type(type); 1077 object_store->set_function_impl_type(type);
1053 1078
1054 cls = Class::New<WeakProperty>(); 1079 cls = Class::New<WeakProperty>();
1055 object_store->set_weak_property_class(cls); 1080 object_store->set_weak_property_class(cls);
1056 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); 1081 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib);
1057 1082
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 // Register Float32x4 and Uint32x4 in the object store. 1150 // Register Float32x4 and Uint32x4 in the object store.
1126 cls = Class::New<Float32x4>(); 1151 cls = Class::New<Float32x4>();
1127 object_store->set_float32x4_class(cls); 1152 object_store->set_float32x4_class(cls);
1128 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib); 1153 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib);
1129 cls = Class::New<Uint32x4>(); 1154 cls = Class::New<Uint32x4>();
1130 object_store->set_uint32x4_class(cls); 1155 object_store->set_uint32x4_class(cls);
1131 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib); 1156 RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib);
1132 1157
1133 cls = Class::New<Instance>(kIllegalCid); 1158 cls = Class::New<Instance>(kIllegalCid);
1134 RegisterClass(cls, Symbols::Float32x4(), lib); 1159 RegisterClass(cls, Symbols::Float32x4(), lib);
1160 cls.set_num_type_arguments(0);
1161 cls.set_num_own_type_arguments(0);
1135 cls.set_is_prefinalized(); 1162 cls.set_is_prefinalized();
1136 pending_classes.Add(cls); 1163 pending_classes.Add(cls);
1137 type = Type::NewNonParameterizedType(cls); 1164 type = Type::NewNonParameterizedType(cls);
1138 object_store->set_float32x4_type(type); 1165 object_store->set_float32x4_type(type);
1139 1166
1140 cls = Class::New<Instance>(kIllegalCid); 1167 cls = Class::New<Instance>(kIllegalCid);
1141 RegisterClass(cls, Symbols::Uint32x4(), lib); 1168 RegisterClass(cls, Symbols::Uint32x4(), lib);
1169 cls.set_num_type_arguments(0);
1170 cls.set_num_own_type_arguments(0);
1142 cls.set_is_prefinalized(); 1171 cls.set_is_prefinalized();
1143 pending_classes.Add(cls); 1172 pending_classes.Add(cls);
1144 type = Type::NewNonParameterizedType(cls); 1173 type = Type::NewNonParameterizedType(cls);
1145 object_store->set_uint32x4_type(type); 1174 object_store->set_uint32x4_type(type);
1146 1175
1147 object_store->set_typed_data_classes(typed_data_classes); 1176 object_store->set_typed_data_classes(typed_data_classes);
1148 1177
1149 // Set the super type of class Stacktrace to Object type so that the 1178 // Set the super type of class Stacktrace to Object type so that the
1150 // 'toString' method is implemented. 1179 // 'toString' method is implemented.
1151 cls = object_store->stacktrace_class(); 1180 cls = object_store->stacktrace_class();
1152 type = object_store->object_type(); 1181 type = object_store->object_type();
1153 cls.set_super_type(type); 1182 cls.set_super_type(type);
1154 1183
1155 // Abstract class that represents the Dart class Function. 1184 // Abstract class that represents the Dart class Function.
1156 cls = Class::New<Instance>(kIllegalCid); 1185 cls = Class::New<Instance>(kIllegalCid);
1186 cls.set_num_type_arguments(0);
1187 cls.set_num_own_type_arguments(0);
1157 cls.set_is_prefinalized(); 1188 cls.set_is_prefinalized();
1158 RegisterClass(cls, Symbols::Function(), core_lib); 1189 RegisterClass(cls, Symbols::Function(), core_lib);
1159 pending_classes.Add(cls); 1190 pending_classes.Add(cls);
1160 type = Type::NewNonParameterizedType(cls); 1191 type = Type::NewNonParameterizedType(cls);
1161 object_store->set_function_type(type); 1192 object_store->set_function_type(type);
1162 1193
1163 cls = Class::New<Number>(); 1194 cls = Class::New<Number>();
1164 RegisterClass(cls, Symbols::Number(), core_lib); 1195 RegisterClass(cls, Symbols::Number(), core_lib);
1165 pending_classes.Add(cls); 1196 pending_classes.Add(cls);
1166 type = Type::NewNonParameterizedType(cls); 1197 type = Type::NewNonParameterizedType(cls);
1167 object_store->set_number_type(type); 1198 object_store->set_number_type(type);
1168 1199
1169 cls = Class::New<Instance>(kIllegalCid); 1200 cls = Class::New<Instance>(kIllegalCid);
1170 RegisterClass(cls, Symbols::Int(), core_lib); 1201 RegisterClass(cls, Symbols::Int(), core_lib);
1202 cls.set_num_type_arguments(0);
1203 cls.set_num_own_type_arguments(0);
1171 cls.set_is_prefinalized(); 1204 cls.set_is_prefinalized();
1172 pending_classes.Add(cls); 1205 pending_classes.Add(cls);
1173 type = Type::NewNonParameterizedType(cls); 1206 type = Type::NewNonParameterizedType(cls);
1174 object_store->set_int_type(type); 1207 object_store->set_int_type(type);
1175 1208
1176 cls = Class::New<Instance>(kIllegalCid); 1209 cls = Class::New<Instance>(kIllegalCid);
1177 RegisterClass(cls, Symbols::Double(), core_lib); 1210 RegisterClass(cls, Symbols::Double(), core_lib);
1211 cls.set_num_type_arguments(0);
1212 cls.set_num_own_type_arguments(0);
1178 cls.set_is_prefinalized(); 1213 cls.set_is_prefinalized();
1179 pending_classes.Add(cls); 1214 pending_classes.Add(cls);
1180 type = Type::NewNonParameterizedType(cls); 1215 type = Type::NewNonParameterizedType(cls);
1181 object_store->set_double_type(type); 1216 object_store->set_double_type(type);
1182 1217
1183 name = Symbols::New("String"); 1218 name = Symbols::New("String");
1184 cls = Class::New<Instance>(kIllegalCid); 1219 cls = Class::New<Instance>(kIllegalCid);
1185 RegisterClass(cls, name, core_lib); 1220 RegisterClass(cls, name, core_lib);
1221 cls.set_num_type_arguments(0);
1222 cls.set_num_own_type_arguments(0);
1186 cls.set_is_prefinalized(); 1223 cls.set_is_prefinalized();
1187 pending_classes.Add(cls); 1224 pending_classes.Add(cls);
1188 type = Type::NewNonParameterizedType(cls); 1225 type = Type::NewNonParameterizedType(cls);
1189 object_store->set_string_type(type); 1226 object_store->set_string_type(type);
1190 1227
1191 cls = object_store->bool_class(); 1228 cls = object_store->bool_class();
1192 type = Type::NewNonParameterizedType(cls); 1229 type = Type::NewNonParameterizedType(cls);
1193 object_store->set_bool_type(type); 1230 object_store->set_bool_type(type);
1194 1231
1195 cls = object_store->smi_class(); 1232 cls = object_store->smi_class();
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 Heap::kOld); 1645 Heap::kOld);
1609 NoGCScope no_gc; 1646 NoGCScope no_gc;
1610 result ^= raw; 1647 result ^= raw;
1611 } 1648 }
1612 FakeObject fake; 1649 FakeObject fake;
1613 result.set_handle_vtable(fake.vtable()); 1650 result.set_handle_vtable(fake.vtable());
1614 result.set_instance_size(FakeObject::InstanceSize()); 1651 result.set_instance_size(FakeObject::InstanceSize());
1615 result.set_next_field_offset(FakeObject::InstanceSize()); 1652 result.set_next_field_offset(FakeObject::InstanceSize());
1616 ASSERT((FakeObject::kClassId != kInstanceCid)); 1653 ASSERT((FakeObject::kClassId != kInstanceCid));
1617 result.set_id(FakeObject::kClassId); 1654 result.set_id(FakeObject::kClassId);
1618 result.raw_ptr()->state_bits_ = 0; 1655 result.set_state_bits(0);
1619 // VM backed classes are almost ready: run checks and resolve class 1656 // VM backed classes are almost ready: run checks and resolve class
1620 // references, but do not recompute size. 1657 // references, but do not recompute size.
1621 result.set_is_prefinalized(); 1658 result.set_is_prefinalized();
1622 result.raw_ptr()->type_arguments_field_offset_in_words_ = kNoTypeArguments; 1659 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
1623 result.raw_ptr()->num_native_fields_ = 0; 1660 result.set_num_type_arguments(0);
1624 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex; 1661 result.set_num_own_type_arguments(0);
1662 result.set_num_native_fields(0);
1663 result.set_token_pos(Scanner::kDummyTokenIndex);
1625 result.InitEmptyFields(); 1664 result.InitEmptyFields();
1626 Isolate::Current()->RegisterClass(result); 1665 Isolate::Current()->RegisterClass(result);
1627 return result.raw(); 1666 return result.raw();
1628 } 1667 }
1629 1668
1630 1669
1670 static RawError* FormatError(const Error& prev_error,
1671 const Script& script,
1672 intptr_t token_pos,
1673 const char* format, ...) {
1674 va_list args;
1675 va_start(args, format);
1676 if (prev_error.IsNull()) {
1677 return Parser::FormatError(script, token_pos, "Error", format, args);
1678 } else {
1679 return Parser::FormatErrorWithAppend(prev_error, script, token_pos,
1680 "Error", format, args);
1681 }
1682 }
1683
1684
1685 static void ReportTooManyTypeArguments(const Class& cls) {
1686 const Error& error = Error::Handle(
1687 FormatError(Error::Handle(), // No previous error.
1688 Script::Handle(cls.script()), cls.token_pos(),
1689 "too many type parameters declared in class '%s' or in its "
1690 "super classes",
1691 String::Handle(cls.Name()).ToCString()));
1692 Isolate::Current()->long_jump_base()->Jump(1, error);
1693 UNREACHABLE();
1694 }
1695
1696
1697 void Class::set_num_type_arguments(intptr_t value) const {
1698 if (!Utils::IsInt(16, value)) {
1699 ReportTooManyTypeArguments(*this);
1700 }
1701 raw_ptr()->num_type_arguments_ = value;
1702 }
1703
1704
1705 void Class::set_num_own_type_arguments(intptr_t value) const {
1706 if (!Utils::IsInt(16, value)) {
1707 ReportTooManyTypeArguments(*this);
1708 }
1709 raw_ptr()->num_own_type_arguments_ = value;
1710 }
1711
1712
1631 // Initialize class fields of type Array with empty array. 1713 // Initialize class fields of type Array with empty array.
1632 void Class::InitEmptyFields() { 1714 void Class::InitEmptyFields() {
1633 if (Object::empty_array().raw() == Array::null()) { 1715 if (Object::empty_array().raw() == Array::null()) {
1634 // The empty array has not been initialized yet. 1716 // The empty array has not been initialized yet.
1635 return; 1717 return;
1636 } 1718 }
1637 StorePointer(&raw_ptr()->interfaces_, Object::empty_array().raw()); 1719 StorePointer(&raw_ptr()->interfaces_, Object::empty_array().raw());
1638 StorePointer(&raw_ptr()->constants_, Object::empty_array().raw()); 1720 StorePointer(&raw_ptr()->constants_, Object::empty_array().raw());
1639 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw()); 1721 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw());
1640 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); 1722 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 } 1830 }
1749 if (type_parameters() == TypeArguments::null()) { 1831 if (type_parameters() == TypeArguments::null()) {
1750 return 0; 1832 return 0;
1751 } 1833 }
1752 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); 1834 const TypeArguments& type_params = TypeArguments::Handle(type_parameters());
1753 return type_params.Length(); 1835 return type_params.Length();
1754 } 1836 }
1755 1837
1756 1838
1757 intptr_t Class::NumOwnTypeArguments() const { 1839 intptr_t Class::NumOwnTypeArguments() const {
1840 // Return cached value if already calculated.
1841 if (num_own_type_arguments() != kUnknownNumTypeArguments) {
1842 return num_own_type_arguments();
1843 }
1758 Isolate* isolate = Isolate::Current(); 1844 Isolate* isolate = Isolate::Current();
1759 const intptr_t num_type_params = NumTypeParameters(); 1845 const intptr_t num_type_params = NumTypeParameters();
1760 if (!FLAG_overlap_type_arguments || 1846 if (!FLAG_overlap_type_arguments ||
1761 (num_type_params == 0) || 1847 (num_type_params == 0) ||
1762 (super_type() == AbstractType::null()) || 1848 (super_type() == AbstractType::null()) ||
1763 (super_type() == isolate->object_store()->object_type())) { 1849 (super_type() == isolate->object_store()->object_type())) {
1850 set_num_own_type_arguments(num_type_params);
1764 return num_type_params; 1851 return num_type_params;
1765 } 1852 }
1766 ASSERT(!IsMixinApplication() || is_mixin_type_applied()); 1853 ASSERT(!IsMixinApplication() || is_mixin_type_applied());
1767 const AbstractType& sup_type = AbstractType::Handle(isolate, super_type()); 1854 const AbstractType& sup_type = AbstractType::Handle(isolate, super_type());
1768 ASSERT(sup_type.IsResolved()); 1855 ASSERT(sup_type.IsResolved());
1769 const AbstractTypeArguments& sup_type_args = 1856 const AbstractTypeArguments& sup_type_args =
1770 AbstractTypeArguments::Handle(isolate, sup_type.arguments()); 1857 AbstractTypeArguments::Handle(isolate, sup_type.arguments());
1771 if (sup_type_args.IsNull()) { 1858 if (sup_type_args.IsNull()) {
1772 // The super type is raw or the super class is non generic. 1859 // The super type is raw or the super class is non generic.
1773 // In either case, overlapping is not possible. 1860 // In either case, overlapping is not possible.
1861 set_num_own_type_arguments(num_type_params);
1774 return num_type_params; 1862 return num_type_params;
1775 } 1863 }
1776 const intptr_t num_sup_type_args = sup_type_args.Length(); 1864 const intptr_t num_sup_type_args = sup_type_args.Length();
1777 // At this point, the super type may or may not be finalized. In either case, 1865 // At this point, the super type may or may not be finalized. In either case,
1778 // the result of this function must remain the same. 1866 // the result of this function must remain the same.
1779 // The value of num_sup_type_args may increase when the super type is 1867 // The value of num_sup_type_args may increase when the super type is
1780 // finalized, but the last num_sup_type_args type arguments will not be 1868 // finalized, but the last num_sup_type_args type arguments will not be
1781 // modified by finalization, only shifted to higher indices in the vector. 1869 // modified by finalization, only shifted to higher indices in the vector.
1782 // They may however get wrapped in a BoundedType, which we skip. 1870 // They may however get wrapped in a BoundedType, which we skip.
1783 const AbstractTypeArguments& type_params = 1871 const AbstractTypeArguments& type_params =
(...skipping 19 matching lines...) Expand all
1803 num_sup_type_args - num_overlapping_type_args + i); 1891 num_sup_type_args - num_overlapping_type_args + i);
1804 // BoundedType can nest in case the finalized super type has bounded type 1892 // BoundedType can nest in case the finalized super type has bounded type
1805 // arguments that overlap multiple times in its own super class chain. 1893 // arguments that overlap multiple times in its own super class chain.
1806 while (sup_type_arg.IsBoundedType()) { 1894 while (sup_type_arg.IsBoundedType()) {
1807 sup_type_arg = BoundedType::Cast(sup_type_arg).type(); 1895 sup_type_arg = BoundedType::Cast(sup_type_arg).type();
1808 } 1896 }
1809 if (!type_param.Equals(sup_type_arg)) break; 1897 if (!type_param.Equals(sup_type_arg)) break;
1810 } 1898 }
1811 if (i == num_overlapping_type_args) { 1899 if (i == num_overlapping_type_args) {
1812 // Overlap found. 1900 // Overlap found.
1901 set_num_own_type_arguments(num_type_params - num_overlapping_type_args);
1813 return num_type_params - num_overlapping_type_args; 1902 return num_type_params - num_overlapping_type_args;
1814 } 1903 }
1815 } 1904 }
1816 // No overlap found. 1905 // No overlap found.
1906 set_num_own_type_arguments(num_type_params);
1817 return num_type_params; 1907 return num_type_params;
1818 } 1908 }
1819 1909
1820 1910
1821 intptr_t Class::NumTypeArguments() const { 1911 intptr_t Class::NumTypeArguments() const {
1912 // Return cached value if already calculated.
1913 if (num_type_arguments() != kUnknownNumTypeArguments) {
1914 return num_type_arguments();
1915 }
1822 // To work properly, this call requires the super class of this class to be 1916 // To work properly, this call requires the super class of this class to be
1823 // resolved, which is checked by the type_class() call on the super type. 1917 // resolved, which is checked by the type_class() call on the super type.
1824 // Note that calling type_class() on a MixinAppType fails. 1918 // Note that calling type_class() on a MixinAppType fails.
1825 Isolate* isolate = Isolate::Current(); 1919 Isolate* isolate = Isolate::Current();
1826 Class& cls = Class::Handle(isolate); 1920 Class& cls = Class::Handle(isolate);
1827 AbstractType& sup_type = AbstractType::Handle(isolate); 1921 AbstractType& sup_type = AbstractType::Handle(isolate);
1828 cls = raw(); 1922 cls = raw();
1829 intptr_t num_type_args = 0; 1923 intptr_t num_type_args = 0;
1830 do { 1924 do {
1831 if (cls.IsSignatureClass()) { 1925 if (cls.IsSignatureClass()) {
1832 Function& signature_fun = Function::Handle(isolate); 1926 Function& signature_fun = Function::Handle(isolate);
1833 signature_fun ^= cls.signature_function(); 1927 signature_fun ^= cls.signature_function();
1834 if (!signature_fun.is_static() && 1928 if (!signature_fun.is_static() &&
1835 !signature_fun.HasInstantiatedSignature()) { 1929 !signature_fun.HasInstantiatedSignature()) {
1836 cls = signature_fun.Owner(); 1930 cls = signature_fun.Owner();
1837 } 1931 }
1838 } 1932 }
1839 // Calling NumOwnTypeArguments() on a mixin application class will setup the 1933 // Calling NumOwnTypeArguments() on a mixin application class will setup the
1840 // type parameters if not already done. 1934 // type parameters if not already done.
1841 num_type_args += cls.NumOwnTypeArguments(); 1935 num_type_args += cls.NumOwnTypeArguments();
1842 // Super type of Object class is null. 1936 // Super type of Object class is null.
1843 if ((cls.super_type() == AbstractType::null()) || 1937 if ((cls.super_type() == AbstractType::null()) ||
1844 (cls.super_type() == isolate->object_store()->object_type())) { 1938 (cls.super_type() == isolate->object_store()->object_type())) {
1845 break; 1939 break;
1846 } 1940 }
1847 sup_type = cls.super_type(); 1941 sup_type = cls.super_type();
1848 cls = sup_type.type_class(); 1942 cls = sup_type.type_class();
1849 } while (true); 1943 } while (true);
1944 set_num_type_arguments(num_type_args);
1850 return num_type_args; 1945 return num_type_args;
1851 } 1946 }
1852 1947
1853 1948
1854 // More efficient than calling NumTypeArguments().
1855 bool Class::HasTypeArguments() const {
1856 // Fast check for a non-signature finalized class.
1857 if (!IsSignatureClass() && (is_finalized() || is_prefinalized())) {
1858 return type_arguments_field_offset() != kNoTypeArguments;
1859 }
1860 Isolate* isolate = Isolate::Current();
1861 Class& cls = Class::Handle(isolate);
1862 cls = raw();
1863 do {
1864 if (cls.IsSignatureClass()) {
1865 Function& signature_fun = Function::Handle(isolate);
1866 signature_fun ^= cls.signature_function();
1867 if (!signature_fun.is_static() &&
1868 !signature_fun.HasInstantiatedSignature()) {
1869 cls = signature_fun.Owner();
1870 }
1871 }
1872 if (cls.NumTypeParameters() > 0) {
1873 return true;
1874 }
1875 if ((cls.super_type() == AbstractType::null()) ||
1876 (cls.super_type() == isolate->object_store()->object_type())) {
1877 return false;
1878 }
1879 cls = cls.SuperClass();
1880 if (!cls.IsSignatureClass() &&
1881 (cls.is_finalized() || cls.is_prefinalized())) {
1882 return cls.type_arguments_field_offset() != kNoTypeArguments;
1883 }
1884 } while (true);
1885 UNREACHABLE();
1886 }
1887
1888
1889 RawClass* Class::SuperClass() const { 1949 RawClass* Class::SuperClass() const {
1890 if (super_type() == AbstractType::null()) { 1950 if (super_type() == AbstractType::null()) {
1891 return Class::null(); 1951 return Class::null();
1892 } 1952 }
1893 const AbstractType& sup_type = AbstractType::Handle(super_type()); 1953 const AbstractType& sup_type = AbstractType::Handle(super_type());
1894 return sup_type.type_class(); 1954 return sup_type.type_class();
1895 } 1955 }
1896 1956
1897 1957
1898 void Class::set_super_type(const AbstractType& value) const { 1958 void Class::set_super_type(const AbstractType& value) const {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 // Prefinalized classes have a VM internal representation and no Dart fields. 2146 // Prefinalized classes have a VM internal representation and no Dart fields.
2087 // Their instance size is precomputed and field offsets are known. 2147 // Their instance size is precomputed and field offsets are known.
2088 if (!is_prefinalized()) { 2148 if (!is_prefinalized()) {
2089 // Compute offsets of instance fields and instance size. 2149 // Compute offsets of instance fields and instance size.
2090 CalculateFieldOffsets(); 2150 CalculateFieldOffsets();
2091 } 2151 }
2092 set_is_finalized(); 2152 set_is_finalized();
2093 } 2153 }
2094 2154
2095 2155
2096 static RawError* FormatError(const Error& prev_error,
2097 const Script& script,
2098 intptr_t token_pos,
2099 const char* format, ...) {
2100 va_list args;
2101 va_start(args, format);
2102 if (prev_error.IsNull()) {
2103 return Parser::FormatError(script, token_pos, "Error", format, args);
2104 } else {
2105 return Parser::FormatErrorWithAppend(prev_error, script, token_pos,
2106 "Error", format, args);
2107 }
2108 }
2109
2110
2111 // Apply the members from the patch class to the original class. 2156 // Apply the members from the patch class to the original class.
2112 bool Class::ApplyPatch(const Class& patch, Error* error) const { 2157 bool Class::ApplyPatch(const Class& patch, Error* error) const {
2113 ASSERT(error != NULL); 2158 ASSERT(error != NULL);
2114 ASSERT(!is_finalized()); 2159 ASSERT(!is_finalized());
2115 // Shared handles used during the iteration. 2160 // Shared handles used during the iteration.
2116 String& member_name = String::Handle(); 2161 String& member_name = String::Handle();
2117 2162
2118 const PatchClass& patch_class = 2163 const PatchClass& patch_class =
2119 PatchClass::Handle(PatchClass::New(*this, patch)); 2164 PatchClass::Handle(PatchClass::New(*this, patch));
2120 2165
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 Heap::kOld); 2351 Heap::kOld);
2307 NoGCScope no_gc; 2352 NoGCScope no_gc;
2308 result ^= raw; 2353 result ^= raw;
2309 } 2354 }
2310 FakeInstance fake; 2355 FakeInstance fake;
2311 ASSERT(fake.IsInstance()); 2356 ASSERT(fake.IsInstance());
2312 result.set_handle_vtable(fake.vtable()); 2357 result.set_handle_vtable(fake.vtable());
2313 result.set_instance_size(FakeInstance::InstanceSize()); 2358 result.set_instance_size(FakeInstance::InstanceSize());
2314 result.set_next_field_offset(FakeInstance::InstanceSize()); 2359 result.set_next_field_offset(FakeInstance::InstanceSize());
2315 result.set_id(index); 2360 result.set_id(index);
2316 result.raw_ptr()->state_bits_ = 0; 2361 result.set_state_bits(0);
2317 result.raw_ptr()->type_arguments_field_offset_in_words_ = kNoTypeArguments; 2362 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
2318 result.raw_ptr()->num_native_fields_ = 0; 2363 result.set_num_type_arguments(kUnknownNumTypeArguments);
2319 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex; 2364 result.set_num_own_type_arguments(kUnknownNumTypeArguments);
2365 result.set_num_native_fields(0);
2366 result.set_token_pos(Scanner::kDummyTokenIndex);
2320 result.InitEmptyFields(); 2367 result.InitEmptyFields();
2321 Isolate::Current()->RegisterClass(result); 2368 Isolate::Current()->RegisterClass(result);
2322 return result.raw(); 2369 return result.raw();
2323 } 2370 }
2324 2371
2325 2372
2326 RawClass* Class::New(const String& name, 2373 RawClass* Class::New(const String& name,
2327 const Script& script, 2374 const Script& script,
2328 intptr_t token_pos) { 2375 intptr_t token_pos) {
2329 Class& result = Class::Handle(New<Instance>(kIllegalCid)); 2376 Class& result = Class::Handle(New<Instance>(kIllegalCid));
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 return (test_kind == kIsMoreSpecificThan) || 2705 return (test_kind == kIsMoreSpecificThan) ||
2659 other.IsObjectClass() || other.IsNullClass(); 2706 other.IsObjectClass() || other.IsNullClass();
2660 } 2707 }
2661 // Check for ObjectType. Any type that is not NullType or DynamicType (already 2708 // Check for ObjectType. Any type that is not NullType or DynamicType (already
2662 // checked above), is more specific than ObjectType. 2709 // checked above), is more specific than ObjectType.
2663 if (other.IsObjectClass()) { 2710 if (other.IsObjectClass()) {
2664 return true; 2711 return true;
2665 } 2712 }
2666 // Check for reflexivity. 2713 // Check for reflexivity.
2667 if (raw() == other.raw()) { 2714 if (raw() == other.raw()) {
2668 if (!HasTypeArguments()) { 2715 const intptr_t len = NumTypeArguments();
2716 if (len == 0) {
2669 return true; 2717 return true;
2670 } 2718 }
2671 const intptr_t len = NumTypeArguments();
2672 // Since we do not truncate the type argument vector of a subclass (see 2719 // Since we do not truncate the type argument vector of a subclass (see
2673 // below), we only check a prefix of the proper length. 2720 // below), we only check a prefix of the proper length.
2674 // Check for covariance. 2721 // Check for covariance.
2675 if (other_type_arguments.IsNull() || other_type_arguments.IsRaw(len)) { 2722 if (other_type_arguments.IsNull() || other_type_arguments.IsRaw(len)) {
2676 return true; 2723 return true;
2677 } 2724 }
2678 if (type_arguments.IsNull() || type_arguments.IsRaw(len)) { 2725 if (type_arguments.IsNull() || type_arguments.IsRaw(len)) {
2679 // Other type can't be more specific than this one because for that 2726 // Other type can't be more specific than this one because for that
2680 // it would have to have all dynamic type arguments which is checked 2727 // it would have to have all dynamic type arguments which is checked
2681 // above. 2728 // above.
(...skipping 8050 matching lines...) Expand 10 before | Expand all | Expand 10 after
10732 return result.raw(); 10779 return result.raw();
10733 } 10780 }
10734 10781
10735 10782
10736 RawType* Instance::GetType() const { 10783 RawType* Instance::GetType() const {
10737 if (IsNull()) { 10784 if (IsNull()) {
10738 return Type::NullType(); 10785 return Type::NullType();
10739 } 10786 }
10740 const Class& cls = Class::Handle(clazz()); 10787 const Class& cls = Class::Handle(clazz());
10741 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 10788 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
10742 if (cls.HasTypeArguments()) { 10789 if (cls.NumTypeArguments() > 0) {
10743 type_arguments = GetTypeArguments(); 10790 type_arguments = GetTypeArguments();
10744 } 10791 }
10745 const Type& type = Type::Handle( 10792 const Type& type = Type::Handle(
10746 Type::New(cls, type_arguments, Scanner::kDummyTokenIndex)); 10793 Type::New(cls, type_arguments, Scanner::kDummyTokenIndex));
10747 type.SetIsFinalized(); 10794 type.SetIsFinalized();
10748 return type.raw(); 10795 return type.raw();
10749 } 10796 }
10750 10797
10751 10798
10752 RawAbstractTypeArguments* Instance::GetTypeArguments() const { 10799 RawAbstractTypeArguments* Instance::GetTypeArguments() const {
(...skipping 21 matching lines...) Expand all
10774 ASSERT(!other.IsDynamicType()); 10821 ASSERT(!other.IsDynamicType());
10775 ASSERT(!other.IsMalformed()); 10822 ASSERT(!other.IsMalformed());
10776 ASSERT(!other.IsMalbounded()); 10823 ASSERT(!other.IsMalbounded());
10777 if (other.IsVoidType()) { 10824 if (other.IsVoidType()) {
10778 return false; 10825 return false;
10779 } 10826 }
10780 Isolate* isolate = Isolate::Current(); 10827 Isolate* isolate = Isolate::Current();
10781 const Class& cls = Class::Handle(isolate, clazz()); 10828 const Class& cls = Class::Handle(isolate, clazz());
10782 AbstractTypeArguments& type_arguments = 10829 AbstractTypeArguments& type_arguments =
10783 AbstractTypeArguments::Handle(isolate); 10830 AbstractTypeArguments::Handle(isolate);
10784 if (cls.HasTypeArguments()) { 10831 if (cls.NumTypeArguments() > 0) {
10785 type_arguments = GetTypeArguments(); 10832 type_arguments = GetTypeArguments();
10786 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { 10833 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) {
10787 type_arguments = type_arguments.Canonicalize(); 10834 type_arguments = type_arguments.Canonicalize();
10788 SetTypeArguments(type_arguments); 10835 SetTypeArguments(type_arguments);
10789 } 10836 }
10790 // The number of type arguments in the instance must be greater or equal to 10837 // The number of type arguments in the instance must be greater or equal to
10791 // the number of type arguments expected by the instance class. 10838 // the number of type arguments expected by the instance class.
10792 // A discrepancy is allowed for closures, which borrow the type argument 10839 // A discrepancy is allowed for closures, which borrow the type argument
10793 // vector of their instantiator, which may be of a subclass of the class 10840 // vector of their instantiator, which may be of a subclass of the class
10794 // defining the closure. Truncating the vector to the correct length on 10841 // defining the closure. Truncating the vector to the correct length on
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
11383 return Isolate::Current()->object_store()->array_type(); 11430 return Isolate::Current()->object_store()->array_type();
11384 } 11431 }
11385 11432
11386 11433
11387 RawType* Type::Function() { 11434 RawType* Type::Function() {
11388 return Isolate::Current()->object_store()->function_type(); 11435 return Isolate::Current()->object_store()->function_type();
11389 } 11436 }
11390 11437
11391 11438
11392 RawType* Type::NewNonParameterizedType(const Class& type_class) { 11439 RawType* Type::NewNonParameterizedType(const Class& type_class) {
11393 ASSERT(!type_class.HasTypeArguments()); 11440 ASSERT(type_class.NumTypeArguments() == 0);
11394 const TypeArguments& no_type_arguments = TypeArguments::Handle(); 11441 const TypeArguments& no_type_arguments = TypeArguments::Handle();
11395 Type& type = Type::Handle(); 11442 Type& type = Type::Handle();
11396 type ^= Type::New(Object::Handle(type_class.raw()), 11443 type ^= Type::New(Object::Handle(type_class.raw()),
11397 no_type_arguments, 11444 no_type_arguments,
11398 Scanner::kDummyTokenIndex); 11445 Scanner::kDummyTokenIndex);
11399 type.SetIsFinalized(); 11446 type.SetIsFinalized();
11400 type ^= type.Canonicalize(); 11447 type ^= type.Canonicalize();
11401 return type.raw(); 11448 return type.raw();
11402 } 11449 }
11403 11450
(...skipping 4101 matching lines...) Expand 10 before | Expand all | Expand 10 after
15505 return "_MirrorReference"; 15552 return "_MirrorReference";
15506 } 15553 }
15507 15554
15508 15555
15509 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15556 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15510 JSONObject jsobj(stream); 15557 JSONObject jsobj(stream);
15511 } 15558 }
15512 15559
15513 15560
15514 } // namespace dart 15561 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698