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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2702 old_map->PrintGeneralization( | 2702 old_map->PrintGeneralization( |
2703 stdout, "", modify_index, split_nof, old_nof, | 2703 stdout, "", modify_index, split_nof, old_nof, |
2704 old_details.type() == CONSTANT && store_mode == FORCE_FIELD, | 2704 old_details.type() == CONSTANT && store_mode == FORCE_FIELD, |
2705 old_details.representation(), new_details.representation(), | 2705 old_details.representation(), new_details.representation(), |
2706 *old_field_type, *new_field_type); | 2706 *old_field_type, *new_field_type); |
2707 } | 2707 } |
2708 | 2708 |
2709 // Add missing transitions. | 2709 // Add missing transitions. |
2710 Handle<Map> new_map = split_map; | 2710 Handle<Map> new_map = split_map; |
2711 for (int i = split_nof; i < old_nof; ++i) { | 2711 for (int i = split_nof; i < old_nof; ++i) { |
| 2712 if (!new_map->CanHaveMoreTransitions()) { |
| 2713 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, |
| 2714 "can't have more transitions"); |
| 2715 } |
2712 new_map = CopyInstallDescriptors(new_map, i, new_descriptors); | 2716 new_map = CopyInstallDescriptors(new_map, i, new_descriptors); |
2713 } | 2717 } |
2714 new_map->set_owns_descriptors(true); | 2718 new_map->set_owns_descriptors(true); |
2715 return new_map; | 2719 return new_map; |
2716 } | 2720 } |
2717 | 2721 |
2718 | 2722 |
2719 // Generalize the representation of all FIELD descriptors. | 2723 // Generalize the representation of all FIELD descriptors. |
2720 Handle<Map> Map::GeneralizeAllFieldRepresentations( | 2724 Handle<Map> Map::GeneralizeAllFieldRepresentations( |
2721 Handle<Map> map) { | 2725 Handle<Map> map) { |
(...skipping 3855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6577 | 6581 |
6578 Handle<Map> result = CopyDropDescriptors(map); | 6582 Handle<Map> result = CopyDropDescriptors(map); |
6579 Handle<Name> name = descriptor->GetKey(); | 6583 Handle<Name> name = descriptor->GetKey(); |
6580 | 6584 |
6581 // Ensure there's space for the new descriptor in the shared descriptor array. | 6585 // Ensure there's space for the new descriptor in the shared descriptor array. |
6582 if (descriptors->NumberOfSlackDescriptors() == 0) { | 6586 if (descriptors->NumberOfSlackDescriptors() == 0) { |
6583 int old_size = descriptors->number_of_descriptors(); | 6587 int old_size = descriptors->number_of_descriptors(); |
6584 if (old_size == 0) { | 6588 if (old_size == 0) { |
6585 descriptors = DescriptorArray::Allocate(map->GetIsolate(), 0, 1); | 6589 descriptors = DescriptorArray::Allocate(map->GetIsolate(), 0, 1); |
6586 } else { | 6590 } else { |
6587 EnsureDescriptorSlack(map, old_size < 4 ? 1 : old_size / 2); | 6591 EnsureDescriptorSlack( |
| 6592 map, SlackForArraySize(old_size, kMaxNumberOfDescriptors)); |
6588 descriptors = handle(map->instance_descriptors()); | 6593 descriptors = handle(map->instance_descriptors()); |
6589 } | 6594 } |
6590 } | 6595 } |
6591 | 6596 |
6592 { | 6597 { |
6593 DisallowHeapAllocation no_gc; | 6598 DisallowHeapAllocation no_gc; |
6594 descriptors->Append(descriptor); | 6599 descriptors->Append(descriptor); |
6595 result->InitializeDescriptors(*descriptors); | 6600 result->InitializeDescriptors(*descriptors); |
6596 } | 6601 } |
6597 | 6602 |
6598 DCHECK(result->NumberOfOwnDescriptors() == map->NumberOfOwnDescriptors() + 1); | 6603 DCHECK(result->NumberOfOwnDescriptors() == map->NumberOfOwnDescriptors() + 1); |
6599 ConnectTransition(map, result, name, SIMPLE_TRANSITION); | 6604 ConnectTransition(map, result, name, SIMPLE_TRANSITION); |
6600 | 6605 |
6601 return result; | 6606 return result; |
6602 } | 6607 } |
6603 | 6608 |
6604 | 6609 |
6605 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, | 6610 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, |
6606 Handle<Name> name, SimpleTransitionFlag flag) { | 6611 Handle<Name> name, SimpleTransitionFlag flag) { |
6607 parent->set_owns_descriptors(false); | 6612 parent->set_owns_descriptors(false); |
6608 if (parent->is_prototype_map()) { | 6613 if (parent->is_prototype_map()) { |
6609 DCHECK(child->is_prototype_map()); | 6614 DCHECK(child->is_prototype_map()); |
6610 } else { | 6615 } else { |
6611 Handle<TransitionArray> transitions = | 6616 Handle<TransitionArray> transitions = |
6612 TransitionArray::CopyInsert(parent, name, child, flag); | 6617 TransitionArray::Insert(parent, name, child, flag); |
6613 parent->set_transitions(*transitions); | 6618 if (!parent->HasTransitionArray() || |
| 6619 *transitions != parent->transitions()) { |
| 6620 parent->set_transitions(*transitions); |
| 6621 } |
6614 child->SetBackPointer(*parent); | 6622 child->SetBackPointer(*parent); |
6615 } | 6623 } |
6616 } | 6624 } |
6617 | 6625 |
6618 | 6626 |
6619 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, | 6627 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, |
6620 Handle<DescriptorArray> descriptors, | 6628 Handle<DescriptorArray> descriptors, |
6621 TransitionFlag flag, | 6629 TransitionFlag flag, |
6622 MaybeHandle<Name> maybe_name, | 6630 MaybeHandle<Name> maybe_name, |
6623 SimpleTransitionFlag simple_flag) { | 6631 SimpleTransitionFlag simple_flag) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6683 DICTIONARY_ELEMENTS || | 6691 DICTIONARY_ELEMENTS || |
6684 IsExternalArrayElementsKind( | 6692 IsExternalArrayElementsKind( |
6685 map->elements_transition_map()->elements_kind())) && | 6693 map->elements_transition_map()->elements_kind())) && |
6686 (kind == DICTIONARY_ELEMENTS || | 6694 (kind == DICTIONARY_ELEMENTS || |
6687 IsExternalArrayElementsKind(kind)))); | 6695 IsExternalArrayElementsKind(kind)))); |
6688 DCHECK(!IsFastElementsKind(kind) || | 6696 DCHECK(!IsFastElementsKind(kind) || |
6689 IsMoreGeneralElementsKindTransition(map->elements_kind(), kind)); | 6697 IsMoreGeneralElementsKindTransition(map->elements_kind(), kind)); |
6690 DCHECK(kind != map->elements_kind()); | 6698 DCHECK(kind != map->elements_kind()); |
6691 } | 6699 } |
6692 | 6700 |
6693 bool insert_transition = | 6701 bool insert_transition = flag == INSERT_TRANSITION && |
6694 flag == INSERT_TRANSITION && !map->HasElementsTransition(); | 6702 map->CanHaveMoreTransitions() && |
| 6703 !map->HasElementsTransition(); |
6695 | 6704 |
6696 if (insert_transition && map->owns_descriptors()) { | 6705 if (insert_transition && map->owns_descriptors()) { |
6697 // In case the map owned its own descriptors, share the descriptors and | 6706 // In case the map owned its own descriptors, share the descriptors and |
6698 // transfer ownership to the new map. | 6707 // transfer ownership to the new map. |
6699 Handle<Map> new_map = CopyDropDescriptors(map); | 6708 Handle<Map> new_map = CopyDropDescriptors(map); |
6700 | 6709 |
6701 ConnectElementsTransition(map, new_map); | 6710 ConnectElementsTransition(map, new_map); |
6702 | 6711 |
6703 new_map->set_elements_kind(kind); | 6712 new_map->set_elements_kind(kind); |
6704 new_map->InitializeDescriptors(map->instance_descriptors()); | 6713 new_map->InitializeDescriptors(map->instance_descriptors()); |
(...skipping 28 matching lines...) Expand all Loading... |
6733 } else { | 6742 } else { |
6734 DCHECK(!map->is_prototype_map()); | 6743 DCHECK(!map->is_prototype_map()); |
6735 new_map = Copy(map); | 6744 new_map = Copy(map); |
6736 } | 6745 } |
6737 | 6746 |
6738 new_map->set_is_observed(); | 6747 new_map->set_is_observed(); |
6739 if (map->owns_descriptors()) { | 6748 if (map->owns_descriptors()) { |
6740 new_map->InitializeDescriptors(map->instance_descriptors()); | 6749 new_map->InitializeDescriptors(map->instance_descriptors()); |
6741 } | 6750 } |
6742 | 6751 |
6743 Handle<Name> name = isolate->factory()->observed_symbol(); | 6752 if (map->CanHaveMoreTransitions()) { |
6744 ConnectTransition(map, new_map, name, FULL_TRANSITION); | 6753 Handle<Name> name = isolate->factory()->observed_symbol(); |
6745 | 6754 ConnectTransition(map, new_map, name, FULL_TRANSITION); |
| 6755 } |
6746 return new_map; | 6756 return new_map; |
6747 } | 6757 } |
6748 | 6758 |
6749 | 6759 |
6750 Handle<Map> Map::Copy(Handle<Map> map) { | 6760 Handle<Map> Map::Copy(Handle<Map> map) { |
6751 Handle<DescriptorArray> descriptors(map->instance_descriptors()); | 6761 Handle<DescriptorArray> descriptors(map->instance_descriptors()); |
6752 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); | 6762 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); |
6753 Handle<DescriptorArray> new_descriptors = | 6763 Handle<DescriptorArray> new_descriptors = |
6754 DescriptorArray::CopyUpTo(descriptors, number_of_own_descriptors); | 6764 DescriptorArray::CopyUpTo(descriptors, number_of_own_descriptors); |
6755 return CopyReplaceDescriptors( | 6765 return CopyReplaceDescriptors( |
(...skipping 9740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16496 Handle<DependentCode> codes = | 16506 Handle<DependentCode> codes = |
16497 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16507 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
16498 DependentCode::kPropertyCellChangedGroup, | 16508 DependentCode::kPropertyCellChangedGroup, |
16499 info->object_wrapper()); | 16509 info->object_wrapper()); |
16500 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16510 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
16501 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16511 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
16502 cell, info->zone()); | 16512 cell, info->zone()); |
16503 } | 16513 } |
16504 | 16514 |
16505 } } // namespace v8::internal | 16515 } } // namespace v8::internal |
OLD | NEW |