| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 class RawObject { | 230 class RawObject { |
| 231 public: | 231 public: |
| 232 // The tags field which is a part of the object header uses the following | 232 // The tags field which is a part of the object header uses the following |
| 233 // bit fields for storing tags. | 233 // bit fields for storing tags. |
| 234 enum TagBits { | 234 enum TagBits { |
| 235 kWatchedBit = 0, | 235 kWatchedBit = 0, |
| 236 kMarkBit = 1, | 236 kMarkBit = 1, |
| 237 kCanonicalBit = 2, | 237 kCanonicalBit = 2, |
| 238 kFromSnapshotBit = 3, | 238 kFromSnapshotBit = 3, |
| 239 kRememberedBit = 4, | 239 kRememberedBit = 4, |
| 240 kReservedTagPos = 5, // kReservedBit{10K,100K,1M,10M} | 240 kReservedTagPos = 5, // kReservedBit{100K,1M,10M} |
| 241 kReservedTagSize = 3, | 241 kReservedTagSize = 3, |
| 242 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8 | 242 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8 |
| 243 kSizeTagSize = 8, | 243 kSizeTagSize = 8, |
| 244 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16 | 244 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16 |
| 245 kClassIdTagSize = 16, | 245 kClassIdTagSize = 16, |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 // Encodes the object size in the tag in units of object alignment. | 248 // Encodes the object size in the tag in units of object alignment. |
| 249 class SizeTag { | 249 class SizeTag { |
| 250 public: | 250 public: |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 RawObject* canonical_types_; // An array of canonicalized types of this class | 602 RawObject* canonical_types_; // An array of canonicalized types of this class |
| 603 // or the canonical type. | 603 // or the canonical type. |
| 604 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. | 604 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. |
| 605 RawArray* cha_codes_; // CHA optimized codes. | 605 RawArray* cha_codes_; // CHA optimized codes. |
| 606 RawCode* allocation_stub_; // Stub code for allocation of instances. | 606 RawCode* allocation_stub_; // Stub code for allocation of instances. |
| 607 RawObject** to() { | 607 RawObject** to() { |
| 608 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); | 608 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); |
| 609 } | 609 } |
| 610 | 610 |
| 611 cpp_vtable handle_vtable_; | 611 cpp_vtable handle_vtable_; |
| 612 int32_t id_; // Class Id, also index in the class table. | |
| 613 int32_t token_pos_; | 612 int32_t token_pos_; |
| 614 int32_t instance_size_in_words_; // Size if fixed len or 0 if variable len. | 613 int32_t instance_size_in_words_; // Size if fixed len or 0 if variable len. |
| 615 int32_t type_arguments_field_offset_in_words_; // Offset of type args fld. | 614 int32_t type_arguments_field_offset_in_words_; // Offset of type args fld. |
| 616 int32_t next_field_offset_in_words_; // Offset of the next instance field. | 615 int32_t next_field_offset_in_words_; // Offset of the next instance field. |
| 616 cid_t id_; // Class Id, also index in the class table. |
| 617 int16_t num_type_arguments_; // Number of type arguments in flatten vector. | 617 int16_t num_type_arguments_; // Number of type arguments in flatten vector. |
| 618 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments. | 618 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments. |
| 619 uint16_t num_native_fields_; // Number of native fields in class. | 619 uint16_t num_native_fields_; // Number of native fields in class. |
| 620 uint16_t state_bits_; | 620 uint16_t state_bits_; |
| 621 | 621 |
| 622 friend class Instance; | 622 friend class Instance; |
| 623 friend class Object; | 623 friend class Object; |
| 624 friend class RawInstance; | 624 friend class RawInstance; |
| 625 friend class RawInstructions; | 625 friend class RawInstructions; |
| 626 friend class SnapshotReader; | 626 friend class SnapshotReader; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 RawObject** to() { | 745 RawObject** to() { |
| 746 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); | 746 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); |
| 747 } | 747 } |
| 748 | 748 |
| 749 int32_t token_pos_; | 749 int32_t token_pos_; |
| 750 int32_t end_token_pos_; | 750 int32_t end_token_pos_; |
| 751 int32_t usage_counter_; // Incremented while function is running. | 751 int32_t usage_counter_; // Incremented while function is running. |
| 752 int16_t num_fixed_parameters_; | 752 int16_t num_fixed_parameters_; |
| 753 int16_t num_optional_parameters_; // > 0: positional; < 0: named. | 753 int16_t num_optional_parameters_; // > 0: positional; < 0: named. |
| 754 int16_t deoptimization_counter_; | 754 int16_t deoptimization_counter_; |
| 755 int16_t regexp_cid_; | 755 cid_t regexp_cid_; |
| 756 uint32_t kind_tag_; // See Function::KindTagBits. | 756 uint32_t kind_tag_; // See Function::KindTagBits. |
| 757 uint16_t optimized_instruction_count_; | 757 uint16_t optimized_instruction_count_; |
| 758 uint16_t optimized_call_site_count_; | 758 uint16_t optimized_call_site_count_; |
| 759 }; | 759 }; |
| 760 | 760 |
| 761 | 761 |
| 762 class RawClosureData : public RawObject { | 762 class RawClosureData : public RawObject { |
| 763 private: | 763 private: |
| 764 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); | 764 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); |
| 765 | 765 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 // where this field is defined. | 803 // where this field is defined. |
| 804 RawAbstractType* type_; | 804 RawAbstractType* type_; |
| 805 RawInstance* value_; // Offset in words for instance and value for static. | 805 RawInstance* value_; // Offset in words for instance and value for static. |
| 806 RawArray* dependent_code_; | 806 RawArray* dependent_code_; |
| 807 RawSmi* guarded_list_length_; | 807 RawSmi* guarded_list_length_; |
| 808 RawObject** to() { | 808 RawObject** to() { |
| 809 return reinterpret_cast<RawObject**>(&ptr()->guarded_list_length_); | 809 return reinterpret_cast<RawObject**>(&ptr()->guarded_list_length_); |
| 810 } | 810 } |
| 811 | 811 |
| 812 int32_t token_pos_; | 812 int32_t token_pos_; |
| 813 // TODO(rmacnak): Make these cid_t. |
| 813 int32_t guarded_cid_; | 814 int32_t guarded_cid_; |
| 814 int32_t is_nullable_; // kNullCid if field can contain null value and | 815 int32_t is_nullable_; // kNullCid if field can contain null value and |
| 815 // any other value otherwise. | 816 // any other value otherwise. |
| 816 // Offset to the guarded length field inside an instance of class matching | 817 // Offset to the guarded length field inside an instance of class matching |
| 817 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code | 818 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code |
| 818 // generated on platforms with weak addressing modes (ARM, MIPS). | 819 // generated on platforms with weak addressing modes (ARM, MIPS). |
| 819 int8_t guarded_list_length_in_object_offset_; | 820 int8_t guarded_list_length_in_object_offset_; |
| 820 | 821 |
| 821 uint8_t kind_bits_; // static, final, const, has initializer. | 822 uint8_t kind_bits_; // static, final, const, has initializer. |
| 822 }; | 823 }; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 RawGrowableObjectArray* metadata_; // Metadata on classes, methods etc. | 905 RawGrowableObjectArray* metadata_; // Metadata on classes, methods etc. |
| 905 RawArray* anonymous_classes_; // Classes containing top-level elements. | 906 RawArray* anonymous_classes_; // Classes containing top-level elements. |
| 906 RawArray* imports_; // List of Namespaces imported without prefix. | 907 RawArray* imports_; // List of Namespaces imported without prefix. |
| 907 RawArray* exports_; // List of re-exported Namespaces. | 908 RawArray* exports_; // List of re-exported Namespaces. |
| 908 RawArray* loaded_scripts_; // Array of scripts loaded in this library. | 909 RawArray* loaded_scripts_; // Array of scripts loaded in this library. |
| 909 RawInstance* load_error_; // Error iff load_state_ == kLoadError. | 910 RawInstance* load_error_; // Error iff load_state_ == kLoadError. |
| 910 RawObject** to() { | 911 RawObject** to() { |
| 911 return reinterpret_cast<RawObject**>(&ptr()->load_error_); | 912 return reinterpret_cast<RawObject**>(&ptr()->load_error_); |
| 912 } | 913 } |
| 913 | 914 |
| 914 int32_t index_; // Library id number. | |
| 915 int32_t num_imports_; // Number of entries in imports_. | |
| 916 int32_t num_anonymous_; // Number of entries in anonymous_classes_. | |
| 917 Dart_NativeEntryResolver native_entry_resolver_; // Resolves natives. | 915 Dart_NativeEntryResolver native_entry_resolver_; // Resolves natives. |
| 918 Dart_NativeEntrySymbol native_entry_symbol_resolver_; | 916 Dart_NativeEntrySymbol native_entry_symbol_resolver_; |
| 917 cid_t index_; // Library id number. |
| 918 cid_t num_imports_; // Number of entries in imports_. |
| 919 cid_t num_anonymous_; // Number of entries in anonymous_classes_. |
| 920 int8_t load_state_; // Of type LibraryState. |
| 919 bool corelib_imported_; | 921 bool corelib_imported_; |
| 920 bool is_dart_scheme_; | 922 bool is_dart_scheme_; |
| 921 bool debuggable_; // True if debugger can stop in library. | 923 bool debuggable_; // True if debugger can stop in library. |
| 922 int8_t load_state_; // Of type LibraryState. | |
| 923 | 924 |
| 924 friend class Isolate; | 925 friend class Isolate; |
| 925 }; | 926 }; |
| 926 | 927 |
| 927 | 928 |
| 928 class RawNamespace : public RawObject { | 929 class RawNamespace : public RawObject { |
| 929 RAW_HEAP_OBJECT_IMPLEMENTATION(Namespace); | 930 RAW_HEAP_OBJECT_IMPLEMENTATION(Namespace); |
| 930 | 931 |
| 931 RawObject** from() { | 932 RawObject** from() { |
| 932 return reinterpret_cast<RawObject**>(&ptr()->library_); | 933 return reinterpret_cast<RawObject**>(&ptr()->library_); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 | 1415 |
| 1415 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 1416 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
| 1416 RawString* name_; // Library prefix name. | 1417 RawString* name_; // Library prefix name. |
| 1417 RawArray* imports_; // Libraries imported with this prefix. | 1418 RawArray* imports_; // Libraries imported with this prefix. |
| 1418 RawLibrary* importer_; // Library which declares this prefix. | 1419 RawLibrary* importer_; // Library which declares this prefix. |
| 1419 RawArray* dependent_code_; // Code that refers to deferred, unloaded | 1420 RawArray* dependent_code_; // Code that refers to deferred, unloaded |
| 1420 // library prefix. | 1421 // library prefix. |
| 1421 RawObject** to() { | 1422 RawObject** to() { |
| 1422 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_); | 1423 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_); |
| 1423 } | 1424 } |
| 1424 int32_t num_imports_; // Number of library entries in libraries_. | 1425 cid_t num_imports_; // Number of library entries in libraries_. |
| 1425 bool is_deferred_load_; | 1426 bool is_deferred_load_; |
| 1426 bool is_loaded_; | 1427 bool is_loaded_; |
| 1427 }; | 1428 }; |
| 1428 | 1429 |
| 1429 | 1430 |
| 1430 class RawAbstractType : public RawInstance { | 1431 class RawAbstractType : public RawInstance { |
| 1431 protected: | 1432 protected: |
| 1432 enum TypeState { | 1433 enum TypeState { |
| 1433 kAllocated, // Initial state. | 1434 kAllocated, // Initial state. |
| 1434 kResolved, // Type class and type arguments resolved. | 1435 kResolved, // Type class and type arguments resolved. |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2155 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2155 kTypedDataInt8ArrayViewCid + 15); | 2156 kTypedDataInt8ArrayViewCid + 15); |
| 2156 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2157 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2157 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2158 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2158 return (kNullCid - kTypedDataInt8ArrayCid); | 2159 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2159 } | 2160 } |
| 2160 | 2161 |
| 2161 } // namespace dart | 2162 } // namespace dart |
| 2162 | 2163 |
| 2163 #endif // VM_RAW_OBJECT_H_ | 2164 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |