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