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

Side by Side Diff: src/objects.cc

Issue 401243003: Rename CurrentMapForDeprecated to TryUpdate, and introduce Map::Update which potentially deprecates (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/type-info.cc » ('j') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 2843 matching lines...) Expand 10 before | Expand all | Expand 10 after
2854 map = GeneralizeRepresentation(map, i, Representation::Tagged(), 2854 map = GeneralizeRepresentation(map, i, Representation::Tagged(),
2855 HeapType::Any(map->GetIsolate()), 2855 HeapType::Any(map->GetIsolate()),
2856 FORCE_FIELD); 2856 FORCE_FIELD);
2857 } 2857 }
2858 } 2858 }
2859 return map; 2859 return map;
2860 } 2860 }
2861 2861
2862 2862
2863 // static 2863 // static
2864 MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) { 2864 MaybeHandle<Map> Map::TryUpdate(Handle<Map> map) {
2865 Handle<Map> proto_map(map); 2865 Handle<Map> proto_map(map);
2866 while (proto_map->prototype()->IsJSObject()) { 2866 while (proto_map->prototype()->IsJSObject()) {
2867 Handle<JSObject> holder(JSObject::cast(proto_map->prototype())); 2867 Handle<JSObject> holder(JSObject::cast(proto_map->prototype()));
2868 proto_map = Handle<Map>(holder->map()); 2868 proto_map = Handle<Map>(holder->map());
2869 if (proto_map->is_deprecated() && JSObject::TryMigrateInstance(holder)) { 2869 if (proto_map->is_deprecated() && JSObject::TryMigrateInstance(holder)) {
2870 proto_map = Handle<Map>(holder->map()); 2870 proto_map = Handle<Map>(holder->map());
2871 } 2871 }
2872 } 2872 }
2873 return CurrentMapForDeprecatedInternal(map); 2873 return TryUpdateInternal(map);
2874 } 2874 }
2875 2875
2876 2876
2877 // static 2877 // static
2878 MaybeHandle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> old_map) { 2878 Handle<Map> Map::Update(Handle<Map> map) {
2879 return GeneralizeRepresentation(map, 0, Representation::None(),
2880 HeapType::None(map->GetIsolate()),
2881 ALLOW_AS_CONSTANT);
2882 }
2883
2884
2885 // static
2886 MaybeHandle<Map> Map::TryUpdateInternal(Handle<Map> old_map) {
2879 DisallowHeapAllocation no_allocation; 2887 DisallowHeapAllocation no_allocation;
2880 DisallowDeoptimization no_deoptimization(old_map->GetIsolate()); 2888 DisallowDeoptimization no_deoptimization(old_map->GetIsolate());
2881 2889
2882 if (!old_map->is_deprecated()) return old_map; 2890 if (!old_map->is_deprecated()) return old_map;
2883 2891
2884 // Check the state of the root map. 2892 // Check the state of the root map.
2885 Map* root_map = old_map->FindRootMap(); 2893 Map* root_map = old_map->FindRootMap();
2886 if (!old_map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>(); 2894 if (!old_map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>();
2887 int root_nof = root_map->NumberOfOwnDescriptors(); 2895 int root_nof = root_map->NumberOfOwnDescriptors();
2888 2896
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 } else { 3941 } else {
3934 TransitionElementsKind(object, to_kind); 3942 TransitionElementsKind(object, to_kind);
3935 } 3943 }
3936 map = Map::AsElementsKind(map, to_kind); 3944 map = Map::AsElementsKind(map, to_kind);
3937 } 3945 }
3938 JSObject::MigrateToMap(object, map); 3946 JSObject::MigrateToMap(object, map);
3939 } 3947 }
3940 3948
3941 3949
3942 void JSObject::MigrateInstance(Handle<JSObject> object) { 3950 void JSObject::MigrateInstance(Handle<JSObject> object) {
3943 // Converting any field to the most specific type will cause the
3944 // GeneralizeFieldRepresentation algorithm to create the most general existing
3945 // transition that matches the object. This achieves what is needed.
3946 Handle<Map> original_map(object->map()); 3951 Handle<Map> original_map(object->map());
3947 GeneralizeFieldRepresentation( 3952 Handle<Map> map = Map::Update(original_map);
3948 object, 0, Representation::None(), 3953 map->set_migration_target(true);
3949 HeapType::None(object->GetIsolate()), 3954 MigrateToMap(object, map);
3950 ALLOW_AS_CONSTANT);
3951 object->map()->set_migration_target(true);
3952 if (FLAG_trace_migration) { 3955 if (FLAG_trace_migration) {
3953 object->PrintInstanceMigration(stdout, *original_map, object->map()); 3956 object->PrintInstanceMigration(stdout, *original_map, *map);
3954 } 3957 }
3955 } 3958 }
3956 3959
3957 3960
3958 // static 3961 // static
3959 bool JSObject::TryMigrateInstance(Handle<JSObject> object) { 3962 bool JSObject::TryMigrateInstance(Handle<JSObject> object) {
3960 Isolate* isolate = object->GetIsolate(); 3963 Isolate* isolate = object->GetIsolate();
3961 DisallowDeoptimization no_deoptimization(isolate); 3964 DisallowDeoptimization no_deoptimization(isolate);
3962 Handle<Map> original_map(object->map(), isolate); 3965 Handle<Map> original_map(object->map(), isolate);
3963 Handle<Map> new_map; 3966 Handle<Map> new_map;
3964 if (!Map::CurrentMapForDeprecatedInternal(original_map).ToHandle(&new_map)) { 3967 if (!Map::TryUpdate(original_map).ToHandle(&new_map)) {
3965 return false; 3968 return false;
3966 } 3969 }
3967 JSObject::MigrateToMap(object, new_map); 3970 JSObject::MigrateToMap(object, new_map);
3968 if (FLAG_trace_migration) { 3971 if (FLAG_trace_migration) {
3969 object->PrintInstanceMigration(stdout, *original_map, object->map()); 3972 object->PrintInstanceMigration(stdout, *original_map, object->map());
3970 } 3973 }
3971 return true; 3974 return true;
3972 } 3975 }
3973 3976
3974 3977
(...skipping 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after
7319 return false; 7322 return false;
7320 } 7323 }
7321 7324
7322 7325
7323 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor, 7326 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor,
7324 Handle<Object> value) { 7327 Handle<Object> value) {
7325 // Dictionaries can store any property value. 7328 // Dictionaries can store any property value.
7326 if (map->is_dictionary_map()) return map; 7329 if (map->is_dictionary_map()) return map;
7327 7330
7328 // Migrate to the newest map before storing the property. 7331 // Migrate to the newest map before storing the property.
7329 if (map->is_deprecated()) { 7332 if (map->is_deprecated()) map = Update(map);
7330 map = GeneralizeRepresentation(map, 0, Representation::None(),
7331 HeapType::None(map->GetIsolate()),
7332 ALLOW_AS_CONSTANT);
7333 }
7334 7333
7335 Handle<DescriptorArray> descriptors(map->instance_descriptors()); 7334 Handle<DescriptorArray> descriptors(map->instance_descriptors());
7336 7335
7337 if (descriptors->CanHoldValue(descriptor, *value)) return map; 7336 if (descriptors->CanHoldValue(descriptor, *value)) return map;
7338 7337
7339 Isolate* isolate = map->GetIsolate(); 7338 Isolate* isolate = map->GetIsolate();
7340 Representation representation = value->OptimalRepresentation(); 7339 Representation representation = value->OptimalRepresentation();
7341 Handle<HeapType> type = value->OptimalType(isolate, representation); 7340 Handle<HeapType> type = value->OptimalType(isolate, representation);
7342 7341
7343 return GeneralizeRepresentation(map, descriptor, representation, type, 7342 return GeneralizeRepresentation(map, descriptor, representation, type,
7344 FORCE_FIELD); 7343 FORCE_FIELD);
7345 } 7344 }
7346 7345
7347 7346
7348 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, 7347 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
7349 Handle<Object> value, 7348 Handle<Object> value,
7350 PropertyAttributes attributes, 7349 PropertyAttributes attributes,
7351 StoreFromKeyed store_mode) { 7350 StoreFromKeyed store_mode) {
7352 // Dictionary maps can always have additional data properties. 7351 // Dictionary maps can always have additional data properties.
7353 if (map->is_dictionary_map()) return map; 7352 if (map->is_dictionary_map()) return map;
7354 7353
7355 // Migrate to the newest map before transitioning to the new property. 7354 // Migrate to the newest map before transitioning to the new property.
7356 if (map->is_deprecated()) { 7355 if (map->is_deprecated()) map = Update(map);
7357 map = GeneralizeRepresentation(map, 0, Representation::None(),
7358 HeapType::None(map->GetIsolate()),
7359 ALLOW_AS_CONSTANT);
7360 }
7361 7356
7362 int index = map->SearchTransition(*name); 7357 int index = map->SearchTransition(*name);
7363 if (index != TransitionArray::kNotFound) { 7358 if (index != TransitionArray::kNotFound) {
7364 Handle<Map> transition(map->GetTransition(index)); 7359 Handle<Map> transition(map->GetTransition(index));
7365 int descriptor = transition->LastAdded(); 7360 int descriptor = transition->LastAdded();
7366 7361
7367 // TODO(verwaest): Handle attributes better. 7362 // TODO(verwaest): Handle attributes better.
7368 DescriptorArray* descriptors = transition->instance_descriptors(); 7363 DescriptorArray* descriptors = transition->instance_descriptors();
7369 if (descriptors->GetDetails(descriptor).attributes() != attributes) { 7364 if (descriptors->GetDetails(descriptor).attributes() != attributes) {
7370 return CopyGeneralizeAllRepresentations(transition, descriptor, 7365 return CopyGeneralizeAllRepresentations(transition, descriptor,
(...skipping 9589 matching lines...) Expand 10 before | Expand all | Expand 10 after
16960 #define ERROR_MESSAGES_TEXTS(C, T) T, 16955 #define ERROR_MESSAGES_TEXTS(C, T) T,
16961 static const char* error_messages_[] = { 16956 static const char* error_messages_[] = {
16962 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16957 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16963 }; 16958 };
16964 #undef ERROR_MESSAGES_TEXTS 16959 #undef ERROR_MESSAGES_TEXTS
16965 return error_messages_[reason]; 16960 return error_messages_[reason];
16966 } 16961 }
16967 16962
16968 16963
16969 } } // namespace v8::internal 16964 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/type-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698