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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 V(SubtypeTestCache) \ | 43 V(SubtypeTestCache) \ |
44 V(Error) \ | 44 V(Error) \ |
45 V(ApiError) \ | 45 V(ApiError) \ |
46 V(LanguageError) \ | 46 V(LanguageError) \ |
47 V(UnhandledException) \ | 47 V(UnhandledException) \ |
48 V(UnwindError) \ | 48 V(UnwindError) \ |
49 V(Instance) \ | 49 V(Instance) \ |
50 V(LibraryPrefix) \ | 50 V(LibraryPrefix) \ |
51 V(AbstractType) \ | 51 V(AbstractType) \ |
52 V(Type) \ | 52 V(Type) \ |
| 53 V(FunctionType) \ |
53 V(TypeRef) \ | 54 V(TypeRef) \ |
54 V(TypeParameter) \ | 55 V(TypeParameter) \ |
55 V(BoundedType) \ | 56 V(BoundedType) \ |
56 V(MixinAppType) \ | 57 V(MixinAppType) \ |
| 58 V(Closure) \ |
57 V(Number) \ | 59 V(Number) \ |
58 V(Integer) \ | 60 V(Integer) \ |
59 V(Smi) \ | 61 V(Smi) \ |
60 V(Mint) \ | 62 V(Mint) \ |
61 V(Bigint) \ | 63 V(Bigint) \ |
62 V(Double) \ | 64 V(Double) \ |
63 V(Bool) \ | 65 V(Bool) \ |
64 V(GrowableObjectArray) \ | 66 V(GrowableObjectArray) \ |
65 V(Float32x4) \ | 67 V(Float32x4) \ |
66 V(Int32x4) \ | 68 V(Int32x4) \ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 #undef DEFINE_OBJECT_KIND | 140 #undef DEFINE_OBJECT_KIND |
139 | 141 |
140 #define DEFINE_OBJECT_KIND(clazz) \ | 142 #define DEFINE_OBJECT_KIND(clazz) \ |
141 kTypedData##clazz##Cid, | 143 kTypedData##clazz##Cid, |
142 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) | 144 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) |
143 #undef DEFINE_OBJECT_KIND | 145 #undef DEFINE_OBJECT_KIND |
144 | 146 |
145 #define DEFINE_OBJECT_KIND(clazz) \ | 147 #define DEFINE_OBJECT_KIND(clazz) \ |
146 kTypedData##clazz##ViewCid, | 148 kTypedData##clazz##ViewCid, |
147 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) | 149 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) |
| 150 #undef DEFINE_OBJECT_KIND |
| 151 |
148 kByteDataViewCid, | 152 kByteDataViewCid, |
149 #undef DEFINE_OBJECT_KIND | |
150 | 153 |
151 #define DEFINE_OBJECT_KIND(clazz) \ | 154 #define DEFINE_OBJECT_KIND(clazz) \ |
152 kExternalTypedData##clazz##Cid, | 155 kExternalTypedData##clazz##Cid, |
153 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) | 156 CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND) |
154 #undef DEFINE_OBJECT_KIND | 157 #undef DEFINE_OBJECT_KIND |
155 | 158 |
156 kByteBufferCid, | 159 kByteBufferCid, |
157 | 160 |
158 // The following entries do not describe a predefined class, but instead | 161 // The following entries do not describe a predefined class, but instead |
159 // are class indexes for pre-allocated instance (Null, dynamic and Void). | 162 // are class indexes for pre-allocated instance (Null, dynamic and Void). |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 #if defined(DEBUG) | 586 #if defined(DEBUG) |
584 static void ValidateOverwrittenPointer(RawObject* raw); | 587 static void ValidateOverwrittenPointer(RawObject* raw); |
585 static void ValidateOverwrittenSmi(RawSmi* raw); | 588 static void ValidateOverwrittenSmi(RawSmi* raw); |
586 #endif // DEBUG | 589 #endif // DEBUG |
587 | 590 |
588 friend class Api; | 591 friend class Api; |
589 friend class ApiMessageReader; // GetClassId | 592 friend class ApiMessageReader; // GetClassId |
590 friend class Array; | 593 friend class Array; |
591 friend class Bigint; | 594 friend class Bigint; |
592 friend class ByteBuffer; | 595 friend class ByteBuffer; |
| 596 friend class Closure; |
593 friend class Code; | 597 friend class Code; |
594 friend class Closure; | |
595 friend class Double; | 598 friend class Double; |
596 friend class FreeListElement; | 599 friend class FreeListElement; |
597 friend class Function; | 600 friend class Function; |
598 friend class GCMarker; | 601 friend class GCMarker; |
599 friend class ExternalTypedData; | 602 friend class ExternalTypedData; |
600 friend class ForwardList; | 603 friend class ForwardList; |
601 friend class GrowableObjectArray; // StorePointer | 604 friend class GrowableObjectArray; // StorePointer |
602 friend class Heap; | 605 friend class Heap; |
603 friend class HeapMapAsJSONVisitor; | 606 friend class HeapMapAsJSONVisitor; |
604 friend class ClassStatsVisitor; | 607 friend class ClassStatsVisitor; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 RawArray* functions_hash_table_; | 655 RawArray* functions_hash_table_; |
653 RawArray* fields_; | 656 RawArray* fields_; |
654 RawArray* offset_in_words_to_field_; | 657 RawArray* offset_in_words_to_field_; |
655 RawArray* interfaces_; // Array of AbstractType. | 658 RawArray* interfaces_; // Array of AbstractType. |
656 RawGrowableObjectArray* direct_subclasses_; // Array of Class. | 659 RawGrowableObjectArray* direct_subclasses_; // Array of Class. |
657 RawScript* script_; | 660 RawScript* script_; |
658 RawLibrary* library_; | 661 RawLibrary* library_; |
659 RawTypeArguments* type_parameters_; // Array of TypeParameter. | 662 RawTypeArguments* type_parameters_; // Array of TypeParameter. |
660 RawAbstractType* super_type_; | 663 RawAbstractType* super_type_; |
661 RawType* mixin_; // Generic mixin type, e.g. M<T>, not M<int>. | 664 RawType* mixin_; // Generic mixin type, e.g. M<T>, not M<int>. |
662 RawFunction* signature_function_; // Associated function for signature class. | 665 RawFunction* signature_function_; // Associated function for typedef class. |
663 RawArray* constants_; // Canonicalized values of this class. | 666 RawArray* constants_; // Canonicalized values of this class. |
664 RawObject* canonical_types_; // An array of canonicalized types of this class | 667 RawObject* canonical_types_; // An array of canonicalized types of this class |
665 // or the canonical type. | 668 // or the canonical type. |
666 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. | 669 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. |
667 RawArray* cha_codes_; // CHA optimized codes. | 670 RawArray* cha_codes_; // CHA optimized codes. |
668 RawCode* allocation_stub_; // Stub code for allocation of instances. | 671 RawCode* allocation_stub_; // Stub code for allocation of instances. |
669 RawObject** to() { | 672 RawObject** to() { |
670 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); | 673 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); |
671 } | 674 } |
672 | 675 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 | 826 |
824 class RawClosureData : public RawObject { | 827 class RawClosureData : public RawObject { |
825 private: | 828 private: |
826 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); | 829 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); |
827 | 830 |
828 RawObject** from() { | 831 RawObject** from() { |
829 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); | 832 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); |
830 } | 833 } |
831 RawContextScope* context_scope_; | 834 RawContextScope* context_scope_; |
832 RawFunction* parent_function_; // Enclosing function of this local function. | 835 RawFunction* parent_function_; // Enclosing function of this local function. |
833 RawClass* signature_class_; | 836 RawFunctionType* signature_type_; |
834 RawInstance* closure_; // Closure object for static implicit closures. | 837 RawInstance* closure_; // Closure object for static implicit closures. |
835 RawObject** to() { | 838 RawObject** to() { |
836 return reinterpret_cast<RawObject**>(&ptr()->closure_); | 839 return reinterpret_cast<RawObject**>(&ptr()->closure_); |
837 } | 840 } |
838 | 841 |
839 friend class Function; | 842 friend class Function; |
840 }; | 843 }; |
841 | 844 |
842 | 845 |
843 class RawRedirectionData : public RawObject { | 846 class RawRedirectionData : public RawObject { |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 RawTypeArguments* arguments_; | 1558 RawTypeArguments* arguments_; |
1556 RawLanguageError* error_; // Error object if type is malformed or malbounded. | 1559 RawLanguageError* error_; // Error object if type is malformed or malbounded. |
1557 RawObject** to() { | 1560 RawObject** to() { |
1558 return reinterpret_cast<RawObject**>(&ptr()->error_); | 1561 return reinterpret_cast<RawObject**>(&ptr()->error_); |
1559 } | 1562 } |
1560 int32_t token_pos_; | 1563 int32_t token_pos_; |
1561 int8_t type_state_; | 1564 int8_t type_state_; |
1562 }; | 1565 }; |
1563 | 1566 |
1564 | 1567 |
| 1568 class RawFunctionType : public RawAbstractType { |
| 1569 private: |
| 1570 RAW_HEAP_OBJECT_IMPLEMENTATION(FunctionType); |
| 1571 |
| 1572 RawObject** from() { |
| 1573 return reinterpret_cast<RawObject**>(&ptr()->scope_class_); |
| 1574 } |
| 1575 RawClass* scope_class_; |
| 1576 RawTypeArguments* arguments_; |
| 1577 RawFunction* signature_; |
| 1578 RawLanguageError* error_; // Error object if type is malformed or malbounded. |
| 1579 RawObject** to() { |
| 1580 return reinterpret_cast<RawObject**>(&ptr()->error_); |
| 1581 } |
| 1582 int32_t token_pos_; |
| 1583 int8_t type_state_; |
| 1584 }; |
| 1585 |
| 1586 |
1565 class RawTypeRef : public RawAbstractType { | 1587 class RawTypeRef : public RawAbstractType { |
1566 private: | 1588 private: |
1567 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); | 1589 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); |
1568 | 1590 |
1569 RawObject** from() { | 1591 RawObject** from() { |
1570 return reinterpret_cast<RawObject**>(&ptr()->type_); | 1592 return reinterpret_cast<RawObject**>(&ptr()->type_); |
1571 } | 1593 } |
1572 RawAbstractType* type_; // The referenced type. | 1594 RawAbstractType* type_; // The referenced type. |
1573 RawObject** to() { | 1595 RawObject** to() { |
1574 return reinterpret_cast<RawObject**>(&ptr()->type_); | 1596 return reinterpret_cast<RawObject**>(&ptr()->type_); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 return reinterpret_cast<RawObject**>(&ptr()->super_type_); | 1639 return reinterpret_cast<RawObject**>(&ptr()->super_type_); |
1618 } | 1640 } |
1619 RawAbstractType* super_type_; | 1641 RawAbstractType* super_type_; |
1620 RawArray* mixin_types_; // Array of AbstractType. | 1642 RawArray* mixin_types_; // Array of AbstractType. |
1621 RawObject** to() { | 1643 RawObject** to() { |
1622 return reinterpret_cast<RawObject**>(&ptr()->mixin_types_); | 1644 return reinterpret_cast<RawObject**>(&ptr()->mixin_types_); |
1623 } | 1645 } |
1624 }; | 1646 }; |
1625 | 1647 |
1626 | 1648 |
| 1649 class RawClosure : public RawInstance { |
| 1650 private: |
| 1651 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); |
| 1652 |
| 1653 RawObject** from() { |
| 1654 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
| 1655 } |
| 1656 |
| 1657 RawTypeArguments* type_arguments_; |
| 1658 RawFunction* function_; |
| 1659 RawContext* context_; |
| 1660 |
| 1661 RawObject** to() { |
| 1662 return reinterpret_cast<RawObject**>(&ptr()->context_); |
| 1663 } |
| 1664 }; |
| 1665 |
| 1666 |
1627 class RawNumber : public RawInstance { | 1667 class RawNumber : public RawInstance { |
1628 RAW_OBJECT_IMPLEMENTATION(Number); | 1668 RAW_OBJECT_IMPLEMENTATION(Number); |
1629 }; | 1669 }; |
1630 | 1670 |
1631 | 1671 |
1632 class RawInteger : public RawNumber { | 1672 class RawInteger : public RawNumber { |
1633 RAW_OBJECT_IMPLEMENTATION(Integer); | 1673 RAW_OBJECT_IMPLEMENTATION(Integer); |
1634 }; | 1674 }; |
1635 | 1675 |
1636 | 1676 |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2269 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2309 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2270 kTypedDataInt8ArrayViewCid + 15); | 2310 kTypedDataInt8ArrayViewCid + 15); |
2271 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2311 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2272 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2312 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2273 return (kNullCid - kTypedDataInt8ArrayCid); | 2313 return (kNullCid - kTypedDataInt8ArrayCid); |
2274 } | 2314 } |
2275 | 2315 |
2276 } // namespace dart | 2316 } // namespace dart |
2277 | 2317 |
2278 #endif // VM_RAW_OBJECT_H_ | 2318 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |