Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: src/objects.cc

Issue 635883003: Limit the number of transitions allowed per hidden class. (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Patch Set: Address Toon comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698