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

Side by Side Diff: src/objects.cc

Issue 8491016: Refactoring only: Make the handling of PropertyType more explicit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unified our 2 UpdateCaches implementations, making some assumptions more explicit Created 9 years, 1 month 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/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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 set_map(target_map); 3016 set_map(target_map);
3017 return value; 3017 return value;
3018 } 3018 }
3019 // Otherwise, replace with a MAP_TRANSITION to a new map with a 3019 // Otherwise, replace with a MAP_TRANSITION to a new map with a
3020 // FIELD, even if the value is a constant function. 3020 // FIELD, even if the value is a constant function.
3021 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); 3021 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
3022 } 3022 }
3023 case NULL_DESCRIPTOR: 3023 case NULL_DESCRIPTOR:
3024 case ELEMENTS_TRANSITION: 3024 case ELEMENTS_TRANSITION:
3025 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); 3025 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
3026 default: 3026 case HANDLER:
3027 UNREACHABLE(); 3027 UNREACHABLE();
3028 return value;
3028 } 3029 }
3029 UNREACHABLE(); 3030 UNREACHABLE(); // keep the compiler happy
3030 return value; 3031 return value;
3031 } 3032 }
3032 3033
3033 3034
3034 // Set a real local property, even if it is READ_ONLY. If the property is not 3035 // Set a real local property, even if it is READ_ONLY. If the property is not
3035 // present, add it with attributes NONE. This code is an exact clone of 3036 // present, add it with attributes NONE. This code is an exact clone of
3036 // SetProperty, with the check for IsReadOnly and the check for a 3037 // SetProperty, with the check for IsReadOnly and the check for a
3037 // callback setter removed. The two lines looking up the LookupResult 3038 // callback setter removed. The two lines looking up the LookupResult
3038 // result are also added. If one of the functions is changed, the other 3039 // result are also added. If one of the functions is changed, the other
3039 // should be. 3040 // should be.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3104 case INTERCEPTOR: 3105 case INTERCEPTOR:
3105 // Override callback in clone 3106 // Override callback in clone
3106 return ConvertDescriptorToField(name, value, attributes); 3107 return ConvertDescriptorToField(name, value, attributes);
3107 case CONSTANT_TRANSITION: 3108 case CONSTANT_TRANSITION:
3108 // Replace with a MAP_TRANSITION to a new map with a FIELD, even 3109 // Replace with a MAP_TRANSITION to a new map with a FIELD, even
3109 // if the value is a function. 3110 // if the value is a function.
3110 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); 3111 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
3111 case NULL_DESCRIPTOR: 3112 case NULL_DESCRIPTOR:
3112 case ELEMENTS_TRANSITION: 3113 case ELEMENTS_TRANSITION:
3113 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); 3114 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
3114 default: 3115 case HANDLER:
3115 UNREACHABLE(); 3116 UNREACHABLE();
3117 return value;
3116 } 3118 }
3117 UNREACHABLE(); 3119 UNREACHABLE(); // keep the compiler happy
3118 return value; 3120 return value;
3119 } 3121 }
3120 3122
3121 3123
3122 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( 3124 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor(
3123 JSObject* receiver, 3125 JSObject* receiver,
3124 String* name, 3126 String* name,
3125 bool continue_search) { 3127 bool continue_search) {
3126 // Check local property, ignore interceptor. 3128 // Check local property, ignore interceptor.
3127 LookupResult result(GetIsolate()); 3129 LookupResult result(GetIsolate());
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3393 } 3395 }
3394 dictionary = StringDictionary::cast(result); 3396 dictionary = StringDictionary::cast(result);
3395 break; 3397 break;
3396 } 3398 }
3397 case MAP_TRANSITION: 3399 case MAP_TRANSITION:
3398 case CONSTANT_TRANSITION: 3400 case CONSTANT_TRANSITION:
3399 case NULL_DESCRIPTOR: 3401 case NULL_DESCRIPTOR:
3400 case INTERCEPTOR: 3402 case INTERCEPTOR:
3401 case ELEMENTS_TRANSITION: 3403 case ELEMENTS_TRANSITION:
3402 break; 3404 break;
3403 default: 3405 case HANDLER:
3406 case NORMAL:
3404 UNREACHABLE(); 3407 UNREACHABLE();
3408 break;
3405 } 3409 }
3406 } 3410 }
3407 3411
3408 Heap* current_heap = GetHeap(); 3412 Heap* current_heap = GetHeap();
3409 3413
3410 // Copy the next enumeration index from instance descriptor. 3414 // Copy the next enumeration index from instance descriptor.
3411 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); 3415 int index = map_of_this->instance_descriptors()->NextEnumerationIndex();
3412 dictionary->SetNextEnumerationIndex(index); 3416 dictionary->SetNextEnumerationIndex(index);
3413 3417
3414 { MaybeObject* maybe_obj = 3418 { MaybeObject* maybe_obj =
(...skipping 3585 matching lines...) Expand 10 before | Expand all | Expand 10 after
7000 #endif 7004 #endif
7001 // Point target back to source. set_prototype() will not let us set 7005 // Point target back to source. set_prototype() will not let us set
7002 // the prototype to a map, as we do here. 7006 // the prototype to a map, as we do here.
7003 *RawField(target, kPrototypeOffset) = this; 7007 *RawField(target, kPrototypeOffset) = this;
7004 } 7008 }
7005 7009
7006 7010
7007 void Map::CreateBackPointers() { 7011 void Map::CreateBackPointers() {
7008 DescriptorArray* descriptors = instance_descriptors(); 7012 DescriptorArray* descriptors = instance_descriptors();
7009 for (int i = 0; i < descriptors->number_of_descriptors(); i++) { 7013 for (int i = 0; i < descriptors->number_of_descriptors(); i++) {
7010 if (descriptors->GetType(i) == MAP_TRANSITION || 7014 if (descriptors->IsTransition(i)) {
7011 descriptors->GetType(i) == ELEMENTS_TRANSITION ||
7012 descriptors->GetType(i) == CONSTANT_TRANSITION) {
7013 Object* object = reinterpret_cast<Object*>(descriptors->GetValue(i)); 7015 Object* object = reinterpret_cast<Object*>(descriptors->GetValue(i));
7014 if (object->IsMap()) { 7016 if (object->IsMap()) {
7015 CreateOneBackPointer(reinterpret_cast<Map*>(object)); 7017 CreateOneBackPointer(reinterpret_cast<Map*>(object));
7016 } else { 7018 } else {
7017 ASSERT(object->IsFixedArray()); 7019 ASSERT(object->IsFixedArray());
7018 ASSERT(descriptors->GetType(i) == ELEMENTS_TRANSITION); 7020 ASSERT(descriptors->GetType(i) == ELEMENTS_TRANSITION);
7019 FixedArray* array = reinterpret_cast<FixedArray*>(object); 7021 FixedArray* array = reinterpret_cast<FixedArray*>(object);
7020 for (int i = 0; i < array->length(); ++i) { 7022 for (int i = 0; i < array->length(); ++i) {
7021 Map* target = reinterpret_cast<Map*>(array->get(i)); 7023 Map* target = reinterpret_cast<Map*>(array->get(i));
7022 if (!target->IsUndefined()) { 7024 if (!target->IsUndefined()) {
(...skipping 17 matching lines...) Expand all
7040 FixedArray* contents = reinterpret_cast<FixedArray*>( 7042 FixedArray* contents = reinterpret_cast<FixedArray*>(
7041 d->get(DescriptorArray::kContentArrayIndex)); 7043 d->get(DescriptorArray::kContentArrayIndex));
7042 ASSERT(contents->length() >= 2); 7044 ASSERT(contents->length() >= 2);
7043 for (int i = 0; i < contents->length(); i += 2) { 7045 for (int i = 0; i < contents->length(); i += 2) {
7044 // If the pair (value, details) is a map transition, 7046 // If the pair (value, details) is a map transition,
7045 // check if the target is live. If not, null the descriptor. 7047 // check if the target is live. If not, null the descriptor.
7046 // Also drop the back pointer for that map transition, so that this 7048 // Also drop the back pointer for that map transition, so that this
7047 // map is not reached again by following a back pointer from a 7049 // map is not reached again by following a back pointer from a
7048 // non-live object. 7050 // non-live object.
7049 PropertyDetails details(Smi::cast(contents->get(i + 1))); 7051 PropertyDetails details(Smi::cast(contents->get(i + 1)));
7050 if (details.type() == MAP_TRANSITION || 7052 if (IsTransitionType(details.type())) {
7051 details.type() == ELEMENTS_TRANSITION ||
7052 details.type() == CONSTANT_TRANSITION) {
7053 Object* object = reinterpret_cast<Object*>(contents->get(i)); 7053 Object* object = reinterpret_cast<Object*>(contents->get(i));
7054 if (object->IsMap()) { 7054 if (object->IsMap()) {
7055 Map* target = reinterpret_cast<Map*>(object); 7055 Map* target = reinterpret_cast<Map*>(object);
7056 ASSERT(target->IsHeapObject()); 7056 ASSERT(target->IsHeapObject());
7057 MarkBit map_mark = Marking::MarkBitFrom(target); 7057 MarkBit map_mark = Marking::MarkBitFrom(target);
7058 if (!map_mark.Get()) { 7058 if (!map_mark.Get()) {
7059 ASSERT(target->IsMap()); 7059 ASSERT(target->IsMap());
7060 contents->set_unchecked(i + 1, NullDescriptorDetails); 7060 contents->set_unchecked(i + 1, NullDescriptorDetails);
7061 contents->set_null_unchecked(heap, i); 7061 contents->set_null_unchecked(heap, i);
7062 ASSERT(target->prototype() == this || 7062 ASSERT(target->prototype() == this ||
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
8027 case FIELD: return "FIELD"; 8027 case FIELD: return "FIELD";
8028 case CONSTANT_FUNCTION: return "CONSTANT_FUNCTION"; 8028 case CONSTANT_FUNCTION: return "CONSTANT_FUNCTION";
8029 case CALLBACKS: return "CALLBACKS"; 8029 case CALLBACKS: return "CALLBACKS";
8030 case HANDLER: return "HANDLER"; 8030 case HANDLER: return "HANDLER";
8031 case INTERCEPTOR: return "INTERCEPTOR"; 8031 case INTERCEPTOR: return "INTERCEPTOR";
8032 case MAP_TRANSITION: return "MAP_TRANSITION"; 8032 case MAP_TRANSITION: return "MAP_TRANSITION";
8033 case ELEMENTS_TRANSITION: return "ELEMENTS_TRANSITION"; 8033 case ELEMENTS_TRANSITION: return "ELEMENTS_TRANSITION";
8034 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION"; 8034 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION";
8035 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR"; 8035 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR";
8036 } 8036 }
8037 UNREACHABLE(); 8037 UNREACHABLE(); // keep the compiler happy
8038 return NULL; 8038 return NULL;
8039 } 8039 }
8040 8040
8041 8041
8042 void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) { 8042 void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) {
8043 const char* name = NULL; 8043 const char* name = NULL;
8044 switch (kind) { 8044 switch (kind) {
8045 case CALL_IC: 8045 case CALL_IC:
8046 if (extra == STRING_INDEX_OUT_OF_BOUNDS) { 8046 if (extra == STRING_INDEX_OUT_OF_BOUNDS) {
8047 name = "STRING_INDEX_OUT_OF_BOUNDS"; 8047 name = "STRING_INDEX_OUT_OF_BOUNDS";
(...skipping 4707 matching lines...) Expand 10 before | Expand all | Expand 10 after
12755 if (break_point_objects()->IsUndefined()) return 0; 12755 if (break_point_objects()->IsUndefined()) return 0;
12756 // Single break point. 12756 // Single break point.
12757 if (!break_point_objects()->IsFixedArray()) return 1; 12757 if (!break_point_objects()->IsFixedArray()) return 1;
12758 // Multiple break points. 12758 // Multiple break points.
12759 return FixedArray::cast(break_point_objects())->length(); 12759 return FixedArray::cast(break_point_objects())->length();
12760 } 12760 }
12761 #endif // ENABLE_DEBUGGER_SUPPORT 12761 #endif // ENABLE_DEBUGGER_SUPPORT
12762 12762
12763 12763
12764 } } // namespace v8::internal 12764 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698