| 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 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 // - constants_list_ position of found element, or | 1206 // - constants_list_ position of found element, or |
| 1207 // - constants_list_ position where new canonical can be inserted. | 1207 // - constants_list_ position where new canonical can be inserted. |
| 1208 RawDouble* LookupCanonicalDouble(Zone* zone, | 1208 RawDouble* LookupCanonicalDouble(Zone* zone, |
| 1209 double value, intptr_t* index) const; | 1209 double value, intptr_t* index) const; |
| 1210 RawMint* LookupCanonicalMint(Zone* zone, | 1210 RawMint* LookupCanonicalMint(Zone* zone, |
| 1211 int64_t value, intptr_t* index) const; | 1211 int64_t value, intptr_t* index) const; |
| 1212 RawBigint* LookupCanonicalBigint(Zone* zone, | 1212 RawBigint* LookupCanonicalBigint(Zone* zone, |
| 1213 const Bigint& value, intptr_t* index) const; | 1213 const Bigint& value, intptr_t* index) const; |
| 1214 // The methods above are more efficient than this generic one. | 1214 // The methods above are more efficient than this generic one. |
| 1215 RawInstance* LookupCanonicalInstance(Zone* zone, | 1215 RawInstance* LookupCanonicalInstance(Zone* zone, |
| 1216 const Instance& value, | 1216 const Instance& value) const; |
| 1217 intptr_t* index) const; | |
| 1218 | 1217 |
| 1219 void InsertCanonicalConstant(intptr_t index, const Instance& constant) const; | 1218 RawInstance* InsertCanonicalConstant(Zone* zone, |
| 1219 const Instance& constant) const; |
| 1220 void InsertCanonicalNumber(Zone* zone, | 1220 void InsertCanonicalNumber(Zone* zone, |
| 1221 intptr_t index, | 1221 intptr_t index, |
| 1222 const Number& constant) const; | 1222 const Number& constant) const; |
| 1223 | 1223 |
| 1224 intptr_t FindCanonicalTypeIndex(const AbstractType& needle) const; | 1224 intptr_t FindCanonicalTypeIndex(const AbstractType& needle) const; |
| 1225 RawAbstractType* CanonicalTypeFromIndex(intptr_t idx) const; | 1225 RawAbstractType* CanonicalTypeFromIndex(intptr_t idx) const; |
| 1226 | 1226 |
| 1227 static intptr_t InstanceSize() { | 1227 static intptr_t InstanceSize() { |
| 1228 return RoundedAllocationSize(sizeof(RawClass)); | 1228 return RoundedAllocationSize(sizeof(RawClass)); |
| 1229 } | 1229 } |
| (...skipping 3916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5146 // Equality and identity testing. | 5146 // Equality and identity testing. |
| 5147 // 1. OperatorEquals: true iff 'this == other' is true in Dart code. | 5147 // 1. OperatorEquals: true iff 'this == other' is true in Dart code. |
| 5148 // 2. IsIdenticalTo: true iff 'identical(this, other)' is true in Dart code. | 5148 // 2. IsIdenticalTo: true iff 'identical(this, other)' is true in Dart code. |
| 5149 // 3. CanonicalizeEquals: used to canonicalize compile-time constants, e.g., | 5149 // 3. CanonicalizeEquals: used to canonicalize compile-time constants, e.g., |
| 5150 // using bitwise equality of fields and list elements. | 5150 // using bitwise equality of fields and list elements. |
| 5151 // Subclasses where 1 and 3 coincide may also define a plain Equals, e.g., | 5151 // Subclasses where 1 and 3 coincide may also define a plain Equals, e.g., |
| 5152 // String and Integer. | 5152 // String and Integer. |
| 5153 virtual bool OperatorEquals(const Instance& other) const; | 5153 virtual bool OperatorEquals(const Instance& other) const; |
| 5154 bool IsIdenticalTo(const Instance& other) const; | 5154 bool IsIdenticalTo(const Instance& other) const; |
| 5155 virtual bool CanonicalizeEquals(const Instance& other) const; | 5155 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 5156 virtual uword ComputeCanonicalTableHash() const; |
| 5157 |
| 5158 intptr_t SizeFromClass() const { |
| 5159 #if defined(DEBUG) |
| 5160 const Class& cls = Class::Handle(clazz()); |
| 5161 ASSERT(cls.is_finalized() || cls.is_prefinalized()); |
| 5162 #endif |
| 5163 return (clazz()->ptr()->instance_size_in_words_ * kWordSize); |
| 5164 } |
| 5156 | 5165 |
| 5157 // Returns Instance::null() if instance cannot be canonicalized. | 5166 // Returns Instance::null() if instance cannot be canonicalized. |
| 5158 // Any non-canonical number of string will be canonicalized here. | 5167 // Any non-canonical number of string will be canonicalized here. |
| 5159 // An instance cannot be canonicalized if it still contains non-canonical | 5168 // An instance cannot be canonicalized if it still contains non-canonical |
| 5160 // instances in its fields. | 5169 // instances in its fields. |
| 5161 // Returns error in error_str, pass NULL if an error cannot occur. | 5170 // Returns error in error_str, pass NULL if an error cannot occur. |
| 5162 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const; | 5171 virtual RawInstance* CheckAndCanonicalize(Thread* thread, |
| 5172 const char** error_str) const; |
| 5163 | 5173 |
| 5164 // Returns true if all fields are OK for canonicalization. | 5174 // Returns true if all fields are OK for canonicalization. |
| 5165 virtual bool CheckAndCanonicalizeFields(Zone* zone, | 5175 virtual bool CheckAndCanonicalizeFields(Thread* thread, |
| 5166 const char** error_str) const; | 5176 const char** error_str) const; |
| 5167 | 5177 |
| 5168 RawObject* GetField(const Field& field) const { | 5178 RawObject* GetField(const Field& field) const { |
| 5169 return *FieldAddr(field); | 5179 return *FieldAddr(field); |
| 5170 } | 5180 } |
| 5171 | 5181 |
| 5172 void SetField(const Field& field, const Object& value) const { | 5182 void SetField(const Field& field, const Object& value) const { |
| 5173 field.RecordStore(value); | 5183 field.RecordStore(value); |
| 5174 StorePointer(FieldAddr(field), value.raw()); | 5184 StorePointer(FieldAddr(field), value.raw()); |
| 5175 } | 5185 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5375 virtual RawAbstractType* CloneUnfinalized() const; | 5385 virtual RawAbstractType* CloneUnfinalized() const; |
| 5376 | 5386 |
| 5377 // Return a clone of this uninstantiated type where all references to type | 5387 // Return a clone of this uninstantiated type where all references to type |
| 5378 // parameters are replaced with references to type parameters of the same name | 5388 // parameters are replaced with references to type parameters of the same name |
| 5379 // but belonging to the new owner class. | 5389 // but belonging to the new owner class. |
| 5380 // Apply recursively to type arguments, i.e. instantiated type arguments of | 5390 // Apply recursively to type arguments, i.e. instantiated type arguments of |
| 5381 // an uninstantiated type are not cloned, but shared. | 5391 // an uninstantiated type are not cloned, but shared. |
| 5382 virtual RawAbstractType* CloneUninstantiated( | 5392 virtual RawAbstractType* CloneUninstantiated( |
| 5383 const Class& new_owner, TrailPtr trail = NULL) const; | 5393 const Class& new_owner, TrailPtr trail = NULL) const; |
| 5384 | 5394 |
| 5385 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 5395 virtual RawInstance* CheckAndCanonicalize(Thread* thread, |
| 5396 const char** error_str) const { |
| 5386 return Canonicalize(); | 5397 return Canonicalize(); |
| 5387 } | 5398 } |
| 5388 | 5399 |
| 5389 // Return the canonical version of this type. | 5400 // Return the canonical version of this type. |
| 5390 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5401 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5391 | 5402 |
| 5392 // Return the object associated with the receiver in the trail or | 5403 // Return the object associated with the receiver in the trail or |
| 5393 // AbstractType::null() if the receiver is not contained in the trail. | 5404 // AbstractType::null() if the receiver is not contained in the trail. |
| 5394 RawAbstractType* OnlyBuddyInTrail(TrailPtr trail) const; | 5405 RawAbstractType* OnlyBuddyInTrail(TrailPtr trail) const; |
| 5395 | 5406 |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5944 friend class Class; | 5955 friend class Class; |
| 5945 }; | 5956 }; |
| 5946 | 5957 |
| 5947 | 5958 |
| 5948 class Number : public Instance { | 5959 class Number : public Instance { |
| 5949 public: | 5960 public: |
| 5950 // TODO(iposva): Add more useful Number methods. | 5961 // TODO(iposva): Add more useful Number methods. |
| 5951 RawString* ToString(Heap::Space space) const; | 5962 RawString* ToString(Heap::Space space) const; |
| 5952 | 5963 |
| 5953 // Numbers are canonicalized differently from other instances/strings. | 5964 // Numbers are canonicalized differently from other instances/strings. |
| 5954 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const; | 5965 virtual RawInstance* CheckAndCanonicalize(Thread* thread, |
| 5966 const char** error_str) const; |
| 5955 | 5967 |
| 5956 private: | 5968 private: |
| 5957 OBJECT_IMPLEMENTATION(Number, Instance); | 5969 OBJECT_IMPLEMENTATION(Number, Instance); |
| 5958 | 5970 |
| 5959 friend class Class; | 5971 friend class Class; |
| 5960 }; | 5972 }; |
| 5961 | 5973 |
| 5962 | 5974 |
| 5963 class Integer : public Number { | 5975 class Integer : public Number { |
| 5964 public: | 5976 public: |
| 5965 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); | 5977 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); |
| 5966 static RawInteger* NewFromUint64(uint64_t value, | 5978 static RawInteger* NewFromUint64(uint64_t value, |
| 5967 Heap::Space space = Heap::kNew); | 5979 Heap::Space space = Heap::kNew); |
| 5968 | 5980 |
| 5969 // Returns a canonical Integer object allocated in the old gen space. | 5981 // Returns a canonical Integer object allocated in the old gen space. |
| 5970 static RawInteger* NewCanonical(const String& str); | 5982 static RawInteger* NewCanonical(const String& str); |
| 5971 | 5983 |
| 5972 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); | 5984 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); |
| 5973 | 5985 |
| 5974 virtual bool OperatorEquals(const Instance& other) const { | 5986 virtual bool OperatorEquals(const Instance& other) const { |
| 5975 return Equals(other); | 5987 return Equals(other); |
| 5976 } | 5988 } |
| 5977 virtual bool CanonicalizeEquals(const Instance& other) const { | 5989 virtual bool CanonicalizeEquals(const Instance& other) const { |
| 5978 return Equals(other); | 5990 return Equals(other); |
| 5979 } | 5991 } |
| 5992 virtual uword ComputeCanonicalTableHash() const { |
| 5993 UNREACHABLE(); |
| 5994 return 0; |
| 5995 } |
| 5980 virtual bool Equals(const Instance& other) const; | 5996 virtual bool Equals(const Instance& other) const; |
| 5981 | 5997 |
| 5982 virtual RawObject* HashCode() const { return raw(); } | 5998 virtual RawObject* HashCode() const { return raw(); } |
| 5983 | 5999 |
| 5984 virtual bool IsZero() const; | 6000 virtual bool IsZero() const; |
| 5985 virtual bool IsNegative() const; | 6001 virtual bool IsNegative() const; |
| 5986 | 6002 |
| 5987 virtual double AsDoubleValue() const; | 6003 virtual double AsDoubleValue() const; |
| 5988 virtual int64_t AsInt64Value() const; | 6004 virtual int64_t AsInt64Value() const; |
| 5989 virtual int64_t AsTruncatedInt64Value() const { | 6005 virtual int64_t AsTruncatedInt64Value() const { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6155 virtual bool IsNegative() const { return Neg(); } | 6171 virtual bool IsNegative() const { return Neg(); } |
| 6156 virtual bool Equals(const Instance& other) const; | 6172 virtual bool Equals(const Instance& other) const; |
| 6157 | 6173 |
| 6158 virtual double AsDoubleValue() const; | 6174 virtual double AsDoubleValue() const; |
| 6159 virtual int64_t AsInt64Value() const; | 6175 virtual int64_t AsInt64Value() const; |
| 6160 virtual int64_t AsTruncatedInt64Value() const; | 6176 virtual int64_t AsTruncatedInt64Value() const; |
| 6161 virtual uint32_t AsTruncatedUint32Value() const; | 6177 virtual uint32_t AsTruncatedUint32Value() const; |
| 6162 | 6178 |
| 6163 virtual int CompareWith(const Integer& other) const; | 6179 virtual int CompareWith(const Integer& other) const; |
| 6164 | 6180 |
| 6165 virtual bool CheckAndCanonicalizeFields(Zone* zone, | 6181 virtual bool CheckAndCanonicalizeFields(Thread* thread, |
| 6166 const char** error_str) const; | 6182 const char** error_str) const; |
| 6167 | 6183 |
| 6168 virtual bool FitsIntoSmi() const; | 6184 virtual bool FitsIntoSmi() const; |
| 6169 bool FitsIntoInt64() const; | 6185 bool FitsIntoInt64() const; |
| 6170 bool FitsIntoUint64() const; | 6186 bool FitsIntoUint64() const; |
| 6171 uint64_t AsUint64Value() const; | 6187 uint64_t AsUint64Value() const; |
| 6172 | 6188 |
| 6173 static intptr_t InstanceSize() { | 6189 static intptr_t InstanceSize() { |
| 6174 return RoundedAllocationSize(sizeof(RawBigint)); | 6190 return RoundedAllocationSize(sizeof(RawBigint)); |
| 6175 } | 6191 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6247 // abstract class double in corelib. | 6263 // abstract class double in corelib. |
| 6248 class Double : public Number { | 6264 class Double : public Number { |
| 6249 public: | 6265 public: |
| 6250 double value() const { | 6266 double value() const { |
| 6251 return raw_ptr()->value_; | 6267 return raw_ptr()->value_; |
| 6252 } | 6268 } |
| 6253 | 6269 |
| 6254 bool BitwiseEqualsToDouble(double value) const; | 6270 bool BitwiseEqualsToDouble(double value) const; |
| 6255 virtual bool OperatorEquals(const Instance& other) const; | 6271 virtual bool OperatorEquals(const Instance& other) const; |
| 6256 virtual bool CanonicalizeEquals(const Instance& other) const; | 6272 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 6273 virtual uword ComputeCanonicalTableHash() const { |
| 6274 UNREACHABLE(); |
| 6275 return 0; |
| 6276 } |
| 6257 | 6277 |
| 6258 static RawDouble* New(double d, Heap::Space space = Heap::kNew); | 6278 static RawDouble* New(double d, Heap::Space space = Heap::kNew); |
| 6259 | 6279 |
| 6260 static RawDouble* New(const String& str, Heap::Space space = Heap::kNew); | 6280 static RawDouble* New(const String& str, Heap::Space space = Heap::kNew); |
| 6261 | 6281 |
| 6262 // Returns a canonical double object allocated in the old gen space. | 6282 // Returns a canonical double object allocated in the old gen space. |
| 6263 static RawDouble* NewCanonical(double d); | 6283 static RawDouble* NewCanonical(double d); |
| 6264 | 6284 |
| 6265 // Returns a canonical double object (allocated in the old gen space) or | 6285 // Returns a canonical double object (allocated in the old gen space) or |
| 6266 // Double::null() if str points to a string that does not convert to a | 6286 // Double::null() if str points to a string that does not convert to a |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6397 | 6417 |
| 6398 // True iff this string equals str1 + str2. | 6418 // True iff this string equals str1 + str2. |
| 6399 bool EqualsConcat(const String& str1, const String& str2) const; | 6419 bool EqualsConcat(const String& str1, const String& str2) const; |
| 6400 | 6420 |
| 6401 virtual bool OperatorEquals(const Instance& other) const { | 6421 virtual bool OperatorEquals(const Instance& other) const { |
| 6402 return Equals(other); | 6422 return Equals(other); |
| 6403 } | 6423 } |
| 6404 virtual bool CanonicalizeEquals(const Instance& other) const { | 6424 virtual bool CanonicalizeEquals(const Instance& other) const { |
| 6405 return Equals(other); | 6425 return Equals(other); |
| 6406 } | 6426 } |
| 6427 virtual uword ComputeCanonicalTableHash() const { |
| 6428 UNREACHABLE(); |
| 6429 return 0; |
| 6430 } |
| 6407 virtual bool Equals(const Instance& other) const; | 6431 virtual bool Equals(const Instance& other) const; |
| 6408 | 6432 |
| 6409 intptr_t CompareTo(const String& other) const; | 6433 intptr_t CompareTo(const String& other) const; |
| 6410 | 6434 |
| 6411 bool StartsWith(const String& other) const; | 6435 bool StartsWith(const String& other) const; |
| 6412 | 6436 |
| 6413 // Strings are canonicalized using the symbol table. | 6437 // Strings are canonicalized using the symbol table. |
| 6414 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const; | 6438 virtual RawInstance* CheckAndCanonicalize(Thread* thread, |
| 6439 const char** error_str) const; |
| 6415 | 6440 |
| 6416 bool IsSymbol() const { return raw()->IsCanonical(); } | 6441 bool IsSymbol() const { return raw()->IsCanonical(); } |
| 6417 | 6442 |
| 6418 bool IsOneByteString() const { | 6443 bool IsOneByteString() const { |
| 6419 return raw()->GetClassId() == kOneByteStringCid; | 6444 return raw()->GetClassId() == kOneByteStringCid; |
| 6420 } | 6445 } |
| 6421 | 6446 |
| 6422 bool IsTwoByteString() const { | 6447 bool IsTwoByteString() const { |
| 6423 return raw()->GetClassId() == kTwoByteStringCid; | 6448 return raw()->GetClassId() == kTwoByteStringCid; |
| 6424 } | 6449 } |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7086 // argument vector of the instantiator. | 7111 // argument vector of the instantiator. |
| 7087 ASSERT(value.IsNull() || | 7112 ASSERT(value.IsNull() || |
| 7088 ((value.Length() >= 1) && | 7113 ((value.Length() >= 1) && |
| 7089 value.IsInstantiated() /*&& value.IsCanonical()*/)); | 7114 value.IsInstantiated() /*&& value.IsCanonical()*/)); |
| 7090 // TODO(asiva): Values read from a message snapshot are not properly marked | 7115 // TODO(asiva): Values read from a message snapshot are not properly marked |
| 7091 // as canonical. See for example tests/isolate/mandel_isolate_test.dart. | 7116 // as canonical. See for example tests/isolate/mandel_isolate_test.dart. |
| 7092 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 7117 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 7093 } | 7118 } |
| 7094 | 7119 |
| 7095 virtual bool CanonicalizeEquals(const Instance& other) const; | 7120 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 7121 virtual uword ComputeCanonicalTableHash() const; |
| 7096 | 7122 |
| 7097 static const intptr_t kBytesPerElement = kWordSize; | 7123 static const intptr_t kBytesPerElement = kWordSize; |
| 7098 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 7124 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 7099 | 7125 |
| 7100 static intptr_t type_arguments_offset() { | 7126 static intptr_t type_arguments_offset() { |
| 7101 return OFFSET_OF(RawArray, type_arguments_); | 7127 return OFFSET_OF(RawArray, type_arguments_); |
| 7102 } | 7128 } |
| 7103 | 7129 |
| 7104 static intptr_t InstanceSize() { | 7130 static intptr_t InstanceSize() { |
| 7105 ASSERT(sizeof(RawArray) == OFFSET_OF_RETURNED_VALUE(RawArray, data)); | 7131 ASSERT(sizeof(RawArray) == OFFSET_OF_RETURNED_VALUE(RawArray, data)); |
| 7106 return 0; | 7132 return 0; |
| 7107 } | 7133 } |
| 7108 | 7134 |
| 7109 static intptr_t InstanceSize(intptr_t len) { | 7135 static intptr_t InstanceSize(intptr_t len) { |
| 7110 // Ensure that variable length data is not adding to the object length. | 7136 // Ensure that variable length data is not adding to the object length. |
| 7111 ASSERT(sizeof(RawArray) == (sizeof(RawInstance) + (2 * kWordSize))); | 7137 ASSERT(sizeof(RawArray) == (sizeof(RawInstance) + (2 * kWordSize))); |
| 7112 ASSERT(0 <= len && len <= kMaxElements); | 7138 ASSERT(0 <= len && len <= kMaxElements); |
| 7113 return RoundedAllocationSize(sizeof(RawArray) + (len * kBytesPerElement)); | 7139 return RoundedAllocationSize(sizeof(RawArray) + (len * kBytesPerElement)); |
| 7114 } | 7140 } |
| 7115 | 7141 |
| 7116 // Returns true if all elements are OK for canonicalization. | 7142 // Returns true if all elements are OK for canonicalization. |
| 7117 virtual bool CheckAndCanonicalizeFields(Zone* zone, | 7143 virtual bool CheckAndCanonicalizeFields(Thread* thread, |
| 7118 const char** error_str) const; | 7144 const char** error_str) const; |
| 7119 | 7145 |
| 7120 // Make the array immutable to Dart code by switching the class pointer | 7146 // Make the array immutable to Dart code by switching the class pointer |
| 7121 // to ImmutableArray. | 7147 // to ImmutableArray. |
| 7122 void MakeImmutable() const; | 7148 void MakeImmutable() const; |
| 7123 | 7149 |
| 7124 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew); | 7150 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew); |
| 7125 | 7151 |
| 7126 // Creates and returns a new array with 'new_length'. Copies all elements from | 7152 // Creates and returns a new array with 'new_length'. Copies all elements from |
| 7127 // 'source' to the new array. 'new_length' must be greater than or equal to | 7153 // 'source' to the new array. 'new_length' must be greater than or equal to |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7259 const Array& contents = Array::Handle(data()); | 7285 const Array& contents = Array::Handle(data()); |
| 7260 contents.SetTypeArguments(value); | 7286 contents.SetTypeArguments(value); |
| 7261 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 7287 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 7262 } | 7288 } |
| 7263 | 7289 |
| 7264 // We don't expect a growable object array to be canonicalized. | 7290 // We don't expect a growable object array to be canonicalized. |
| 7265 virtual bool CanonicalizeEquals(const Instance& other) const { | 7291 virtual bool CanonicalizeEquals(const Instance& other) const { |
| 7266 UNREACHABLE(); | 7292 UNREACHABLE(); |
| 7267 return false; | 7293 return false; |
| 7268 } | 7294 } |
| 7295 virtual uword ComputeCanonicalTableHash() const { |
| 7296 UNREACHABLE(); |
| 7297 return 0; |
| 7298 } |
| 7269 | 7299 |
| 7270 // We don't expect a growable object array to be canonicalized. | 7300 // We don't expect a growable object array to be canonicalized. |
| 7271 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 7301 virtual RawInstance* CheckAndCanonicalize(Thread* thread, |
| 7302 const char** error_str) const { |
| 7272 UNREACHABLE(); | 7303 UNREACHABLE(); |
| 7273 return Instance::null(); | 7304 return Instance::null(); |
| 7274 } | 7305 } |
| 7275 | 7306 |
| 7276 static intptr_t type_arguments_offset() { | 7307 static intptr_t type_arguments_offset() { |
| 7277 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); | 7308 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); |
| 7278 } | 7309 } |
| 7279 | 7310 |
| 7280 static intptr_t length_offset() { | 7311 static intptr_t length_offset() { |
| 7281 return OFFSET_OF(RawGrowableObjectArray, length_); | 7312 return OFFSET_OF(RawGrowableObjectArray, length_); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7435 } | 7466 } |
| 7436 | 7467 |
| 7437 void* DataAddr(intptr_t byte_offset) const { | 7468 void* DataAddr(intptr_t byte_offset) const { |
| 7438 ASSERT((byte_offset == 0) || | 7469 ASSERT((byte_offset == 0) || |
| 7439 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); | 7470 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); |
| 7440 return reinterpret_cast<void*>( | 7471 return reinterpret_cast<void*>( |
| 7441 UnsafeMutableNonPointer(raw_ptr()->data()) + byte_offset); | 7472 UnsafeMutableNonPointer(raw_ptr()->data()) + byte_offset); |
| 7442 } | 7473 } |
| 7443 | 7474 |
| 7444 virtual bool CanonicalizeEquals(const Instance& other) const; | 7475 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 7476 virtual uword ComputeCanonicalTableHash() const; |
| 7445 | 7477 |
| 7446 #define TYPED_GETTER_SETTER(name, type) \ | 7478 #define TYPED_GETTER_SETTER(name, type) \ |
| 7447 type Get##name(intptr_t byte_offset) const { \ | 7479 type Get##name(intptr_t byte_offset) const { \ |
| 7448 NoSafepointScope no_safepoint; \ | 7480 NoSafepointScope no_safepoint; \ |
| 7449 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ | 7481 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ |
| 7450 } \ | 7482 } \ |
| 7451 void Set##name(intptr_t byte_offset, type value) const { \ | 7483 void Set##name(intptr_t byte_offset, type value) const { \ |
| 7452 NoSafepointScope no_safepoint; \ | 7484 NoSafepointScope no_safepoint; \ |
| 7453 *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ | 7485 *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ |
| 7454 } | 7486 } |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7950 | 7982 |
| 7951 static intptr_t type_arguments_offset() { | 7983 static intptr_t type_arguments_offset() { |
| 7952 return OFFSET_OF(RawClosure, type_arguments_); | 7984 return OFFSET_OF(RawClosure, type_arguments_); |
| 7953 } | 7985 } |
| 7954 | 7986 |
| 7955 static intptr_t InstanceSize() { | 7987 static intptr_t InstanceSize() { |
| 7956 return RoundedAllocationSize(sizeof(RawClosure)); | 7988 return RoundedAllocationSize(sizeof(RawClosure)); |
| 7957 } | 7989 } |
| 7958 | 7990 |
| 7959 // Returns true if all elements are OK for canonicalization. | 7991 // Returns true if all elements are OK for canonicalization. |
| 7960 virtual bool CheckAndCanonicalizeFields(Zone* zone, | 7992 virtual bool CheckAndCanonicalizeFields(Thread* thread, |
| 7961 const char** error_str) const { | 7993 const char** error_str) const { |
| 7962 // None of the fields of a closure are instances. | 7994 // None of the fields of a closure are instances. |
| 7963 return true; | 7995 return true; |
| 7964 } | 7996 } |
| 7965 | 7997 |
| 7966 static RawClosure* New(const Function& function, | 7998 static RawClosure* New(const Function& function, |
| 7967 const Context& context, | 7999 const Context& context, |
| 7968 Heap::Space space = Heap::kNew); | 8000 Heap::Space space = Heap::kNew); |
| 7969 | 8001 |
| 7970 private: | 8002 private: |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8455 | 8487 |
| 8456 | 8488 |
| 8457 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8489 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8458 intptr_t index) { | 8490 intptr_t index) { |
| 8459 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8491 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8460 } | 8492 } |
| 8461 | 8493 |
| 8462 } // namespace dart | 8494 } // namespace dart |
| 8463 | 8495 |
| 8464 #endif // VM_OBJECT_H_ | 8496 #endif // VM_OBJECT_H_ |
| OLD | NEW |