| 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 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 class Instance : public Object { | 2207 class Instance : public Object { |
| 2208 public: | 2208 public: |
| 2209 virtual bool Equals(const Instance& other) const; | 2209 virtual bool Equals(const Instance& other) const; |
| 2210 virtual RawInstance* Canonicalize() const; | 2210 virtual RawInstance* Canonicalize() const; |
| 2211 | 2211 |
| 2212 RawObject* GetField(const Field& field) const { | 2212 RawObject* GetField(const Field& field) const { |
| 2213 return *FieldAddr(field); | 2213 return *FieldAddr(field); |
| 2214 } | 2214 } |
| 2215 | 2215 |
| 2216 void SetField(const Field& field, const Object& value) const { | 2216 void SetField(const Field& field, const Object& value) const { |
| 2217 *FieldAddr(field) = value.raw(); | 2217 StorePointer(FieldAddr(field), value.raw()); |
| 2218 } | 2218 } |
| 2219 | 2219 |
| 2220 RawType* GetType() const; | 2220 RawType* GetType() const; |
| 2221 | 2221 |
| 2222 virtual RawAbstractTypeArguments* GetTypeArguments() const; | 2222 virtual RawAbstractTypeArguments* GetTypeArguments() const; |
| 2223 virtual void SetTypeArguments(const AbstractTypeArguments& value) const; | 2223 virtual void SetTypeArguments(const AbstractTypeArguments& value) const; |
| 2224 | 2224 |
| 2225 // Check if this instance is an instance of the given type. | 2225 // Check if this instance is an instance of the given type. |
| 2226 bool IsInstanceOf(const AbstractType& type, | 2226 bool IsInstanceOf(const AbstractType& type, |
| 2227 const AbstractTypeArguments& type_instantiator) const { | 2227 const AbstractTypeArguments& type_instantiator) const { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2258 RawObject** FieldAddr(const Field& field) const { | 2258 RawObject** FieldAddr(const Field& field) const { |
| 2259 return FieldAddrAtOffset(field.Offset()); | 2259 return FieldAddrAtOffset(field.Offset()); |
| 2260 } | 2260 } |
| 2261 intptr_t* NativeFieldAddr(int index) const { | 2261 intptr_t* NativeFieldAddr(int index) const { |
| 2262 ASSERT(IsValidNativeIndex(index)); | 2262 ASSERT(IsValidNativeIndex(index)); |
| 2263 return reinterpret_cast<intptr_t*>((raw_value() - kHeapObjectTag) | 2263 return reinterpret_cast<intptr_t*>((raw_value() - kHeapObjectTag) |
| 2264 + (index * kWordSize) | 2264 + (index * kWordSize) |
| 2265 + sizeof(RawObject)); | 2265 + sizeof(RawObject)); |
| 2266 } | 2266 } |
| 2267 void SetFieldAtOffset(intptr_t offset, const Object& value) const { | 2267 void SetFieldAtOffset(intptr_t offset, const Object& value) const { |
| 2268 *FieldAddrAtOffset(offset) = value.raw(); | 2268 StorePointer(FieldAddrAtOffset(offset), value.raw()); |
| 2269 } | 2269 } |
| 2270 bool IsValidFieldOffset(int offset) const; | 2270 bool IsValidFieldOffset(int offset) const; |
| 2271 | 2271 |
| 2272 // Check the subtype or assignability relationship between the type of this | 2272 // Check the subtype or assignability relationship between the type of this |
| 2273 // instance and the given type. | 2273 // instance and the given type. |
| 2274 bool TestType(TypeTestKind test, | 2274 bool TestType(TypeTestKind test, |
| 2275 const AbstractType& type, | 2275 const AbstractType& type, |
| 2276 const AbstractTypeArguments& type_instantiator) const; | 2276 const AbstractTypeArguments& type_instantiator) const; |
| 2277 | 2277 |
| 2278 // TODO(iposva): Determine if this gets in the way of Smi. | 2278 // TODO(iposva): Determine if this gets in the way of Smi. |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 return Smi::Value(raw_ptr()->length_); | 2987 return Smi::Value(raw_ptr()->length_); |
| 2988 } | 2988 } |
| 2989 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } | 2989 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } |
| 2990 static intptr_t data_offset() { return length_offset() + kWordSize; } | 2990 static intptr_t data_offset() { return length_offset() + kWordSize; } |
| 2991 | 2991 |
| 2992 RawObject* At(intptr_t index) const { | 2992 RawObject* At(intptr_t index) const { |
| 2993 return *ObjectAddr(index); | 2993 return *ObjectAddr(index); |
| 2994 } | 2994 } |
| 2995 void SetAt(intptr_t index, const Object& value) const { | 2995 void SetAt(intptr_t index, const Object& value) const { |
| 2996 // TODO(iposva): Add storing NoGCScope. | 2996 // TODO(iposva): Add storing NoGCScope. |
| 2997 *ObjectAddr(index) = value.raw(); | 2997 StorePointer(ObjectAddr(index), value.raw()); |
| 2998 } | 2998 } |
| 2999 | 2999 |
| 3000 virtual RawAbstractTypeArguments* GetTypeArguments() const { | 3000 virtual RawAbstractTypeArguments* GetTypeArguments() const { |
| 3001 return raw_ptr()->type_arguments_; | 3001 return raw_ptr()->type_arguments_; |
| 3002 } | 3002 } |
| 3003 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { | 3003 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { |
| 3004 raw_ptr()->type_arguments_ = value.Canonicalize(); | 3004 raw_ptr()->type_arguments_ = value.Canonicalize(); |
| 3005 } | 3005 } |
| 3006 | 3006 |
| 3007 virtual bool Equals(const Instance& other) const; | 3007 virtual bool Equals(const Instance& other) const; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3157 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { | 3157 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { |
| 3158 raw_ptr()->type_arguments_ = value.Canonicalize(); | 3158 raw_ptr()->type_arguments_ = value.Canonicalize(); |
| 3159 } | 3159 } |
| 3160 static intptr_t type_arguments_offset() { | 3160 static intptr_t type_arguments_offset() { |
| 3161 return OFFSET_OF(RawClosure, type_arguments_); | 3161 return OFFSET_OF(RawClosure, type_arguments_); |
| 3162 } | 3162 } |
| 3163 | 3163 |
| 3164 // TODO(iposva): Remove smrck support once mapping to arbitrary is available. | 3164 // TODO(iposva): Remove smrck support once mapping to arbitrary is available. |
| 3165 RawInteger* smrck() const { return raw_ptr()->smrck_; } | 3165 RawInteger* smrck() const { return raw_ptr()->smrck_; } |
| 3166 void set_smrck(const Integer& smrck) const { | 3166 void set_smrck(const Integer& smrck) const { |
| 3167 raw_ptr()->smrck_ = smrck.raw(); | 3167 StorePointer(&raw_ptr()->smrck_, smrck.raw()); |
| 3168 } | 3168 } |
| 3169 static intptr_t smrck_offset() { return OFFSET_OF(RawClosure, smrck_); } | 3169 static intptr_t smrck_offset() { return OFFSET_OF(RawClosure, smrck_); } |
| 3170 | 3170 |
| 3171 static intptr_t InstanceSize() { | 3171 static intptr_t InstanceSize() { |
| 3172 return RoundedAllocationSize(sizeof(RawClosure)); | 3172 return RoundedAllocationSize(sizeof(RawClosure)); |
| 3173 } | 3173 } |
| 3174 | 3174 |
| 3175 static RawClosure* New(const Function& function, | 3175 static RawClosure* New(const Function& function, |
| 3176 const Context& context, | 3176 const Context& context, |
| 3177 Heap::Space space = Heap::kNew); | 3177 Heap::Space space = Heap::kNew); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3347 } | 3347 } |
| 3348 | 3348 |
| 3349 | 3349 |
| 3350 void Context::SetAt(intptr_t index, const Instance& value) const { | 3350 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 3351 StorePointer(InstanceAddr(index), value.raw()); | 3351 StorePointer(InstanceAddr(index), value.raw()); |
| 3352 } | 3352 } |
| 3353 | 3353 |
| 3354 } // namespace dart | 3354 } // namespace dart |
| 3355 | 3355 |
| 3356 #endif // VM_OBJECT_H_ | 3356 #endif // VM_OBJECT_H_ |
| OLD | NEW |