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 4461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6908 MaybeObject* added_elements = set_elements_transition_map(new_map); | 6918 MaybeObject* added_elements = set_elements_transition_map(new_map); |
6909 if (added_elements->IsFailure()) return added_elements; | 6919 if (added_elements->IsFailure()) return added_elements; |
6910 new_map->SetBackPointer(this); | 6920 new_map->SetBackPointer(this); |
6911 } | 6921 } |
6912 | 6922 |
6913 return new_map; | 6923 return new_map; |
6914 } | 6924 } |
6915 | 6925 |
6916 | 6926 |
6917 Handle<Map> Map::CopyForObserved(Handle<Map> map) { | 6927 Handle<Map> Map::CopyForObserved(Handle<Map> map) { |
6918 CALL_HEAP_FUNCTION(map->GetIsolate(), | 6928 ASSERT(!map->is_observed()); |
6919 map->CopyForObserved(), | |
6920 Map); | |
6921 } | |
6922 | 6929 |
6923 | 6930 Isolate* isolate = map->GetIsolate(); |
6924 MaybeObject* Map::CopyForObserved() { | |
6925 ASSERT(!is_observed()); | |
6926 | 6931 |
6927 // In case the map owned its own descriptors, share the descriptors and | 6932 // In case the map owned its own descriptors, share the descriptors and |
6928 // transfer ownership to the new map. | 6933 // transfer ownership to the new map. |
6929 Map* new_map; | 6934 Handle<Map> new_map; |
6930 MaybeObject* maybe_new_map; | 6935 if (map->owns_descriptors()) { |
6931 if (owns_descriptors()) { | 6936 new_map = Map::CopyDropDescriptors(map); |
6932 maybe_new_map = CopyDropDescriptors(); | |
6933 } else { | 6937 } else { |
6934 maybe_new_map = Copy(); | 6938 new_map = Map::Copy(map); |
6935 } | 6939 } |
6936 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | |
6937 | 6940 |
6938 TransitionArray* transitions; | 6941 Handle<TransitionArray> transitions = |
6939 MaybeObject* maybe_transitions = AddTransition(GetHeap()->observed_symbol(), | 6942 Map::AddTransition(map, handle(isolate->heap()->observed_symbol()), |
Michael Starzinger
2013/10/22 09:28:22
nit: Better use isolate->factory()->observed_symbo
rafaelw
2013/10/22 17:24:08
Done.
| |
6940 new_map, | 6943 new_map, |
6941 FULL_TRANSITION); | 6944 FULL_TRANSITION); |
6942 if (!maybe_transitions->To(&transitions)) return maybe_transitions; | 6945 |
6943 set_transitions(transitions); | 6946 map->set_transitions(*transitions); |
6944 | 6947 |
6945 new_map->set_is_observed(true); | 6948 new_map->set_is_observed(true); |
6946 | 6949 |
6947 if (owns_descriptors()) { | 6950 if (map->owns_descriptors()) { |
6948 new_map->InitializeDescriptors(instance_descriptors()); | 6951 new_map->InitializeDescriptors(map->instance_descriptors()); |
6949 set_owns_descriptors(false); | 6952 map->set_owns_descriptors(false); |
6950 } | 6953 } |
6951 | 6954 |
6952 new_map->SetBackPointer(this); | 6955 new_map->SetBackPointer(*map); |
6953 return new_map; | 6956 return new_map; |
6954 } | 6957 } |
6955 | 6958 |
6956 | 6959 |
6957 MaybeObject* Map::CopyWithPreallocatedFieldDescriptors() { | 6960 MaybeObject* Map::CopyWithPreallocatedFieldDescriptors() { |
6958 if (pre_allocated_property_fields() == 0) return CopyDropDescriptors(); | 6961 if (pre_allocated_property_fields() == 0) return CopyDropDescriptors(); |
6959 | 6962 |
6960 // If the map has pre-allocated properties always start out with a descriptor | 6963 // If the map has pre-allocated properties always start out with a descriptor |
6961 // array describing these properties. | 6964 // array describing these properties. |
6962 ASSERT(constructor()->IsJSFunction()); | 6965 ASSERT(constructor()->IsJSFunction()); |
(...skipping 9406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16369 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16372 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16370 static const char* error_messages_[] = { | 16373 static const char* error_messages_[] = { |
16371 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16374 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16372 }; | 16375 }; |
16373 #undef ERROR_MESSAGES_TEXTS | 16376 #undef ERROR_MESSAGES_TEXTS |
16374 return error_messages_[reason]; | 16377 return error_messages_[reason]; |
16375 } | 16378 } |
16376 | 16379 |
16377 | 16380 |
16378 } } // namespace v8::internal | 16381 } } // namespace v8::internal |
OLD | NEW |