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_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/atomic.h" | 9 #include "vm/atomic.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 RawArray* functions_hash_table_; | 690 RawArray* functions_hash_table_; |
691 RawArray* fields_; | 691 RawArray* fields_; |
692 RawArray* offset_in_words_to_field_; | 692 RawArray* offset_in_words_to_field_; |
693 RawArray* interfaces_; // Array of AbstractType. | 693 RawArray* interfaces_; // Array of AbstractType. |
694 RawScript* script_; | 694 RawScript* script_; |
695 RawLibrary* library_; | 695 RawLibrary* library_; |
696 RawTypeArguments* type_parameters_; // Array of TypeParameter. | 696 RawTypeArguments* type_parameters_; // Array of TypeParameter. |
697 RawAbstractType* super_type_; | 697 RawAbstractType* super_type_; |
698 RawType* mixin_; // Generic mixin type, e.g. M<T>, not M<int>. | 698 RawType* mixin_; // Generic mixin type, e.g. M<T>, not M<int>. |
699 RawFunction* signature_function_; // Associated function for typedef class. | 699 RawFunction* signature_function_; // Associated function for typedef class. |
700 RawArray* constants_; // Canonicalized values of this class. | 700 RawArray* constants_; // Canonicalized const instances of this class. |
701 RawObject* canonical_types_; // An array of canonicalized types of this class | 701 RawType* canonical_type_; // Canonical type for this class. |
702 // or the canonical type. | |
703 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. | 702 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. |
704 RawCode* allocation_stub_; // Stub code for allocation of instances. | 703 RawCode* allocation_stub_; // Stub code for allocation of instances. |
705 RawGrowableObjectArray* direct_subclasses_; // Array of Class. | 704 RawGrowableObjectArray* direct_subclasses_; // Array of Class. |
706 RawArray* dependent_code_; // CHA optimized codes. | 705 RawArray* dependent_code_; // CHA optimized codes. |
707 RawObject** to() { | 706 RawObject** to() { |
708 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_); | 707 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_); |
709 } | 708 } |
710 RawObject** to_snapshot(Snapshot::Kind kind) { | 709 RawObject** to_snapshot(Snapshot::Kind kind) { |
711 switch (kind) { | 710 switch (kind) { |
712 case Snapshot::kCore: | 711 case Snapshot::kCore: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 RawObject** from() { | 763 RawObject** from() { |
765 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); | 764 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); |
766 } | 765 } |
767 // The instantiations_ array remains empty for instantiated type arguments. | 766 // The instantiations_ array remains empty for instantiated type arguments. |
768 RawArray* instantiations_; // Array of paired canonical vectors: | 767 RawArray* instantiations_; // Array of paired canonical vectors: |
769 // Even index: instantiator. | 768 // Even index: instantiator. |
770 // Odd index: instantiated (without bound error). | 769 // Odd index: instantiated (without bound error). |
771 // Instantiations leading to bound errors do not get cached. | 770 // Instantiations leading to bound errors do not get cached. |
772 RawSmi* length_; | 771 RawSmi* length_; |
773 | 772 |
| 773 RawSmi* hash_; |
| 774 |
774 // Variable length data follows here. | 775 // Variable length data follows here. |
775 RawAbstractType* const* types() const { | 776 RawAbstractType* const* types() const { |
776 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); | 777 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); |
777 } | 778 } |
778 RawAbstractType** types() { | 779 RawAbstractType** types() { |
779 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); | 780 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); |
780 } | 781 } |
781 RawObject** to(intptr_t length) { | 782 RawObject** to(intptr_t length) { |
782 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]); | 783 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]); |
783 } | 784 } |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 | 1681 |
1681 class RawType : public RawAbstractType { | 1682 class RawType : public RawAbstractType { |
1682 private: | 1683 private: |
1683 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); | 1684 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); |
1684 | 1685 |
1685 RawObject** from() { | 1686 RawObject** from() { |
1686 return reinterpret_cast<RawObject**>(&ptr()->type_class_); | 1687 return reinterpret_cast<RawObject**>(&ptr()->type_class_); |
1687 } | 1688 } |
1688 RawObject* type_class_; // Either resolved class or unresolved class. | 1689 RawObject* type_class_; // Either resolved class or unresolved class. |
1689 RawTypeArguments* arguments_; | 1690 RawTypeArguments* arguments_; |
| 1691 RawSmi* hash_; |
1690 // This type object represents a function type if its signature field is a | 1692 // This type object represents a function type if its signature field is a |
1691 // non-null function object. | 1693 // non-null function object. |
1692 // If this type is malformed or malbounded, the signature field gets | 1694 // If this type is malformed or malbounded, the signature field gets |
1693 // overwritten by the error object in order to save space. If the type is a | 1695 // overwritten by the error object in order to save space. If the type is a |
1694 // function type, its signature is lost, but the message in the error object | 1696 // function type, its signature is lost, but the message in the error object |
1695 // can describe the issue without needing the signature. | 1697 // can describe the issue without needing the signature. |
1696 union { | 1698 union { |
1697 RawFunction* signature_; // If not null, this type is a function type. | 1699 RawFunction* signature_; // If not null, this type is a function type. |
1698 RawLanguageError* error_; // If not null, type is malformed or malbounded. | 1700 RawLanguageError* error_; // If not null, type is malformed or malbounded. |
1699 } sig_or_err_; | 1701 } sig_or_err_; |
(...skipping 21 matching lines...) Expand all Loading... |
1721 | 1723 |
1722 class RawTypeParameter : public RawAbstractType { | 1724 class RawTypeParameter : public RawAbstractType { |
1723 private: | 1725 private: |
1724 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter); | 1726 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter); |
1725 | 1727 |
1726 RawObject** from() { | 1728 RawObject** from() { |
1727 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_); | 1729 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_); |
1728 } | 1730 } |
1729 RawClass* parameterized_class_; | 1731 RawClass* parameterized_class_; |
1730 RawString* name_; | 1732 RawString* name_; |
| 1733 RawSmi* hash_; |
1731 RawAbstractType* bound_; // ObjectType if no explicit bound specified. | 1734 RawAbstractType* bound_; // ObjectType if no explicit bound specified. |
1732 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); } | 1735 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); } |
1733 TokenPosition token_pos_; | 1736 TokenPosition token_pos_; |
1734 int16_t index_; | 1737 int16_t index_; |
1735 int8_t type_state_; | 1738 int8_t type_state_; |
1736 }; | 1739 }; |
1737 | 1740 |
1738 | 1741 |
1739 class RawBoundedType : public RawAbstractType { | 1742 class RawBoundedType : public RawAbstractType { |
1740 private: | 1743 private: |
1741 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType); | 1744 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType); |
1742 | 1745 |
1743 RawObject** from() { | 1746 RawObject** from() { |
1744 return reinterpret_cast<RawObject**>(&ptr()->type_); | 1747 return reinterpret_cast<RawObject**>(&ptr()->type_); |
1745 } | 1748 } |
1746 RawAbstractType* type_; | 1749 RawAbstractType* type_; |
1747 RawAbstractType* bound_; | 1750 RawAbstractType* bound_; |
| 1751 RawSmi* hash_; |
1748 RawTypeParameter* type_parameter_; // For more detailed error reporting. | 1752 RawTypeParameter* type_parameter_; // For more detailed error reporting. |
1749 RawObject** to() { | 1753 RawObject** to() { |
1750 return reinterpret_cast<RawObject**>(&ptr()->type_parameter_); | 1754 return reinterpret_cast<RawObject**>(&ptr()->type_parameter_); |
1751 } | 1755 } |
1752 }; | 1756 }; |
1753 | 1757 |
1754 | 1758 |
1755 class RawMixinAppType : public RawAbstractType { | 1759 class RawMixinAppType : public RawAbstractType { |
1756 private: | 1760 private: |
1757 RAW_HEAP_OBJECT_IMPLEMENTATION(MixinAppType); | 1761 RAW_HEAP_OBJECT_IMPLEMENTATION(MixinAppType); |
1758 | 1762 |
1759 RawObject** from() { | 1763 RawObject** from() { |
1760 return reinterpret_cast<RawObject**>(&ptr()->super_type_); | 1764 return reinterpret_cast<RawObject**>(&ptr()->super_type_); |
1761 } | 1765 } |
1762 RawAbstractType* super_type_; | 1766 RawAbstractType* super_type_; |
| 1767 RawSmi* hash_; |
1763 RawArray* mixin_types_; // Array of AbstractType. | 1768 RawArray* mixin_types_; // Array of AbstractType. |
1764 RawObject** to() { | 1769 RawObject** to() { |
1765 return reinterpret_cast<RawObject**>(&ptr()->mixin_types_); | 1770 return reinterpret_cast<RawObject**>(&ptr()->mixin_types_); |
1766 } | 1771 } |
1767 }; | 1772 }; |
1768 | 1773 |
1769 | 1774 |
1770 class RawClosure : public RawInstance { | 1775 class RawClosure : public RawInstance { |
1771 private: | 1776 private: |
1772 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); | 1777 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2436 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2432 kTypedDataInt8ArrayViewCid + 15); | 2437 kTypedDataInt8ArrayViewCid + 15); |
2433 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2438 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2434 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2439 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2435 return (kNullCid - kTypedDataInt8ArrayCid); | 2440 return (kNullCid - kTypedDataInt8ArrayCid); |
2436 } | 2441 } |
2437 | 2442 |
2438 } // namespace dart | 2443 } // namespace dart |
2439 | 2444 |
2440 #endif // VM_RAW_OBJECT_H_ | 2445 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |