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 6566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6577 | 6577 |
6578 Handle<Map> result = CopyDropDescriptors(map); | 6578 Handle<Map> result = CopyDropDescriptors(map); |
6579 Handle<Name> name = descriptor->GetKey(); | 6579 Handle<Name> name = descriptor->GetKey(); |
6580 | 6580 |
6581 // Ensure there's space for the new descriptor in the shared descriptor array. | 6581 // Ensure there's space for the new descriptor in the shared descriptor array. |
6582 if (descriptors->NumberOfSlackDescriptors() == 0) { | 6582 if (descriptors->NumberOfSlackDescriptors() == 0) { |
6583 int old_size = descriptors->number_of_descriptors(); | 6583 int old_size = descriptors->number_of_descriptors(); |
6584 if (old_size == 0) { | 6584 if (old_size == 0) { |
6585 descriptors = DescriptorArray::Allocate(map->GetIsolate(), 0, 1); | 6585 descriptors = DescriptorArray::Allocate(map->GetIsolate(), 0, 1); |
6586 } else { | 6586 } else { |
6587 EnsureDescriptorSlack( | 6587 EnsureDescriptorSlack(map, old_size < 4 ? 1 : old_size / 2); |
6588 map, SlackForArraySize(old_size, kMaxNumberOfDescriptors)); | |
6589 descriptors = handle(map->instance_descriptors()); | 6588 descriptors = handle(map->instance_descriptors()); |
6590 } | 6589 } |
6591 } | 6590 } |
6592 | 6591 |
6593 { | 6592 { |
6594 DisallowHeapAllocation no_gc; | 6593 DisallowHeapAllocation no_gc; |
6595 descriptors->Append(descriptor); | 6594 descriptors->Append(descriptor); |
6596 result->InitializeDescriptors(*descriptors); | 6595 result->InitializeDescriptors(*descriptors); |
6597 } | 6596 } |
6598 | 6597 |
6599 DCHECK(result->NumberOfOwnDescriptors() == map->NumberOfOwnDescriptors() + 1); | 6598 DCHECK(result->NumberOfOwnDescriptors() == map->NumberOfOwnDescriptors() + 1); |
6600 ConnectTransition(map, result, name, SIMPLE_TRANSITION); | 6599 ConnectTransition(map, result, name, SIMPLE_TRANSITION); |
6601 | 6600 |
6602 return result; | 6601 return result; |
6603 } | 6602 } |
6604 | 6603 |
6605 | 6604 |
6606 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, | 6605 void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, |
6607 Handle<Name> name, SimpleTransitionFlag flag) { | 6606 Handle<Name> name, SimpleTransitionFlag flag) { |
6608 parent->set_owns_descriptors(false); | 6607 parent->set_owns_descriptors(false); |
6609 if (parent->is_prototype_map()) { | 6608 if (parent->is_prototype_map()) { |
6610 DCHECK(child->is_prototype_map()); | 6609 DCHECK(child->is_prototype_map()); |
6611 } else { | 6610 } else { |
6612 Handle<TransitionArray> transitions = | 6611 Handle<TransitionArray> transitions = |
6613 TransitionArray::Insert(parent, name, child, flag); | 6612 TransitionArray::CopyInsert(parent, name, child, flag); |
6614 if (!parent->HasTransitionArray() || | 6613 parent->set_transitions(*transitions); |
6615 *transitions != parent->transitions()) { | |
6616 parent->set_transitions(*transitions); | |
6617 } | |
6618 child->SetBackPointer(*parent); | 6614 child->SetBackPointer(*parent); |
6619 } | 6615 } |
6620 } | 6616 } |
6621 | 6617 |
6622 | 6618 |
6623 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, | 6619 Handle<Map> Map::CopyReplaceDescriptors(Handle<Map> map, |
6624 Handle<DescriptorArray> descriptors, | 6620 Handle<DescriptorArray> descriptors, |
6625 TransitionFlag flag, | 6621 TransitionFlag flag, |
6626 MaybeHandle<Name> maybe_name, | 6622 MaybeHandle<Name> maybe_name, |
6627 SimpleTransitionFlag simple_flag) { | 6623 SimpleTransitionFlag simple_flag) { |
(...skipping 9872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16500 Handle<DependentCode> codes = | 16496 Handle<DependentCode> codes = |
16501 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16497 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
16502 DependentCode::kPropertyCellChangedGroup, | 16498 DependentCode::kPropertyCellChangedGroup, |
16503 info->object_wrapper()); | 16499 info->object_wrapper()); |
16504 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16500 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
16505 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16501 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
16506 cell, info->zone()); | 16502 cell, info->zone()); |
16507 } | 16503 } |
16508 | 16504 |
16509 } } // namespace v8::internal | 16505 } } // namespace v8::internal |
OLD | NEW |