| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 intptr_t SizeFromClass() const; | 334 intptr_t SizeFromClass() const; |
| 335 | 335 |
| 336 intptr_t GetClassIndex() const { | 336 intptr_t GetClassIndex() const { |
| 337 uword tags = ptr()->tags_; | 337 uword tags = ptr()->tags_; |
| 338 return ClassTag::decode(tags); | 338 return ClassTag::decode(tags); |
| 339 } | 339 } |
| 340 | 340 |
| 341 friend class Api; | 341 friend class Api; |
| 342 friend class Array; | 342 friend class Array; |
| 343 friend class Heap; | 343 friend class Heap; |
| 344 friend class HeapProfiler; |
| 344 friend class MarkingVisitor; | 345 friend class MarkingVisitor; |
| 345 friend class Object; | 346 friend class Object; |
| 346 friend class RawInstructions; | 347 friend class RawInstructions; |
| 347 friend class SnapshotReader; | 348 friend class SnapshotReader; |
| 348 friend class SnapshotWriter; | 349 friend class SnapshotWriter; |
| 349 | 350 |
| 350 DISALLOW_ALLOCATION(); | 351 DISALLOW_ALLOCATION(); |
| 351 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); | 352 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |
| 352 }; | 353 }; |
| 353 | 354 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 378 RawFunction* signature_function_; // Associated function for signature class. | 379 RawFunction* signature_function_; // Associated function for signature class. |
| 379 RawArray* functions_cache_; // See class FunctionsCache. | 380 RawArray* functions_cache_; // See class FunctionsCache. |
| 380 RawArray* constants_; // Canonicalized values of this class. | 381 RawArray* constants_; // Canonicalized values of this class. |
| 381 RawArray* canonical_types_; // Canonicalized types of this class. | 382 RawArray* canonical_types_; // Canonicalized types of this class. |
| 382 RawCode* allocation_stub_; // Stub code for allocation of instances. | 383 RawCode* allocation_stub_; // Stub code for allocation of instances. |
| 383 RawObject** to() { | 384 RawObject** to() { |
| 384 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); | 385 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); |
| 385 } | 386 } |
| 386 | 387 |
| 387 cpp_vtable handle_vtable_; | 388 cpp_vtable handle_vtable_; |
| 388 intptr_t instance_size_; | 389 intptr_t instance_size_; // Size if fixed length or 0 if variable length. |
| 389 ObjectKind instance_kind_; | 390 ObjectKind instance_kind_; |
| 390 intptr_t index_; // Index in the class table. | 391 intptr_t index_; // Index in the class table. |
| 391 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. | 392 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. |
| 392 intptr_t next_field_offset_; // Offset of then next instance field. | 393 intptr_t next_field_offset_; // Offset of the next instance field. |
| 393 intptr_t num_native_fields_; // Number of native fields in class. | 394 intptr_t num_native_fields_; // Number of native fields in class. |
| 394 intptr_t token_index_; | 395 intptr_t token_index_; |
| 395 int8_t class_state_; // Of type ClassState. | 396 int8_t class_state_; // Of type ClassState. |
| 396 bool is_const_; | 397 bool is_const_; |
| 397 bool is_interface_; | 398 bool is_interface_; |
| 398 | 399 |
| 400 friend class HeapProfiler; |
| 399 friend class Object; | 401 friend class Object; |
| 400 friend class RawInstance; | 402 friend class RawInstance; |
| 401 friend class RawInstructions; | 403 friend class RawInstructions; |
| 402 friend RawClass* AllocateFakeClass(); | 404 friend RawClass* AllocateFakeClass(); |
| 403 friend class SnapshotReader; | 405 friend class SnapshotReader; |
| 404 }; | 406 }; |
| 405 | 407 |
| 406 | 408 |
| 407 class RawUnresolvedClass : public RawObject { | 409 class RawUnresolvedClass : public RawObject { |
| 408 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); | 410 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 RawAbstractTypeArguments* instantiator_type_arguments_; | 483 RawAbstractTypeArguments* instantiator_type_arguments_; |
| 482 RawObject** to() { | 484 RawObject** to() { |
| 483 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); | 485 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); |
| 484 } | 486 } |
| 485 }; | 487 }; |
| 486 | 488 |
| 487 | 489 |
| 488 class RawAbstractTypeArguments : public RawObject { | 490 class RawAbstractTypeArguments : public RawObject { |
| 489 private: | 491 private: |
| 490 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments); | 492 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments); |
| 493 |
| 494 friend class HeapProfiler; |
| 491 }; | 495 }; |
| 492 | 496 |
| 493 | 497 |
| 494 class RawTypeArguments : public RawAbstractTypeArguments { | 498 class RawTypeArguments : public RawAbstractTypeArguments { |
| 495 private: | 499 private: |
| 496 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); | 500 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); |
| 497 | 501 |
| 498 RawObject** from() { | 502 RawObject** from() { |
| 499 return reinterpret_cast<RawObject**>(&ptr()->length_); | 503 return reinterpret_cast<RawObject**>(&ptr()->length_); |
| 500 } | 504 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 RawString* name_; | 585 RawString* name_; |
| 582 RawClass* owner_; | 586 RawClass* owner_; |
| 583 RawAbstractType* type_; | 587 RawAbstractType* type_; |
| 584 RawInstance* value_; // Offset for instance and value for static fields. | 588 RawInstance* value_; // Offset for instance and value for static fields. |
| 585 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->value_); } | 589 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->value_); } |
| 586 | 590 |
| 587 intptr_t token_index_; | 591 intptr_t token_index_; |
| 588 bool is_static_; | 592 bool is_static_; |
| 589 bool is_final_; | 593 bool is_final_; |
| 590 bool has_initializer_; | 594 bool has_initializer_; |
| 595 |
| 596 friend class HeapProfiler; |
| 591 }; | 597 }; |
| 592 | 598 |
| 593 | 599 |
| 594 class RawLiteralToken : public RawObject { | 600 class RawLiteralToken : public RawObject { |
| 595 RAW_HEAP_OBJECT_IMPLEMENTATION(LiteralToken); | 601 RAW_HEAP_OBJECT_IMPLEMENTATION(LiteralToken); |
| 596 | 602 |
| 597 RawObject** from() { | 603 RawObject** from() { |
| 598 return reinterpret_cast<RawObject**>(&ptr()->literal_); | 604 return reinterpret_cast<RawObject**>(&ptr()->literal_); |
| 599 } | 605 } |
| 600 RawString* literal_; // Literal characters as they appear in source text. | 606 RawString* literal_; // Literal characters as they appear in source text. |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 | 1003 |
| 998 | 1004 |
| 999 class RawString : public RawInstance { | 1005 class RawString : public RawInstance { |
| 1000 RAW_HEAP_OBJECT_IMPLEMENTATION(String); | 1006 RAW_HEAP_OBJECT_IMPLEMENTATION(String); |
| 1001 | 1007 |
| 1002 protected: | 1008 protected: |
| 1003 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1009 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1004 RawSmi* length_; | 1010 RawSmi* length_; |
| 1005 RawSmi* hash_; | 1011 RawSmi* hash_; |
| 1006 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } | 1012 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } |
| 1013 |
| 1014 friend class HeapProfiler; |
| 1007 }; | 1015 }; |
| 1008 | 1016 |
| 1009 | 1017 |
| 1010 class RawOneByteString : public RawString { | 1018 class RawOneByteString : public RawString { |
| 1011 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); | 1019 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); |
| 1012 | 1020 |
| 1013 // Variable length data follows here. | 1021 // Variable length data follows here. |
| 1014 uint8_t data_[0]; | 1022 uint8_t data_[0]; |
| 1015 | 1023 |
| 1024 friend class HeapProfiler; |
| 1016 friend class SnapshotReader; | 1025 friend class SnapshotReader; |
| 1017 }; | 1026 }; |
| 1018 | 1027 |
| 1019 | 1028 |
| 1020 class RawTwoByteString : public RawString { | 1029 class RawTwoByteString : public RawString { |
| 1021 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); | 1030 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); |
| 1022 | 1031 |
| 1023 // Variable length data follows here. | 1032 // Variable length data follows here. |
| 1024 uint16_t data_[0]; | 1033 uint16_t data_[0]; |
| 1025 | 1034 |
| 1035 friend class HeapProfiler; |
| 1026 friend class SnapshotReader; | 1036 friend class SnapshotReader; |
| 1027 }; | 1037 }; |
| 1028 | 1038 |
| 1029 | 1039 |
| 1030 class RawFourByteString : public RawString { | 1040 class RawFourByteString : public RawString { |
| 1031 RAW_HEAP_OBJECT_IMPLEMENTATION(FourByteString); | 1041 RAW_HEAP_OBJECT_IMPLEMENTATION(FourByteString); |
| 1032 | 1042 |
| 1033 // Variable length data follows here. | 1043 // Variable length data follows here. |
| 1034 uint32_t data_[0]; | 1044 uint32_t data_[0]; |
| 1035 | 1045 |
| 1046 friend class HeapProfiler; |
| 1036 friend class SnapshotReader; | 1047 friend class SnapshotReader; |
| 1037 }; | 1048 }; |
| 1038 | 1049 |
| 1039 | 1050 |
| 1040 template<typename T> | 1051 template<typename T> |
| 1041 class ExternalStringData { | 1052 class ExternalStringData { |
| 1042 public: | 1053 public: |
| 1043 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : | 1054 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : |
| 1044 data_(data), peer_(peer), callback_(callback) { | 1055 data_(data), peer_(peer), callback_(callback) { |
| 1045 } | 1056 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 RawSmi* length_; | 1110 RawSmi* length_; |
| 1100 // Variable length data follows here. | 1111 // Variable length data follows here. |
| 1101 RawObject** data() { | 1112 RawObject** data() { |
| 1102 uword address_of_length = reinterpret_cast<uword>(&length_); | 1113 uword address_of_length = reinterpret_cast<uword>(&length_); |
| 1103 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); | 1114 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); |
| 1104 } | 1115 } |
| 1105 RawObject** to(intptr_t length) { | 1116 RawObject** to(intptr_t length) { |
| 1106 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); | 1117 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); |
| 1107 } | 1118 } |
| 1108 | 1119 |
| 1120 friend class GrowableObjectArray; |
| 1121 friend class HeapProfiler; |
| 1109 friend class RawCode; | 1122 friend class RawCode; |
| 1110 friend class RawImmutableArray; | 1123 friend class RawImmutableArray; |
| 1111 friend class SnapshotReader; | 1124 friend class SnapshotReader; |
| 1112 friend class GrowableObjectArray; | |
| 1113 }; | 1125 }; |
| 1114 | 1126 |
| 1115 | 1127 |
| 1116 class RawImmutableArray : public RawArray { | 1128 class RawImmutableArray : public RawArray { |
| 1117 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); | 1129 RAW_HEAP_OBJECT_IMPLEMENTATION(ImmutableArray); |
| 1118 | 1130 |
| 1119 friend class SnapshotReader; | 1131 friend class SnapshotReader; |
| 1120 }; | 1132 }; |
| 1121 | 1133 |
| 1122 | 1134 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1137 }; | 1149 }; |
| 1138 | 1150 |
| 1139 | 1151 |
| 1140 class RawByteArray : public RawInstance { | 1152 class RawByteArray : public RawInstance { |
| 1141 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray); | 1153 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray); |
| 1142 | 1154 |
| 1143 protected: | 1155 protected: |
| 1144 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1156 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1145 RawSmi* length_; | 1157 RawSmi* length_; |
| 1146 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1158 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1159 |
| 1160 friend class HeapProfiler; |
| 1147 }; | 1161 }; |
| 1148 | 1162 |
| 1149 | 1163 |
| 1150 class RawInt8Array: public RawByteArray { | 1164 class RawInt8Array: public RawByteArray { |
| 1151 RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array); | 1165 RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array); |
| 1152 | 1166 |
| 1153 // Variable length data follows here. | 1167 // Variable length data follows here. |
| 1154 int8_t data_[0]; | 1168 int8_t data_[0]; |
| 1169 |
| 1170 friend class HeapProfiler; |
| 1155 }; | 1171 }; |
| 1156 | 1172 |
| 1157 | 1173 |
| 1158 class RawUint8Array: public RawByteArray { | 1174 class RawUint8Array: public RawByteArray { |
| 1159 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8Array); | 1175 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8Array); |
| 1160 | 1176 |
| 1161 // Variable length data follows here. | 1177 // Variable length data follows here. |
| 1162 uint8_t data_[0]; | 1178 uint8_t data_[0]; |
| 1179 |
| 1180 friend class HeapProfiler; |
| 1163 }; | 1181 }; |
| 1164 | 1182 |
| 1165 | 1183 |
| 1166 class RawInt16Array: public RawByteArray { | 1184 class RawInt16Array: public RawByteArray { |
| 1167 RAW_HEAP_OBJECT_IMPLEMENTATION(Int16Array); | 1185 RAW_HEAP_OBJECT_IMPLEMENTATION(Int16Array); |
| 1168 | 1186 |
| 1169 // Variable length data follows here. | 1187 // Variable length data follows here. |
| 1170 int16_t data_[0]; | 1188 int16_t data_[0]; |
| 1189 |
| 1190 friend class HeapProfiler; |
| 1171 }; | 1191 }; |
| 1172 | 1192 |
| 1173 | 1193 |
| 1174 class RawUint16Array: public RawByteArray { | 1194 class RawUint16Array: public RawByteArray { |
| 1175 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint16Array); | 1195 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint16Array); |
| 1176 | 1196 |
| 1177 // Variable length data follows here. | 1197 // Variable length data follows here. |
| 1178 uint16_t data_[0]; | 1198 uint16_t data_[0]; |
| 1199 |
| 1200 friend class HeapProfiler; |
| 1179 }; | 1201 }; |
| 1180 | 1202 |
| 1181 | 1203 |
| 1182 class RawInt32Array: public RawByteArray { | 1204 class RawInt32Array: public RawByteArray { |
| 1183 RAW_HEAP_OBJECT_IMPLEMENTATION(Int32Array); | 1205 RAW_HEAP_OBJECT_IMPLEMENTATION(Int32Array); |
| 1184 | 1206 |
| 1185 // Variable length data follows here. | 1207 // Variable length data follows here. |
| 1186 int32_t data_[0]; | 1208 int32_t data_[0]; |
| 1209 |
| 1210 friend class HeapProfiler; |
| 1187 }; | 1211 }; |
| 1188 | 1212 |
| 1189 | 1213 |
| 1190 class RawUint32Array: public RawByteArray { | 1214 class RawUint32Array: public RawByteArray { |
| 1191 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint32Array); | 1215 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint32Array); |
| 1192 | 1216 |
| 1193 // Variable length data follows here. | 1217 // Variable length data follows here. |
| 1194 uint32_t data_[0]; | 1218 uint32_t data_[0]; |
| 1219 |
| 1220 friend class HeapProfiler; |
| 1195 }; | 1221 }; |
| 1196 | 1222 |
| 1197 | 1223 |
| 1198 class RawInt64Array: public RawByteArray { | 1224 class RawInt64Array: public RawByteArray { |
| 1199 RAW_HEAP_OBJECT_IMPLEMENTATION(Int64Array); | 1225 RAW_HEAP_OBJECT_IMPLEMENTATION(Int64Array); |
| 1200 | 1226 |
| 1201 // Variable length data follows here. | 1227 // Variable length data follows here. |
| 1202 int64_t data_[0]; | 1228 int64_t data_[0]; |
| 1229 |
| 1230 friend class HeapProfiler; |
| 1203 }; | 1231 }; |
| 1204 | 1232 |
| 1205 | 1233 |
| 1206 class RawUint64Array: public RawByteArray { | 1234 class RawUint64Array: public RawByteArray { |
| 1207 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint64Array); | 1235 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint64Array); |
| 1208 | 1236 |
| 1209 // Variable length data follows here. | 1237 // Variable length data follows here. |
| 1210 uint64_t data_[0]; | 1238 uint64_t data_[0]; |
| 1239 |
| 1240 friend class HeapProfiler; |
| 1211 }; | 1241 }; |
| 1212 | 1242 |
| 1213 | 1243 |
| 1214 class RawFloat32Array: public RawByteArray { | 1244 class RawFloat32Array: public RawByteArray { |
| 1215 RAW_HEAP_OBJECT_IMPLEMENTATION(Float32Array); | 1245 RAW_HEAP_OBJECT_IMPLEMENTATION(Float32Array); |
| 1216 | 1246 |
| 1217 // Variable length data follows here. | 1247 // Variable length data follows here. |
| 1218 float data_[0]; | 1248 float data_[0]; |
| 1249 |
| 1250 friend class HeapProfiler; |
| 1219 }; | 1251 }; |
| 1220 | 1252 |
| 1221 | 1253 |
| 1222 class RawFloat64Array: public RawByteArray { | 1254 class RawFloat64Array: public RawByteArray { |
| 1223 RAW_HEAP_OBJECT_IMPLEMENTATION(Float64Array); | 1255 RAW_HEAP_OBJECT_IMPLEMENTATION(Float64Array); |
| 1224 | 1256 |
| 1225 // Variable length data follows here. | 1257 // Variable length data follows here. |
| 1226 double data_[0]; | 1258 double data_[0]; |
| 1259 |
| 1260 friend class HeapProfiler; |
| 1227 }; | 1261 }; |
| 1228 | 1262 |
| 1229 | 1263 |
| 1230 template<typename T> | 1264 template<typename T> |
| 1231 class ExternalByteArrayData { | 1265 class ExternalByteArrayData { |
| 1232 public: | 1266 public: |
| 1233 ExternalByteArrayData(T* data, | 1267 ExternalByteArrayData(T* data, |
| 1234 void* peer, | 1268 void* peer, |
| 1235 Dart_PeerFinalizer callback) : | 1269 Dart_PeerFinalizer callback) : |
| 1236 data_(data), peer_(peer), callback_(callback) { | 1270 data_(data), peer_(peer), callback_(callback) { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 kExternalUint64Array == kByteArray + 18 && | 1528 kExternalUint64Array == kByteArray + 18 && |
| 1495 kExternalFloat32Array == kByteArray + 19 && | 1529 kExternalFloat32Array == kByteArray + 19 && |
| 1496 kExternalFloat64Array == kByteArray + 20 && | 1530 kExternalFloat64Array == kByteArray + 20 && |
| 1497 kClosure == kByteArray + 21); | 1531 kClosure == kByteArray + 21); |
| 1498 return (index >= kByteArray && index <= kClosure); | 1532 return (index >= kByteArray && index <= kClosure); |
| 1499 } | 1533 } |
| 1500 | 1534 |
| 1501 } // namespace dart | 1535 } // namespace dart |
| 1502 | 1536 |
| 1503 #endif // VM_RAW_OBJECT_H_ | 1537 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |