| 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 4763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4774 } | 4774 } |
| 4775 void SetAt(intptr_t index, const Object& value) const { | 4775 void SetAt(intptr_t index, const Object& value) const { |
| 4776 // TODO(iposva): Add storing NoGCScope. | 4776 // TODO(iposva): Add storing NoGCScope. |
| 4777 StorePointer(ObjectAddr(index), value.raw()); | 4777 StorePointer(ObjectAddr(index), value.raw()); |
| 4778 } | 4778 } |
| 4779 | 4779 |
| 4780 virtual RawAbstractTypeArguments* GetTypeArguments() const { | 4780 virtual RawAbstractTypeArguments* GetTypeArguments() const { |
| 4781 return raw_ptr()->type_arguments_; | 4781 return raw_ptr()->type_arguments_; |
| 4782 } | 4782 } |
| 4783 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { | 4783 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { |
| 4784 ASSERT(value.IsNull() || ((value.Length() == 1) && value.IsInstantiated())); | 4784 // An Array is raw or takes one type argument. However, its type argument |
| 4785 // vector may be longer than 1 due to a type optimization reusing the type |
| 4786 // argument vector of the instantiator. |
| 4787 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated())); |
| 4785 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 4788 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 4786 } | 4789 } |
| 4787 | 4790 |
| 4788 virtual bool Equals(const Instance& other) const; | 4791 virtual bool Equals(const Instance& other) const; |
| 4789 | 4792 |
| 4790 static const intptr_t kBytesPerElement = kWordSize; | 4793 static const intptr_t kBytesPerElement = kWordSize; |
| 4791 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 4794 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 4792 | 4795 |
| 4793 static intptr_t type_arguments_offset() { | 4796 static intptr_t type_arguments_offset() { |
| 4794 return OFFSET_OF(RawArray, type_arguments_); | 4797 return OFFSET_OF(RawArray, type_arguments_); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4902 | 4905 |
| 4903 void Add(const Object& value, Heap::Space space = Heap::kNew) const; | 4906 void Add(const Object& value, Heap::Space space = Heap::kNew) const; |
| 4904 | 4907 |
| 4905 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; | 4908 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; |
| 4906 RawObject* RemoveLast() const; | 4909 RawObject* RemoveLast() const; |
| 4907 | 4910 |
| 4908 virtual RawAbstractTypeArguments* GetTypeArguments() const { | 4911 virtual RawAbstractTypeArguments* GetTypeArguments() const { |
| 4909 return raw_ptr()->type_arguments_; | 4912 return raw_ptr()->type_arguments_; |
| 4910 } | 4913 } |
| 4911 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { | 4914 virtual void SetTypeArguments(const AbstractTypeArguments& value) const { |
| 4912 ASSERT(value.IsNull() || ((value.Length() == 1) && value.IsInstantiated())); | 4915 // A GrowableObjectArray is raw or takes one type argument. However, its |
| 4916 // type argument vector may be longer than 1 due to a type optimization |
| 4917 // reusing the type argument vector of the instantiator. |
| 4918 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated())); |
| 4913 const Array& contents = Array::Handle(data()); | 4919 const Array& contents = Array::Handle(data()); |
| 4914 contents.SetTypeArguments(value); | 4920 contents.SetTypeArguments(value); |
| 4915 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 4921 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 4916 } | 4922 } |
| 4917 | 4923 |
| 4918 virtual bool Equals(const Instance& other) const; | 4924 virtual bool Equals(const Instance& other) const; |
| 4919 | 4925 |
| 4920 static intptr_t type_arguments_offset() { | 4926 static intptr_t type_arguments_offset() { |
| 4921 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); | 4927 return OFFSET_OF(RawGrowableObjectArray, type_arguments_); |
| 4922 } | 4928 } |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5705 | 5711 |
| 5706 | 5712 |
| 5707 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 5713 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 5708 intptr_t index) { | 5714 intptr_t index) { |
| 5709 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 5715 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 5710 } | 5716 } |
| 5711 | 5717 |
| 5712 } // namespace dart | 5718 } // namespace dart |
| 5713 | 5719 |
| 5714 #endif // VM_OBJECT_H_ | 5720 #endif // VM_OBJECT_H_ |
| OLD | NEW |