Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: src/objects-debug.cc

Issue 218993005: Tighten object verification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 23 matching lines...) Expand all
34 #include "objects-visiting.h" 34 #include "objects-visiting.h"
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 #ifdef VERIFY_HEAP 39 #ifdef VERIFY_HEAP
40 40
41 void MaybeObject::Verify() { 41 void MaybeObject::Verify() {
42 Object* this_as_object; 42 Object* this_as_object;
43 if (ToObject(&this_as_object)) { 43 if (ToObject(&this_as_object)) {
44 if (this_as_object->IsSmi()) { 44 this_as_object->ObjectVerify();
45 Smi::cast(this_as_object)->SmiVerify();
46 } else {
47 HeapObject::cast(this_as_object)->HeapObjectVerify();
48 }
49 } else { 45 } else {
50 Failure::cast(this)->FailureVerify(); 46 Failure::cast(this)->FailureVerify();
51 } 47 }
52 } 48 }
53 49
54 50
51 void Object::ObjectVerify() {
52 if (IsSmi()) {
53 Smi::cast(this)->SmiVerify();
54 } else {
55 HeapObject::cast(this)->HeapObjectVerify();
56 }
57 }
58
59
55 void Object::VerifyPointer(Object* p) { 60 void Object::VerifyPointer(Object* p) {
56 if (p->IsHeapObject()) { 61 if (p->IsHeapObject()) {
57 HeapObject::VerifyHeapPointer(p); 62 HeapObject::VerifyHeapPointer(p);
58 } else { 63 } else {
59 CHECK(p->IsSmi()); 64 CHECK(p->IsSmi());
60 } 65 }
61 } 66 }
62 67
63 68
64 void Smi::SmiVerify() { 69 void Smi::SmiVerify() {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 378
374 379
375 void AliasedArgumentsEntry::AliasedArgumentsEntryVerify() { 380 void AliasedArgumentsEntry::AliasedArgumentsEntryVerify() {
376 VerifySmiField(kAliasedContextSlot); 381 VerifySmiField(kAliasedContextSlot);
377 } 382 }
378 383
379 384
380 void FixedArray::FixedArrayVerify() { 385 void FixedArray::FixedArrayVerify() {
381 for (int i = 0; i < length(); i++) { 386 for (int i = 0; i < length(); i++) {
382 Object* e = get(i); 387 Object* e = get(i);
383 if (e->IsHeapObject()) { 388 VerifyPointer(e);
384 VerifyHeapPointer(e);
385 } else {
386 e->Verify();
387 }
388 } 389 }
389 } 390 }
390 391
391 392
392 void FixedDoubleArray::FixedDoubleArrayVerify() { 393 void FixedDoubleArray::FixedDoubleArrayVerify() {
393 for (int i = 0; i < length(); i++) { 394 for (int i = 0; i < length(); i++) {
394 if (!is_the_hole(i)) { 395 if (!is_the_hole(i)) {
395 double value = get_scalar(i); 396 double value = get_scalar(i);
396 CHECK(!std::isnan(value) || 397 CHECK(!std::isnan(value) ||
397 (BitCast<uint64_t>(value) == 398 (BitCast<uint64_t>(value) ==
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 void PropertyCell::PropertyCellVerify() { 620 void PropertyCell::PropertyCellVerify() {
620 CHECK(IsPropertyCell()); 621 CHECK(IsPropertyCell());
621 VerifyObjectField(kValueOffset); 622 VerifyObjectField(kValueOffset);
622 VerifyObjectField(kTypeOffset); 623 VerifyObjectField(kTypeOffset);
623 } 624 }
624 625
625 626
626 void Code::CodeVerify() { 627 void Code::CodeVerify() {
627 CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), 628 CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()),
628 kCodeAlignment)); 629 kCodeAlignment));
629 relocation_info()->Verify(); 630 relocation_info()->ObjectVerify();
630 Address last_gc_pc = NULL; 631 Address last_gc_pc = NULL;
631 for (RelocIterator it(this); !it.done(); it.next()) { 632 for (RelocIterator it(this); !it.done(); it.next()) {
632 it.rinfo()->Verify(); 633 it.rinfo()->Verify();
633 // Ensure that GC will not iterate twice over the same pointer. 634 // Ensure that GC will not iterate twice over the same pointer.
634 if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { 635 if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) {
635 CHECK(it.rinfo()->pc() != last_gc_pc); 636 CHECK(it.rinfo()->pc() != last_gc_pc);
636 last_gc_pc = it.rinfo()->pc(); 637 last_gc_pc = it.rinfo()->pc();
637 } 638 }
638 } 639 }
639 } 640 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } 805 }
805 806
806 807
807 void Foreign::ForeignVerify() { 808 void Foreign::ForeignVerify() {
808 CHECK(IsForeign()); 809 CHECK(IsForeign());
809 } 810 }
810 811
811 812
812 void Box::BoxVerify() { 813 void Box::BoxVerify() {
813 CHECK(IsBox()); 814 CHECK(IsBox());
814 value()->Verify(); 815 value()->ObjectVerify();
815 } 816 }
816 817
817 818
818 void AccessorInfo::AccessorInfoVerify() { 819 void AccessorInfo::AccessorInfoVerify() {
819 VerifyPointer(name()); 820 VerifyPointer(name());
820 VerifyPointer(flag()); 821 VerifyPointer(flag());
821 VerifyPointer(expected_receiver_type()); 822 VerifyPointer(expected_receiver_type());
822 } 823 }
823 824
824 825
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 line_offset()->SmiVerify(); 941 line_offset()->SmiVerify();
941 column_offset()->SmiVerify(); 942 column_offset()->SmiVerify();
942 VerifyPointer(wrapper()); 943 VerifyPointer(wrapper());
943 type()->SmiVerify(); 944 type()->SmiVerify();
944 VerifyPointer(line_ends()); 945 VerifyPointer(line_ends());
945 VerifyPointer(id()); 946 VerifyPointer(id());
946 } 947 }
947 948
948 949
949 void JSFunctionResultCache::JSFunctionResultCacheVerify() { 950 void JSFunctionResultCache::JSFunctionResultCacheVerify() {
950 JSFunction::cast(get(kFactoryIndex))->Verify(); 951 JSFunction::cast(get(kFactoryIndex))->ObjectVerify();
951 952
952 int size = Smi::cast(get(kCacheSizeIndex))->value(); 953 int size = Smi::cast(get(kCacheSizeIndex))->value();
953 CHECK(kEntriesIndex <= size); 954 CHECK(kEntriesIndex <= size);
954 CHECK(size <= length()); 955 CHECK(size <= length());
955 CHECK_EQ(0, size % kEntrySize); 956 CHECK_EQ(0, size % kEntrySize);
956 957
957 int finger = Smi::cast(get(kFingerIndex))->value(); 958 int finger = Smi::cast(get(kFingerIndex))->value();
958 CHECK(kEntriesIndex <= finger); 959 CHECK(kEntriesIndex <= finger);
959 CHECK((finger < size) || (finger == kEntriesIndex && finger == size)); 960 CHECK((finger < size) || (finger == kEntriesIndex && finger == size));
960 CHECK_EQ(0, finger % kEntrySize); 961 CHECK_EQ(0, finger % kEntrySize);
961 962
962 if (FLAG_enable_slow_asserts) { 963 if (FLAG_enable_slow_asserts) {
963 for (int i = kEntriesIndex; i < size; i++) { 964 for (int i = kEntriesIndex; i < size; i++) {
964 CHECK(!get(i)->IsTheHole()); 965 CHECK(!get(i)->IsTheHole());
965 get(i)->Verify(); 966 get(i)->ObjectVerify();
966 } 967 }
967 for (int i = size; i < length(); i++) { 968 for (int i = size; i < length(); i++) {
968 CHECK(get(i)->IsTheHole()); 969 CHECK(get(i)->IsTheHole());
969 get(i)->Verify(); 970 get(i)->ObjectVerify();
970 } 971 }
971 } 972 }
972 } 973 }
973 974
974 975
975 void NormalizedMapCache::NormalizedMapCacheVerify() { 976 void NormalizedMapCache::NormalizedMapCacheVerify() {
976 FixedArray::cast(this)->Verify(); 977 FixedArray::cast(this)->FixedArrayVerify();
977 if (FLAG_enable_slow_asserts) { 978 if (FLAG_enable_slow_asserts) {
978 for (int i = 0; i < length(); i++) { 979 for (int i = 0; i < length(); i++) {
979 Object* e = get(i); 980 Object* e = get(i);
980 if (e->IsMap()) { 981 if (e->IsMap()) {
981 Map::cast(e)->SharedMapVerify(); 982 Map::cast(e)->SharedMapVerify();
982 } else { 983 } else {
983 CHECK(e->IsUndefined()); 984 CHECK(e->IsUndefined());
984 } 985 }
985 } 986 }
986 } 987 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 for (int i = 0; i < number_of_transitions(); ++i) { 1159 for (int i = 0; i < number_of_transitions(); ++i) {
1159 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false; 1160 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false;
1160 } 1161 }
1161 return true; 1162 return true;
1162 } 1163 }
1163 1164
1164 1165
1165 #endif // DEBUG 1166 #endif // DEBUG
1166 1167
1167 } } // namespace v8::internal 1168 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698