| 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 #include "vm/raw_object.h" | 5 #include "vm/raw_object.h" |
| 6 | 6 |
| 7 #include "vm/class_table.h" | 7 #include "vm/class_table.h" |
| 8 #include "vm/freelist.h" | 8 #include "vm/freelist.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 instance_size = Float32Array::InstanceSize(byte_array_length); | 196 instance_size = Float32Array::InstanceSize(byte_array_length); |
| 197 break; | 197 break; |
| 198 } | 198 } |
| 199 case kFloat64ArrayCid: { | 199 case kFloat64ArrayCid: { |
| 200 const RawFloat64Array* raw_byte_array = | 200 const RawFloat64Array* raw_byte_array = |
| 201 reinterpret_cast<const RawFloat64Array*>(this); | 201 reinterpret_cast<const RawFloat64Array*>(this); |
| 202 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); | 202 intptr_t byte_array_length = Smi::Value(raw_byte_array->ptr()->length_); |
| 203 instance_size = Float64Array::InstanceSize(byte_array_length); | 203 instance_size = Float64Array::InstanceSize(byte_array_length); |
| 204 break; | 204 break; |
| 205 } | 205 } |
| 206 #define SIZE_FROM_CLASS(clazz) \ |
| 207 case kTypedData##clazz##Cid: |
| 208 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) { |
| 209 const RawTypedData* raw_obj = |
| 210 reinterpret_cast<const RawTypedData*>(this); |
| 211 intptr_t cid = raw_obj->GetClassId(); |
| 212 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); |
| 213 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); |
| 214 instance_size = TypedData::InstanceSize(lengthInBytes); |
| 215 break; |
| 216 } |
| 217 #undef SIZE_FROM_CLASS |
| 206 case kTypeArgumentsCid: { | 218 case kTypeArgumentsCid: { |
| 207 const RawTypeArguments* raw_array = | 219 const RawTypeArguments* raw_array = |
| 208 reinterpret_cast<const RawTypeArguments*>(this); | 220 reinterpret_cast<const RawTypeArguments*>(this); |
| 209 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 221 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 210 instance_size = TypeArguments::InstanceSize(array_length); | 222 instance_size = TypeArguments::InstanceSize(array_length); |
| 211 break; | 223 break; |
| 212 } | 224 } |
| 213 case kPcDescriptorsCid: { | 225 case kPcDescriptorsCid: { |
| 214 const RawPcDescriptors* raw_descriptors = | 226 const RawPcDescriptors* raw_descriptors = |
| 215 reinterpret_cast<const RawPcDescriptors*>(this); | 227 reinterpret_cast<const RawPcDescriptors*>(this); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 if (class_id < kNumPredefinedCids) { | 296 if (class_id < kNumPredefinedCids) { |
| 285 switch (class_id) { | 297 switch (class_id) { |
| 286 #define RAW_VISITPOINTERS(clazz) \ | 298 #define RAW_VISITPOINTERS(clazz) \ |
| 287 case clazz::kClassId: { \ | 299 case clazz::kClassId: { \ |
| 288 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ | 300 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ |
| 289 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ | 301 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ |
| 290 break; \ | 302 break; \ |
| 291 } | 303 } |
| 292 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) | 304 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) |
| 293 #undef RAW_VISITPOINTERS | 305 #undef RAW_VISITPOINTERS |
| 306 #define RAW_VISITPOINTERS(clazz) \ |
| 307 case kTypedData##clazz##Cid: |
| 308 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) { |
| 309 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(this); |
| 310 size = RawTypedData::VisitTypedDataPointers(raw_obj, visitor); |
| 311 break; |
| 312 } |
| 313 #undef RAW_VISITPOINTERS |
| 314 #define RAW_VISITPOINTERS(clazz) \ |
| 315 case kExternalTypedData##clazz##Cid: |
| 316 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) { |
| 317 RawExternalTypedData* raw_obj = |
| 318 reinterpret_cast<RawExternalTypedData*>(this); |
| 319 size = RawExternalTypedData::VisitExternalTypedDataPointers(raw_obj, |
| 320 visitor); |
| 321 break; |
| 322 } |
| 323 #undef RAW_VISITPOINTERS |
| 294 case kFreeListElement: { | 324 case kFreeListElement: { |
| 295 ASSERT(FreeBit::decode(ptr()->tags_)); | 325 ASSERT(FreeBit::decode(ptr()->tags_)); |
| 296 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); | 326 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); |
| 297 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); | 327 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); |
| 298 size = element->Size(); | 328 size = element->Size(); |
| 299 break; | 329 break; |
| 300 } | 330 } |
| 301 default: | 331 default: |
| 302 OS::Print("Class Id: %"Pd"\n", class_id); | 332 OS::Print("Class Id: %"Pd"\n", class_id); |
| 303 UNREACHABLE(); | 333 UNREACHABLE(); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 | 1022 |
| 993 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers( | 1023 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers( |
| 994 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) { | 1024 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 995 // Make sure that we got here with the tagged pointer as this. | 1025 // Make sure that we got here with the tagged pointer as this. |
| 996 ASSERT(raw_obj->IsHeapObject()); | 1026 ASSERT(raw_obj->IsHeapObject()); |
| 997 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1027 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 998 return ExternalUint64Array::InstanceSize(); | 1028 return ExternalUint64Array::InstanceSize(); |
| 999 } | 1029 } |
| 1000 | 1030 |
| 1001 | 1031 |
| 1002 intptr_t | 1032 intptr_t RawExternalFloat32x4Array::VisitExternalFloat32x4ArrayPointers( |
| 1003 RawExternalFloat32x4Array::VisitExternalFloat32x4ArrayPointers( | |
| 1004 RawExternalFloat32x4Array* raw_obj, ObjectPointerVisitor* visitor) { | 1033 RawExternalFloat32x4Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 1005 // Make sure that we got here with the tagged pointer as this. | 1034 // Make sure that we got here with the tagged pointer as this. |
| 1006 ASSERT(raw_obj->IsHeapObject()); | 1035 ASSERT(raw_obj->IsHeapObject()); |
| 1007 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1036 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1008 return ExternalFloat32x4Array::InstanceSize(); | 1037 return ExternalFloat32x4Array::InstanceSize(); |
| 1009 } | 1038 } |
| 1010 | 1039 |
| 1011 | 1040 |
| 1012 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers( | 1041 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers( |
| 1013 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) { | 1042 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 1014 // Make sure that we got here with the tagged pointer as this. | 1043 // Make sure that we got here with the tagged pointer as this. |
| 1015 ASSERT(raw_obj->IsHeapObject()); | 1044 ASSERT(raw_obj->IsHeapObject()); |
| 1016 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1045 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1017 return ExternalFloat32Array::InstanceSize(); | 1046 return ExternalFloat32Array::InstanceSize(); |
| 1018 } | 1047 } |
| 1019 | 1048 |
| 1020 | 1049 |
| 1021 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers( | 1050 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers( |
| 1022 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) { | 1051 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 1023 // Make sure that we got here with the tagged pointer as this. | 1052 // Make sure that we got here with the tagged pointer as this. |
| 1024 ASSERT(raw_obj->IsHeapObject()); | 1053 ASSERT(raw_obj->IsHeapObject()); |
| 1025 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1054 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1026 return ExternalFloat64Array::InstanceSize(); | 1055 return ExternalFloat64Array::InstanceSize(); |
| 1027 } | 1056 } |
| 1028 | 1057 |
| 1029 | 1058 |
| 1059 intptr_t RawTypedData::VisitTypedDataPointers( |
| 1060 RawTypedData* raw_obj, ObjectPointerVisitor* visitor) { |
| 1061 // Make sure that we got here with the tagged pointer as this. |
| 1062 ASSERT(raw_obj->IsHeapObject()); |
| 1063 intptr_t cid = raw_obj->GetClassId(); |
| 1064 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); |
| 1065 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); |
| 1066 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1067 return TypedData::InstanceSize(lengthInBytes); |
| 1068 } |
| 1069 |
| 1070 |
| 1071 intptr_t RawExternalTypedData::VisitExternalTypedDataPointers( |
| 1072 RawExternalTypedData* raw_obj, ObjectPointerVisitor* visitor) { |
| 1073 // Make sure that we got here with the tagged pointer as this. |
| 1074 ASSERT(raw_obj->IsHeapObject()); |
| 1075 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1076 return ExternalTypedData::InstanceSize(); |
| 1077 } |
| 1078 |
| 1079 |
| 1030 intptr_t RawDartFunction::VisitDartFunctionPointers( | 1080 intptr_t RawDartFunction::VisitDartFunctionPointers( |
| 1031 RawDartFunction* raw_obj, ObjectPointerVisitor* visitor) { | 1081 RawDartFunction* raw_obj, ObjectPointerVisitor* visitor) { |
| 1032 // Function (defined in core library) is an abstract class. | 1082 // Function (defined in core library) is an abstract class. |
| 1033 UNREACHABLE(); | 1083 UNREACHABLE(); |
| 1034 return 0; | 1084 return 0; |
| 1035 } | 1085 } |
| 1036 | 1086 |
| 1037 | 1087 |
| 1038 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, | 1088 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, |
| 1039 ObjectPointerVisitor* visitor) { | 1089 ObjectPointerVisitor* visitor) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1056 | 1106 |
| 1057 intptr_t RawWeakProperty::VisitWeakPropertyPointers( | 1107 intptr_t RawWeakProperty::VisitWeakPropertyPointers( |
| 1058 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { | 1108 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { |
| 1059 // Make sure that we got here with the tagged pointer as this. | 1109 // Make sure that we got here with the tagged pointer as this. |
| 1060 ASSERT(raw_obj->IsHeapObject()); | 1110 ASSERT(raw_obj->IsHeapObject()); |
| 1061 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1111 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1062 return WeakProperty::InstanceSize(); | 1112 return WeakProperty::InstanceSize(); |
| 1063 } | 1113 } |
| 1064 | 1114 |
| 1065 } // namespace dart | 1115 } // namespace dart |
| OLD | NEW |