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 7634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7645 Heap::Space space = Heap::kNew); | 7645 Heap::Space space = Heap::kNew); |
7646 | 7646 |
7647 // Return an Array object that contains all the elements currently present | 7647 // Return an Array object that contains all the elements currently present |
7648 // in the specified Growable Object Array. This is done by first truncating | 7648 // in the specified Growable Object Array. This is done by first truncating |
7649 // the Growable Object Array's backing array to the currently used size and | 7649 // the Growable Object Array's backing array to the currently used size and |
7650 // returning the truncated backing array. | 7650 // returning the truncated backing array. |
7651 // The remaining unused part of the backing array is marked as an Array | 7651 // The remaining unused part of the backing array is marked as an Array |
7652 // object or a regular Object so that it can be traversed during garbage | 7652 // object or a regular Object so that it can be traversed during garbage |
7653 // collection. The backing array of the original Growable Object Array is | 7653 // collection. The backing array of the original Growable Object Array is |
7654 // set to an empty array. | 7654 // set to an empty array. |
7655 static RawArray* MakeArray(const GrowableObjectArray& growable_array); | 7655 // If the unique parameter is false, the function is allowed to return |
| 7656 // a shared Array instance. |
| 7657 static RawArray* MakeFixedLength(const GrowableObjectArray& growable_array, |
| 7658 bool unique = false); |
7656 | 7659 |
7657 RawArray* Slice(intptr_t start, | 7660 RawArray* Slice(intptr_t start, |
7658 intptr_t count, | 7661 intptr_t count, |
7659 bool with_type_argument) const; | 7662 bool with_type_argument) const; |
7660 | 7663 |
7661 protected: | 7664 protected: |
7662 static RawArray* New(intptr_t class_id, | 7665 static RawArray* New(intptr_t class_id, |
7663 intptr_t len, | 7666 intptr_t len, |
7664 Heap::Space space = Heap::kNew); | 7667 Heap::Space space = Heap::kNew); |
7665 | 7668 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7759 | 7762 |
7760 virtual RawTypeArguments* GetTypeArguments() const { | 7763 virtual RawTypeArguments* GetTypeArguments() const { |
7761 return raw_ptr()->type_arguments_; | 7764 return raw_ptr()->type_arguments_; |
7762 } | 7765 } |
7763 virtual void SetTypeArguments(const TypeArguments& value) const { | 7766 virtual void SetTypeArguments(const TypeArguments& value) const { |
7764 // A GrowableObjectArray is raw or takes one type argument. However, its | 7767 // A GrowableObjectArray is raw or takes one type argument. However, its |
7765 // type argument vector may be longer than 1 due to a type optimization | 7768 // type argument vector may be longer than 1 due to a type optimization |
7766 // reusing the type argument vector of the instantiator. | 7769 // reusing the type argument vector of the instantiator. |
7767 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated() && | 7770 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated() && |
7768 value.IsCanonical())); | 7771 value.IsCanonical())); |
7769 const Array& contents = Array::Handle(data()); | |
7770 contents.SetTypeArguments(value); | |
7771 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 7772 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
7772 } | 7773 } |
7773 | 7774 |
7774 // We don't expect a growable object array to be canonicalized. | 7775 // We don't expect a growable object array to be canonicalized. |
7775 virtual bool CanonicalizeEquals(const Instance& other) const { | 7776 virtual bool CanonicalizeEquals(const Instance& other) const { |
7776 UNREACHABLE(); | 7777 UNREACHABLE(); |
7777 return false; | 7778 return false; |
7778 } | 7779 } |
7779 virtual uword ComputeCanonicalTableHash() const { | 7780 virtual uword ComputeCanonicalTableHash() const { |
7780 UNREACHABLE(); | 7781 UNREACHABLE(); |
(...skipping 30 matching lines...) Expand all Loading... |
7811 static RawGrowableObjectArray* New(const Array& array, | 7812 static RawGrowableObjectArray* New(const Array& array, |
7812 Heap::Space space = Heap::kNew); | 7813 Heap::Space space = Heap::kNew); |
7813 | 7814 |
7814 private: | 7815 private: |
7815 RawArray* DataArray() const { return data()->ptr(); } | 7816 RawArray* DataArray() const { return data()->ptr(); } |
7816 RawObject** ObjectAddr(intptr_t index) const { | 7817 RawObject** ObjectAddr(intptr_t index) const { |
7817 ASSERT((index >= 0) && (index < Length())); | 7818 ASSERT((index >= 0) && (index < Length())); |
7818 return &(DataArray()->data()[index]); | 7819 return &(DataArray()->data()[index]); |
7819 } | 7820 } |
7820 | 7821 |
7821 static const int kDefaultInitialCapacity = 4; | 7822 static const int kDefaultInitialCapacity = 0; |
7822 | 7823 |
7823 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); | 7824 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); |
7824 friend class Array; | 7825 friend class Array; |
7825 friend class Class; | 7826 friend class Class; |
7826 }; | 7827 }; |
7827 | 7828 |
7828 | 7829 |
7829 class Float32x4 : public Instance { | 7830 class Float32x4 : public Instance { |
7830 public: | 7831 public: |
7831 static RawFloat32x4* New(float value0, | 7832 static RawFloat32x4* New(float value0, |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9067 | 9068 |
9068 inline void TypeArguments::SetHash(intptr_t value) const { | 9069 inline void TypeArguments::SetHash(intptr_t value) const { |
9069 // This is only safe because we create a new Smi, which does not cause | 9070 // This is only safe because we create a new Smi, which does not cause |
9070 // heap allocation. | 9071 // heap allocation. |
9071 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 9072 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
9072 } | 9073 } |
9073 | 9074 |
9074 } // namespace dart | 9075 } // namespace dart |
9075 | 9076 |
9076 #endif // RUNTIME_VM_OBJECT_H_ | 9077 #endif // RUNTIME_VM_OBJECT_H_ |
OLD | NEW |