| 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/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/snapshot.h" | 10 #include "vm/snapshot.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. | 334 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. |
| 335 intptr_t next_field_offset_; // Offset of then next instance field. | 335 intptr_t next_field_offset_; // Offset of then next instance field. |
| 336 intptr_t num_native_fields_; // Number of native fields in class. | 336 intptr_t num_native_fields_; // Number of native fields in class. |
| 337 int8_t class_state_; // Of type ClassState. | 337 int8_t class_state_; // Of type ClassState. |
| 338 bool is_const_; | 338 bool is_const_; |
| 339 bool is_interface_; | 339 bool is_interface_; |
| 340 | 340 |
| 341 friend class Object; | 341 friend class Object; |
| 342 friend class RawInstance; | 342 friend class RawInstance; |
| 343 friend RawClass* AllocateFakeClass(); | 343 friend RawClass* AllocateFakeClass(); |
| 344 friend class SnapshotReader; |
| 344 }; | 345 }; |
| 345 | 346 |
| 346 | 347 |
| 347 class RawUnresolvedClass : public RawObject { | 348 class RawUnresolvedClass : public RawObject { |
| 348 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); | 349 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); |
| 349 | 350 |
| 350 RawObject** from() { | 351 RawObject** from() { |
| 351 return reinterpret_cast<RawObject**>(&ptr()->qualifier_); | 352 return reinterpret_cast<RawObject**>(&ptr()->qualifier_); |
| 352 } | 353 } |
| 353 RawString* qualifier_; // Qualifier for the identifier. | 354 RawString* qualifier_; // Qualifier for the identifier. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 RawObject** from() { | 430 RawObject** from() { |
| 430 return reinterpret_cast<RawObject**>(&ptr()->length_); | 431 return reinterpret_cast<RawObject**>(&ptr()->length_); |
| 431 } | 432 } |
| 432 RawSmi* length_; | 433 RawSmi* length_; |
| 433 | 434 |
| 434 // Variable length data follows here. | 435 // Variable length data follows here. |
| 435 RawAbstractType* types_[0]; | 436 RawAbstractType* types_[0]; |
| 436 RawObject** to(intptr_t length) { | 437 RawObject** to(intptr_t length) { |
| 437 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); | 438 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); |
| 438 } | 439 } |
| 440 |
| 441 friend class SnapshotReader; |
| 439 }; | 442 }; |
| 440 | 443 |
| 441 | 444 |
| 442 class RawInstantiatedTypeArguments : public RawAbstractTypeArguments { | 445 class RawInstantiatedTypeArguments : public RawAbstractTypeArguments { |
| 443 private: | 446 private: |
| 444 RAW_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments); | 447 RAW_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments); |
| 445 | 448 |
| 446 RawObject** from() { | 449 RawObject** from() { |
| 447 return reinterpret_cast<RawObject**>( | 450 return reinterpret_cast<RawObject**>( |
| 448 &ptr()->uninstantiated_type_arguments_); | 451 &ptr()->uninstantiated_type_arguments_); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 536 } |
| 534 RawString* private_key_; // Key used for private identifiers. | 537 RawString* private_key_; // Key used for private identifiers. |
| 535 RawSmi* length_; // Number of tokens. | 538 RawSmi* length_; // Number of tokens. |
| 536 | 539 |
| 537 // Variable length data follows here. | 540 // Variable length data follows here. |
| 538 RawObject* data_[0]; | 541 RawObject* data_[0]; |
| 539 RawObject** to(intptr_t length) { | 542 RawObject** to(intptr_t length) { |
| 540 return reinterpret_cast<RawObject**>( | 543 return reinterpret_cast<RawObject**>( |
| 541 &ptr()->data_[length * kNumberOfEntries - 1]); | 544 &ptr()->data_[length * kNumberOfEntries - 1]); |
| 542 } | 545 } |
| 546 |
| 547 friend class SnapshotReader; |
| 543 }; | 548 }; |
| 544 | 549 |
| 545 | 550 |
| 546 class RawScript : public RawObject { | 551 class RawScript : public RawObject { |
| 547 public: | 552 public: |
| 548 enum Kind { | 553 enum Kind { |
| 549 kScript = 0, | 554 kScript = 0, |
| 550 kLibrary, | 555 kLibrary, |
| 551 kSource | 556 kSource |
| 552 }; | 557 }; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 Isolate* isolate_; | 698 Isolate* isolate_; |
| 694 | 699 |
| 695 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } | 700 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } |
| 696 RawContext* parent_; | 701 RawContext* parent_; |
| 697 | 702 |
| 698 // Variable length data follows here. | 703 // Variable length data follows here. |
| 699 RawInstance* data_[0]; | 704 RawInstance* data_[0]; |
| 700 RawObject** to(intptr_t num_vars) { | 705 RawObject** to(intptr_t num_vars) { |
| 701 return reinterpret_cast<RawObject**>(&ptr()->data_[num_vars - 1]); | 706 return reinterpret_cast<RawObject**>(&ptr()->data_[num_vars - 1]); |
| 702 } | 707 } |
| 708 |
| 709 friend class SnapshotReader; |
| 703 }; | 710 }; |
| 704 | 711 |
| 705 | 712 |
| 706 class RawContextScope : public RawObject { | 713 class RawContextScope : public RawObject { |
| 707 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); | 714 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); |
| 708 | 715 |
| 709 // TODO(iposva): Switch to convential enum offset based structure to avoid | 716 // TODO(iposva): Switch to convential enum offset based structure to avoid |
| 710 // alignment mishaps. | 717 // alignment mishaps. |
| 711 struct VariableDesc { | 718 struct VariableDesc { |
| 712 RawSmi* token_index; | 719 RawSmi* token_index; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 | 811 |
| 805 class RawSmi : public RawInteger { | 812 class RawSmi : public RawInteger { |
| 806 RAW_OBJECT_IMPLEMENTATION(Smi); | 813 RAW_OBJECT_IMPLEMENTATION(Smi); |
| 807 }; | 814 }; |
| 808 | 815 |
| 809 | 816 |
| 810 class RawMint : public RawInteger { | 817 class RawMint : public RawInteger { |
| 811 RAW_HEAP_OBJECT_IMPLEMENTATION(Mint); | 818 RAW_HEAP_OBJECT_IMPLEMENTATION(Mint); |
| 812 | 819 |
| 813 int64_t value_; | 820 int64_t value_; |
| 821 |
| 822 friend class SnapshotReader; |
| 814 }; | 823 }; |
| 815 | 824 |
| 816 | 825 |
| 817 class RawBigint : public RawInteger { | 826 class RawBigint : public RawInteger { |
| 818 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); | 827 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); |
| 819 | 828 |
| 820 // Note that the structure is not necessarily valid unless tweaked | 829 // Note that the structure is not necessarily valid unless tweaked |
| 821 // by Bigint::BNAddr(). | 830 // by Bigint::BNAddr(). |
| 822 BIGNUM bn_; | 831 BIGNUM bn_; |
| 823 | 832 |
| 824 // Variable length data follows here. | 833 // Variable length data follows here. |
| 825 BN_ULONG data_[0]; | 834 BN_ULONG data_[0]; |
| 826 }; | 835 }; |
| 827 | 836 |
| 828 | 837 |
| 829 class RawDouble : public RawNumber { | 838 class RawDouble : public RawNumber { |
| 830 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); | 839 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); |
| 831 | 840 |
| 832 double value_; | 841 double value_; |
| 842 |
| 843 friend class SnapshotReader; |
| 833 }; | 844 }; |
| 834 | 845 |
| 835 | 846 |
| 836 class RawString : public RawInstance { | 847 class RawString : public RawInstance { |
| 837 RAW_HEAP_OBJECT_IMPLEMENTATION(String); | 848 RAW_HEAP_OBJECT_IMPLEMENTATION(String); |
| 838 | 849 |
| 839 protected: | 850 protected: |
| 840 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 851 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 841 RawSmi* length_; | 852 RawSmi* length_; |
| 842 RawSmi* hash_; | 853 RawSmi* hash_; |
| 843 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } | 854 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } |
| 844 }; | 855 }; |
| 845 | 856 |
| 846 | 857 |
| 847 class RawOneByteString : public RawString { | 858 class RawOneByteString : public RawString { |
| 848 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); | 859 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); |
| 849 | 860 |
| 850 // Variable length data follows here. | 861 // Variable length data follows here. |
| 851 uint8_t data_[0]; | 862 uint8_t data_[0]; |
| 863 |
| 864 friend class SnapshotReader; |
| 852 }; | 865 }; |
| 853 | 866 |
| 854 | 867 |
| 855 class RawTwoByteString : public RawString { | 868 class RawTwoByteString : public RawString { |
| 856 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); | 869 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); |
| 857 | 870 |
| 858 // Variable length data follows here. | 871 // Variable length data follows here. |
| 859 uint16_t data_[0]; | 872 uint16_t data_[0]; |
| 873 |
| 874 friend class SnapshotReader; |
| 860 }; | 875 }; |
| 861 | 876 |
| 862 | 877 |
| 863 class RawFourByteString : public RawString { | 878 class RawFourByteString : public RawString { |
| 864 RAW_HEAP_OBJECT_IMPLEMENTATION(FourByteString); | 879 RAW_HEAP_OBJECT_IMPLEMENTATION(FourByteString); |
| 865 | 880 |
| 866 // Variable length data follows here. | 881 // Variable length data follows here. |
| 867 uint32_t data_[0]; | 882 uint32_t data_[0]; |
| 883 |
| 884 friend class SnapshotReader; |
| 868 }; | 885 }; |
| 869 | 886 |
| 870 | 887 |
| 871 template<typename T> | 888 template<typename T> |
| 872 class ExternalStringData { | 889 class ExternalStringData { |
| 873 public: | 890 public: |
| 874 typedef void Callback(void* peer); | 891 typedef void Callback(void* peer); |
| 875 ExternalStringData(const T* data, void* peer, Callback* callback) : | 892 ExternalStringData(const T* data, void* peer, Callback* callback) : |
| 876 data_(data), peer_(peer), callback_(callback) { | 893 data_(data), peer_(peer), callback_(callback) { |
| 877 } | 894 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 // Variable length data follows here. | 937 // Variable length data follows here. |
| 921 RawObject** data() { | 938 RawObject** data() { |
| 922 uword address_of_length = reinterpret_cast<uword>(&length_); | 939 uword address_of_length = reinterpret_cast<uword>(&length_); |
| 923 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); | 940 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); |
| 924 } | 941 } |
| 925 RawObject** to(intptr_t length) { | 942 RawObject** to(intptr_t length) { |
| 926 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); | 943 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); |
| 927 } | 944 } |
| 928 | 945 |
| 929 friend class RawImmutableArray; | 946 friend class RawImmutableArray; |
| 947 friend class SnapshotReader; |
| 930 }; | 948 }; |
| 931 | 949 |
| 932 | 950 |
| 933 class RawImmutableArray : public RawArray { | 951 class RawImmutableArray : public RawArray { |
| 934 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); | 952 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); |
| 953 |
| 954 friend class SnapshotReader; |
| 935 }; | 955 }; |
| 936 | 956 |
| 937 | 957 |
| 938 class RawByteBuffer : public RawInstance { | 958 class RawByteBuffer : public RawInstance { |
| 939 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteBuffer); | 959 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteBuffer); |
| 940 | 960 |
| 941 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 961 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 942 RawSmi* length_; | 962 RawSmi* length_; |
| 943 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 963 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 944 uint8_t* data_; | 964 uint8_t* data_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 intptr_t type_; // Uninitialized, simple or complex. | 1016 intptr_t type_; // Uninitialized, simple or complex. |
| 997 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1017 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 998 | 1018 |
| 999 // Variable length data follows here. | 1019 // Variable length data follows here. |
| 1000 uint8_t data_[0]; | 1020 uint8_t data_[0]; |
| 1001 }; | 1021 }; |
| 1002 | 1022 |
| 1003 } // namespace dart | 1023 } // namespace dart |
| 1004 | 1024 |
| 1005 #endif // VM_RAW_OBJECT_H_ | 1025 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |