Chromium Code Reviews| 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 if (!map->is_deprecated()) return map; | |
| 2816 | |
| 2807 DisallowHeapAllocation no_allocation; | 2817 DisallowHeapAllocation no_allocation; |
| 2808 if (!is_deprecated()) return this; | 2818 DescriptorArray* old_descriptors = map->instance_descriptors(); |
| 2809 | 2819 |
| 2810 DescriptorArray* old_descriptors = instance_descriptors(); | 2820 int descriptors = map->NumberOfOwnDescriptors(); |
| 2811 | 2821 Map* root_map = map->FindRootMap(); |
| 2812 int descriptors = NumberOfOwnDescriptors(); | |
| 2813 Map* root_map = FindRootMap(); | |
| 2814 | 2822 |
| 2815 // Check the state of the root map. | 2823 // Check the state of the root map. |
| 2816 if (!EquivalentToForTransition(root_map)) return NULL; | 2824 if (!map->EquivalentToForTransition(root_map)) return Handle<Map>(); |
| 2817 int verbatim = root_map->NumberOfOwnDescriptors(); | 2825 int verbatim = root_map->NumberOfOwnDescriptors(); |
| 2818 | 2826 |
| 2819 Map* updated = root_map->FindUpdatedMap( | 2827 Map* updated = root_map->FindUpdatedMap( |
| 2820 verbatim, descriptors, old_descriptors); | 2828 verbatim, descriptors, old_descriptors); |
| 2821 if (updated == NULL) return NULL; | 2829 if (updated == NULL) return Handle<Map>(); |
| 2822 | 2830 |
| 2823 DescriptorArray* updated_descriptors = updated->instance_descriptors(); | 2831 DescriptorArray* updated_descriptors = updated->instance_descriptors(); |
| 2824 int valid = updated->NumberOfOwnDescriptors(); | 2832 int valid = updated->NumberOfOwnDescriptors(); |
| 2825 if (!updated_descriptors->IsMoreGeneralThan( | 2833 if (!updated_descriptors->IsMoreGeneralThan( |
| 2826 verbatim, valid, descriptors, old_descriptors)) { | 2834 verbatim, valid, descriptors, old_descriptors)) { |
| 2827 return NULL; | 2835 return Handle<Map>(); |
| 2828 } | 2836 } |
| 2829 | 2837 |
| 2830 return updated; | 2838 return handle(updated); |
| 2831 } | 2839 } |
| 2832 | 2840 |
| 2833 | 2841 |
| 2834 Handle<Object> JSObject::SetPropertyWithInterceptor( | 2842 Handle<Object> JSObject::SetPropertyWithInterceptor( |
| 2835 Handle<JSObject> object, | 2843 Handle<JSObject> object, |
| 2836 Handle<Name> name, | 2844 Handle<Name> name, |
| 2837 Handle<Object> value, | 2845 Handle<Object> value, |
| 2838 PropertyAttributes attributes, | 2846 PropertyAttributes attributes, |
| 2839 StrictModeFlag strict_mode) { | 2847 StrictModeFlag strict_mode) { |
| 2840 // TODO(rossberg): Support symbols in the API. | 2848 // TODO(rossberg): Support symbols in the API. |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3872 GeneralizeFieldRepresentation( | 3880 GeneralizeFieldRepresentation( |
| 3873 object, 0, Representation::None(), ALLOW_AS_CONSTANT); | 3881 object, 0, Representation::None(), ALLOW_AS_CONSTANT); |
| 3874 object->map()->set_migration_target(true); | 3882 object->map()->set_migration_target(true); |
| 3875 if (FLAG_trace_migration) { | 3883 if (FLAG_trace_migration) { |
| 3876 object->PrintInstanceMigration(stdout, *original_map, object->map()); | 3884 object->PrintInstanceMigration(stdout, *original_map, object->map()); |
| 3877 } | 3885 } |
| 3878 } | 3886 } |
| 3879 | 3887 |
| 3880 | 3888 |
| 3881 Handle<Object> JSObject::TryMigrateInstance(Handle<JSObject> object) { | 3889 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()); | 3890 Handle<Map> original_map(object->map()); |
| 3885 JSObject::MigrateToMap(object, handle(new_map)); | 3891 Handle<Map> new_map = Map::CurrentMapForDeprecated(original_map); |
|
Toon Verwaest
2013/12/09 16:32:59
Euh, yeah. Now CurrentMapForDeprecated links back
Jakob Kummerow
2013/12/10 11:06:22
Done.
| |
| 3892 if (new_map.is_null()) return Handle<Object>(); | |
| 3893 JSObject::MigrateToMap(object, new_map); | |
| 3886 if (FLAG_trace_migration) { | 3894 if (FLAG_trace_migration) { |
| 3887 object->PrintInstanceMigration(stdout, *original_map, object->map()); | 3895 object->PrintInstanceMigration(stdout, *original_map, object->map()); |
| 3888 } | 3896 } |
| 3889 return object; | 3897 return object; |
| 3890 } | 3898 } |
| 3891 | 3899 |
| 3892 | 3900 |
| 3893 Handle<Object> JSObject::SetPropertyUsingTransition( | 3901 Handle<Object> JSObject::SetPropertyUsingTransition( |
| 3894 Handle<JSObject> object, | 3902 Handle<JSObject> object, |
| 3895 LookupResult* lookup, | 3903 LookupResult* lookup, |
| (...skipping 12755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16651 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16659 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16652 static const char* error_messages_[] = { | 16660 static const char* error_messages_[] = { |
| 16653 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16661 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16654 }; | 16662 }; |
| 16655 #undef ERROR_MESSAGES_TEXTS | 16663 #undef ERROR_MESSAGES_TEXTS |
| 16656 return error_messages_[reason]; | 16664 return error_messages_[reason]; |
| 16657 } | 16665 } |
| 16658 | 16666 |
| 16659 | 16667 |
| 16660 } } // namespace v8::internal | 16668 } } // namespace v8::internal |
| OLD | NEW |