| OLD | NEW |
| 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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); | 1132 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); |
| 1133 friend class Class; | 1133 friend class Class; |
| 1134 }; | 1134 }; |
| 1135 | 1135 |
| 1136 | 1136 |
| 1137 // AbstractTypeArguments is an abstract superclass. | 1137 // AbstractTypeArguments is an abstract superclass. |
| 1138 // Subclasses of AbstractTypeArguments are TypeArguments and | 1138 // Subclasses of AbstractTypeArguments are TypeArguments and |
| 1139 // InstantiatedTypeArguments. | 1139 // InstantiatedTypeArguments. |
| 1140 class AbstractTypeArguments : public Object { | 1140 class AbstractTypeArguments : public Object { |
| 1141 public: | 1141 public: |
| 1142 // Returns true if all types of this vector are finalized. |
| 1143 virtual bool IsFinalized() const { return true; } |
| 1144 |
| 1142 // Returns true if both arguments represent vectors of equal types. | 1145 // Returns true if both arguments represent vectors of equal types. |
| 1143 static bool AreEqual(const AbstractTypeArguments& arguments, | 1146 static bool AreEqual(const AbstractTypeArguments& arguments, |
| 1144 const AbstractTypeArguments& other_arguments); | 1147 const AbstractTypeArguments& other_arguments); |
| 1145 | 1148 |
| 1146 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 1149 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
| 1147 // not refer to type parameters. Otherwise, return a new type argument vector | 1150 // not refer to type parameters. Otherwise, return a new type argument vector |
| 1148 // where each reference to a type parameter is replaced with the corresponding | 1151 // where each reference to a type parameter is replaced with the corresponding |
| 1149 // type of the instantiator type argument vector. | 1152 // type of the instantiator type argument vector. |
| 1150 // If bound_error is not NULL, it may be set to reflect a bound error. | 1153 // If bound_error is not NULL, it may be set to reflect a bound error. |
| 1151 virtual RawAbstractTypeArguments* InstantiateFrom( | 1154 virtual RawAbstractTypeArguments* InstantiateFrom( |
| 1152 const AbstractTypeArguments& instantiator_type_arguments, | 1155 const AbstractTypeArguments& instantiator_type_arguments, |
| 1153 Error* bound_error) const; | 1156 Error* bound_error) const; |
| 1154 | 1157 |
| 1155 // Do not canonicalize InstantiatedTypeArguments or NULL objects | 1158 // Do not clone InstantiatedTypeArguments or null vectors, since they are |
| 1159 // considered finalized. |
| 1160 virtual RawAbstractTypeArguments* CloneUnfinalized() const { |
| 1161 return this->raw(); |
| 1162 } |
| 1163 |
| 1164 // Do not canonicalize InstantiatedTypeArguments or null vectors. |
| 1156 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } | 1165 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } |
| 1157 | 1166 |
| 1158 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". | 1167 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". |
| 1159 virtual RawString* Name() const { | 1168 virtual RawString* Name() const { |
| 1160 return SubvectorName(0, Length(), kInternalName); | 1169 return SubvectorName(0, Length(), kInternalName); |
| 1161 } | 1170 } |
| 1162 | 1171 |
| 1163 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". | 1172 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". |
| 1164 // Names of internal classes are mapped to their public interfaces. | 1173 // Names of internal classes are mapped to their public interfaces. |
| 1165 virtual RawString* UserVisibleName() const { | 1174 virtual RawString* UserVisibleName() const { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1253 virtual RawAbstractType* TypeAt(intptr_t index) const; |
| 1245 static intptr_t type_at_offset(intptr_t index) { | 1254 static intptr_t type_at_offset(intptr_t index) { |
| 1246 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; | 1255 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; |
| 1247 } | 1256 } |
| 1248 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1257 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
| 1249 virtual bool IsResolved() const; | 1258 virtual bool IsResolved() const; |
| 1250 virtual bool IsInstantiated() const; | 1259 virtual bool IsInstantiated() const; |
| 1251 virtual bool IsUninstantiatedIdentity() const; | 1260 virtual bool IsUninstantiatedIdentity() const; |
| 1252 virtual bool CanShareInstantiatorTypeArguments( | 1261 virtual bool CanShareInstantiatorTypeArguments( |
| 1253 const Class& instantiator_class) const; | 1262 const Class& instantiator_class) const; |
| 1263 virtual bool IsFinalized() const; |
| 1254 virtual bool IsBounded() const; | 1264 virtual bool IsBounded() const; |
| 1265 virtual RawAbstractTypeArguments* CloneUnfinalized() const; |
| 1255 // Canonicalize only if instantiated, otherwise returns 'this'. | 1266 // Canonicalize only if instantiated, otherwise returns 'this'. |
| 1256 virtual RawAbstractTypeArguments* Canonicalize() const; | 1267 virtual RawAbstractTypeArguments* Canonicalize() const; |
| 1257 | 1268 |
| 1258 virtual RawAbstractTypeArguments* InstantiateFrom( | 1269 virtual RawAbstractTypeArguments* InstantiateFrom( |
| 1259 const AbstractTypeArguments& instantiator_type_arguments, | 1270 const AbstractTypeArguments& instantiator_type_arguments, |
| 1260 Error* bound_error) const; | 1271 Error* bound_error) const; |
| 1261 | 1272 |
| 1262 static const intptr_t kBytesPerElement = kWordSize; | 1273 static const intptr_t kBytesPerElement = kWordSize; |
| 1263 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 1274 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 1264 | 1275 |
| (...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3860 virtual bool IsInstantiated() const; | 3871 virtual bool IsInstantiated() const; |
| 3861 virtual bool Equals(const Instance& other) const; | 3872 virtual bool Equals(const Instance& other) const; |
| 3862 | 3873 |
| 3863 // Instantiate this type using the given type argument vector. | 3874 // Instantiate this type using the given type argument vector. |
| 3864 // Return a new type, or return 'this' if it is already instantiated. | 3875 // Return a new type, or return 'this' if it is already instantiated. |
| 3865 // If bound_error is not NULL, it may be set to reflect a bound error. | 3876 // If bound_error is not NULL, it may be set to reflect a bound error. |
| 3866 virtual RawAbstractType* InstantiateFrom( | 3877 virtual RawAbstractType* InstantiateFrom( |
| 3867 const AbstractTypeArguments& instantiator_type_arguments, | 3878 const AbstractTypeArguments& instantiator_type_arguments, |
| 3868 Error* bound_error) const; | 3879 Error* bound_error) const; |
| 3869 | 3880 |
| 3881 // Return a clone of this unfinalized type or the type itself if it is |
| 3882 // already finalized. Apply recursively to type arguments, i.e. finalized |
| 3883 // type arguments of an unfinalized type are not cloned, but shared. |
| 3884 virtual RawAbstractType* CloneUnfinalized() const; |
| 3885 |
| 3870 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 3886 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
| 3871 return Canonicalize(); | 3887 return Canonicalize(); |
| 3872 } | 3888 } |
| 3873 | 3889 |
| 3874 // Return the canonical version of this type. | 3890 // Return the canonical version of this type. |
| 3875 virtual RawAbstractType* Canonicalize() const; | 3891 virtual RawAbstractType* Canonicalize() const; |
| 3876 | 3892 |
| 3877 // The name of this type, including the names of its type arguments, if any. | 3893 // The name of this type, including the names of its type arguments, if any. |
| 3878 virtual RawString* Name() const { | 3894 virtual RawString* Name() const { |
| 3879 return BuildName(kInternalName); | 3895 return BuildName(kInternalName); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3997 virtual RawUnresolvedClass* unresolved_class() const; | 4013 virtual RawUnresolvedClass* unresolved_class() const; |
| 3998 RawString* TypeClassName() const; | 4014 RawString* TypeClassName() const; |
| 3999 virtual RawAbstractTypeArguments* arguments() const; | 4015 virtual RawAbstractTypeArguments* arguments() const; |
| 4000 void set_arguments(const AbstractTypeArguments& value) const; | 4016 void set_arguments(const AbstractTypeArguments& value) const; |
| 4001 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 4017 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 4002 virtual bool IsInstantiated() const; | 4018 virtual bool IsInstantiated() const; |
| 4003 virtual bool Equals(const Instance& other) const; | 4019 virtual bool Equals(const Instance& other) const; |
| 4004 virtual RawAbstractType* InstantiateFrom( | 4020 virtual RawAbstractType* InstantiateFrom( |
| 4005 const AbstractTypeArguments& instantiator_type_arguments, | 4021 const AbstractTypeArguments& instantiator_type_arguments, |
| 4006 Error* malformed_error) const; | 4022 Error* malformed_error) const; |
| 4023 virtual RawAbstractType* CloneUnfinalized() const; |
| 4007 virtual RawAbstractType* Canonicalize() const; | 4024 virtual RawAbstractType* Canonicalize() const; |
| 4008 | 4025 |
| 4009 virtual intptr_t Hash() const; | 4026 virtual intptr_t Hash() const; |
| 4010 | 4027 |
| 4011 static intptr_t InstanceSize() { | 4028 static intptr_t InstanceSize() { |
| 4012 return RoundedAllocationSize(sizeof(RawType)); | 4029 return RoundedAllocationSize(sizeof(RawType)); |
| 4013 } | 4030 } |
| 4014 | 4031 |
| 4015 // The type of the literal 'null'. | 4032 // The type of the literal 'null'. |
| 4016 static RawType* NullType(); | 4033 static RawType* NullType(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4111 // and set bound_error if not NULL. | 4128 // and set bound_error if not NULL. |
| 4112 bool CheckBound(const AbstractType& bounded_type, | 4129 bool CheckBound(const AbstractType& bounded_type, |
| 4113 const AbstractType& upper_bound, | 4130 const AbstractType& upper_bound, |
| 4114 Error* bound_error) const; | 4131 Error* bound_error) const; |
| 4115 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 4132 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 4116 virtual bool IsInstantiated() const { return false; } | 4133 virtual bool IsInstantiated() const { return false; } |
| 4117 virtual bool Equals(const Instance& other) const; | 4134 virtual bool Equals(const Instance& other) const; |
| 4118 virtual RawAbstractType* InstantiateFrom( | 4135 virtual RawAbstractType* InstantiateFrom( |
| 4119 const AbstractTypeArguments& instantiator_type_arguments, | 4136 const AbstractTypeArguments& instantiator_type_arguments, |
| 4120 Error* bound_error) const; | 4137 Error* bound_error) const; |
| 4138 virtual RawAbstractType* CloneUnfinalized() const; |
| 4121 virtual RawAbstractType* Canonicalize() const { return raw(); } | 4139 virtual RawAbstractType* Canonicalize() const { return raw(); } |
| 4122 | 4140 |
| 4123 virtual intptr_t Hash() const; | 4141 virtual intptr_t Hash() const; |
| 4124 | 4142 |
| 4125 static intptr_t InstanceSize() { | 4143 static intptr_t InstanceSize() { |
| 4126 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 4144 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
| 4127 } | 4145 } |
| 4128 | 4146 |
| 4129 static RawTypeParameter* New(const Class& parameterized_class, | 4147 static RawTypeParameter* New(const Class& parameterized_class, |
| 4130 intptr_t index, | 4148 intptr_t index, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4183 virtual intptr_t token_pos() const { | 4201 virtual intptr_t token_pos() const { |
| 4184 return AbstractType::Handle(type()).token_pos(); | 4202 return AbstractType::Handle(type()).token_pos(); |
| 4185 } | 4203 } |
| 4186 virtual bool IsInstantiated() const { | 4204 virtual bool IsInstantiated() const { |
| 4187 return AbstractType::Handle(type()).IsInstantiated(); | 4205 return AbstractType::Handle(type()).IsInstantiated(); |
| 4188 } | 4206 } |
| 4189 virtual bool Equals(const Instance& other) const; | 4207 virtual bool Equals(const Instance& other) const; |
| 4190 virtual RawAbstractType* InstantiateFrom( | 4208 virtual RawAbstractType* InstantiateFrom( |
| 4191 const AbstractTypeArguments& instantiator_type_arguments, | 4209 const AbstractTypeArguments& instantiator_type_arguments, |
| 4192 Error* bound_error) const; | 4210 Error* bound_error) const; |
| 4211 virtual RawAbstractType* CloneUnfinalized() const; |
| 4193 virtual RawAbstractType* Canonicalize() const { return raw(); } | 4212 virtual RawAbstractType* Canonicalize() const { return raw(); } |
| 4194 | 4213 |
| 4195 virtual intptr_t Hash() const; | 4214 virtual intptr_t Hash() const; |
| 4196 | 4215 |
| 4197 static intptr_t InstanceSize() { | 4216 static intptr_t InstanceSize() { |
| 4198 return RoundedAllocationSize(sizeof(RawBoundedType)); | 4217 return RoundedAllocationSize(sizeof(RawBoundedType)); |
| 4199 } | 4218 } |
| 4200 | 4219 |
| 4201 static RawBoundedType* New(const AbstractType& type, | 4220 static RawBoundedType* New(const AbstractType& type, |
| 4202 const AbstractType& bound, | 4221 const AbstractType& bound, |
| (...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6224 | 6243 |
| 6225 | 6244 |
| 6226 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6245 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6227 intptr_t index) { | 6246 intptr_t index) { |
| 6228 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6247 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6229 } | 6248 } |
| 6230 | 6249 |
| 6231 } // namespace dart | 6250 } // namespace dart |
| 6232 | 6251 |
| 6233 #endif // VM_OBJECT_H_ | 6252 #endif // VM_OBJECT_H_ |
| OLD | NEW |