| 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/become.h" | 7 #include "vm/become.h" |
| 8 #include "vm/class_table.h" | 8 #include "vm/class_table.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/freelist.h" | 10 #include "vm/freelist.h" |
| 11 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/visitor.h" | 13 #include "vm/visitor.h" |
| 14 | 14 |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 #if defined(DEBUG) | |
| 19 DEFINE_FLAG(bool, validate_overwrite, true, "Verify overwritten fields."); | |
| 20 #endif // DEBUG | |
| 21 | |
| 22 | |
| 23 void RawObject::Validate(Isolate* isolate) const { | 18 void RawObject::Validate(Isolate* isolate) const { |
| 24 if (Object::void_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) { | 19 if (Object::void_class_ == reinterpret_cast<RawClass*>(kHeapObjectTag)) { |
| 25 // Validation relies on properly initialized class classes. Skip if the | 20 // Validation relies on properly initialized class classes. Skip if the |
| 26 // VM is still being initialized. | 21 // VM is still being initialized. |
| 27 return; | 22 return; |
| 28 } | 23 } |
| 29 // All Smi values are valid. | 24 // All Smi values are valid. |
| 30 if (!IsHeapObject()) { | 25 if (!IsHeapObject()) { |
| 31 return; | 26 return; |
| 32 } | 27 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 214 } |
| 220 if ((instance_size != tags_size) && (tags_size != 0)) { | 215 if ((instance_size != tags_size) && (tags_size != 0)) { |
| 221 FATAL3("Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n", | 216 FATAL3("Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n", |
| 222 instance_size, tags_size, tags); | 217 instance_size, tags_size, tags); |
| 223 } | 218 } |
| 224 #endif // DEBUG | 219 #endif // DEBUG |
| 225 return instance_size; | 220 return instance_size; |
| 226 } | 221 } |
| 227 | 222 |
| 228 | 223 |
| 229 #if defined(DEBUG) | |
| 230 void RawObject::ValidateOverwrittenPointer(RawObject* raw) { | |
| 231 if (FLAG_validate_overwrite) { | |
| 232 raw->Validate(Isolate::Current()); | |
| 233 } | |
| 234 } | |
| 235 | |
| 236 | |
| 237 void RawObject::ValidateOverwrittenSmi(RawSmi* raw) { | |
| 238 if (FLAG_validate_overwrite && raw->IsHeapObject() && raw != Object::null()) { | |
| 239 FATAL1("Expected smi/null, found: %" Px "\n", reinterpret_cast<uword>(raw)); | |
| 240 } | |
| 241 } | |
| 242 #endif // DEBUG | |
| 243 | |
| 244 | |
| 245 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { | 224 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { |
| 246 intptr_t size = 0; | 225 intptr_t size = 0; |
| 247 | 226 |
| 248 // Only reasonable to be called on heap objects. | 227 // Only reasonable to be called on heap objects. |
| 249 ASSERT(IsHeapObject()); | 228 ASSERT(IsHeapObject()); |
| 250 | 229 |
| 251 // Read the necessary data out of the class before visting the class itself. | 230 // Read the necessary data out of the class before visting the class itself. |
| 252 intptr_t class_id = GetClassId(); | 231 intptr_t class_id = GetClassId(); |
| 253 | 232 |
| 254 if (class_id < kNumPredefinedCids) { | 233 if (class_id < kNumPredefinedCids) { |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 intptr_t RawUserTag::VisitUserTagPointers( | 954 intptr_t RawUserTag::VisitUserTagPointers( |
| 976 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 955 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
| 977 // Make sure that we got here with the tagged pointer as this. | 956 // Make sure that we got here with the tagged pointer as this. |
| 978 ASSERT(raw_obj->IsHeapObject()); | 957 ASSERT(raw_obj->IsHeapObject()); |
| 979 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 958 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 980 return UserTag::InstanceSize(); | 959 return UserTag::InstanceSize(); |
| 981 } | 960 } |
| 982 | 961 |
| 983 | 962 |
| 984 } // namespace dart | 963 } // namespace dart |
| OLD | NEW |