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