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**>(address_of_length + kWordSize); | |
|
Florian Schneider
2014/06/16 08:27:26
Can't you just use sizeof(RawTypeArguments::length
zra
2014/06/16 14:22:52
Not sure what you mean.
Florian Schneider
2014/06/16 14:46:24
return reinterpret_cast<RawAbstractType**>(address
zra
2014/06/16 17:00:15
Yah, that makes sense. Done here and elsewhere.
| |
| 564 } | |
| 562 RawObject** to(intptr_t length) { | 565 RawObject** to(intptr_t length) { |
| 563 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); | 566 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]); |
| 564 } | 567 } |
| 565 | 568 |
| 566 friend class SnapshotReader; | 569 friend class SnapshotReader; |
| 567 }; | 570 }; |
| 568 | 571 |
| 569 | 572 |
| 570 class RawPatchClass : public RawObject { | 573 class RawPatchClass : public RawObject { |
| 571 private: | 574 private: |
| 572 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); | 575 RAW_HEAP_OBJECT_IMPLEMENTATION(PatchClass); |
| 573 | 576 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 // Alive: If true, the embedded object pointers will be visited during GC. | 848 // Alive: If true, the embedded object pointers will be visited during GC. |
| 846 // This field cannot be shorter because of alignment issues on x64 | 849 // This field cannot be shorter because of alignment issues on x64 |
| 847 // architectures. | 850 // architectures. |
| 848 intptr_t state_bits_; // state, is_optimized, is_alive. | 851 intptr_t state_bits_; // state, is_optimized, is_alive. |
| 849 | 852 |
| 850 // PC offsets for code patching. | 853 // PC offsets for code patching. |
| 851 intptr_t entry_patch_pc_offset_; | 854 intptr_t entry_patch_pc_offset_; |
| 852 intptr_t patch_code_pc_offset_; | 855 intptr_t patch_code_pc_offset_; |
| 853 intptr_t lazy_deopt_pc_offset_; | 856 intptr_t lazy_deopt_pc_offset_; |
| 854 | 857 |
| 855 intptr_t dummy_alignment_; | |
| 856 | |
| 857 // Variable length data follows here. | 858 // Variable length data follows here. |
| 858 int32_t data_[0]; | 859 int32_t* data() { |
| 860 uword address_of_lazy = reinterpret_cast<uword>(&lazy_deopt_pc_offset_); | |
| 861 return reinterpret_cast<int32_t*>(address_of_lazy + kWordSize); | |
| 862 } | |
| 859 | 863 |
| 860 friend class StackFrame; | 864 friend class StackFrame; |
| 861 friend class MarkingVisitor; | 865 friend class MarkingVisitor; |
| 862 friend class Function; | 866 friend class Function; |
| 863 }; | 867 }; |
| 864 | 868 |
| 865 | 869 |
| 866 class RawInstructions : public RawObject { | 870 class RawInstructions : public RawObject { |
| 867 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); | 871 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); |
| 868 | 872 |
| 869 RawObject** from() { | 873 RawObject** from() { |
| 870 return reinterpret_cast<RawObject**>(&ptr()->code_); | 874 return reinterpret_cast<RawObject**>(&ptr()->code_); |
| 871 } | 875 } |
| 872 RawCode* code_; | 876 RawCode* code_; |
| 873 RawArray* object_pool_; | 877 RawArray* object_pool_; |
| 874 RawObject** to() { | 878 RawObject** to() { |
| 875 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); | 879 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); |
| 876 } | 880 } |
| 877 intptr_t size_; | 881 intptr_t size_; |
| 878 | 882 |
| 879 // Variable length data follows here. | 883 // Variable length data follows here. |
| 880 uint8_t data_[0]; | 884 uint8_t* data() { |
| 885 const uword address_of_size = reinterpret_cast<uword>(&size_); | |
| 886 return reinterpret_cast<uint8_t*>(address_of_size + kWordSize); | |
| 887 } | |
| 881 | 888 |
| 882 // Private helper function used while visiting stack frames. The | 889 // Private helper function used while visiting stack frames. The |
| 883 // code which iterates over dart frames is also called during GC and | 890 // code which iterates over dart frames is also called during GC and |
| 884 // is not allowed to create handles. | 891 // is not allowed to create handles. |
| 885 static bool ContainsPC(RawObject* raw_obj, uword pc); | 892 static bool ContainsPC(RawObject* raw_obj, uword pc); |
| 886 | 893 |
| 887 friend class RawCode; | 894 friend class RawCode; |
| 888 friend class Code; | 895 friend class Code; |
| 889 friend class StackFrame; | 896 friend class StackFrame; |
| 890 friend class MarkingVisitor; | 897 friend class MarkingVisitor; |
| 891 friend class Function; | 898 friend class Function; |
| 892 }; | 899 }; |
| 893 | 900 |
| 894 | 901 |
| 895 class RawPcDescriptors : public RawObject { | 902 class RawPcDescriptors : public RawObject { |
| 896 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); | 903 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); |
| 897 | 904 |
| 898 intptr_t length_; // Number of descriptors. | 905 intptr_t length_; // Number of descriptors. |
| 899 | 906 |
| 900 // Variable length data follows here. | 907 // Variable length data follows here. |
| 901 intptr_t data_[0]; | 908 intptr_t* data() { |
| 909 const uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 910 return reinterpret_cast<intptr_t*>(address_of_length + kWordSize); | |
| 911 } | |
| 902 | 912 |
| 903 friend class Object; | 913 friend class Object; |
| 904 }; | 914 }; |
| 905 | 915 |
| 906 | 916 |
| 907 // Stackmap is an immutable representation of the layout of the stack at a | 917 // Stackmap is an immutable representation of the layout of the stack at a |
| 908 // PC. The stack map representation consists of a bit map which marks each | 918 // PC. The stack map representation consists of a bit map which marks each |
| 909 // live object index starting from the base of the frame. | 919 // live object index starting from the base of the frame. |
| 910 // | 920 // |
| 911 // The Stackmap also consists of a link to the code object corresponding to | 921 // The Stackmap also consists of a link to the code object corresponding to |
| 912 // the frame which the stack map is describing. The bit map representation | 922 // the frame which the stack map is describing. The bit map representation |
| 913 // is optimized for dense and small bit maps, without any upper bound. | 923 // is optimized for dense and small bit maps, without any upper bound. |
| 914 class RawStackmap : public RawObject { | 924 class RawStackmap : public RawObject { |
| 915 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); | 925 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); |
| 916 | 926 |
| 917 // TODO(kmillikin): We need a small number of bits to encode the register | 927 // TODO(kmillikin): We need a small number of bits to encode the register |
| 918 // count. Consider packing them in with the length. | 928 // count. Consider packing them in with the length. |
| 919 intptr_t length_; // Length of payload, in bits. | 929 intptr_t length_; // Length of payload, in bits. |
| 920 intptr_t register_bit_count_; // Live register bits, included in length_. | 930 intptr_t register_bit_count_; // Live register bits, included in length_. |
| 921 | 931 |
| 922 uword pc_; // PC corresponding to this stack map representation. | 932 uword pc_; // PC corresponding to this stack map representation. |
| 923 | 933 |
| 924 // Variable length data follows here (bitmap of the stack layout). | 934 // Variable length data follows here (bitmap of the stack layout). |
| 925 uint8_t data_[0]; | 935 uint8_t* data() { |
| 936 const uword address_of_pc = reinterpret_cast<uword>(&pc_); | |
| 937 return reinterpret_cast<uint8_t*>(address_of_pc + kWordSize); | |
| 938 } | |
| 926 }; | 939 }; |
| 927 | 940 |
| 928 | 941 |
| 929 class RawLocalVarDescriptors : public RawObject { | 942 class RawLocalVarDescriptors : public RawObject { |
| 930 public: | 943 public: |
| 931 enum VarInfoKind { | 944 enum VarInfoKind { |
| 932 kStackVar = 1, | 945 kStackVar = 1, |
| 933 kContextVar, | 946 kContextVar, |
| 934 kContextLevel, | 947 kContextLevel, |
| 935 kSavedEntryContext, | 948 kSavedEntryContext, |
| 936 kSavedCurrentContext | 949 kSavedCurrentContext |
| 937 }; | 950 }; |
| 938 | 951 |
| 939 struct VarInfo { | 952 struct VarInfo { |
| 940 intptr_t index; // Slot index on stack or in context. | 953 intptr_t index; // Slot index on stack or in context. |
| 941 int8_t kind; // Entry kind of type VarInfoKind. | 954 int8_t kind; // Entry kind of type VarInfoKind. |
| 942 int16_t scope_id; // Scope to which the variable belongs. | 955 int16_t scope_id; // Scope to which the variable belongs. |
| 943 intptr_t begin_pos; // Token position of scope start. | 956 intptr_t begin_pos; // Token position of scope start. |
| 944 intptr_t end_pos; // Token position of scope end. | 957 intptr_t end_pos; // Token position of scope end. |
| 945 }; | 958 }; |
| 946 | 959 |
| 947 private: | 960 private: |
| 948 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); | 961 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); |
| 949 intptr_t length_; // Number of descriptors. | 962 intptr_t length_; // Number of descriptors. |
| 950 RawArray* names_; // Array of [length_] variable names. | 963 RawArray* names_; // Array of [length_] variable names. |
| 951 | 964 |
| 952 VarInfo data_[0]; // Variable info with [length_] entries. | 965 // Variable info with [length_] entries. |
| 966 VarInfo* data() { | |
| 967 const uword address_of_names = reinterpret_cast<uword>(&names_); | |
| 968 return reinterpret_cast<VarInfo*>(address_of_names + kWordSize); | |
| 969 } | |
| 953 }; | 970 }; |
| 954 | 971 |
| 955 | 972 |
| 956 class RawExceptionHandlers : public RawObject { | 973 class RawExceptionHandlers : public RawObject { |
| 957 public: | 974 public: |
| 958 // The index into the ExceptionHandlers table corresponds to | 975 // The index into the ExceptionHandlers table corresponds to |
| 959 // the try_index of the handler. | 976 // the try_index of the handler. |
| 960 struct HandlerInfo { | 977 struct HandlerInfo { |
| 961 intptr_t handler_pc; // PC value of handler. | 978 intptr_t handler_pc; // PC value of handler. |
| 962 int16_t outer_try_index; // Try block index of enclosing try block. | 979 int16_t outer_try_index; // Try block index of enclosing try block. |
| 963 int8_t needs_stacktrace; // True if a stacktrace is needed. | 980 int8_t needs_stacktrace; // True if a stacktrace is needed. |
| 964 int8_t has_catch_all; // Catches all exceptions. | 981 int8_t has_catch_all; // Catches all exceptions. |
| 965 }; | 982 }; |
| 983 | |
| 966 private: | 984 private: |
| 967 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); | 985 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); |
| 968 | 986 |
| 969 // Number of exception handler entries. | 987 // Number of exception handler entries. |
| 970 intptr_t length_; | 988 intptr_t length_; |
| 971 | 989 |
| 972 // Array with [length_] entries. Each entry is an array of all handled | 990 // Array with [length_] entries. Each entry is an array of all handled |
| 973 // exception types. | 991 // exception types. |
| 974 RawArray* handled_types_data_; | 992 RawArray* handled_types_data_; |
| 975 | 993 |
| 976 // Exception handler info of length [length_]. | 994 // Exception handler info of length [length_]. |
| 977 HandlerInfo data_[0]; | 995 HandlerInfo* data() { |
| 996 const uword address_of_htd = reinterpret_cast<uword>(&handled_types_data_); | |
| 997 return reinterpret_cast<HandlerInfo*>(address_of_htd + kWordSize); | |
| 998 } | |
| 978 }; | 999 }; |
| 979 | 1000 |
| 980 | 1001 |
| 981 // Contains an array of deoptimization commands, e.g., move a specific register | 1002 // Contains an array of deoptimization commands, e.g., move a specific register |
| 982 // into a specific slot of unoptimized frame. | 1003 // into a specific slot of unoptimized frame. |
| 983 class RawDeoptInfo : public RawObject { | 1004 class RawDeoptInfo : public RawObject { |
| 984 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); | 1005 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); |
| 985 | 1006 |
| 986 RawSmi* length_; // Number of deoptimization commands | 1007 RawSmi* length_; // Number of deoptimization commands |
| 987 | 1008 |
| 988 // Variable length data follows here. | 1009 // Variable length data follows here. |
| 989 intptr_t data_[0]; | 1010 intptr_t* data() { |
| 1011 const uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 1012 return reinterpret_cast<intptr_t*>(address_of_length + kWordSize); | |
| 1013 } | |
| 990 }; | 1014 }; |
| 991 | 1015 |
| 992 | 1016 |
| 993 class RawContext : public RawObject { | 1017 class RawContext : public RawObject { |
| 994 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); | 1018 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); |
| 995 | 1019 |
| 996 intptr_t num_variables_; | 1020 intptr_t num_variables_; |
| 997 Isolate* isolate_; | 1021 Isolate* isolate_; |
| 998 | 1022 |
| 999 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } | 1023 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } |
| 1000 RawContext* parent_; | 1024 RawContext* parent_; |
| 1001 | 1025 |
| 1002 // Variable length data follows here. | 1026 // Variable length data follows here. |
| 1003 RawInstance* data_[0]; | 1027 RawInstance** data() { |
| 1028 const uword address_of_parent = reinterpret_cast<uword>(&parent_); | |
| 1029 return reinterpret_cast<RawInstance**>(address_of_parent + kWordSize); | |
| 1030 } | |
| 1004 RawObject** to(intptr_t num_vars) { | 1031 RawObject** to(intptr_t num_vars) { |
| 1005 return reinterpret_cast<RawObject**>(&ptr()->data_[num_vars - 1]); | 1032 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]); |
| 1006 } | 1033 } |
| 1007 | 1034 |
| 1008 friend class SnapshotReader; | 1035 friend class SnapshotReader; |
| 1009 }; | 1036 }; |
| 1010 | 1037 |
| 1011 | 1038 |
| 1012 class RawContextScope : public RawObject { | 1039 class RawContextScope : public RawObject { |
| 1013 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); | 1040 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); |
| 1014 | 1041 |
| 1015 // TODO(iposva): Switch to convential enum offset based structure to avoid | 1042 // TODO(iposva): Switch to convential enum offset based structure to avoid |
| 1016 // alignment mishaps. | 1043 // alignment mishaps. |
| 1017 struct VariableDesc { | 1044 struct VariableDesc { |
| 1018 RawSmi* token_pos; | 1045 RawSmi* token_pos; |
| 1019 RawString* name; | 1046 RawString* name; |
| 1020 RawBool* is_final; | 1047 RawBool* is_final; |
| 1021 RawBool* is_const; | 1048 RawBool* is_const; |
| 1022 union { | 1049 union { |
| 1023 RawAbstractType* type; | 1050 RawAbstractType* type; |
| 1024 RawInstance* value; // iff is_const is true | 1051 RawInstance* value; // iff is_const is true |
| 1025 }; | 1052 }; |
| 1026 RawSmi* context_index; | 1053 RawSmi* context_index; |
| 1027 RawSmi* context_level; | 1054 RawSmi* context_level; |
| 1028 }; | 1055 }; |
| 1029 | 1056 |
| 1030 intptr_t num_variables_; | 1057 intptr_t num_variables_; |
| 1031 | 1058 |
| 1032 // Variable length data follows here. | 1059 // Variable length data follows here. |
| 1033 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->data_[0]); } | 1060 RawObject** from() { |
| 1034 RawObject* data_[0]; | 1061 return reinterpret_cast<RawObject**>(&ptr()->data()[0]); |
| 1062 } | |
| 1063 RawObject** data() { | |
| 1064 const uword address_of_nv = reinterpret_cast<uword>(&num_variables_); | |
| 1065 return reinterpret_cast<RawObject**>(address_of_nv + kWordSize); | |
| 1066 } | |
| 1035 RawObject** to(intptr_t num_vars) { | 1067 RawObject** to(intptr_t num_vars) { |
| 1036 intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); | 1068 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); |
| 1037 return reinterpret_cast<RawObject**>(&ptr()->data_[data_length - 1]); | 1069 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]); |
| 1038 } | 1070 } |
| 1039 }; | 1071 }; |
| 1040 | 1072 |
| 1041 | 1073 |
| 1042 class RawICData : public RawObject { | 1074 class RawICData : public RawObject { |
| 1043 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); | 1075 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); |
| 1044 | 1076 |
| 1045 RawObject** from() { | 1077 RawObject** from() { |
| 1046 return reinterpret_cast<RawObject**>(&ptr()->owner_); | 1078 return reinterpret_cast<RawObject**>(&ptr()->owner_); |
| 1047 } | 1079 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1295 // object length so that the object can be traversed during GC). | 1327 // object length so that the object can be traversed during GC). |
| 1296 intptr_t allocated_length_; | 1328 intptr_t allocated_length_; |
| 1297 | 1329 |
| 1298 // Operational length in chunks of the bigint object, clamping can | 1330 // Operational length in chunks of the bigint object, clamping can |
| 1299 // cause this length to be reduced. If the signed_length_ is | 1331 // cause this length to be reduced. If the signed_length_ is |
| 1300 // negative then the number is negative. | 1332 // negative then the number is negative. |
| 1301 intptr_t signed_length_; | 1333 intptr_t signed_length_; |
| 1302 | 1334 |
| 1303 // A sequence of Chunks (typedef in Bignum) representing bignum digits. | 1335 // A sequence of Chunks (typedef in Bignum) representing bignum digits. |
| 1304 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)]; | 1336 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)]; |
| 1305 uint8_t data_[0]; | 1337 uint8_t* data() { |
| 1338 const uword address_of_length = reinterpret_cast<uword>(&signed_length_); | |
| 1339 return reinterpret_cast<uint8_t*>(address_of_length + kWordSize); | |
| 1340 } | |
| 1306 | 1341 |
| 1307 friend class SnapshotReader; | 1342 friend class SnapshotReader; |
| 1308 }; | 1343 }; |
| 1309 | 1344 |
| 1310 | 1345 |
| 1311 class RawDouble : public RawNumber { | 1346 class RawDouble : public RawNumber { |
| 1312 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); | 1347 RAW_HEAP_OBJECT_IMPLEMENTATION(Double); |
| 1313 | 1348 |
| 1314 double value_; | 1349 double value_; |
| 1315 | 1350 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1326 RawSmi* length_; | 1361 RawSmi* length_; |
| 1327 RawSmi* hash_; | 1362 RawSmi* hash_; |
| 1328 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } | 1363 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } |
| 1329 }; | 1364 }; |
| 1330 | 1365 |
| 1331 | 1366 |
| 1332 class RawOneByteString : public RawString { | 1367 class RawOneByteString : public RawString { |
| 1333 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); | 1368 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); |
| 1334 | 1369 |
| 1335 // Variable length data follows here. | 1370 // Variable length data follows here. |
| 1336 uint8_t data_[0]; | 1371 uint8_t* data() { |
| 1372 const uword address_of_hash = reinterpret_cast<uword>(&hash_); | |
| 1373 return reinterpret_cast<uint8_t*>(address_of_hash + kWordSize); | |
| 1374 } | |
| 1337 | 1375 |
| 1338 friend class ApiMessageReader; | 1376 friend class ApiMessageReader; |
| 1339 friend class SnapshotReader; | 1377 friend class SnapshotReader; |
| 1340 }; | 1378 }; |
| 1341 | 1379 |
| 1342 | 1380 |
| 1343 class RawTwoByteString : public RawString { | 1381 class RawTwoByteString : public RawString { |
| 1344 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); | 1382 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); |
| 1345 | 1383 |
| 1346 // Variable length data follows here. | 1384 // Variable length data follows here. |
| 1347 uint16_t data_[0]; | 1385 uint16_t* data() { |
| 1386 const uword address_of_hash = reinterpret_cast<uword>(&hash_); | |
| 1387 return reinterpret_cast<uint16_t*>(address_of_hash + kWordSize); | |
| 1388 } | |
| 1348 | 1389 |
| 1349 friend class SnapshotReader; | 1390 friend class SnapshotReader; |
| 1350 }; | 1391 }; |
| 1351 | 1392 |
| 1352 | 1393 |
| 1353 template<typename T> | 1394 template<typename T> |
| 1354 class ExternalStringData { | 1395 class ExternalStringData { |
| 1355 public: | 1396 public: |
| 1356 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : | 1397 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : |
| 1357 data_(data), peer_(peer), callback_(callback) { | 1398 data_(data), peer_(peer), callback_(callback) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1499 #error Architecture is not 32-bit or 64-bit. | 1540 #error Architecture is not 32-bit or 64-bit. |
| 1500 #endif // ARCH_IS_32_BIT | 1541 #endif // ARCH_IS_32_BIT |
| 1501 | 1542 |
| 1502 | 1543 |
| 1503 class RawTypedData : public RawInstance { | 1544 class RawTypedData : public RawInstance { |
| 1504 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData); | 1545 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData); |
| 1505 | 1546 |
| 1506 protected: | 1547 protected: |
| 1507 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1548 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1508 RawSmi* length_; | 1549 RawSmi* length_; |
| 1550 // Variable length data follows here. | |
| 1551 uint8_t* data() { | |
| 1552 uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 1553 return reinterpret_cast<uint8_t*>(address_of_length + kWordSize); | |
| 1554 } | |
| 1509 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1555 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1510 | 1556 |
| 1511 // Variable length data follows here. | |
| 1512 uint8_t data_[0]; | |
| 1513 | |
| 1514 friend class Api; | 1557 friend class Api; |
| 1515 friend class Object; | 1558 friend class Object; |
| 1516 friend class Instance; | 1559 friend class Instance; |
| 1517 }; | 1560 }; |
| 1518 | 1561 |
| 1519 | 1562 |
| 1520 class RawExternalTypedData : public RawInstance { | 1563 class RawExternalTypedData : public RawInstance { |
| 1521 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData); | 1564 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData); |
| 1522 | 1565 |
| 1523 protected: | 1566 protected: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1593 RawSmi* num_bracket_expressions_; | 1636 RawSmi* num_bracket_expressions_; |
| 1594 RawString* pattern_; // Pattern to be used for matching. | 1637 RawString* pattern_; // Pattern to be used for matching. |
| 1595 RawObject** to() { | 1638 RawObject** to() { |
| 1596 return reinterpret_cast<RawObject**>(&ptr()->pattern_); | 1639 return reinterpret_cast<RawObject**>(&ptr()->pattern_); |
| 1597 } | 1640 } |
| 1598 | 1641 |
| 1599 intptr_t type_; // Uninitialized, simple or complex. | 1642 intptr_t type_; // Uninitialized, simple or complex. |
| 1600 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1643 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 1601 | 1644 |
| 1602 // Variable length data follows here. | 1645 // Variable length data follows here. |
| 1603 uint8_t data_[0]; | 1646 uint8_t* data() { |
| 1647 const uword address_of_flags = reinterpret_cast<uword>(&flags_); | |
| 1648 return reinterpret_cast<uint8_t*>(address_of_flags + kWordSize); | |
| 1649 } | |
| 1604 }; | 1650 }; |
| 1605 | 1651 |
| 1606 | 1652 |
| 1607 class RawWeakProperty : public RawInstance { | 1653 class RawWeakProperty : public RawInstance { |
| 1608 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty); | 1654 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty); |
| 1609 | 1655 |
| 1610 RawObject** from() { | 1656 RawObject** from() { |
| 1611 return reinterpret_cast<RawObject**>(&ptr()->key_); | 1657 return reinterpret_cast<RawObject**>(&ptr()->key_); |
| 1612 } | 1658 } |
| 1613 RawObject* key_; | 1659 RawObject* key_; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1863 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); | 1909 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); |
| 1864 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 1910 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 1865 kTypedDataInt8ArrayViewCid + 15); | 1911 kTypedDataInt8ArrayViewCid + 15); |
| 1866 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); | 1912 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); |
| 1867 return (kNullCid - kTypedDataInt8ArrayCid); | 1913 return (kNullCid - kTypedDataInt8ArrayCid); |
| 1868 } | 1914 } |
| 1869 | 1915 |
| 1870 } // namespace dart | 1916 } // namespace dart |
| 1871 | 1917 |
| 1872 #endif // VM_RAW_OBJECT_H_ | 1918 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |