| 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 6811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6822 return raw()->GetClassId() == kImmutableArrayCid; | 6822 return raw()->GetClassId() == kImmutableArrayCid; |
| 6823 } | 6823 } |
| 6824 | 6824 |
| 6825 virtual RawTypeArguments* GetTypeArguments() const { | 6825 virtual RawTypeArguments* GetTypeArguments() const { |
| 6826 return raw_ptr()->type_arguments_; | 6826 return raw_ptr()->type_arguments_; |
| 6827 } | 6827 } |
| 6828 virtual void SetTypeArguments(const TypeArguments& value) const { | 6828 virtual void SetTypeArguments(const TypeArguments& value) const { |
| 6829 // An Array is raw or takes one type argument. However, its type argument | 6829 // An Array is raw or takes one type argument. However, its type argument |
| 6830 // vector may be longer than 1 due to a type optimization reusing the type | 6830 // vector may be longer than 1 due to a type optimization reusing the type |
| 6831 // argument vector of the instantiator. | 6831 // argument vector of the instantiator. |
| 6832 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated())); | 6832 ASSERT(value.IsNull() || |
| 6833 ((value.Length() >= 1) && |
| 6834 value.IsInstantiated() /*&& value.IsCanonical()*/)); |
| 6835 // TODO(asiva): Values read from a message snapshot are not properly marked |
| 6836 // as canonical. See for example tests/isolate/mandel_isolate_test.dart. |
| 6833 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 6837 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 6834 } | 6838 } |
| 6835 | 6839 |
| 6836 virtual bool CanonicalizeEquals(const Instance& other) const; | 6840 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 6837 | 6841 |
| 6838 static const intptr_t kBytesPerElement = kWordSize; | 6842 static const intptr_t kBytesPerElement = kWordSize; |
| 6839 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 6843 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 6840 | 6844 |
| 6841 static intptr_t type_arguments_offset() { | 6845 static intptr_t type_arguments_offset() { |
| 6842 return OFFSET_OF(RawArray, type_arguments_); | 6846 return OFFSET_OF(RawArray, type_arguments_); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6985 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; | 6989 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; |
| 6986 RawObject* RemoveLast() const; | 6990 RawObject* RemoveLast() const; |
| 6987 | 6991 |
| 6988 virtual RawTypeArguments* GetTypeArguments() const { | 6992 virtual RawTypeArguments* GetTypeArguments() const { |
| 6989 return raw_ptr()->type_arguments_; | 6993 return raw_ptr()->type_arguments_; |
| 6990 } | 6994 } |
| 6991 virtual void SetTypeArguments(const TypeArguments& value) const { | 6995 virtual void SetTypeArguments(const TypeArguments& value) const { |
| 6992 // A GrowableObjectArray is raw or takes one type argument. However, its | 6996 // A GrowableObjectArray is raw or takes one type argument. However, its |
| 6993 // type argument vector may be longer than 1 due to a type optimization | 6997 // type argument vector may be longer than 1 due to a type optimization |
| 6994 // reusing the type argument vector of the instantiator. | 6998 // reusing the type argument vector of the instantiator. |
| 6995 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated())); | 6999 ASSERT(value.IsNull() || |
| 7000 ((value.Length() >= 1) && |
| 7001 value.IsInstantiated() && |
| 7002 value.IsCanonical())); |
| 6996 const Array& contents = Array::Handle(data()); | 7003 const Array& contents = Array::Handle(data()); |
| 6997 contents.SetTypeArguments(value); | 7004 contents.SetTypeArguments(value); |
| 6998 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 7005 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 6999 } | 7006 } |
| 7000 | 7007 |
| 7001 virtual bool CanonicalizeEquals(const Instance& other) const; | 7008 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 7002 | 7009 |
| 7003 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 7010 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
| 7004 UNREACHABLE(); | 7011 UNREACHABLE(); |
| 7005 return Instance::null(); | 7012 return Instance::null(); |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7533 const TypedData& index, | 7540 const TypedData& index, |
| 7534 intptr_t hash_mask, | 7541 intptr_t hash_mask, |
| 7535 intptr_t used_data, | 7542 intptr_t used_data, |
| 7536 intptr_t deleted_keys, | 7543 intptr_t deleted_keys, |
| 7537 Heap::Space space = Heap::kNew); | 7544 Heap::Space space = Heap::kNew); |
| 7538 | 7545 |
| 7539 virtual RawTypeArguments* GetTypeArguments() const { | 7546 virtual RawTypeArguments* GetTypeArguments() const { |
| 7540 return raw_ptr()->type_arguments_; | 7547 return raw_ptr()->type_arguments_; |
| 7541 } | 7548 } |
| 7542 virtual void SetTypeArguments(const TypeArguments& value) const { | 7549 virtual void SetTypeArguments(const TypeArguments& value) const { |
| 7543 ASSERT(value.IsNull() || ((value.Length() >= 2) && value.IsInstantiated())); | 7550 ASSERT(value.IsNull() || |
| 7551 ((value.Length() >= 2) && |
| 7552 value.IsInstantiated() /*&& value.IsCanonical()*/)); |
| 7553 // TODO(asiva): Values read from a message snapshot are not properly marked |
| 7554 // as canonical. See for example tests/isolate/message3_test.dart. |
| 7544 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 7555 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 7545 } | 7556 } |
| 7546 static intptr_t type_arguments_offset() { | 7557 static intptr_t type_arguments_offset() { |
| 7547 return OFFSET_OF(RawLinkedHashMap, type_arguments_); | 7558 return OFFSET_OF(RawLinkedHashMap, type_arguments_); |
| 7548 } | 7559 } |
| 7549 | 7560 |
| 7550 RawTypedData* index() const { | 7561 RawTypedData* index() const { |
| 7551 return raw_ptr()->index_; | 7562 return raw_ptr()->index_; |
| 7552 } | 7563 } |
| 7553 void SetIndex(const TypedData& value) const { | 7564 void SetIndex(const TypedData& value) const { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7674 } | 7685 } |
| 7675 static intptr_t context_offset() { | 7686 static intptr_t context_offset() { |
| 7676 return static_cast<intptr_t>(kContextOffset * kWordSize); | 7687 return static_cast<intptr_t>(kContextOffset * kWordSize); |
| 7677 } | 7688 } |
| 7678 | 7689 |
| 7679 static RawTypeArguments* GetTypeArguments(const Instance& closure) { | 7690 static RawTypeArguments* GetTypeArguments(const Instance& closure) { |
| 7680 return *TypeArgumentsAddr(closure); | 7691 return *TypeArgumentsAddr(closure); |
| 7681 } | 7692 } |
| 7682 static void SetTypeArguments(const Instance& closure, | 7693 static void SetTypeArguments(const Instance& closure, |
| 7683 const TypeArguments& value) { | 7694 const TypeArguments& value) { |
| 7695 ASSERT(value.IsNull() || value.IsCanonical()); |
| 7684 closure.StorePointer(TypeArgumentsAddr(closure), value.raw()); | 7696 closure.StorePointer(TypeArgumentsAddr(closure), value.raw()); |
| 7685 } | 7697 } |
| 7686 static intptr_t type_arguments_offset() { | 7698 static intptr_t type_arguments_offset() { |
| 7687 return static_cast<intptr_t>(kTypeArgumentsOffset * kWordSize); | 7699 return static_cast<intptr_t>(kTypeArgumentsOffset * kWordSize); |
| 7688 } | 7700 } |
| 7689 | 7701 |
| 7690 static const char* ToCString(const Instance& closure); | 7702 static const char* ToCString(const Instance& closure); |
| 7691 | 7703 |
| 7692 static intptr_t InstanceSize() { | 7704 static intptr_t InstanceSize() { |
| 7693 intptr_t size = sizeof(RawInstance) + (kNumFields * kWordSize); | 7705 intptr_t size = sizeof(RawInstance) + (kNumFields * kWordSize); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8235 | 8247 |
| 8236 | 8248 |
| 8237 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8249 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8238 intptr_t index) { | 8250 intptr_t index) { |
| 8239 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8251 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8240 } | 8252 } |
| 8241 | 8253 |
| 8242 } // namespace dart | 8254 } // namespace dart |
| 8243 | 8255 |
| 8244 #endif // VM_OBJECT_H_ | 8256 #endif // VM_OBJECT_H_ |
| OLD | NEW |