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

Side by Side Diff: src/objects.cc

Issue 228483005: Bugfix: A TransitionArray can disappear during copy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 years, 8 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/transitions.h » ('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 // 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 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 ASSERT(target_number_of_fields + target_unused == target_inobject); 2368 ASSERT(target_number_of_fields + target_unused == target_inobject);
2369 return false; 2369 return false;
2370 } 2370 }
2371 // Otherwise, properties will need to be moved to the backing store. 2371 // Otherwise, properties will need to be moved to the backing store.
2372 return true; 2372 return true;
2373 } 2373 }
2374 2374
2375 2375
2376 Handle<TransitionArray> Map::SetElementsTransitionMap( 2376 Handle<TransitionArray> Map::SetElementsTransitionMap(
2377 Handle<Map> map, Handle<Map> transitioned_map) { 2377 Handle<Map> map, Handle<Map> transitioned_map) {
2378 Handle<TransitionArray> transitions = Map::AddTransition( 2378 Handle<TransitionArray> transitions = TransitionArray::CopyInsert(
2379 map, 2379 map,
2380 map->GetIsolate()->factory()->elements_transition_symbol(), 2380 map->GetIsolate()->factory()->elements_transition_symbol(),
2381 transitioned_map, 2381 transitioned_map,
2382 FULL_TRANSITION); 2382 FULL_TRANSITION);
2383 map->set_transitions(*transitions); 2383 map->set_transitions(*transitions);
2384 return transitions; 2384 return transitions;
2385 } 2385 }
2386 2386
2387 2387
2388 // To migrate an instance to a map: 2388 // To migrate an instance to a map:
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 } 2498 }
2499 2499
2500 // The trimming is performed on a newly allocated object, which is on a 2500 // The trimming is performed on a newly allocated object, which is on a
2501 // fresly allocated page or on an already swept page. Hence, the sweeper 2501 // fresly allocated page or on an already swept page. Hence, the sweeper
2502 // thread can not get confused with the filler creation. No synchronization 2502 // thread can not get confused with the filler creation. No synchronization
2503 // needed. 2503 // needed.
2504 object->set_map(*new_map); 2504 object->set_map(*new_map);
2505 } 2505 }
2506 2506
2507 2507
2508 Handle<TransitionArray> Map::AddTransition(Handle<Map> map,
2509 Handle<Name> key,
2510 Handle<Map> target,
2511 SimpleTransitionFlag flag) {
2512 if (map->HasTransitionArray()) {
2513 return TransitionArray::CopyInsert(map, key, target);
2514 }
2515 return TransitionArray::NewWith(
2516 flag, key, target, handle(map->GetBackPointer(), map->GetIsolate()));
2517 }
2518
2519
2520 void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object, 2508 void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object,
2521 int modify_index, 2509 int modify_index,
2522 Representation new_representation, 2510 Representation new_representation,
2523 StoreMode store_mode) { 2511 StoreMode store_mode) {
2524 Handle<Map> new_map = Map::GeneralizeRepresentation( 2512 Handle<Map> new_map = Map::GeneralizeRepresentation(
2525 handle(object->map()), modify_index, new_representation, store_mode); 2513 handle(object->map()), modify_index, new_representation, store_mode);
2526 if (object->map() == *new_map) return; 2514 if (object->map() == *new_map) return;
2527 return MigrateToMap(object, new_map); 2515 return MigrateToMap(object, new_map);
2528 } 2516 }
2529 2517
(...skipping 4338 matching lines...) Expand 10 before | Expand all | Expand 10 after
6868 Descriptor* descriptor) { 6856 Descriptor* descriptor) {
6869 // Sanity check. This path is only to be taken if the map owns its descriptor 6857 // Sanity check. This path is only to be taken if the map owns its descriptor
6870 // array, implying that its NumberOfOwnDescriptors equals the number of 6858 // array, implying that its NumberOfOwnDescriptors equals the number of
6871 // descriptors in the descriptor array. 6859 // descriptors in the descriptor array.
6872 ASSERT(map->NumberOfOwnDescriptors() == 6860 ASSERT(map->NumberOfOwnDescriptors() ==
6873 map->instance_descriptors()->number_of_descriptors()); 6861 map->instance_descriptors()->number_of_descriptors());
6874 6862
6875 Handle<Map> result = Map::CopyDropDescriptors(map); 6863 Handle<Map> result = Map::CopyDropDescriptors(map);
6876 Handle<Name> name = descriptor->GetKey(); 6864 Handle<Name> name = descriptor->GetKey();
6877 Handle<TransitionArray> transitions = 6865 Handle<TransitionArray> transitions =
6878 Map::AddTransition(map, name, result, SIMPLE_TRANSITION); 6866 TransitionArray::CopyInsert(map, name, result, SIMPLE_TRANSITION);
6879 6867
6880 // Ensure there's space for the new descriptor in the shared descriptor array. 6868 // Ensure there's space for the new descriptor in the shared descriptor array.
6881 if (descriptors->NumberOfSlackDescriptors() == 0) { 6869 if (descriptors->NumberOfSlackDescriptors() == 0) {
6882 int old_size = descriptors->number_of_descriptors(); 6870 int old_size = descriptors->number_of_descriptors();
6883 if (old_size == 0) { 6871 if (old_size == 0) {
6884 descriptors = map->GetIsolate()->factory()->NewDescriptorArray(0, 1); 6872 descriptors = map->GetIsolate()->factory()->NewDescriptorArray(0, 1);
6885 } else { 6873 } else {
6886 Map::EnsureDescriptorSlack(map, old_size < 4 ? 1 : old_size / 2); 6874 Map::EnsureDescriptorSlack(map, old_size < 4 ? 1 : old_size / 2);
6887 descriptors = handle(map->instance_descriptors()); 6875 descriptors = handle(map->instance_descriptors());
6888 } 6876 }
(...skipping 28 matching lines...) Expand all
6917 Handle<DescriptorArray> descriptors, 6905 Handle<DescriptorArray> descriptors,
6918 TransitionFlag flag, 6906 TransitionFlag flag,
6919 Handle<Name> name, 6907 Handle<Name> name,
6920 SimpleTransitionFlag simple_flag) { 6908 SimpleTransitionFlag simple_flag) {
6921 ASSERT(descriptors->IsSortedNoDuplicates()); 6909 ASSERT(descriptors->IsSortedNoDuplicates());
6922 6910
6923 Handle<Map> result = CopyDropDescriptors(map); 6911 Handle<Map> result = CopyDropDescriptors(map);
6924 result->InitializeDescriptors(*descriptors); 6912 result->InitializeDescriptors(*descriptors);
6925 6913
6926 if (flag == INSERT_TRANSITION && map->CanHaveMoreTransitions()) { 6914 if (flag == INSERT_TRANSITION && map->CanHaveMoreTransitions()) {
6927 Handle<TransitionArray> transitions = Map::AddTransition( 6915 Handle<TransitionArray> transitions = TransitionArray::CopyInsert(
6928 map, name, result, simple_flag); 6916 map, name, result, simple_flag);
6929 map->set_transitions(*transitions); 6917 map->set_transitions(*transitions);
6930 result->SetBackPointer(*map); 6918 result->SetBackPointer(*map);
6931 } else { 6919 } else {
6932 descriptors->InitializeRepresentations(Representation::Tagged()); 6920 descriptors->InitializeRepresentations(Representation::Tagged());
6933 } 6921 }
6934 6922
6935 return result; 6923 return result;
6936 } 6924 }
6937 6925
(...skipping 15 matching lines...) Expand all
6953 unused_property_fields = map->unused_property_fields() - 1; 6941 unused_property_fields = map->unused_property_fields() - 1;
6954 if (unused_property_fields < 0) { 6942 if (unused_property_fields < 0) {
6955 unused_property_fields += JSObject::kFieldsAdded; 6943 unused_property_fields += JSObject::kFieldsAdded;
6956 } 6944 }
6957 } 6945 }
6958 6946
6959 result->set_unused_property_fields(unused_property_fields); 6947 result->set_unused_property_fields(unused_property_fields);
6960 result->set_owns_descriptors(false); 6948 result->set_owns_descriptors(false);
6961 6949
6962 Handle<Name> name = handle(descriptors->GetKey(new_descriptor)); 6950 Handle<Name> name = handle(descriptors->GetKey(new_descriptor));
6963 Handle<TransitionArray> transitions = Map::AddTransition(map, name, result, 6951 Handle<TransitionArray> transitions = TransitionArray::CopyInsert(
6964 SIMPLE_TRANSITION); 6952 map, name, result, SIMPLE_TRANSITION);
6965 6953
6966 map->set_transitions(*transitions); 6954 map->set_transitions(*transitions);
6967 result->SetBackPointer(*map); 6955 result->SetBackPointer(*map);
6968 6956
6969 return result; 6957 return result;
6970 } 6958 }
6971 6959
6972 6960
6973 Handle<Map> Map::CopyAsElementsKind(Handle<Map> map, ElementsKind kind, 6961 Handle<Map> Map::CopyAsElementsKind(Handle<Map> map, ElementsKind kind,
6974 TransitionFlag flag) { 6962 TransitionFlag flag) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7025 7013
7026 // In case the map owned its own descriptors, share the descriptors and 7014 // In case the map owned its own descriptors, share the descriptors and
7027 // transfer ownership to the new map. 7015 // transfer ownership to the new map.
7028 Handle<Map> new_map; 7016 Handle<Map> new_map;
7029 if (map->owns_descriptors()) { 7017 if (map->owns_descriptors()) {
7030 new_map = Map::CopyDropDescriptors(map); 7018 new_map = Map::CopyDropDescriptors(map);
7031 } else { 7019 } else {
7032 new_map = Map::Copy(map); 7020 new_map = Map::Copy(map);
7033 } 7021 }
7034 7022
7035 Handle<TransitionArray> transitions = 7023 Handle<TransitionArray> transitions = TransitionArray::CopyInsert(
7036 Map::AddTransition(map, isolate->factory()->observed_symbol(), new_map, 7024 map, isolate->factory()->observed_symbol(), new_map, FULL_TRANSITION);
7037 FULL_TRANSITION);
7038 7025
7039 map->set_transitions(*transitions); 7026 map->set_transitions(*transitions);
7040 7027
7041 new_map->set_is_observed(); 7028 new_map->set_is_observed();
7042 7029
7043 if (map->owns_descriptors()) { 7030 if (map->owns_descriptors()) {
7044 new_map->InitializeDescriptors(map->instance_descriptors()); 7031 new_map->InitializeDescriptors(map->instance_descriptors());
7045 map->set_owns_descriptors(false); 7032 map->set_owns_descriptors(false);
7046 } 7033 }
7047 7034
(...skipping 9594 matching lines...) Expand 10 before | Expand all | Expand 10 after
16642 #define ERROR_MESSAGES_TEXTS(C, T) T, 16629 #define ERROR_MESSAGES_TEXTS(C, T) T,
16643 static const char* error_messages_[] = { 16630 static const char* error_messages_[] = {
16644 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16631 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16645 }; 16632 };
16646 #undef ERROR_MESSAGES_TEXTS 16633 #undef ERROR_MESSAGES_TEXTS
16647 return error_messages_[reason]; 16634 return error_messages_[reason];
16648 } 16635 }
16649 16636
16650 16637
16651 } } // namespace v8::internal 16638 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/transitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698