OLD | NEW |
---|---|
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 | 296 |
297 void Map::MapVerify() { | 297 void Map::MapVerify() { |
298 ASSERT(!HEAP->InNewSpace(this)); | 298 ASSERT(!HEAP->InNewSpace(this)); |
299 ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); | 299 ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
300 ASSERT(instance_size() == kVariableSizeSentinel || | 300 ASSERT(instance_size() == kVariableSizeSentinel || |
301 (kPointerSize <= instance_size() && | 301 (kPointerSize <= instance_size() && |
302 instance_size() < HEAP->Capacity())); | 302 instance_size() < HEAP->Capacity())); |
303 VerifyHeapPointer(prototype()); | 303 VerifyHeapPointer(prototype()); |
304 VerifyHeapPointer(instance_descriptors()); | 304 VerifyHeapPointer(instance_descriptors()); |
305 SLOW_ASSERT(instance_descriptors()->IsSortedNoDuplicates()); | 305 SLOW_ASSERT(instance_descriptors()->IsSortedNoDuplicates()); |
306 SLOW_ASSERT(instance_descriptors()->IsConsistentWithBackPointers(this)); | 306 SLOW_ASSERT(transitions()->IsSortedNoDuplicates()); |
307 SLOW_ASSERT(transitions()->IsConsistentWithBackPointers(this)); | |
307 } | 308 } |
308 | 309 |
309 | 310 |
310 void Map::SharedMapVerify() { | 311 void Map::SharedMapVerify() { |
311 MapVerify(); | 312 MapVerify(); |
312 ASSERT(is_shared()); | 313 ASSERT(is_shared()); |
313 ASSERT(instance_descriptors()->IsEmpty()); | 314 ASSERT(instance_descriptors()->IsEmpty()); |
314 ASSERT_EQ(0, pre_allocated_property_fields()); | 315 ASSERT_EQ(0, pre_allocated_property_fields()); |
315 ASSERT_EQ(0, unused_property_fields()); | 316 ASSERT_EQ(0, unused_property_fields()); |
316 ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), | 317 ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 if (hash < current) { | 910 if (hash < current) { |
910 PrintDescriptors(); | 911 PrintDescriptors(); |
911 return false; | 912 return false; |
912 } | 913 } |
913 current = hash; | 914 current = hash; |
914 } | 915 } |
915 return true; | 916 return true; |
916 } | 917 } |
917 | 918 |
918 | 919 |
920 bool TransitionArray::IsSortedNoDuplicates() { | |
921 if (!IsTransitionArray()) return true; | |
Michael Starzinger
2012/06/28 16:02:12
Can this really happen? If not, drop this line.
Toon Verwaest
2012/06/29 08:14:55
Done.
| |
922 String* current_key = NULL; | |
923 uint32_t current = 0; | |
924 for (int i = 0; i < number_of_transitions(); i++) { | |
925 String* key = GetKey(i); | |
926 if (key == current_key) { | |
927 PrintTransitions(); | |
928 return false; | |
929 } | |
930 current_key = key; | |
931 uint32_t hash = GetKey(i)->Hash(); | |
932 if (hash < current) { | |
933 PrintTransitions(); | |
934 return false; | |
935 } | |
936 current = hash; | |
937 } | |
938 return true; | |
939 } | |
940 | |
941 | |
919 static bool CheckOneBackPointer(Map* current_map, Object* target) { | 942 static bool CheckOneBackPointer(Map* current_map, Object* target) { |
920 return !target->IsMap() || Map::cast(target)->GetBackPointer() == current_map; | 943 return !target->IsMap() || Map::cast(target)->GetBackPointer() == current_map; |
921 } | 944 } |
922 | 945 |
923 | 946 |
924 bool DescriptorArray::IsConsistentWithBackPointers(Map* current_map) { | 947 bool TransitionArray::IsConsistentWithBackPointers(Map* current_map) { |
925 Map* elements_transition = elements_transition_map(); | 948 if (this == NULL) return true; |
Michael Starzinger
2012/06/28 16:02:12
Can "this" really be NULL? If not, drop this line.
Toon Verwaest
2012/06/29 08:14:55
Done.
| |
926 if (elements_transition != NULL && | 949 if (!CheckOneBackPointer(current_map, elements())) return false; |
927 !CheckOneBackPointer(current_map, elements_transition)) { | 950 for (int i = 0; i < number_of_transitions(); ++i) { |
928 return false; | 951 Object* value = GetValue(i); |
929 } | 952 if (value->IsAccessorPair()) { |
930 for (int i = 0; i < number_of_descriptors(); ++i) { | 953 AccessorPair* accessors = AccessorPair::cast(value); |
931 switch (GetType(i)) { | 954 if (!CheckOneBackPointer(current_map, accessors->getter())) return false; |
932 case MAP_TRANSITION: | 955 if (!CheckOneBackPointer(current_map, accessors->setter())) return false; |
933 case CONSTANT_TRANSITION: | 956 continue; |
Michael Starzinger
2012/06/28 16:02:12
Drop the continue.
Toon Verwaest
2012/06/29 08:14:55
Done.
| |
934 if (!CheckOneBackPointer(current_map, GetValue(i))) { | |
935 return false; | |
936 } | |
937 break; | |
938 case CALLBACKS: { | |
939 Object* object = GetValue(i); | |
940 if (object->IsAccessorPair()) { | |
941 AccessorPair* accessors = AccessorPair::cast(object); | |
942 if (!CheckOneBackPointer(current_map, accessors->getter())) { | |
943 return false; | |
944 } | |
945 if (!CheckOneBackPointer(current_map, accessors->setter())) { | |
946 return false; | |
947 } | |
948 } | |
949 break; | |
950 } | |
951 case NORMAL: | |
952 case FIELD: | |
953 case CONSTANT_FUNCTION: | |
954 case HANDLER: | |
955 case INTERCEPTOR: | |
956 break; | |
957 case NONEXISTENT: | |
958 UNREACHABLE(); | |
959 break; | |
960 } | 957 } |
958 if (!CheckOneBackPointer(current_map, value)) return false; | |
Michael Starzinger
2012/06/28 16:02:12
Can we turn this into a proper "else" branch and a
Toon Verwaest
2012/06/29 08:14:55
Done.
| |
961 } | 959 } |
962 return true; | 960 return true; |
963 } | 961 } |
964 | 962 |
965 | 963 |
966 void JSFunctionResultCache::JSFunctionResultCacheVerify() { | 964 void JSFunctionResultCache::JSFunctionResultCacheVerify() { |
967 JSFunction::cast(get(kFactoryIndex))->Verify(); | 965 JSFunction::cast(get(kFactoryIndex))->Verify(); |
968 | 966 |
969 int size = Smi::cast(get(kCacheSizeIndex))->value(); | 967 int size = Smi::cast(get(kCacheSizeIndex))->value(); |
970 ASSERT(kEntriesIndex <= size); | 968 ASSERT(kEntriesIndex <= size); |
(...skipping 26 matching lines...) Expand all Loading... | |
997 if (e->IsMap()) { | 995 if (e->IsMap()) { |
998 Map::cast(e)->SharedMapVerify(); | 996 Map::cast(e)->SharedMapVerify(); |
999 } else { | 997 } else { |
1000 ASSERT(e->IsUndefined()); | 998 ASSERT(e->IsUndefined()); |
1001 } | 999 } |
1002 } | 1000 } |
1003 } | 1001 } |
1004 } | 1002 } |
1005 | 1003 |
1006 | 1004 |
1007 void Map::ZapInstanceDescriptors() { | 1005 void Map::ZapTransitions() { |
1008 DescriptorArray* descriptors = instance_descriptors(); | 1006 TransitionArray* transition_array = transitions(); |
1009 if (descriptors == GetHeap()->empty_descriptor_array()) return; | 1007 if (transition_array == NULL) return; |
1010 MemsetPointer(descriptors->data_start(), | 1008 MemsetPointer(transition_array->data_start(), |
1011 GetHeap()->the_hole_value(), | 1009 GetHeap()->the_hole_value(), |
1012 descriptors->length()); | 1010 transition_array->length()); |
1013 } | 1011 } |
1014 | 1012 |
1015 | 1013 |
1016 void Map::ZapPrototypeTransitions() { | 1014 void Map::ZapPrototypeTransitions() { |
1017 FixedArray* proto_transitions = prototype_transitions(); | 1015 FixedArray* proto_transitions = prototype_transitions(); |
1018 MemsetPointer(proto_transitions->data_start(), | 1016 MemsetPointer(proto_transitions->data_start(), |
1019 GetHeap()->the_hole_value(), | 1017 GetHeap()->the_hole_value(), |
1020 proto_transitions->length()); | 1018 proto_transitions->length()); |
1021 } | 1019 } |
1022 | 1020 |
1023 | 1021 |
1024 #endif // DEBUG | 1022 #endif // DEBUG |
1025 | 1023 |
1026 } } // namespace v8::internal | 1024 } } // namespace v8::internal |
OLD | NEW |