Chromium Code Reviews| Index: runtime/vm/raw_object.cc |
| =================================================================== |
| --- runtime/vm/raw_object.cc (revision 42249) |
| +++ runtime/vm/raw_object.cc (working copy) |
| @@ -14,6 +14,9 @@ |
| namespace dart { |
| +#if defined(DEBUG) |
| +DEFINE_FLAG(bool, validate_overwrite, true, "Verify overwritten fields."); |
| +#endif // DEBUG |
| const intptr_t RawPcDescriptors::kFullRecSize = |
| sizeof(RawPcDescriptors::PcDescriptorRec); |
| @@ -35,6 +38,10 @@ |
| if (!IsHeapObject()) { |
| return; |
| } |
| + // Slightly more readable than a segfault. |
| + if (this == reinterpret_cast<RawObject*>(kHeapObjectTag)) { |
| + FATAL("RAW_NULL encountered"); |
| + } |
| // Validate that the tags_ field is sensible. |
| uword tags = ptr()->tags_; |
| intptr_t reserved = ReservedBits::decode(tags); |
| @@ -45,6 +52,10 @@ |
| if (!isolate->class_table()->IsValidIndex(class_id)) { |
| FATAL1("Invalid class id encountered %" Pd "\n", class_id); |
| } |
| + if (class_id == kNullCid && isolate->class_table()->At(class_id) == NULL) { |
|
Ivan Posva
2015/01/02 17:09:39
()
koda
2015/01/02 17:30:53
Done.
|
| + // Null class not yet initialized; skip. |
| + return; |
| + } |
| intptr_t size = SizeTag::decode(tags); |
| if (size != 0 && size != SizeFromClass()) { |
| FATAL1("Inconsistent class size encountered %" Pd "\n", size); |
| @@ -200,6 +211,22 @@ |
| } |
| +#if defined(DEBUG) |
| +void RawObject::ValidateOverwrittenPointer(RawObject* raw) { |
| + if (FLAG_validate_overwrite) { |
| + raw->Validate(Isolate::Current()); |
| + } |
| +} |
| + |
| + |
| +void RawObject::ValidateOverwrittenSmi(RawSmi* raw) { |
| + if (FLAG_validate_overwrite && raw->IsHeapObject() && raw != Object::null()) { |
| + FATAL1("Expected smi/null, found: %" Px "\n", reinterpret_cast<uword>(raw)); |
| + } |
| +} |
| +#endif // DEBUG |
| + |
| + |
| intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { |
| intptr_t size = 0; |
| NoHandleScope no_handles(visitor->isolate()); |