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