| OLD | NEW |
| 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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 const AbstractTypeArguments& other_arguments); | 974 const AbstractTypeArguments& other_arguments); |
| 975 | 975 |
| 976 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 976 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
| 977 // not refer to type parameters. Otherwise, return a new type argument vector | 977 // not refer to type parameters. Otherwise, return a new type argument vector |
| 978 // where each reference to a type parameter is replaced with the corresponding | 978 // where each reference to a type parameter is replaced with the corresponding |
| 979 // type of the instantiator type argument vector starting at the given offset. | 979 // type of the instantiator type argument vector starting at the given offset. |
| 980 virtual RawAbstractTypeArguments* InstantiateFrom( | 980 virtual RawAbstractTypeArguments* InstantiateFrom( |
| 981 const AbstractTypeArguments& instantiator_type_arguments, | 981 const AbstractTypeArguments& instantiator_type_arguments, |
| 982 intptr_t offset) const; | 982 intptr_t offset) const; |
| 983 | 983 |
| 984 // Do not canonicalize InstantiatedTypeArguments or NULL objects |
| 985 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } |
| 986 |
| 984 // Check if this type argument vector consists solely of DynamicType, | 987 // Check if this type argument vector consists solely of DynamicType, |
| 985 // considering only a prefix of length 'len'. | 988 // considering only a prefix of length 'len'. |
| 986 bool IsDynamicTypes(intptr_t len) const; | 989 bool IsDynamicTypes(intptr_t len) const; |
| 987 | 990 |
| 988 // Check the "more specific than" relationship, considering only a prefix of | 991 // Check the "more specific than" relationship, considering only a prefix of |
| 989 // length 'len'. | 992 // length 'len'. |
| 990 bool IsMoreSpecificThan( | 993 bool IsMoreSpecificThan( |
| 991 const AbstractTypeArguments& other, intptr_t len) const; | 994 const AbstractTypeArguments& other, intptr_t len) const; |
| 992 | 995 |
| 993 static RawAbstractTypeArguments* NewInstantiatedTypeArguments( | 996 bool Equals(const AbstractTypeArguments& other) const; |
| 994 const AbstractTypeArguments& uninstantiated_type_arguments, | |
| 995 const AbstractTypeArguments& instantiator_type_arguments); | |
| 996 | 997 |
| 997 // UNREACHABLEs as AbstractTypeArguments is an abstract class. | 998 // UNREACHABLEs as AbstractTypeArguments is an abstract class. |
| 998 virtual intptr_t Length() const; | 999 virtual intptr_t Length() const; |
| 999 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1000 virtual RawAbstractType* TypeAt(intptr_t index) const; |
| 1000 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1001 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
| 1001 virtual bool IsResolved() const; | 1002 virtual bool IsResolved() const; |
| 1002 virtual bool IsInstantiated() const; | 1003 virtual bool IsInstantiated() const; |
| 1003 virtual bool IsUninstantiatedIdentity() const; | 1004 virtual bool IsUninstantiatedIdentity() const; |
| 1004 virtual bool Equals(const AbstractTypeArguments& other) const; | |
| 1005 | 1005 |
| 1006 protected: | 1006 protected: |
| 1007 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object); | 1007 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object); |
| 1008 friend class Class; | 1008 friend class Class; |
| 1009 }; | 1009 }; |
| 1010 | 1010 |
| 1011 | 1011 |
| 1012 // A TypeArguments is simply an array of Types. | 1012 // A TypeArguments is simply an array of Types. |
| 1013 class TypeArguments : public AbstractTypeArguments { | 1013 class TypeArguments : public AbstractTypeArguments { |
| 1014 public: | 1014 public: |
| 1015 virtual intptr_t Length() const; | 1015 virtual intptr_t Length() const; |
| 1016 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1016 virtual RawAbstractType* TypeAt(intptr_t index) const; |
| 1017 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1017 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
| 1018 virtual bool IsResolved() const; | 1018 virtual bool IsResolved() const; |
| 1019 virtual bool IsInstantiated() const; | 1019 virtual bool IsInstantiated() const; |
| 1020 virtual bool IsUninstantiatedIdentity() const; | 1020 virtual bool IsUninstantiatedIdentity() const; |
| 1021 virtual bool Equals(const AbstractTypeArguments& other) const; | 1021 // Canonicalize only if instantiated, otherwise returns 'this'. |
| 1022 virtual RawAbstractTypeArguments* Canonicalize() const; |
| 1022 | 1023 |
| 1023 virtual RawAbstractTypeArguments* InstantiateFrom( | 1024 virtual RawAbstractTypeArguments* InstantiateFrom( |
| 1024 const AbstractTypeArguments& instantiator_type_arguments, | 1025 const AbstractTypeArguments& instantiator_type_arguments, |
| 1025 intptr_t offset) const; | 1026 intptr_t offset) const; |
| 1026 | 1027 |
| 1027 static intptr_t length_offset() { | 1028 static intptr_t length_offset() { |
| 1028 return OFFSET_OF(RawTypeArguments, length_); | 1029 return OFFSET_OF(RawTypeArguments, length_); |
| 1029 } | 1030 } |
| 1030 | 1031 |
| 1031 static intptr_t InstanceSize() { | 1032 static intptr_t InstanceSize() { |
| 1032 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); | 1033 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); |
| 1033 return 0; | 1034 return 0; |
| 1034 } | 1035 } |
| 1035 | 1036 |
| 1036 static intptr_t InstanceSize(intptr_t len) { | 1037 static intptr_t InstanceSize(intptr_t len) { |
| 1037 // Ensure that the types_ is not adding to the object length. | 1038 // Ensure that the types_ is not adding to the object length. |
| 1038 ASSERT(sizeof(RawTypeArguments) == 2 * kWordSize); | 1039 ASSERT(sizeof(RawTypeArguments) == 3 * kWordSize); |
| 1039 return RoundedAllocationSize(sizeof(RawTypeArguments) + (len * kWordSize)); | 1040 return RoundedAllocationSize(sizeof(RawTypeArguments) + (len * kWordSize)); |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 static RawTypeArguments* New(intptr_t len); | 1043 static RawTypeArguments* New(intptr_t len); |
| 1043 | 1044 |
| 1044 private: | 1045 private: |
| 1046 bool is_canonical() const; |
| 1047 void set_is_canonical(bool value) const; |
| 1048 |
| 1045 // Make sure that the array size cannot wrap around. | 1049 // Make sure that the array size cannot wrap around. |
| 1046 static const intptr_t kMaxTypes = 512 * 1024 * 1024; | 1050 static const intptr_t kMaxTypes = 512 * 1024 * 1024; |
| 1047 RawAbstractType** TypeAddr(intptr_t index) const; | 1051 RawAbstractType** TypeAddr(intptr_t index) const; |
| 1048 void SetLength(intptr_t value); | 1052 void SetLength(intptr_t value); |
| 1049 | 1053 |
| 1050 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, AbstractTypeArguments); | 1054 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, AbstractTypeArguments); |
| 1051 friend class Class; | 1055 friend class Class; |
| 1052 }; | 1056 }; |
| 1053 | 1057 |
| 1054 | 1058 |
| (...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 } | 2920 } |
| 2917 void SetAt(intptr_t index, const Object& value) const { | 2921 void SetAt(intptr_t index, const Object& value) const { |
| 2918 // TODO(iposva): Add storing NoGCScope. | 2922 // TODO(iposva): Add storing NoGCScope. |
| 2919 *ObjectAddr(index) = value.raw(); | 2923 *ObjectAddr(index) = value.raw(); |
| 2920 } | 2924 } |
| 2921 | 2925 |
| 2922 virtual RawAbstractTypeArguments* GetTypeArguments() const { | 2926 virtual RawAbstractTypeArguments* GetTypeArguments() const { |
| 2923 return raw_ptr()->type_arguments_; | 2927 return raw_ptr()->type_arguments_; |
| 2924 } | 2928 } |
| 2925 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { | 2929 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { |
| 2926 raw_ptr()->type_arguments_ = value.raw(); | 2930 raw_ptr()->type_arguments_ = value.Canonicalize(); |
| 2927 } | 2931 } |
| 2928 | 2932 |
| 2929 virtual bool Equals(const Instance& other) const; | 2933 virtual bool Equals(const Instance& other) const; |
| 2930 | 2934 |
| 2931 static intptr_t type_arguments_offset() { | 2935 static intptr_t type_arguments_offset() { |
| 2932 return OFFSET_OF(RawArray, type_arguments_); | 2936 return OFFSET_OF(RawArray, type_arguments_); |
| 2933 } | 2937 } |
| 2934 | 2938 |
| 2935 static intptr_t InstanceSize() { | 2939 static intptr_t InstanceSize() { |
| 2936 ASSERT(sizeof(RawArray) == OFFSET_OF_RETURNED_VALUE(RawArray, data)); | 2940 ASSERT(sizeof(RawArray) == OFFSET_OF_RETURNED_VALUE(RawArray, data)); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3069 return OFFSET_OF(RawClosure, function_); | 3073 return OFFSET_OF(RawClosure, function_); |
| 3070 } | 3074 } |
| 3071 | 3075 |
| 3072 RawContext* context() const { return raw_ptr()->context_; } | 3076 RawContext* context() const { return raw_ptr()->context_; } |
| 3073 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); } | 3077 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); } |
| 3074 | 3078 |
| 3075 virtual RawAbstractTypeArguments* GetTypeArguments() const { | 3079 virtual RawAbstractTypeArguments* GetTypeArguments() const { |
| 3076 return raw_ptr()->type_arguments_; | 3080 return raw_ptr()->type_arguments_; |
| 3077 } | 3081 } |
| 3078 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { | 3082 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { |
| 3079 raw_ptr()->type_arguments_ = value.raw(); | 3083 raw_ptr()->type_arguments_ = value.Canonicalize(); |
| 3080 } | 3084 } |
| 3081 static intptr_t type_arguments_offset() { | 3085 static intptr_t type_arguments_offset() { |
| 3082 return OFFSET_OF(RawClosure, type_arguments_); | 3086 return OFFSET_OF(RawClosure, type_arguments_); |
| 3083 } | 3087 } |
| 3084 | 3088 |
| 3085 // TODO(iposva): Remove smrck support once mapping to arbitrary is available. | 3089 // TODO(iposva): Remove smrck support once mapping to arbitrary is available. |
| 3086 RawInteger* smrck() const { return raw_ptr()->smrck_; } | 3090 RawInteger* smrck() const { return raw_ptr()->smrck_; } |
| 3087 void set_smrck(const Integer& smrck) const { | 3091 void set_smrck(const Integer& smrck) const { |
| 3088 raw_ptr()->smrck_ = smrck.raw(); | 3092 raw_ptr()->smrck_ = smrck.raw(); |
| 3089 } | 3093 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3268 } | 3272 } |
| 3269 | 3273 |
| 3270 | 3274 |
| 3271 void Context::SetAt(intptr_t index, const Instance& value) const { | 3275 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 3272 StorePointer(InstanceAddr(index), value.raw()); | 3276 StorePointer(InstanceAddr(index), value.raw()); |
| 3273 } | 3277 } |
| 3274 | 3278 |
| 3275 } // namespace dart | 3279 } // namespace dart |
| 3276 | 3280 |
| 3277 #endif // VM_OBJECT_H_ | 3281 #endif // VM_OBJECT_H_ |
| OLD | NEW |