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 RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_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 7647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7658 Heap::Space space = Heap::kNew); | 7658 Heap::Space space = Heap::kNew); |
7659 | 7659 |
7660 // Return an Array object that contains all the elements currently present | 7660 // Return an Array object that contains all the elements currently present |
7661 // in the specified Growable Object Array. This is done by first truncating | 7661 // in the specified Growable Object Array. This is done by first truncating |
7662 // the Growable Object Array's backing array to the currently used size and | 7662 // the Growable Object Array's backing array to the currently used size and |
7663 // returning the truncated backing array. | 7663 // returning the truncated backing array. |
7664 // The remaining unused part of the backing array is marked as an Array | 7664 // The remaining unused part of the backing array is marked as an Array |
7665 // object or a regular Object so that it can be traversed during garbage | 7665 // object or a regular Object so that it can be traversed during garbage |
7666 // collection. The backing array of the original Growable Object Array is | 7666 // collection. The backing array of the original Growable Object Array is |
7667 // set to an empty array. | 7667 // set to an empty array. |
7668 // If the unique parameter is false, the function is allowed to return | 7668 static RawArray* MakeArray(const GrowableObjectArray& growable_array); |
7669 // a shared Array instance. | |
7670 static RawArray* MakeFixedLength(const GrowableObjectArray& growable_array, | |
7671 bool unique = false); | |
7672 | 7669 |
7673 RawArray* Slice(intptr_t start, | 7670 RawArray* Slice(intptr_t start, |
7674 intptr_t count, | 7671 intptr_t count, |
7675 bool with_type_argument) const; | 7672 bool with_type_argument) const; |
7676 | 7673 |
7677 protected: | 7674 protected: |
7678 static RawArray* New(intptr_t class_id, | 7675 static RawArray* New(intptr_t class_id, |
7679 intptr_t len, | 7676 intptr_t len, |
7680 Heap::Space space = Heap::kNew); | 7677 Heap::Space space = Heap::kNew); |
7681 | 7678 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7775 | 7772 |
7776 virtual RawTypeArguments* GetTypeArguments() const { | 7773 virtual RawTypeArguments* GetTypeArguments() const { |
7777 return raw_ptr()->type_arguments_; | 7774 return raw_ptr()->type_arguments_; |
7778 } | 7775 } |
7779 virtual void SetTypeArguments(const TypeArguments& value) const { | 7776 virtual void SetTypeArguments(const TypeArguments& value) const { |
7780 // A GrowableObjectArray is raw or takes one type argument. However, its | 7777 // A GrowableObjectArray is raw or takes one type argument. However, its |
7781 // type argument vector may be longer than 1 due to a type optimization | 7778 // type argument vector may be longer than 1 due to a type optimization |
7782 // reusing the type argument vector of the instantiator. | 7779 // reusing the type argument vector of the instantiator. |
7783 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated() && | 7780 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated() && |
7784 value.IsCanonical())); | 7781 value.IsCanonical())); |
| 7782 const Array& contents = Array::Handle(data()); |
| 7783 contents.SetTypeArguments(value); |
7785 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 7784 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
7786 } | 7785 } |
7787 | 7786 |
7788 // We don't expect a growable object array to be canonicalized. | 7787 // We don't expect a growable object array to be canonicalized. |
7789 virtual bool CanonicalizeEquals(const Instance& other) const { | 7788 virtual bool CanonicalizeEquals(const Instance& other) const { |
7790 UNREACHABLE(); | 7789 UNREACHABLE(); |
7791 return false; | 7790 return false; |
7792 } | 7791 } |
7793 virtual uword ComputeCanonicalTableHash() const { | 7792 virtual uword ComputeCanonicalTableHash() const { |
7794 UNREACHABLE(); | 7793 UNREACHABLE(); |
(...skipping 30 matching lines...) Expand all Loading... |
7825 static RawGrowableObjectArray* New(const Array& array, | 7824 static RawGrowableObjectArray* New(const Array& array, |
7826 Heap::Space space = Heap::kNew); | 7825 Heap::Space space = Heap::kNew); |
7827 | 7826 |
7828 private: | 7827 private: |
7829 RawArray* DataArray() const { return data()->ptr(); } | 7828 RawArray* DataArray() const { return data()->ptr(); } |
7830 RawObject** ObjectAddr(intptr_t index) const { | 7829 RawObject** ObjectAddr(intptr_t index) const { |
7831 ASSERT((index >= 0) && (index < Length())); | 7830 ASSERT((index >= 0) && (index < Length())); |
7832 return &(DataArray()->data()[index]); | 7831 return &(DataArray()->data()[index]); |
7833 } | 7832 } |
7834 | 7833 |
7835 static const int kDefaultInitialCapacity = 0; | 7834 static const int kDefaultInitialCapacity = 4; |
7836 | 7835 |
7837 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); | 7836 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); |
7838 friend class Array; | 7837 friend class Array; |
7839 friend class Class; | 7838 friend class Class; |
7840 }; | 7839 }; |
7841 | 7840 |
7842 | 7841 |
7843 class Float32x4 : public Instance { | 7842 class Float32x4 : public Instance { |
7844 public: | 7843 public: |
7845 static RawFloat32x4* New(float value0, | 7844 static RawFloat32x4* New(float value0, |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9067 | 9066 |
9068 inline void TypeArguments::SetHash(intptr_t value) const { | 9067 inline void TypeArguments::SetHash(intptr_t value) const { |
9069 // This is only safe because we create a new Smi, which does not cause | 9068 // This is only safe because we create a new Smi, which does not cause |
9070 // heap allocation. | 9069 // heap allocation. |
9071 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 9070 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
9072 } | 9071 } |
9073 | 9072 |
9074 } // namespace dart | 9073 } // namespace dart |
9075 | 9074 |
9076 #endif // RUNTIME_VM_OBJECT_H_ | 9075 #endif // RUNTIME_VM_OBJECT_H_ |
OLD | NEW |