Chromium Code Reviews| 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/token.h" | 10 #include "vm/token.h" |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); | 551 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); |
| 552 } | 552 } |
| 553 // The instantiations_ array remains empty for instantiated type arguments. | 553 // The instantiations_ array remains empty for instantiated type arguments. |
| 554 RawArray* instantiations_; // Array of paired canonical vectors: | 554 RawArray* instantiations_; // Array of paired canonical vectors: |
| 555 // Even index: instantiator. | 555 // Even index: instantiator. |
| 556 // Odd index: instantiated (without bound error). | 556 // Odd index: instantiated (without bound error). |
| 557 // Instantiations leading to bound errors do not get cached. | 557 // Instantiations leading to bound errors do not get cached. |
| 558 RawSmi* length_; | 558 RawSmi* length_; |
| 559 | 559 |
| 560 // Variable length data follows here. | 560 // Variable length data follows here. |
| 561 RawAbstractType* types_[0]; | 561 RawAbstractType** types() { |
| 562 const uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 563 return reinterpret_cast<RawAbstractType**>( | |
| 564 address_of_length + sizeof(length_)); | |
| 565 } | |
| 562 RawObject** to(intptr_t length) { | 566 RawObject** to(intptr_t length) { |
| 563 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); | 567 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]); |
| 564 } | 568 } |
| 565 | 569 |
| 566 friend class SnapshotReader; | 570 friend class SnapshotReader; |
| 567 }; | 571 }; |
| 568 | 572 |
| 569 | 573 |
| 570 class RawPatchClass : public RawObject { | 574 class RawPatchClass : public RawObject { |
| 571 private: | 575 private: |
| 572 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); | 576 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); |
| 573 | 577 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 846 // Alive: If true, the embedded object pointers will be visited during GC. | 850 // Alive: If true, the embedded object pointers will be visited during GC. |
| 847 // This field cannot be shorter because of alignment issues on x64 | 851 // This field cannot be shorter because of alignment issues on x64 |
| 848 // architectures. | 852 // architectures. |
| 849 intptr_t state_bits_; // state, is_optimized, is_alive. | 853 intptr_t state_bits_; // state, is_optimized, is_alive. |
| 850 | 854 |
| 851 // PC offsets for code patching. | 855 // PC offsets for code patching. |
| 852 intptr_t entry_patch_pc_offset_; | 856 intptr_t entry_patch_pc_offset_; |
| 853 intptr_t patch_code_pc_offset_; | 857 intptr_t patch_code_pc_offset_; |
| 854 intptr_t lazy_deopt_pc_offset_; | 858 intptr_t lazy_deopt_pc_offset_; |
| 855 | 859 |
| 856 intptr_t dummy_alignment_; | |
| 857 | |
| 858 // Variable length data follows here. | 860 // Variable length data follows here. |
| 859 int32_t data_[0]; | 861 int32_t* data() { |
| 862 uword address_of_lazy = reinterpret_cast<uword>(&lazy_deopt_pc_offset_); | |
|
Ivan Posva
2014/06/16 23:02:13
As discussed this pattern looks a bit fragile from
zra
2014/06/17 17:24:08
Changed to:
const uword result = reinterpret_cast
| |
| 863 return reinterpret_cast<int32_t*>( | |
| 864 address_of_lazy + sizeof(lazy_deopt_pc_offset_)); | |
| 865 } | |
| 860 | 866 |
| 861 friend class StackFrame; | 867 friend class StackFrame; |
| 862 friend class MarkingVisitor; | 868 friend class MarkingVisitor; |
| 863 friend class Function; | 869 friend class Function; |
| 864 }; | 870 }; |
| 865 | 871 |
| 866 | 872 |
| 867 class RawInstructions : public RawObject { | 873 class RawInstructions : public RawObject { |
| 868 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); | 874 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); |
| 869 | 875 |
| 870 RawObject** from() { | 876 RawObject** from() { |
| 871 return reinterpret_cast<RawObject**>(&ptr()->code_); | 877 return reinterpret_cast<RawObject**>(&ptr()->code_); |
| 872 } | 878 } |
| 873 RawCode* code_; | 879 RawCode* code_; |
| 874 RawArray* object_pool_; | 880 RawArray* object_pool_; |
| 875 RawObject** to() { | 881 RawObject** to() { |
| 876 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); | 882 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); |
| 877 } | 883 } |
| 878 intptr_t size_; | 884 intptr_t size_; |
| 879 | 885 |
| 880 // Variable length data follows here. | 886 // Variable length data follows here. |
| 881 uint8_t data_[0]; | 887 uint8_t* data() { |
| 888 const uword address_of_size = reinterpret_cast<uword>(&size_); | |
| 889 return reinterpret_cast<uint8_t*>(address_of_size + sizeof(size_)); | |
| 890 } | |
| 882 | 891 |
| 883 // Private helper function used while visiting stack frames. The | 892 // Private helper function used while visiting stack frames. The |
| 884 // code which iterates over dart frames is also called during GC and | 893 // code which iterates over dart frames is also called during GC and |
| 885 // is not allowed to create handles. | 894 // is not allowed to create handles. |
| 886 static bool ContainsPC(RawObject* raw_obj, uword pc); | 895 static bool ContainsPC(RawObject* raw_obj, uword pc); |
| 887 | 896 |
| 888 friend class RawCode; | 897 friend class RawCode; |
| 889 friend class Code; | 898 friend class Code; |
| 890 friend class StackFrame; | 899 friend class StackFrame; |
| 891 friend class MarkingVisitor; | 900 friend class MarkingVisitor; |
| 892 friend class Function; | 901 friend class Function; |
| 893 }; | 902 }; |
| 894 | 903 |
| 895 | 904 |
| 896 class RawPcDescriptors : public RawObject { | 905 class RawPcDescriptors : public RawObject { |
| 897 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); | 906 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); |
| 898 | 907 |
| 899 intptr_t length_; // Number of descriptors. | 908 intptr_t length_; // Number of descriptors. |
| 900 | 909 |
| 901 // Variable length data follows here. | 910 // Variable length data follows here. |
| 902 intptr_t data_[0]; | 911 intptr_t* data() { |
| 912 const uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 913 return reinterpret_cast<intptr_t*>(address_of_length + sizeof(length_)); | |
| 914 } | |
| 903 | 915 |
| 904 friend class Object; | 916 friend class Object; |
| 905 }; | 917 }; |
| 906 | 918 |
| 907 | 919 |
| 908 // Stackmap is an immutable representation of the layout of the stack at a | 920 // Stackmap is an immutable representation of the layout of the stack at a |
| 909 // PC. The stack map representation consists of a bit map which marks each | 921 // PC. The stack map representation consists of a bit map which marks each |
| 910 // live object index starting from the base of the frame. | 922 // live object index starting from the base of the frame. |
| 911 // | 923 // |
| 912 // The Stackmap also consists of a link to the code object corresponding to | 924 // The Stackmap also consists of a link to the code object corresponding to |
| 913 // the frame which the stack map is describing. The bit map representation | 925 // the frame which the stack map is describing. The bit map representation |
| 914 // is optimized for dense and small bit maps, without any upper bound. | 926 // is optimized for dense and small bit maps, without any upper bound. |
| 915 class RawStackmap : public RawObject { | 927 class RawStackmap : public RawObject { |
| 916 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); | 928 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); |
| 917 | 929 |
| 918 // TODO(kmillikin): We need a small number of bits to encode the register | 930 // TODO(kmillikin): We need a small number of bits to encode the register |
| 919 // count. Consider packing them in with the length. | 931 // count. Consider packing them in with the length. |
| 920 intptr_t length_; // Length of payload, in bits. | 932 intptr_t length_; // Length of payload, in bits. |
| 921 intptr_t register_bit_count_; // Live register bits, included in length_. | 933 intptr_t register_bit_count_; // Live register bits, included in length_. |
| 922 | 934 |
| 923 uword pc_; // PC corresponding to this stack map representation. | 935 uword pc_; // PC corresponding to this stack map representation. |
| 924 | 936 |
| 925 // Variable length data follows here (bitmap of the stack layout). | 937 // Variable length data follows here (bitmap of the stack layout). |
| 926 uint8_t data_[0]; | 938 uint8_t* data() { |
| 939 const uword address_of_pc = reinterpret_cast<uword>(&pc_); | |
| 940 return reinterpret_cast<uint8_t*>(address_of_pc + sizeof(pc_)); | |
| 941 } | |
| 927 }; | 942 }; |
| 928 | 943 |
| 929 | 944 |
| 930 class RawLocalVarDescriptors : public RawObject { | 945 class RawLocalVarDescriptors : public RawObject { |
| 931 public: | 946 public: |
| 932 enum VarInfoKind { | 947 enum VarInfoKind { |
| 933 kStackVar = 1, | 948 kStackVar = 1, |
| 934 kContextVar, | 949 kContextVar, |
| 935 kContextLevel, | 950 kContextLevel, |
| 936 kSavedEntryContext, | 951 kSavedEntryContext, |
| 937 kSavedCurrentContext | 952 kSavedCurrentContext |
| 938 }; | 953 }; |
| 939 | 954 |
| 940 struct VarInfo { | 955 struct VarInfo { |
| 941 intptr_t index; // Slot index on stack or in context. | 956 intptr_t index; // Slot index on stack or in context. |
| 942 int8_t kind; // Entry kind of type VarInfoKind. | 957 int8_t kind; // Entry kind of type VarInfoKind. |
| 943 int16_t scope_id; // Scope to which the variable belongs. | 958 int16_t scope_id; // Scope to which the variable belongs. |
| 944 intptr_t begin_pos; // Token position of scope start. | 959 intptr_t begin_pos; // Token position of scope start. |
| 945 intptr_t end_pos; // Token position of scope end. | 960 intptr_t end_pos; // Token position of scope end. |
| 946 }; | 961 }; |
| 947 | 962 |
| 948 private: | 963 private: |
| 949 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); | 964 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); |
| 950 intptr_t length_; // Number of descriptors. | 965 intptr_t length_; // Number of descriptors. |
| 951 RawArray* names_; // Array of [length_] variable names. | 966 RawArray* names_; // Array of [length_] variable names. |
| 952 | 967 |
| 953 VarInfo data_[0]; // Variable info with [length_] entries. | 968 // Variable info with [length_] entries. |
| 969 VarInfo* data() { | |
| 970 const uword address_of_names = reinterpret_cast<uword>(&names_); | |
| 971 return reinterpret_cast<VarInfo*>(address_of_names + sizeof(names_)); | |
| 972 } | |
| 954 }; | 973 }; |
| 955 | 974 |
| 956 | 975 |
| 957 class RawExceptionHandlers : public RawObject { | 976 class RawExceptionHandlers : public RawObject { |
| 958 public: | 977 public: |
| 959 // The index into the ExceptionHandlers table corresponds to | 978 // The index into the ExceptionHandlers table corresponds to |
| 960 // the try_index of the handler. | 979 // the try_index of the handler. |
| 961 struct HandlerInfo { | 980 struct HandlerInfo { |
| 962 intptr_t handler_pc; // PC value of handler. | 981 intptr_t handler_pc; // PC value of handler. |
| 963 int16_t outer_try_index; // Try block index of enclosing try block. | 982 int16_t outer_try_index; // Try block index of enclosing try block. |
| 964 int8_t needs_stacktrace; // True if a stacktrace is needed. | 983 int8_t needs_stacktrace; // True if a stacktrace is needed. |
| 965 int8_t has_catch_all; // Catches all exceptions. | 984 int8_t has_catch_all; // Catches all exceptions. |
| 966 }; | 985 }; |
| 986 | |
| 967 private: | 987 private: |
| 968 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); | 988 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); |
| 969 | 989 |
| 970 // Number of exception handler entries. | 990 // Number of exception handler entries. |
| 971 intptr_t length_; | 991 intptr_t length_; |
| 972 | 992 |
| 973 // Array with [length_] entries. Each entry is an array of all handled | 993 // Array with [length_] entries. Each entry is an array of all handled |
| 974 // exception types. | 994 // exception types. |
| 975 RawArray* handled_types_data_; | 995 RawArray* handled_types_data_; |
| 976 | 996 |
| 977 // Exception handler info of length [length_]. | 997 // Exception handler info of length [length_]. |
| 978 HandlerInfo data_[0]; | 998 HandlerInfo* data() { |
| 999 const uword address_of_htd = reinterpret_cast<uword>(&handled_types_data_); | |
| 1000 return reinterpret_cast<HandlerInfo*>( | |
| 1001 address_of_htd + sizeof(handled_types_data_)); | |
| 1002 } | |
| 979 }; | 1003 }; |
| 980 | 1004 |
| 981 | 1005 |
| 982 // Contains an array of deoptimization commands, e.g., move a specific register | 1006 // Contains an array of deoptimization commands, e.g., move a specific register |
| 983 // into a specific slot of unoptimized frame. | 1007 // into a specific slot of unoptimized frame. |
| 984 class RawDeoptInfo : public RawObject { | 1008 class RawDeoptInfo : public RawObject { |
| 985 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); | 1009 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); |
| 986 | 1010 |
| 987 RawSmi* length_; // Number of deoptimization commands | 1011 RawSmi* length_; // Number of deoptimization commands |
| 988 | 1012 |
| 989 // Variable length data follows here. | 1013 // Variable length data follows here. |
| 990 intptr_t data_[0]; | 1014 intptr_t* data() { |
| 1015 const uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 1016 return reinterpret_cast<intptr_t*>(address_of_length + sizeof(length_)); | |
| 1017 } | |
| 991 }; | 1018 }; |
| 992 | 1019 |
| 993 | 1020 |
| 994 class RawContext : public RawObject { | 1021 class RawContext : public RawObject { |
| 995 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); | 1022 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); |
| 996 | 1023 |
| 997 intptr_t num_variables_; | 1024 intptr_t num_variables_; |
| 998 Isolate* isolate_; | 1025 Isolate* isolate_; |
| 999 | 1026 |
| 1000 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } | 1027 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } |
| 1001 RawContext* parent_; | 1028 RawContext* parent_; |
| 1002 | 1029 |
| 1003 // Variable length data follows here. | 1030 // Variable length data follows here. |
| 1004 RawInstance* data_[0]; | 1031 RawInstance** data() { |
| 1032 const uword address_of_parent = reinterpret_cast<uword>(&parent_); | |
| 1033 return reinterpret_cast<RawInstance**>( | |
| 1034 address_of_parent + sizeof(parent_)); | |
| 1035 } | |
| 1005 RawObject** to(intptr_t num_vars) { | 1036 RawObject** to(intptr_t num_vars) { |
| 1006 return reinterpret_cast<RawObject**>(&ptr()->data_[num_vars - 1]); | 1037 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]); |
| 1007 } | 1038 } |
| 1008 | 1039 |
| 1009 friend class SnapshotReader; | 1040 friend class SnapshotReader; |
| 1010 }; | 1041 }; |
| 1011 | 1042 |
| 1012 | 1043 |
| 1013 class RawContextScope : public RawObject { | 1044 class RawContextScope : public RawObject { |
| 1014 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); | 1045 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); |
| 1015 | 1046 |
| 1016 // TODO(iposva): Switch to convential enum offset based structure to avoid | 1047 // TODO(iposva): Switch to convential enum offset based structure to avoid |
| 1017 // alignment mishaps. | 1048 // alignment mishaps. |
| 1018 struct VariableDesc { | 1049 struct VariableDesc { |
| 1019 RawSmi* token_pos; | 1050 RawSmi* token_pos; |
| 1020 RawString* name; | 1051 RawString* name; |
| 1021 RawBool* is_final; | 1052 RawBool* is_final; |
| 1022 RawBool* is_const; | 1053 RawBool* is_const; |
| 1023 union { | 1054 union { |
| 1024 RawAbstractType* type; | 1055 RawAbstractType* type; |
| 1025 RawInstance* value; // iff is_const is true | 1056 RawInstance* value; // iff is_const is true |
| 1026 }; | 1057 }; |
| 1027 RawSmi* context_index; | 1058 RawSmi* context_index; |
| 1028 RawSmi* context_level; | 1059 RawSmi* context_level; |
| 1029 }; | 1060 }; |
| 1030 | 1061 |
| 1031 intptr_t num_variables_; | 1062 intptr_t num_variables_; |
| 1032 | 1063 |
| 1033 // Variable length data follows here. | 1064 // Variable length data follows here. |
| 1034 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->data_[0]); } | 1065 RawObject** from() { |
| 1035 RawObject* data_[0]; | 1066 return reinterpret_cast<RawObject**>(&ptr()->data()[0]); |
| 1067 } | |
| 1068 RawObject** data() { | |
| 1069 const uword address_of_nv = reinterpret_cast<uword>(&num_variables_); | |
| 1070 return reinterpret_cast<RawObject**>( | |
| 1071 address_of_nv + sizeof(num_variables_)); | |
| 1072 } | |
| 1036 RawObject** to(intptr_t num_vars) { | 1073 RawObject** to(intptr_t num_vars) { |
| 1037 intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); | 1074 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); |
| 1038 return reinterpret_cast<RawObject**>(&ptr()->data_[data_length - 1]); | 1075 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]); |
| 1039 } | 1076 } |
| 1040 }; | 1077 }; |
| 1041 | 1078 |
| 1042 | 1079 |
| 1043 class RawICData : public RawObject { | 1080 class RawICData : public RawObject { |
| 1044 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); | 1081 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); |
| 1045 | 1082 |
| 1046 RawObject** from() { | 1083 RawObject** from() { |
| 1047 return reinterpret_cast<RawObject**>(&ptr()->owner_); | 1084 return reinterpret_cast<RawObject**>(&ptr()->owner_); |
| 1048 } | 1085 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1297 // object length so that the object can be traversed during GC). | 1334 // object length so that the object can be traversed during GC). |
| 1298 intptr_t allocated_length_; | 1335 intptr_t allocated_length_; |
| 1299 | 1336 |
| 1300 // Operational length in chunks of the bigint object, clamping can | 1337 // Operational length in chunks of the bigint object, clamping can |
| 1301 // cause this length to be reduced. If the signed_length_ is | 1338 // cause this length to be reduced. If the signed_length_ is |
| 1302 // negative then the number is negative. | 1339 // negative then the number is negative. |
| 1303 intptr_t signed_length_; | 1340 intptr_t signed_length_; |
| 1304 | 1341 |
| 1305 // A sequence of Chunks (typedef in Bignum) representing bignum digits. | 1342 // A sequence of Chunks (typedef in Bignum) representing bignum digits. |
| 1306 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)]; | 1343 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)]; |
| 1307 uint8_t data_[0]; | 1344 uint8_t* data() { |
| 1345 const uword address_of_length = reinterpret_cast<uword>(&signed_length_); | |
| 1346 return reinterpret_cast<uint8_t*>( | |
| 1347 address_of_length + sizeof(signed_length_)); | |
| 1348 } | |
| 1308 | 1349 |
| 1309 friend class SnapshotReader; | 1350 friend class SnapshotReader; |
| 1310 }; | 1351 }; |
| 1311 | 1352 |
| 1312 | 1353 |
| 1313 class RawDouble : public RawNumber { | 1354 class RawDouble : public RawNumber { |
| 1314 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); | 1355 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); |
| 1315 | 1356 |
| 1316 double value_; | 1357 double value_; |
| 1317 | 1358 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1328 RawSmi* length_; | 1369 RawSmi* length_; |
| 1329 RawSmi* hash_; | 1370 RawSmi* hash_; |
| 1330 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } | 1371 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } |
| 1331 }; | 1372 }; |
| 1332 | 1373 |
| 1333 | 1374 |
| 1334 class RawOneByteString : public RawString { | 1375 class RawOneByteString : public RawString { |
| 1335 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); | 1376 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); |
| 1336 | 1377 |
| 1337 // Variable length data follows here. | 1378 // Variable length data follows here. |
| 1338 uint8_t data_[0]; | 1379 uint8_t* data() { |
| 1380 const uword address_of_hash = reinterpret_cast<uword>(&hash_); | |
| 1381 return reinterpret_cast<uint8_t*>(address_of_hash + sizeof(hash_)); | |
| 1382 } | |
| 1339 | 1383 |
| 1340 friend class ApiMessageReader; | 1384 friend class ApiMessageReader; |
| 1341 friend class SnapshotReader; | 1385 friend class SnapshotReader; |
| 1342 }; | 1386 }; |
| 1343 | 1387 |
| 1344 | 1388 |
| 1345 class RawTwoByteString : public RawString { | 1389 class RawTwoByteString : public RawString { |
| 1346 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); | 1390 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); |
| 1347 | 1391 |
| 1348 // Variable length data follows here. | 1392 // Variable length data follows here. |
| 1349 uint16_t data_[0]; | 1393 uint16_t* data() { |
| 1394 const uword address_of_hash = reinterpret_cast<uword>(&hash_); | |
| 1395 return reinterpret_cast<uint16_t*>(address_of_hash + sizeof(hash_)); | |
| 1396 } | |
| 1350 | 1397 |
| 1351 friend class SnapshotReader; | 1398 friend class SnapshotReader; |
| 1352 }; | 1399 }; |
| 1353 | 1400 |
| 1354 | 1401 |
| 1355 template<typename T> | 1402 template<typename T> |
| 1356 class ExternalStringData { | 1403 class ExternalStringData { |
| 1357 public: | 1404 public: |
| 1358 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : | 1405 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : |
| 1359 data_(data), peer_(peer), callback_(callback) { | 1406 data_(data), peer_(peer), callback_(callback) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1403 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); | 1450 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); |
| 1404 | 1451 |
| 1405 RawObject** from() { | 1452 RawObject** from() { |
| 1406 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 1453 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
| 1407 } | 1454 } |
| 1408 RawTypeArguments* type_arguments_; | 1455 RawTypeArguments* type_arguments_; |
| 1409 RawSmi* length_; | 1456 RawSmi* length_; |
| 1410 // Variable length data follows here. | 1457 // Variable length data follows here. |
| 1411 RawObject** data() { | 1458 RawObject** data() { |
| 1412 uword address_of_length = reinterpret_cast<uword>(&length_); | 1459 uword address_of_length = reinterpret_cast<uword>(&length_); |
| 1413 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); | 1460 return reinterpret_cast<RawObject**>(address_of_length + sizeof(length_)); |
| 1414 } | 1461 } |
| 1415 RawObject** to(intptr_t length) { | 1462 RawObject** to(intptr_t length) { |
| 1416 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); | 1463 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); |
| 1417 } | 1464 } |
| 1418 | 1465 |
| 1419 friend class RawCode; | 1466 friend class RawCode; |
| 1420 friend class RawImmutableArray; | 1467 friend class RawImmutableArray; |
| 1421 friend class SnapshotReader; | 1468 friend class SnapshotReader; |
| 1422 friend class GrowableObjectArray; | 1469 friend class GrowableObjectArray; |
| 1423 friend class Object; | 1470 friend class Object; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1501 #error Architecture is not 32-bit or 64-bit. | 1548 #error Architecture is not 32-bit or 64-bit. |
| 1502 #endif // ARCH_IS_32_BIT | 1549 #endif // ARCH_IS_32_BIT |
| 1503 | 1550 |
| 1504 | 1551 |
| 1505 class RawTypedData : public RawInstance { | 1552 class RawTypedData : public RawInstance { |
| 1506 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData); | 1553 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData); |
| 1507 | 1554 |
| 1508 protected: | 1555 protected: |
| 1509 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1556 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1510 RawSmi* length_; | 1557 RawSmi* length_; |
| 1558 // Variable length data follows here. | |
| 1559 uint8_t* data() { | |
| 1560 uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 1561 return reinterpret_cast<uint8_t*>(address_of_length + sizeof(length_)); | |
| 1562 } | |
| 1511 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1563 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1512 | 1564 |
| 1513 // Variable length data follows here. | |
| 1514 uint8_t data_[0]; | |
| 1515 | |
| 1516 friend class Api; | 1565 friend class Api; |
| 1517 friend class Object; | 1566 friend class Object; |
| 1518 friend class Instance; | 1567 friend class Instance; |
| 1519 }; | 1568 }; |
| 1520 | 1569 |
| 1521 | 1570 |
| 1522 class RawExternalTypedData : public RawInstance { | 1571 class RawExternalTypedData : public RawInstance { |
| 1523 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData); | 1572 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData); |
| 1524 | 1573 |
| 1525 protected: | 1574 protected: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1595 RawSmi* num_bracket_expressions_; | 1644 RawSmi* num_bracket_expressions_; |
| 1596 RawString* pattern_; // Pattern to be used for matching. | 1645 RawString* pattern_; // Pattern to be used for matching. |
| 1597 RawObject** to() { | 1646 RawObject** to() { |
| 1598 return reinterpret_cast<RawObject**>(&ptr()->pattern_); | 1647 return reinterpret_cast<RawObject**>(&ptr()->pattern_); |
| 1599 } | 1648 } |
| 1600 | 1649 |
| 1601 intptr_t type_; // Uninitialized, simple or complex. | 1650 intptr_t type_; // Uninitialized, simple or complex. |
| 1602 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1651 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 1603 | 1652 |
| 1604 // Variable length data follows here. | 1653 // Variable length data follows here. |
| 1605 uint8_t data_[0]; | 1654 uint8_t* data() { |
| 1655 const uword address_of_flags = reinterpret_cast<uword>(&flags_); | |
| 1656 return reinterpret_cast<uint8_t*>(address_of_flags + sizeof(flags_)); | |
| 1657 } | |
| 1606 }; | 1658 }; |
| 1607 | 1659 |
| 1608 | 1660 |
| 1609 class RawWeakProperty : public RawInstance { | 1661 class RawWeakProperty : public RawInstance { |
| 1610 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty); | 1662 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty); |
| 1611 | 1663 |
| 1612 RawObject** from() { | 1664 RawObject** from() { |
| 1613 return reinterpret_cast<RawObject**>(&ptr()->key_); | 1665 return reinterpret_cast<RawObject**>(&ptr()->key_); |
| 1614 } | 1666 } |
| 1615 RawObject* key_; | 1667 RawObject* key_; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1865 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); | 1917 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); |
| 1866 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 1918 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 1867 kTypedDataInt8ArrayViewCid + 15); | 1919 kTypedDataInt8ArrayViewCid + 15); |
| 1868 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); | 1920 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); |
| 1869 return (kNullCid - kTypedDataInt8ArrayCid); | 1921 return (kNullCid - kTypedDataInt8ArrayCid); |
| 1870 } | 1922 } |
| 1871 | 1923 |
| 1872 } // namespace dart | 1924 } // namespace dart |
| 1873 | 1925 |
| 1874 #endif // VM_RAW_OBJECT_H_ | 1926 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |