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 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 // size and install the backing store into the object. | 2427 // size and install the backing store into the object. |
2428 if (external > 0) { | 2428 if (external > 0) { |
2429 RightTrimFixedArray<FROM_MUTATOR>(isolate->heap(), *array, inobject); | 2429 RightTrimFixedArray<FROM_MUTATOR>(isolate->heap(), *array, inobject); |
2430 object->set_properties(*array); | 2430 object->set_properties(*array); |
2431 } | 2431 } |
2432 | 2432 |
2433 object->set_map(*new_map); | 2433 object->set_map(*new_map); |
2434 } | 2434 } |
2435 | 2435 |
2436 | 2436 |
| 2437 Handle<TransitionArray> Map::AddTransition(Handle<Map> map, |
| 2438 Handle<Name> key, |
| 2439 Handle<Map> target, |
| 2440 SimpleTransitionFlag flag) { |
| 2441 CALL_HEAP_FUNCTION(map->GetIsolate(), |
| 2442 map->AddTransition(*key, *target, flag), |
| 2443 TransitionArray); |
| 2444 } |
| 2445 |
| 2446 |
2437 void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object, | 2447 void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object, |
2438 int modify_index, | 2448 int modify_index, |
2439 Representation new_representation, | 2449 Representation new_representation, |
2440 StoreMode store_mode) { | 2450 StoreMode store_mode) { |
2441 Handle<Map> new_map = Map::GeneralizeRepresentation( | 2451 Handle<Map> new_map = Map::GeneralizeRepresentation( |
2442 handle(object->map()), modify_index, new_representation, store_mode); | 2452 handle(object->map()), modify_index, new_representation, store_mode); |
2443 if (object->map() == *new_map) return; | 2453 if (object->map() == *new_map) return; |
2444 return MigrateToMap(object, new_map); | 2454 return MigrateToMap(object, new_map); |
2445 } | 2455 } |
2446 | 2456 |
(...skipping 4476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6923 MaybeObject* added_elements = set_elements_transition_map(new_map); | 6933 MaybeObject* added_elements = set_elements_transition_map(new_map); |
6924 if (added_elements->IsFailure()) return added_elements; | 6934 if (added_elements->IsFailure()) return added_elements; |
6925 new_map->SetBackPointer(this); | 6935 new_map->SetBackPointer(this); |
6926 } | 6936 } |
6927 | 6937 |
6928 return new_map; | 6938 return new_map; |
6929 } | 6939 } |
6930 | 6940 |
6931 | 6941 |
6932 Handle<Map> Map::CopyForObserved(Handle<Map> map) { | 6942 Handle<Map> Map::CopyForObserved(Handle<Map> map) { |
6933 CALL_HEAP_FUNCTION(map->GetIsolate(), | 6943 ASSERT(!map->is_observed()); |
6934 map->CopyForObserved(), | |
6935 Map); | |
6936 } | |
6937 | 6944 |
6938 | 6945 Isolate* isolate = map->GetIsolate(); |
6939 MaybeObject* Map::CopyForObserved() { | |
6940 ASSERT(!is_observed()); | |
6941 | 6946 |
6942 // In case the map owned its own descriptors, share the descriptors and | 6947 // In case the map owned its own descriptors, share the descriptors and |
6943 // transfer ownership to the new map. | 6948 // transfer ownership to the new map. |
6944 Map* new_map; | 6949 Handle<Map> new_map; |
6945 MaybeObject* maybe_new_map; | 6950 if (map->owns_descriptors()) { |
6946 if (owns_descriptors()) { | 6951 new_map = Map::CopyDropDescriptors(map); |
6947 maybe_new_map = CopyDropDescriptors(); | |
6948 } else { | 6952 } else { |
6949 maybe_new_map = Copy(); | 6953 new_map = Map::Copy(map); |
6950 } | 6954 } |
6951 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | |
6952 | 6955 |
6953 TransitionArray* transitions; | 6956 Handle<TransitionArray> transitions = |
6954 MaybeObject* maybe_transitions = AddTransition(GetHeap()->observed_symbol(), | 6957 Map::AddTransition(map, isolate->factory()->observed_symbol(), new_map, |
6955 new_map, | 6958 FULL_TRANSITION); |
6956 FULL_TRANSITION); | 6959 |
6957 if (!maybe_transitions->To(&transitions)) return maybe_transitions; | 6960 map->set_transitions(*transitions); |
6958 set_transitions(transitions); | |
6959 | 6961 |
6960 new_map->set_is_observed(true); | 6962 new_map->set_is_observed(true); |
6961 | 6963 |
6962 if (owns_descriptors()) { | 6964 if (map->owns_descriptors()) { |
6963 new_map->InitializeDescriptors(instance_descriptors()); | 6965 new_map->InitializeDescriptors(map->instance_descriptors()); |
6964 set_owns_descriptors(false); | 6966 map->set_owns_descriptors(false); |
6965 } | 6967 } |
6966 | 6968 |
6967 new_map->SetBackPointer(this); | 6969 new_map->SetBackPointer(*map); |
6968 return new_map; | 6970 return new_map; |
6969 } | 6971 } |
6970 | 6972 |
6971 | 6973 |
6972 MaybeObject* Map::CopyWithPreallocatedFieldDescriptors() { | 6974 MaybeObject* Map::CopyWithPreallocatedFieldDescriptors() { |
6973 if (pre_allocated_property_fields() == 0) return CopyDropDescriptors(); | 6975 if (pre_allocated_property_fields() == 0) return CopyDropDescriptors(); |
6974 | 6976 |
6975 // If the map has pre-allocated properties always start out with a descriptor | 6977 // If the map has pre-allocated properties always start out with a descriptor |
6976 // array describing these properties. | 6978 // array describing these properties. |
6977 ASSERT(constructor()->IsJSFunction()); | 6979 ASSERT(constructor()->IsJSFunction()); |
(...skipping 9406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16384 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16386 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16385 static const char* error_messages_[] = { | 16387 static const char* error_messages_[] = { |
16386 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16388 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16387 }; | 16389 }; |
16388 #undef ERROR_MESSAGES_TEXTS | 16390 #undef ERROR_MESSAGES_TEXTS |
16389 return error_messages_[reason]; | 16391 return error_messages_[reason]; |
16390 } | 16392 } |
16391 | 16393 |
16392 | 16394 |
16393 } } // namespace v8::internal | 16395 } } // namespace v8::internal |
OLD | NEW |