| OLD | NEW |
| 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 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 // converted to doubles. | 1939 // converted to doubles. |
| 1940 if (!old_map->InstancesNeedRewriting(*new_map, number_of_fields, inobject, | 1940 if (!old_map->InstancesNeedRewriting(*new_map, number_of_fields, inobject, |
| 1941 unused, &old_number_of_fields)) { | 1941 unused, &old_number_of_fields)) { |
| 1942 object->synchronized_set_map(*new_map); | 1942 object->synchronized_set_map(*new_map); |
| 1943 return; | 1943 return; |
| 1944 } | 1944 } |
| 1945 | 1945 |
| 1946 int total_size = number_of_fields + unused; | 1946 int total_size = number_of_fields + unused; |
| 1947 int external = total_size - inobject; | 1947 int external = total_size - inobject; |
| 1948 | 1948 |
| 1949 if ((old_map->unused_property_fields() == 0) && | 1949 if (number_of_fields != old_number_of_fields && |
| 1950 (number_of_fields != old_number_of_fields) && | 1950 new_map->GetBackPointer() == *old_map) { |
| 1951 (new_map->GetBackPointer() == *old_map)) { | 1951 PropertyDetails details = new_map->GetLastDescriptorDetails(); |
| 1952 |
| 1953 if (old_map->unused_property_fields() > 0) { |
| 1954 if (details.representation().IsDouble()) { |
| 1955 Handle<Object> value = isolate->factory()->NewHeapNumber(0, MUTABLE); |
| 1956 FieldIndex index = |
| 1957 FieldIndex::ForDescriptor(*new_map, new_map->LastAdded()); |
| 1958 object->FastPropertyAtPut(index, *value); |
| 1959 } |
| 1960 object->synchronized_set_map(*new_map); |
| 1961 return; |
| 1962 } |
| 1963 |
| 1952 DCHECK(number_of_fields == old_number_of_fields + 1); | 1964 DCHECK(number_of_fields == old_number_of_fields + 1); |
| 1953 // This migration is a transition from a map that has run out out property | 1965 // This migration is a transition from a map that has run out out property |
| 1954 // space. Therefore it could be done by extending the backing store. | 1966 // space. Therefore it could be done by extending the backing store. |
| 1955 Handle<FixedArray> old_storage = handle(object->properties(), isolate); | 1967 Handle<FixedArray> old_storage = handle(object->properties(), isolate); |
| 1956 Handle<FixedArray> new_storage = | 1968 Handle<FixedArray> new_storage = |
| 1957 FixedArray::CopySize(old_storage, external); | 1969 FixedArray::CopySize(old_storage, external); |
| 1958 | 1970 |
| 1959 // Properly initialize newly added property. | 1971 // Properly initialize newly added property. |
| 1960 PropertyDetails details = new_map->GetLastDescriptorDetails(); | |
| 1961 Handle<Object> value; | 1972 Handle<Object> value; |
| 1962 if (details.representation().IsDouble()) { | 1973 if (details.representation().IsDouble()) { |
| 1963 value = isolate->factory()->NewHeapNumber(0, MUTABLE); | 1974 value = isolate->factory()->NewHeapNumber(0, MUTABLE); |
| 1964 } else { | 1975 } else { |
| 1965 value = isolate->factory()->uninitialized_value(); | 1976 value = isolate->factory()->uninitialized_value(); |
| 1966 } | 1977 } |
| 1967 DCHECK(details.type() == FIELD); | 1978 DCHECK(details.type() == FIELD); |
| 1968 int target_index = details.field_index() - inobject; | 1979 int target_index = details.field_index() - inobject; |
| 1969 DCHECK(target_index >= 0); // Must be a backing store index. | 1980 DCHECK(target_index >= 0); // Must be a backing store index. |
| 1970 new_storage->set(target_index, *value); | 1981 new_storage->set(target_index, *value); |
| (...skipping 14388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16359 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16370 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16360 static const char* error_messages_[] = { | 16371 static const char* error_messages_[] = { |
| 16361 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16372 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16362 }; | 16373 }; |
| 16363 #undef ERROR_MESSAGES_TEXTS | 16374 #undef ERROR_MESSAGES_TEXTS |
| 16364 return error_messages_[reason]; | 16375 return error_messages_[reason]; |
| 16365 } | 16376 } |
| 16366 | 16377 |
| 16367 | 16378 |
| 16368 } } // namespace v8::internal | 16379 } } // namespace v8::internal |
| OLD | NEW |