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 6576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6587 | 6587 |
6588 Handle<Map> result = CopyDropDescriptors(map); | 6588 Handle<Map> result = CopyDropDescriptors(map); |
6589 Handle<Name> name = descriptor->GetKey(); | 6589 Handle<Name> name = descriptor->GetKey(); |
6590 | 6590 |
6591 // Ensure there's space for the new descriptor in the shared descriptor array. | 6591 // Ensure there's space for the new descriptor in the shared descriptor array. |
6592 if (descriptors->NumberOfSlackDescriptors() == 0) { | 6592 if (descriptors->NumberOfSlackDescriptors() == 0) { |
6593 int old_size = descriptors->number_of_descriptors(); | 6593 int old_size = descriptors->number_of_descriptors(); |
6594 if (old_size == 0) { | 6594 if (old_size == 0) { |
6595 descriptors = DescriptorArray::Allocate(map->GetIsolate(), 0, 1); | 6595 descriptors = DescriptorArray::Allocate(map->GetIsolate(), 0, 1); |
6596 } else { | 6596 } else { |
6597 EnsureDescriptorSlack(map, old_size < 4 ? 1 : old_size / 2); | 6597 EnsureDescriptorSlack( |
| 6598 map, SlackForArraySize(old_size, kMaxNumberOfDescriptors)); |
6598 descriptors = handle(map->instance_descriptors()); | 6599 descriptors = handle(map->instance_descriptors()); |
6599 } | 6600 } |
6600 } | 6601 } |
6601 | 6602 |
6602 { | 6603 { |
6603 DisallowHeapAllocation no_gc; | 6604 DisallowHeapAllocation no_gc; |
6604 descriptors->Append(descriptor); | 6605 descriptors->Append(descriptor); |
6605 result->InitializeDescriptors(*descriptors); | 6606 result->InitializeDescriptors(*descriptors); |
6606 } | 6607 } |
6607 | 6608 |
6608 DCHECK(result->NumberOfOwnDescriptors() == map->NumberOfOwnDescriptors() + 1); | 6609 DCHECK(result->NumberOfOwnDescriptors() == map->NumberOfOwnDescriptors() + 1); |
6609 ConnectTransition(map, result, name, SIMPLE_TRANSITION); | 6610 ConnectTransition(map, result, name, SIMPLE_TRANSITION); |
6610 | 6611 |
6611 return result; | 6612 return result; |
6612 } | 6613 } |
6613 | 6614 |
6614 | 6615 |
6615 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, | 6616 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, |
6616 Handle<Name> name, SimpleTransitionFlag flag) { | 6617 Handle<Name> name, SimpleTransitionFlag flag) { |
6617 parent->set_owns_descriptors(false); | 6618 parent->set_owns_descriptors(false); |
6618 if (parent->is_prototype_map()) { | 6619 if (parent->is_prototype_map()) { |
6619 DCHECK(child->is_prototype_map()); | 6620 DCHECK(child->is_prototype_map()); |
6620 } else { | 6621 } else { |
6621 Handle<TransitionArray> transitions = | 6622 Handle<TransitionArray> transitions = |
6622 TransitionArray::CopyInsert(parent, name, child, flag); | 6623 TransitionArray::Insert(parent, name, child, flag); |
6623 parent->set_transitions(*transitions); | 6624 if (!parent->HasTransitionArray() || |
| 6625 *transitions != parent->transitions()) { |
| 6626 parent->set_transitions(*transitions); |
| 6627 } |
6624 child->SetBackPointer(*parent); | 6628 child->SetBackPointer(*parent); |
6625 } | 6629 } |
6626 } | 6630 } |
6627 | 6631 |
6628 | 6632 |
6629 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, | 6633 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, |
6630 Handle<DescriptorArray> descriptors, | 6634 Handle<DescriptorArray> descriptors, |
6631 TransitionFlag flag, | 6635 TransitionFlag flag, |
6632 MaybeHandle<Name> maybe_name, | 6636 MaybeHandle<Name> maybe_name, |
6633 SimpleTransitionFlag simple_flag) { | 6637 SimpleTransitionFlag simple_flag) { |
(...skipping 9835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16469 Handle<DependentCode> codes = | 16473 Handle<DependentCode> codes = |
16470 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16474 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
16471 DependentCode::kPropertyCellChangedGroup, | 16475 DependentCode::kPropertyCellChangedGroup, |
16472 info->object_wrapper()); | 16476 info->object_wrapper()); |
16473 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16477 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
16474 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16478 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
16475 cell, info->zone()); | 16479 cell, info->zone()); |
16476 } | 16480 } |
16477 | 16481 |
16478 } } // namespace v8::internal | 16482 } } // namespace v8::internal |
OLD | NEW |