| OLD | NEW |
| 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 2746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2757 if (descriptors->GetDetails(i).type() == FIELD) { | 2757 if (descriptors->GetDetails(i).type() == FIELD) { |
| 2758 map = GeneralizeRepresentation(map, i, Representation::Tagged(), | 2758 map = GeneralizeRepresentation(map, i, Representation::Tagged(), |
| 2759 HeapType::Any(map->GetIsolate()), | 2759 HeapType::Any(map->GetIsolate()), |
| 2760 FORCE_FIELD); | 2760 FORCE_FIELD); |
| 2761 } | 2761 } |
| 2762 } | 2762 } |
| 2763 return map; | 2763 return map; |
| 2764 } | 2764 } |
| 2765 | 2765 |
| 2766 | 2766 |
| 2767 Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) { | 2767 // static |
| 2768 MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) { |
| 2768 Handle<Map> proto_map(map); | 2769 Handle<Map> proto_map(map); |
| 2769 while (proto_map->prototype()->IsJSObject()) { | 2770 while (proto_map->prototype()->IsJSObject()) { |
| 2770 Handle<JSObject> holder(JSObject::cast(proto_map->prototype())); | 2771 Handle<JSObject> holder(JSObject::cast(proto_map->prototype())); |
| 2771 if (holder->map()->is_deprecated()) { | 2772 proto_map = Handle<Map>(holder->map()); |
| 2772 JSObject::TryMigrateInstance(holder); | 2773 if (proto_map->is_deprecated() && JSObject::TryMigrateInstance(holder)) { |
| 2774 proto_map = Handle<Map>(holder->map()); |
| 2773 } | 2775 } |
| 2774 proto_map = Handle<Map>(holder->map()); | |
| 2775 } | 2776 } |
| 2776 return CurrentMapForDeprecatedInternal(map); | 2777 return CurrentMapForDeprecatedInternal(map); |
| 2777 } | 2778 } |
| 2778 | 2779 |
| 2779 | 2780 |
| 2780 Handle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) { | 2781 // static |
| 2782 MaybeHandle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) { |
| 2781 if (!map->is_deprecated()) return map; | 2783 if (!map->is_deprecated()) return map; |
| 2782 | 2784 |
| 2783 DisallowHeapAllocation no_allocation; | 2785 DisallowHeapAllocation no_allocation; |
| 2784 DescriptorArray* old_descriptors = map->instance_descriptors(); | 2786 DescriptorArray* old_descriptors = map->instance_descriptors(); |
| 2785 | 2787 |
| 2786 int descriptors = map->NumberOfOwnDescriptors(); | 2788 int descriptors = map->NumberOfOwnDescriptors(); |
| 2787 Map* root_map = map->FindRootMap(); | 2789 Map* root_map = map->FindRootMap(); |
| 2788 | 2790 |
| 2789 // Check the state of the root map. | 2791 // Check the state of the root map. |
| 2790 if (!map->EquivalentToForTransition(root_map)) return Handle<Map>(); | 2792 if (!map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>(); |
| 2791 int verbatim = root_map->NumberOfOwnDescriptors(); | 2793 int verbatim = root_map->NumberOfOwnDescriptors(); |
| 2792 | 2794 |
| 2793 Map* updated = root_map->FindUpdatedMap( | 2795 Map* updated = root_map->FindUpdatedMap( |
| 2794 verbatim, descriptors, old_descriptors); | 2796 verbatim, descriptors, old_descriptors); |
| 2795 if (updated == NULL) return Handle<Map>(); | 2797 if (updated == NULL) return MaybeHandle<Map>(); |
| 2796 | 2798 |
| 2797 DescriptorArray* updated_descriptors = updated->instance_descriptors(); | 2799 DescriptorArray* updated_descriptors = updated->instance_descriptors(); |
| 2798 int valid = updated->NumberOfOwnDescriptors(); | 2800 int valid = updated->NumberOfOwnDescriptors(); |
| 2799 if (!updated_descriptors->IsMoreGeneralThan( | 2801 if (!updated_descriptors->IsMoreGeneralThan( |
| 2800 verbatim, valid, descriptors, old_descriptors)) { | 2802 verbatim, valid, descriptors, old_descriptors)) { |
| 2801 return Handle<Map>(); | 2803 return MaybeHandle<Map>(); |
| 2802 } | 2804 } |
| 2803 | 2805 |
| 2804 return handle(updated); | 2806 return handle(updated); |
| 2805 } | 2807 } |
| 2806 | 2808 |
| 2807 | 2809 |
| 2808 MaybeHandle<Object> JSObject::SetPropertyWithInterceptor( | 2810 MaybeHandle<Object> JSObject::SetPropertyWithInterceptor( |
| 2809 Handle<JSObject> object, | 2811 Handle<JSObject> object, |
| 2810 Handle<Name> name, | 2812 Handle<Name> name, |
| 2811 Handle<Object> value, | 2813 Handle<Object> value, |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3896 object, 0, Representation::None(), | 3898 object, 0, Representation::None(), |
| 3897 HeapType::None(object->GetIsolate()), | 3899 HeapType::None(object->GetIsolate()), |
| 3898 ALLOW_AS_CONSTANT); | 3900 ALLOW_AS_CONSTANT); |
| 3899 object->map()->set_migration_target(true); | 3901 object->map()->set_migration_target(true); |
| 3900 if (FLAG_trace_migration) { | 3902 if (FLAG_trace_migration) { |
| 3901 object->PrintInstanceMigration(stdout, *original_map, object->map()); | 3903 object->PrintInstanceMigration(stdout, *original_map, object->map()); |
| 3902 } | 3904 } |
| 3903 } | 3905 } |
| 3904 | 3906 |
| 3905 | 3907 |
| 3906 Handle<Object> JSObject::TryMigrateInstance(Handle<JSObject> object) { | 3908 // static |
| 3909 bool JSObject::TryMigrateInstance(Handle<JSObject> object) { |
| 3907 Handle<Map> original_map(object->map()); | 3910 Handle<Map> original_map(object->map()); |
| 3908 Handle<Map> new_map = Map::CurrentMapForDeprecatedInternal(original_map); | 3911 Handle<Map> new_map; |
| 3909 if (new_map.is_null()) return Handle<Object>(); | 3912 if (!Map::CurrentMapForDeprecatedInternal(original_map).ToHandle(&new_map)) { |
| 3913 return false; |
| 3914 } |
| 3910 JSObject::MigrateToMap(object, new_map); | 3915 JSObject::MigrateToMap(object, new_map); |
| 3911 if (FLAG_trace_migration) { | 3916 if (FLAG_trace_migration) { |
| 3912 object->PrintInstanceMigration(stdout, *original_map, object->map()); | 3917 object->PrintInstanceMigration(stdout, *original_map, object->map()); |
| 3913 } | 3918 } |
| 3914 return object; | 3919 return true; |
| 3915 } | 3920 } |
| 3916 | 3921 |
| 3917 | 3922 |
| 3918 MaybeHandle<Object> JSObject::SetPropertyUsingTransition( | 3923 MaybeHandle<Object> JSObject::SetPropertyUsingTransition( |
| 3919 Handle<JSObject> object, | 3924 Handle<JSObject> object, |
| 3920 LookupResult* lookup, | 3925 LookupResult* lookup, |
| 3921 Handle<Name> name, | 3926 Handle<Name> name, |
| 3922 Handle<Object> value, | 3927 Handle<Object> value, |
| 3923 PropertyAttributes attributes) { | 3928 PropertyAttributes attributes) { |
| 3924 Handle<Map> transition_map(lookup->GetTransitionTarget()); | 3929 Handle<Map> transition_map(lookup->GetTransitionTarget()); |
| (...skipping 13424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17349 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17354 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 17350 static const char* error_messages_[] = { | 17355 static const char* error_messages_[] = { |
| 17351 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17356 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 17352 }; | 17357 }; |
| 17353 #undef ERROR_MESSAGES_TEXTS | 17358 #undef ERROR_MESSAGES_TEXTS |
| 17354 return error_messages_[reason]; | 17359 return error_messages_[reason]; |
| 17355 } | 17360 } |
| 17356 | 17361 |
| 17357 | 17362 |
| 17358 } } // namespace v8::internal | 17363 } } // namespace v8::internal |
| OLD | NEW |