Index: src/objects-debug.cc |
diff --git a/src/objects-debug.cc b/src/objects-debug.cc |
index cd2ccf81c775187266357dc49c371b04ede4e431..3bfb74d6a494e8a1a60d9cba10fe461a5c95e22d 100644 |
--- a/src/objects-debug.cc |
+++ b/src/objects-debug.cc |
@@ -303,6 +303,8 @@ void Map::MapVerify() { |
instance_size() < HEAP->Capacity())); |
VerifyHeapPointer(prototype()); |
VerifyHeapPointer(instance_descriptors()); |
+ SLOW_ASSERT(instance_descriptors()->IsSortedNoDuplicates()); |
+ SLOW_ASSERT(instance_descriptors()->IsConsistentWithBackPointers(this)); |
} |
@@ -894,6 +896,61 @@ bool DescriptorArray::IsSortedNoDuplicates() { |
} |
+static bool CheckOneBackPointer(Map* current_map, Object* target) { |
+ return !target->IsMap() || Map::cast(target)->GetBackPointer() == current_map; |
+} |
+ |
+ |
+bool DescriptorArray::IsConsistentWithBackPointers(Map* current_map) { |
+ for (int i = 0; i < number_of_descriptors(); ++i) { |
+ switch (GetType(i)) { |
+ case MAP_TRANSITION: |
+ case CONSTANT_TRANSITION: |
+ if (!CheckOneBackPointer(current_map, GetValue(i))) { |
+ return false; |
+ } |
+ break; |
+ case ELEMENTS_TRANSITION: { |
+ Object* object = GetValue(i); |
+ if (!CheckOneBackPointer(current_map, object)) { |
+ return false; |
+ } |
+ if (object->IsFixedArray()) { |
+ FixedArray* array = FixedArray::cast(object); |
+ for (int i = 0; i < array->length(); ++i) { |
+ if (!CheckOneBackPointer(current_map, array->get(i))) { |
+ return false; |
+ } |
+ } |
+ } |
+ break; |
+ } |
+ case CALLBACKS: { |
+ Object* object = GetValue(i); |
+ if (object->IsAccessorPair()) { |
+ AccessorPair* accessors = AccessorPair::cast(object); |
+ if (!CheckOneBackPointer(current_map, accessors->getter())) { |
+ return false; |
+ } |
+ if (!CheckOneBackPointer(current_map, accessors->setter())) { |
+ return false; |
+ } |
+ } |
+ break; |
+ } |
+ case NORMAL: |
+ case FIELD: |
+ case CONSTANT_FUNCTION: |
+ case HANDLER: |
+ case INTERCEPTOR: |
+ case NULL_DESCRIPTOR: |
+ break; |
+ } |
+ } |
+ return true; |
+} |
+ |
+ |
void JSFunctionResultCache::JSFunctionResultCacheVerify() { |
JSFunction::cast(get(kFactoryIndex))->Verify(); |