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 #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 | |
| 218 #define SIZE_FROM_CLASS(clazz) \ | |
| 219 case kExternalTypedData##clazz##Cid: | |
|
Ivan Posva
2013/03/07 08:53:31
This code should never be reached, as the size of
siva
2013/03/07 21:47:43
True, I removed it.
On 2013/03/07 08:53:31, Ivan
| |
| 220 CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) { | |
| 221 instance_size = ExternalTypedData::InstanceSize(); | |
| 222 break; | |
| 223 } | |
| 224 #undef SIZE_FROM_CLASS | |
| 206 case kTypeArgumentsCid: { | 225 case kTypeArgumentsCid: { |
| 207 const RawTypeArguments* raw_array = | 226 const RawTypeArguments* raw_array = |
| 208 reinterpret_cast<const RawTypeArguments*>(this); | 227 reinterpret_cast<const RawTypeArguments*>(this); |
| 209 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); | 228 intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
| 210 instance_size = TypeArguments::InstanceSize(array_length); | 229 instance_size = TypeArguments::InstanceSize(array_length); |
| 211 break; | 230 break; |
| 212 } | 231 } |
| 213 case kPcDescriptorsCid: { | 232 case kPcDescriptorsCid: { |
| 214 const RawPcDescriptors* raw_descriptors = | 233 const RawPcDescriptors* raw_descriptors = |
| 215 reinterpret_cast<const RawPcDescriptors*>(this); | 234 reinterpret_cast<const RawPcDescriptors*>(this); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 if (class_id < kNumPredefinedCids) { | 303 if (class_id < kNumPredefinedCids) { |
| 285 switch (class_id) { | 304 switch (class_id) { |
| 286 #define RAW_VISITPOINTERS(clazz) \ | 305 #define RAW_VISITPOINTERS(clazz) \ |
| 287 case clazz::kClassId: { \ | 306 case clazz::kClassId: { \ |
| 288 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ | 307 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ |
| 289 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ | 308 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ |
| 290 break; \ | 309 break; \ |
| 291 } | 310 } |
| 292 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) | 311 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) |
| 293 #undef RAW_VISITPOINTERS | 312 #undef RAW_VISITPOINTERS |
| 313 #define RAW_VISITPOINTERS(clazz) \ | |
| 314 case kTypedData##clazz##Cid: | |
| 315 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) { | |
| 316 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(this); | |
| 317 size = RawTypedData::VisitTypedDataPointers(raw_obj, visitor); | |
| 318 break; | |
| 319 } | |
| 320 #undef RAW_VISITPOINTERS | |
| 321 #define RAW_VISITPOINTERS(clazz) \ | |
| 322 case kExternalTypedData##clazz##Cid: | |
| 323 CLASS_LIST_TYPED_DATA(RAW_VISITPOINTERS) { | |
| 324 RawExternalTypedData* raw_obj = | |
| 325 reinterpret_cast<RawExternalTypedData*>(this); | |
| 326 size = RawExternalTypedData::VisitExternalTypedDataPointers(raw_obj, | |
| 327 visitor); | |
| 328 break; | |
| 329 } | |
| 330 #undef RAW_VISITPOINTERS | |
| 294 case kFreeListElement: { | 331 case kFreeListElement: { |
| 295 ASSERT(FreeBit::decode(ptr()->tags_)); | 332 ASSERT(FreeBit::decode(ptr()->tags_)); |
| 296 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); | 333 uword addr = RawObject::ToAddr(const_cast<RawObject*>(this)); |
| 297 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); | 334 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr); |
| 298 size = element->Size(); | 335 size = element->Size(); |
| 299 break; | 336 break; |
| 300 } | 337 } |
| 301 default: | 338 default: |
| 302 OS::Print("Class Id: %"Pd"\n", class_id); | 339 OS::Print("Class Id: %"Pd"\n", class_id); |
| 303 UNREACHABLE(); | 340 UNREACHABLE(); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 | 1029 |
| 993 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers( | 1030 intptr_t RawExternalUint64Array::VisitExternalUint64ArrayPointers( |
| 994 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) { | 1031 RawExternalUint64Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 995 // Make sure that we got here with the tagged pointer as this. | 1032 // Make sure that we got here with the tagged pointer as this. |
| 996 ASSERT(raw_obj->IsHeapObject()); | 1033 ASSERT(raw_obj->IsHeapObject()); |
| 997 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1034 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 998 return ExternalUint64Array::InstanceSize(); | 1035 return ExternalUint64Array::InstanceSize(); |
| 999 } | 1036 } |
| 1000 | 1037 |
| 1001 | 1038 |
| 1002 intptr_t | 1039 intptr_t RawExternalFloat32x4Array::VisitExternalFloat32x4ArrayPointers( |
| 1003 RawExternalFloat32x4Array::VisitExternalFloat32x4ArrayPointers( | |
| 1004 RawExternalFloat32x4Array* raw_obj, ObjectPointerVisitor* visitor) { | 1040 RawExternalFloat32x4Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 1005 // Make sure that we got here with the tagged pointer as this. | 1041 // Make sure that we got here with the tagged pointer as this. |
| 1006 ASSERT(raw_obj->IsHeapObject()); | 1042 ASSERT(raw_obj->IsHeapObject()); |
| 1007 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1043 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1008 return ExternalFloat32x4Array::InstanceSize(); | 1044 return ExternalFloat32x4Array::InstanceSize(); |
| 1009 } | 1045 } |
| 1010 | 1046 |
| 1011 | 1047 |
| 1012 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers( | 1048 intptr_t RawExternalFloat32Array::VisitExternalFloat32ArrayPointers( |
| 1013 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) { | 1049 RawExternalFloat32Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 1014 // Make sure that we got here with the tagged pointer as this. | 1050 // Make sure that we got here with the tagged pointer as this. |
| 1015 ASSERT(raw_obj->IsHeapObject()); | 1051 ASSERT(raw_obj->IsHeapObject()); |
| 1016 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1052 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1017 return ExternalFloat32Array::InstanceSize(); | 1053 return ExternalFloat32Array::InstanceSize(); |
| 1018 } | 1054 } |
| 1019 | 1055 |
| 1020 | 1056 |
| 1021 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers( | 1057 intptr_t RawExternalFloat64Array::VisitExternalFloat64ArrayPointers( |
| 1022 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) { | 1058 RawExternalFloat64Array* raw_obj, ObjectPointerVisitor* visitor) { |
| 1023 // Make sure that we got here with the tagged pointer as this. | 1059 // Make sure that we got here with the tagged pointer as this. |
| 1024 ASSERT(raw_obj->IsHeapObject()); | 1060 ASSERT(raw_obj->IsHeapObject()); |
| 1025 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1061 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1026 return ExternalFloat64Array::InstanceSize(); | 1062 return ExternalFloat64Array::InstanceSize(); |
| 1027 } | 1063 } |
| 1028 | 1064 |
| 1029 | 1065 |
| 1066 intptr_t RawTypedData::VisitTypedDataPointers( | |
| 1067 RawTypedData* raw_obj, ObjectPointerVisitor* visitor) { | |
| 1068 // Make sure that we got here with the tagged pointer as this. | |
| 1069 ASSERT(raw_obj->IsHeapObject()); | |
| 1070 intptr_t cid = raw_obj->GetClassId(); | |
| 1071 intptr_t array_len = Smi::Value(raw_obj->ptr()->length_); | |
| 1072 intptr_t lengthInBytes = array_len * TypedData::ElementSizeInBytes(cid); | |
| 1073 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 1074 return TypedData::InstanceSize(lengthInBytes); | |
| 1075 } | |
| 1076 | |
| 1077 | |
| 1078 intptr_t RawExternalTypedData::VisitExternalTypedDataPointers( | |
| 1079 RawExternalTypedData* raw_obj, ObjectPointerVisitor* visitor) { | |
| 1080 // Make sure that we got here with the tagged pointer as this. | |
| 1081 ASSERT(raw_obj->IsHeapObject()); | |
| 1082 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | |
| 1083 return ExternalTypedData::InstanceSize(); | |
| 1084 } | |
| 1085 | |
| 1086 | |
| 1030 intptr_t RawDartFunction::VisitDartFunctionPointers( | 1087 intptr_t RawDartFunction::VisitDartFunctionPointers( |
| 1031 RawDartFunction* raw_obj, ObjectPointerVisitor* visitor) { | 1088 RawDartFunction* raw_obj, ObjectPointerVisitor* visitor) { |
| 1032 // Function (defined in core library) is an abstract class. | 1089 // Function (defined in core library) is an abstract class. |
| 1033 UNREACHABLE(); | 1090 UNREACHABLE(); |
| 1034 return 0; | 1091 return 0; |
| 1035 } | 1092 } |
| 1036 | 1093 |
| 1037 | 1094 |
| 1038 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, | 1095 intptr_t RawStacktrace::VisitStacktracePointers(RawStacktrace* raw_obj, |
| 1039 ObjectPointerVisitor* visitor) { | 1096 ObjectPointerVisitor* visitor) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1056 | 1113 |
| 1057 intptr_t RawWeakProperty::VisitWeakPropertyPointers( | 1114 intptr_t RawWeakProperty::VisitWeakPropertyPointers( |
| 1058 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { | 1115 RawWeakProperty* raw_obj, ObjectPointerVisitor* visitor) { |
| 1059 // Make sure that we got here with the tagged pointer as this. | 1116 // Make sure that we got here with the tagged pointer as this. |
| 1060 ASSERT(raw_obj->IsHeapObject()); | 1117 ASSERT(raw_obj->IsHeapObject()); |
| 1061 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 1118 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 1062 return WeakProperty::InstanceSize(); | 1119 return WeakProperty::InstanceSize(); |
| 1063 } | 1120 } |
| 1064 | 1121 |
| 1065 } // namespace dart | 1122 } // namespace dart |
| OLD | NEW |