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