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

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

Issue 10697015: Separating transitions from descriptors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Using WhitenessWitness in TransitionArray code. Created 8 years, 5 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.cc ('k') | src/objects-inl.h » ('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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (HasTransitionArray()) {
307 SLOW_ASSERT(transitions()->IsSortedNoDuplicates());
308 SLOW_ASSERT(transitions()->IsConsistentWithBackPointers(this));
309 }
307 } 310 }
308 311
309 312
310 void Map::SharedMapVerify() { 313 void Map::SharedMapVerify() {
311 MapVerify(); 314 MapVerify();
312 ASSERT(is_shared()); 315 ASSERT(is_shared());
313 ASSERT(instance_descriptors()->IsEmpty()); 316 ASSERT(instance_descriptors()->IsEmpty());
314 ASSERT_EQ(0, pre_allocated_property_fields()); 317 ASSERT_EQ(0, pre_allocated_property_fields());
315 ASSERT_EQ(0, unused_property_fields()); 318 ASSERT_EQ(0, unused_property_fields());
316 ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), 319 ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()),
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 if (hash < current) { 912 if (hash < current) {
910 PrintDescriptors(); 913 PrintDescriptors();
911 return false; 914 return false;
912 } 915 }
913 current = hash; 916 current = hash;
914 } 917 }
915 return true; 918 return true;
916 } 919 }
917 920
918 921
922 bool TransitionArray::IsSortedNoDuplicates() {
923 String* current_key = NULL;
924 uint32_t current = 0;
925 for (int i = 0; i < number_of_transitions(); i++) {
926 String* key = GetKey(i);
927 if (key == current_key) {
928 PrintTransitions();
929 return false;
930 }
931 current_key = key;
932 uint32_t hash = GetKey(i)->Hash();
933 if (hash < current) {
934 PrintTransitions();
935 return false;
936 }
937 current = hash;
938 }
939 return true;
940 }
941
942
919 static bool CheckOneBackPointer(Map* current_map, Object* target) { 943 static bool CheckOneBackPointer(Map* current_map, Object* target) {
920 return !target->IsMap() || Map::cast(target)->GetBackPointer() == current_map; 944 return !target->IsMap() || Map::cast(target)->GetBackPointer() == current_map;
921 } 945 }
922 946
923 947
924 bool DescriptorArray::IsConsistentWithBackPointers(Map* current_map) { 948 bool TransitionArray::IsConsistentWithBackPointers(Map* current_map) {
925 Map* elements_transition = elements_transition_map(); 949 if (HasElementsTransition() &&
926 if (elements_transition != NULL && 950 !CheckOneBackPointer(current_map, elements_transition())) {
927 !CheckOneBackPointer(current_map, elements_transition)) {
928 return false; 951 return false;
929 } 952 }
930 for (int i = 0; i < number_of_descriptors(); ++i) { 953 for (int i = 0; i < number_of_transitions(); ++i) {
931 switch (GetType(i)) { 954 Object* value = GetValue(i);
932 case MAP_TRANSITION: 955 if (value->IsAccessorPair()) {
933 case CONSTANT_TRANSITION: 956 AccessorPair* accessors = AccessorPair::cast(value);
934 if (!CheckOneBackPointer(current_map, GetValue(i))) { 957 if (!CheckOneBackPointer(current_map, accessors->getter())) return false;
935 return false; 958 if (!CheckOneBackPointer(current_map, accessors->setter())) return false;
936 } 959 } else {
937 break; 960 ASSERT(value->IsMap());
938 case CALLBACKS: { 961 if (!CheckOneBackPointer(current_map, value)) return false;
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 } 962 }
961 } 963 }
962 return true; 964 return true;
963 } 965 }
964 966
965 967
966 void JSFunctionResultCache::JSFunctionResultCacheVerify() { 968 void JSFunctionResultCache::JSFunctionResultCacheVerify() {
967 JSFunction::cast(get(kFactoryIndex))->Verify(); 969 JSFunction::cast(get(kFactoryIndex))->Verify();
968 970
969 int size = Smi::cast(get(kCacheSizeIndex))->value(); 971 int size = Smi::cast(get(kCacheSizeIndex))->value();
(...skipping 27 matching lines...) Expand all
997 if (e->IsMap()) { 999 if (e->IsMap()) {
998 Map::cast(e)->SharedMapVerify(); 1000 Map::cast(e)->SharedMapVerify();
999 } else { 1001 } else {
1000 ASSERT(e->IsUndefined()); 1002 ASSERT(e->IsUndefined());
1001 } 1003 }
1002 } 1004 }
1003 } 1005 }
1004 } 1006 }
1005 1007
1006 1008
1007 void Map::ZapInstanceDescriptors() { 1009 void Map::ZapTransitions() {
1008 DescriptorArray* descriptors = instance_descriptors(); 1010 TransitionArray* transition_array = transitions();
1009 if (descriptors == GetHeap()->empty_descriptor_array()) return; 1011 if (transition_array == NULL) return;
1010 MemsetPointer(descriptors->data_start(), 1012 MemsetPointer(transition_array->data_start(),
1011 GetHeap()->the_hole_value(), 1013 GetHeap()->the_hole_value(),
1012 descriptors->length()); 1014 transition_array->length());
1013 } 1015 }
1014 1016
1015 1017
1016 void Map::ZapPrototypeTransitions() { 1018 void Map::ZapPrototypeTransitions() {
1017 FixedArray* proto_transitions = prototype_transitions(); 1019 FixedArray* proto_transitions = prototype_transitions();
1018 MemsetPointer(proto_transitions->data_start(), 1020 MemsetPointer(proto_transitions->data_start(),
1019 GetHeap()->the_hole_value(), 1021 GetHeap()->the_hole_value(),
1020 proto_transitions->length()); 1022 proto_transitions->length());
1021 } 1023 }
1022 1024
1023 1025
1024 #endif // DEBUG 1026 #endif // DEBUG
1025 1027
1026 } } // namespace v8::internal 1028 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698