| 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 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 2796 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { |
| 2797 PropertyDetails details = descriptors->GetDetails(i); | 2797 PropertyDetails details = descriptors->GetDetails(i); |
| 2798 if (details.type() == FIELD) { | 2798 if (details.type() == FIELD) { |
| 2799 map = GeneralizeRepresentation(map, i, new_representation, FORCE_FIELD); | 2799 map = GeneralizeRepresentation(map, i, new_representation, FORCE_FIELD); |
| 2800 } | 2800 } |
| 2801 } | 2801 } |
| 2802 return map; | 2802 return map; |
| 2803 } | 2803 } |
| 2804 | 2804 |
| 2805 | 2805 |
| 2806 Map* Map::CurrentMapForDeprecated() { | 2806 Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) { |
| 2807 Handle<Map> proto_map(map); |
| 2808 while (proto_map->prototype()->IsJSObject()) { |
| 2809 Handle<JSObject> holder(JSObject::cast(proto_map->prototype())); |
| 2810 if (holder->map()->is_deprecated()) { |
| 2811 JSObject::TryMigrateInstance(holder); |
| 2812 } |
| 2813 proto_map = Handle<Map>(holder->map()); |
| 2814 } |
| 2815 return CurrentMapForDeprecatedInternal(map); |
| 2816 } |
| 2817 |
| 2818 |
| 2819 Handle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) { |
| 2820 if (!map->is_deprecated()) return map; |
| 2821 |
| 2807 DisallowHeapAllocation no_allocation; | 2822 DisallowHeapAllocation no_allocation; |
| 2808 if (!is_deprecated()) return this; | 2823 DescriptorArray* old_descriptors = map->instance_descriptors(); |
| 2809 | 2824 |
| 2810 DescriptorArray* old_descriptors = instance_descriptors(); | 2825 int descriptors = map->NumberOfOwnDescriptors(); |
| 2811 | 2826 Map* root_map = map->FindRootMap(); |
| 2812 int descriptors = NumberOfOwnDescriptors(); | |
| 2813 Map* root_map = FindRootMap(); | |
| 2814 | 2827 |
| 2815 // Check the state of the root map. | 2828 // Check the state of the root map. |
| 2816 if (!EquivalentToForTransition(root_map)) return NULL; | 2829 if (!map->EquivalentToForTransition(root_map)) return Handle<Map>(); |
| 2817 int verbatim = root_map->NumberOfOwnDescriptors(); | 2830 int verbatim = root_map->NumberOfOwnDescriptors(); |
| 2818 | 2831 |
| 2819 Map* updated = root_map->FindUpdatedMap( | 2832 Map* updated = root_map->FindUpdatedMap( |
| 2820 verbatim, descriptors, old_descriptors); | 2833 verbatim, descriptors, old_descriptors); |
| 2821 if (updated == NULL) return NULL; | 2834 if (updated == NULL) return Handle<Map>(); |
| 2822 | 2835 |
| 2823 DescriptorArray* updated_descriptors = updated->instance_descriptors(); | 2836 DescriptorArray* updated_descriptors = updated->instance_descriptors(); |
| 2824 int valid = updated->NumberOfOwnDescriptors(); | 2837 int valid = updated->NumberOfOwnDescriptors(); |
| 2825 if (!updated_descriptors->IsMoreGeneralThan( | 2838 if (!updated_descriptors->IsMoreGeneralThan( |
| 2826 verbatim, valid, descriptors, old_descriptors)) { | 2839 verbatim, valid, descriptors, old_descriptors)) { |
| 2827 return NULL; | 2840 return Handle<Map>(); |
| 2828 } | 2841 } |
| 2829 | 2842 |
| 2830 return updated; | 2843 return handle(updated); |
| 2831 } | 2844 } |
| 2832 | 2845 |
| 2833 | 2846 |
| 2834 Handle<Object> JSObject::SetPropertyWithInterceptor( | 2847 Handle<Object> JSObject::SetPropertyWithInterceptor( |
| 2835 Handle<JSObject> object, | 2848 Handle<JSObject> object, |
| 2836 Handle<Name> name, | 2849 Handle<Name> name, |
| 2837 Handle<Object> value, | 2850 Handle<Object> value, |
| 2838 PropertyAttributes attributes, | 2851 PropertyAttributes attributes, |
| 2839 StrictModeFlag strict_mode) { | 2852 StrictModeFlag strict_mode) { |
| 2840 // TODO(rossberg): Support symbols in the API. | 2853 // TODO(rossberg): Support symbols in the API. |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3872 GeneralizeFieldRepresentation( | 3885 GeneralizeFieldRepresentation( |
| 3873 object, 0, Representation::None(), ALLOW_AS_CONSTANT); | 3886 object, 0, Representation::None(), ALLOW_AS_CONSTANT); |
| 3874 object->map()->set_migration_target(true); | 3887 object->map()->set_migration_target(true); |
| 3875 if (FLAG_trace_migration) { | 3888 if (FLAG_trace_migration) { |
| 3876 object->PrintInstanceMigration(stdout, *original_map, object->map()); | 3889 object->PrintInstanceMigration(stdout, *original_map, object->map()); |
| 3877 } | 3890 } |
| 3878 } | 3891 } |
| 3879 | 3892 |
| 3880 | 3893 |
| 3881 Handle<Object> JSObject::TryMigrateInstance(Handle<JSObject> object) { | 3894 Handle<Object> JSObject::TryMigrateInstance(Handle<JSObject> object) { |
| 3882 Map* new_map = object->map()->CurrentMapForDeprecated(); | |
| 3883 if (new_map == NULL) return Handle<Object>(); | |
| 3884 Handle<Map> original_map(object->map()); | 3895 Handle<Map> original_map(object->map()); |
| 3885 JSObject::MigrateToMap(object, handle(new_map)); | 3896 Handle<Map> new_map = Map::CurrentMapForDeprecatedInternal(original_map); |
| 3897 if (new_map.is_null()) return Handle<Object>(); |
| 3898 JSObject::MigrateToMap(object, new_map); |
| 3886 if (FLAG_trace_migration) { | 3899 if (FLAG_trace_migration) { |
| 3887 object->PrintInstanceMigration(stdout, *original_map, object->map()); | 3900 object->PrintInstanceMigration(stdout, *original_map, object->map()); |
| 3888 } | 3901 } |
| 3889 return object; | 3902 return object; |
| 3890 } | 3903 } |
| 3891 | 3904 |
| 3892 | 3905 |
| 3893 Handle<Object> JSObject::SetPropertyUsingTransition( | 3906 Handle<Object> JSObject::SetPropertyUsingTransition( |
| 3894 Handle<JSObject> object, | 3907 Handle<JSObject> object, |
| 3895 LookupResult* lookup, | 3908 LookupResult* lookup, |
| (...skipping 12755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16651 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16664 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16652 static const char* error_messages_[] = { | 16665 static const char* error_messages_[] = { |
| 16653 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16666 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16654 }; | 16667 }; |
| 16655 #undef ERROR_MESSAGES_TEXTS | 16668 #undef ERROR_MESSAGES_TEXTS |
| 16656 return error_messages_[reason]; | 16669 return error_messages_[reason]; |
| 16657 } | 16670 } |
| 16658 | 16671 |
| 16659 | 16672 |
| 16660 } } // namespace v8::internal | 16673 } } // namespace v8::internal |
| OLD | NEW |