| 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_RAW_OBJECT_H_ | 5 #ifndef RUNTIME_VM_RAW_OBJECT_H_ |
| 6 #define RUNTIME_VM_RAW_OBJECT_H_ | 6 #define RUNTIME_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/exceptions.h" | 10 #include "vm/exceptions.h" |
| 11 #include "vm/globals.h" | 11 #include "vm/globals.h" |
| 12 #include "vm/snapshot.h" | 12 #include "vm/snapshot.h" |
| 13 #include "vm/token.h" | 13 #include "vm/token.h" |
| 14 #include "vm/token_position.h" | 14 #include "vm/token_position.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // Macrobatics to define the Object hierarchy of VM implementation classes. | 18 // Macrobatics to define the Object hierarchy of VM implementation classes. |
| 19 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ | 19 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ |
| 20 V(Class) \ | 20 V(Class) \ |
| 21 V(UnresolvedClass) \ | 21 V(UnresolvedClass) \ |
| 22 V(TypeArguments) \ | |
| 23 V(PatchClass) \ | 22 V(PatchClass) \ |
| 24 V(Function) \ | 23 V(Function) \ |
| 25 V(ClosureData) \ | 24 V(ClosureData) \ |
| 26 V(SignatureData) \ | 25 V(SignatureData) \ |
| 27 V(RedirectionData) \ | 26 V(RedirectionData) \ |
| 28 V(Field) \ | 27 V(Field) \ |
| 29 V(LiteralToken) \ | 28 V(LiteralToken) \ |
| 30 V(TokenStream) \ | 29 V(TokenStream) \ |
| 31 V(Script) \ | 30 V(Script) \ |
| 32 V(Library) \ | 31 V(Library) \ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 V(ICData) \ | 45 V(ICData) \ |
| 47 V(MegamorphicCache) \ | 46 V(MegamorphicCache) \ |
| 48 V(SubtypeTestCache) \ | 47 V(SubtypeTestCache) \ |
| 49 V(Error) \ | 48 V(Error) \ |
| 50 V(ApiError) \ | 49 V(ApiError) \ |
| 51 V(LanguageError) \ | 50 V(LanguageError) \ |
| 52 V(UnhandledException) \ | 51 V(UnhandledException) \ |
| 53 V(UnwindError) \ | 52 V(UnwindError) \ |
| 54 V(Instance) \ | 53 V(Instance) \ |
| 55 V(LibraryPrefix) \ | 54 V(LibraryPrefix) \ |
| 55 V(TypeArguments) \ |
| 56 V(AbstractType) \ | 56 V(AbstractType) \ |
| 57 V(Type) \ | 57 V(Type) \ |
| 58 V(TypeRef) \ | 58 V(TypeRef) \ |
| 59 V(TypeParameter) \ | 59 V(TypeParameter) \ |
| 60 V(BoundedType) \ | 60 V(BoundedType) \ |
| 61 V(MixinAppType) \ | 61 V(MixinAppType) \ |
| 62 V(Closure) \ | 62 V(Closure) \ |
| 63 V(Number) \ | 63 V(Number) \ |
| 64 V(Integer) \ | 64 V(Integer) \ |
| 65 V(Smi) \ | 65 V(Smi) \ |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 RawObject** from() { | 775 RawObject** from() { |
| 776 return reinterpret_cast<RawObject**>(&ptr()->library_or_library_prefix_); | 776 return reinterpret_cast<RawObject**>(&ptr()->library_or_library_prefix_); |
| 777 } | 777 } |
| 778 RawObject* library_or_library_prefix_; // Library or library prefix qualifier | 778 RawObject* library_or_library_prefix_; // Library or library prefix qualifier |
| 779 // for the ident. | 779 // for the ident. |
| 780 RawString* ident_; // Name of the unresolved identifier. | 780 RawString* ident_; // Name of the unresolved identifier. |
| 781 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->ident_); } | 781 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->ident_); } |
| 782 TokenPosition token_pos_; | 782 TokenPosition token_pos_; |
| 783 }; | 783 }; |
| 784 | 784 |
| 785 class RawTypeArguments : public RawObject { | |
| 786 private: | |
| 787 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); | |
| 788 | |
| 789 RawObject** from() { | |
| 790 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); | |
| 791 } | |
| 792 // The instantiations_ array remains empty for instantiated type arguments. | |
| 793 RawArray* instantiations_; // Array of paired canonical vectors: | |
| 794 // Even index: instantiator. | |
| 795 // Odd index: instantiated (without bound error). | |
| 796 // Instantiations leading to bound errors do not get cached. | |
| 797 RawSmi* length_; | |
| 798 | |
| 799 RawSmi* hash_; | |
| 800 | |
| 801 // Variable length data follows here. | |
| 802 RawAbstractType* const* types() const { | |
| 803 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); | |
| 804 } | |
| 805 RawAbstractType** types() { | |
| 806 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); | |
| 807 } | |
| 808 RawObject** to(intptr_t length) { | |
| 809 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]); | |
| 810 } | |
| 811 | |
| 812 friend class Object; | |
| 813 friend class SnapshotReader; | |
| 814 }; | |
| 815 | |
| 816 class RawPatchClass : public RawObject { | 785 class RawPatchClass : public RawObject { |
| 817 private: | 786 private: |
| 818 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); | 787 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); |
| 819 | 788 |
| 820 RawObject** from() { | 789 RawObject** from() { |
| 821 return reinterpret_cast<RawObject**>(&ptr()->patched_class_); | 790 return reinterpret_cast<RawObject**>(&ptr()->patched_class_); |
| 822 } | 791 } |
| 823 RawClass* patched_class_; | 792 RawClass* patched_class_; |
| 824 RawClass* origin_class_; | 793 RawClass* origin_class_; |
| 825 RawScript* script_; | 794 RawScript* script_; |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 break; | 1654 break; |
| 1686 } | 1655 } |
| 1687 UNREACHABLE(); | 1656 UNREACHABLE(); |
| 1688 return NULL; | 1657 return NULL; |
| 1689 } | 1658 } |
| 1690 uint16_t num_imports_; // Number of library entries in libraries_. | 1659 uint16_t num_imports_; // Number of library entries in libraries_. |
| 1691 bool is_deferred_load_; | 1660 bool is_deferred_load_; |
| 1692 bool is_loaded_; | 1661 bool is_loaded_; |
| 1693 }; | 1662 }; |
| 1694 | 1663 |
| 1664 class RawTypeArguments : public RawInstance { |
| 1665 private: |
| 1666 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); |
| 1667 |
| 1668 RawObject** from() { |
| 1669 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); |
| 1670 } |
| 1671 // The instantiations_ array remains empty for instantiated type arguments. |
| 1672 RawArray* instantiations_; // Array of paired canonical vectors: |
| 1673 // Even index: instantiator. |
| 1674 // Odd index: instantiated (without bound error). |
| 1675 // Instantiations leading to bound errors do not get cached. |
| 1676 RawSmi* length_; |
| 1677 |
| 1678 RawSmi* hash_; |
| 1679 |
| 1680 // Variable length data follows here. |
| 1681 RawAbstractType* const* types() const { |
| 1682 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); |
| 1683 } |
| 1684 RawAbstractType** types() { |
| 1685 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); |
| 1686 } |
| 1687 RawObject** to(intptr_t length) { |
| 1688 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]); |
| 1689 } |
| 1690 |
| 1691 friend class Object; |
| 1692 friend class SnapshotReader; |
| 1693 }; |
| 1694 |
| 1695 class RawAbstractType : public RawInstance { | 1695 class RawAbstractType : public RawInstance { |
| 1696 protected: | 1696 protected: |
| 1697 enum TypeState { | 1697 enum TypeState { |
| 1698 kAllocated, // Initial state. | 1698 kAllocated, // Initial state. |
| 1699 kResolved, // Type class and type arguments resolved. | 1699 kResolved, // Type class and type arguments resolved. |
| 1700 kBeingFinalized, // In the process of being finalized. | 1700 kBeingFinalized, // In the process of being finalized. |
| 1701 kFinalizedInstantiated, // Instantiated type ready for use. | 1701 kFinalizedInstantiated, // Instantiated type ready for use. |
| 1702 kFinalizedUninstantiated, // Uninstantiated type ready for use. | 1702 kFinalizedUninstantiated, // Uninstantiated type ready for use. |
| 1703 }; | 1703 }; |
| 1704 | 1704 |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2440 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2440 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2441 kTypedDataInt8ArrayViewCid + 15); | 2441 kTypedDataInt8ArrayViewCid + 15); |
| 2442 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2442 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2443 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2443 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2444 return (kNullCid - kTypedDataInt8ArrayCid); | 2444 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2445 } | 2445 } |
| 2446 | 2446 |
| 2447 } // namespace dart | 2447 } // namespace dart |
| 2448 | 2448 |
| 2449 #endif // RUNTIME_VM_RAW_OBJECT_H_ | 2449 #endif // RUNTIME_VM_RAW_OBJECT_H_ |
| OLD | NEW |