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

Side by Side Diff: src/objects.cc

Issue 257893004: Fix and improve Map::CurrentMapForDeprecatedInternal(). (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 proto_map = Handle<Map>(holder->map()); 2772 proto_map = Handle<Map>(holder->map());
2773 if (proto_map->is_deprecated() && JSObject::TryMigrateInstance(holder)) { 2773 if (proto_map->is_deprecated() && JSObject::TryMigrateInstance(holder)) {
2774 proto_map = Handle<Map>(holder->map()); 2774 proto_map = Handle<Map>(holder->map());
2775 } 2775 }
2776 } 2776 }
2777 return CurrentMapForDeprecatedInternal(map); 2777 return CurrentMapForDeprecatedInternal(map);
2778 } 2778 }
2779 2779
2780 2780
2781 // static 2781 // static
2782 MaybeHandle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) { 2782 MaybeHandle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> old_map) {
2783 if (!map->is_deprecated()) return map; 2783 DisallowHeapAllocation no_allocation;
2784 2784
2785 DisallowHeapAllocation no_allocation; 2785 if (!old_map->is_deprecated()) return old_map;
2786 DescriptorArray* old_descriptors = map->instance_descriptors();
2787
2788 int descriptors = map->NumberOfOwnDescriptors();
2789 Map* root_map = map->FindRootMap();
2790 2786
2791 // Check the state of the root map. 2787 // Check the state of the root map.
2792 if (!map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>(); 2788 Map* root_map = old_map->FindRootMap();
2793 int verbatim = root_map->NumberOfOwnDescriptors(); 2789 if (!old_map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>();
2790 int root_nof = root_map->NumberOfOwnDescriptors();
2794 2791
2795 Map* updated = root_map->FindUpdatedMap( 2792 int old_nof = old_map->NumberOfOwnDescriptors();
2796 verbatim, descriptors, old_descriptors); 2793 DescriptorArray* old_descriptors = old_map->instance_descriptors();
2797 if (updated == NULL) return MaybeHandle<Map>();
2798 2794
2799 DescriptorArray* updated_descriptors = updated->instance_descriptors(); 2795 Map* new_map = root_map;
2800 int valid = updated->NumberOfOwnDescriptors(); 2796 for (int i = root_nof; i < old_nof; ++i) {
2801 if (!updated_descriptors->IsMoreGeneralThan( 2797 int j = new_map->SearchTransition(old_descriptors->GetKey(i));
2802 verbatim, valid, descriptors, old_descriptors)) { 2798 if (j == TransitionArray::kNotFound) return MaybeHandle<Map>();
2803 return MaybeHandle<Map>(); 2799 new_map = new_map->GetTransition(j);
2800 DescriptorArray* new_descriptors = new_map->instance_descriptors();
2801
2802 PropertyDetails new_details = new_descriptors->GetDetails(i);
2803 PropertyDetails old_details = old_descriptors->GetDetails(i);
2804 if (old_details.attributes() != new_details.attributes() ||
2805 !old_details.representation().fits_into(new_details.representation())) {
2806 return MaybeHandle<Map>();
2807 }
2808 PropertyType new_type = new_details.type();
2809 PropertyType old_type = old_details.type();
2810 Object* new_value = new_descriptors->GetValue(i);
2811 Object* old_value = old_descriptors->GetValue(i);
2812 switch (new_type) {
2813 case FIELD:
2814 if ((old_type == FIELD &&
2815 !HeapType::cast(old_value)->NowIs(HeapType::cast(new_value))) ||
2816 (old_type == CONSTANT &&
2817 !HeapType::cast(new_value)->NowContains(old_value)) ||
2818 (old_type == CALLBACKS &&
2819 !HeapType::Any()->Is(HeapType::cast(new_value)))) {
2820 return MaybeHandle<Map>();
2821 }
2822 break;
2823
2824 case CONSTANT:
2825 case CALLBACKS:
2826 if (old_type != new_type || old_value != new_value) {
2827 return MaybeHandle<Map>();
2828 }
2829 break;
2830
2831 case NORMAL:
2832 case HANDLER:
2833 case INTERCEPTOR:
2834 case NONEXISTENT:
2835 UNREACHABLE();
2836 }
2804 } 2837 }
2805 2838 if (new_map->NumberOfOwnDescriptors() != old_nof) return MaybeHandle<Map>();
2806 return handle(updated); 2839 return handle(new_map);
2807 } 2840 }
2808 2841
2809 2842
2810 MaybeHandle<Object> JSObject::SetPropertyWithInterceptor( 2843 MaybeHandle<Object> JSObject::SetPropertyWithInterceptor(
2811 Handle<JSObject> object, 2844 Handle<JSObject> object,
2812 Handle<Name> name, 2845 Handle<Name> name,
2813 Handle<Object> value, 2846 Handle<Object> value,
2814 PropertyAttributes attributes, 2847 PropertyAttributes attributes,
2815 StrictMode strict_mode) { 2848 StrictMode strict_mode) {
2816 // TODO(rossberg): Support symbols in the API. 2849 // TODO(rossberg): Support symbols in the API.
(...skipping 14489 matching lines...) Expand 10 before | Expand all | Expand 10 after
17306 #define ERROR_MESSAGES_TEXTS(C, T) T, 17339 #define ERROR_MESSAGES_TEXTS(C, T) T,
17307 static const char* error_messages_[] = { 17340 static const char* error_messages_[] = {
17308 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17341 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17309 }; 17342 };
17310 #undef ERROR_MESSAGES_TEXTS 17343 #undef ERROR_MESSAGES_TEXTS
17311 return error_messages_[reason]; 17344 return error_messages_[reason];
17312 } 17345 }
17313 17346
17314 17347
17315 } } // namespace v8::internal 17348 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698