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 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 Handle<Object> value = isolate->factory()->NewHeapNumber(0, MUTABLE); | 1955 Handle<Object> value = isolate->factory()->NewHeapNumber(0, MUTABLE); |
1956 FieldIndex index = | 1956 FieldIndex index = |
1957 FieldIndex::ForDescriptor(*new_map, new_map->LastAdded()); | 1957 FieldIndex::ForDescriptor(*new_map, new_map->LastAdded()); |
1958 object->FastPropertyAtPut(index, *value); | 1958 object->FastPropertyAtPut(index, *value); |
1959 } | 1959 } |
1960 object->synchronized_set_map(*new_map); | 1960 object->synchronized_set_map(*new_map); |
1961 return; | 1961 return; |
1962 } | 1962 } |
1963 | 1963 |
1964 DCHECK(number_of_fields == old_number_of_fields + 1); | 1964 DCHECK(number_of_fields == old_number_of_fields + 1); |
1965 // 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 of property |
1966 // space. Therefore it could be done by extending the backing store. | 1966 // space. Therefore it could be done by extending the backing store. |
1967 Handle<FixedArray> old_storage = handle(object->properties(), isolate); | 1967 Handle<FixedArray> old_storage = handle(object->properties(), isolate); |
1968 Handle<FixedArray> new_storage = | 1968 Handle<FixedArray> new_storage = |
1969 FixedArray::CopySize(old_storage, external); | 1969 FixedArray::CopySize(old_storage, external); |
1970 | 1970 |
1971 // Properly initialize newly added property. | 1971 // Properly initialize newly added property. |
1972 Handle<Object> value; | 1972 Handle<Object> value; |
1973 if (details.representation().IsDouble()) { | 1973 if (details.representation().IsDouble()) { |
1974 value = isolate->factory()->NewHeapNumber(0, MUTABLE); | 1974 value = isolate->factory()->NewHeapNumber(0, MUTABLE); |
1975 } else { | 1975 } else { |
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3735 return false; | 3735 return false; |
3736 } | 3736 } |
3737 JSObject::MigrateToMap(object, new_map); | 3737 JSObject::MigrateToMap(object, new_map); |
3738 if (FLAG_trace_migration) { | 3738 if (FLAG_trace_migration) { |
3739 object->PrintInstanceMigration(stdout, *original_map, object->map()); | 3739 object->PrintInstanceMigration(stdout, *original_map, object->map()); |
3740 } | 3740 } |
3741 return true; | 3741 return true; |
3742 } | 3742 } |
3743 | 3743 |
3744 | 3744 |
3745 void JSObject::MigrateToNewProperty(Handle<JSObject> object, | |
3746 Handle<Map> map, | |
3747 Handle<Object> value) { | |
3748 JSObject::MigrateToMap(object, map); | |
3749 if (map->GetLastDescriptorDetails().type() != FIELD) return; | |
3750 object->WriteToField(map->LastAdded(), *value); | |
3751 } | |
3752 | |
3753 | |
3754 void JSObject::WriteToField(int descriptor, Object* value) { | 3745 void JSObject::WriteToField(int descriptor, Object* value) { |
3755 DisallowHeapAllocation no_gc; | 3746 DisallowHeapAllocation no_gc; |
3756 | 3747 |
3757 DescriptorArray* desc = map()->instance_descriptors(); | 3748 DescriptorArray* desc = map()->instance_descriptors(); |
3758 PropertyDetails details = desc->GetDetails(descriptor); | 3749 PropertyDetails details = desc->GetDetails(descriptor); |
3759 | 3750 |
3760 DCHECK(details.type() == FIELD); | 3751 DCHECK(details.type() == FIELD); |
3761 | 3752 |
3762 FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor); | 3753 FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor); |
3763 if (details.representation().IsDouble()) { | 3754 if (details.representation().IsDouble()) { |
(...skipping 12602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16366 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16357 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16367 static const char* error_messages_[] = { | 16358 static const char* error_messages_[] = { |
16368 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16359 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16369 }; | 16360 }; |
16370 #undef ERROR_MESSAGES_TEXTS | 16361 #undef ERROR_MESSAGES_TEXTS |
16371 return error_messages_[reason]; | 16362 return error_messages_[reason]; |
16372 } | 16363 } |
16373 | 16364 |
16374 | 16365 |
16375 } } // namespace v8::internal | 16366 } } // namespace v8::internal |
OLD | NEW |