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

Side by Side Diff: src/objects.cc

Issue 931083002: Implement most common usecase for elements kind generalization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months 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 | « no previous file | no next file » | 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 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 } 2236 }
2237 } 2237 }
2238 2238
2239 2239
2240 Map* Map::FindLastMatchMap(int verbatim, 2240 Map* Map::FindLastMatchMap(int verbatim,
2241 int length, 2241 int length,
2242 DescriptorArray* descriptors) { 2242 DescriptorArray* descriptors) {
2243 DisallowHeapAllocation no_allocation; 2243 DisallowHeapAllocation no_allocation;
2244 2244
2245 // This can only be called on roots of transition trees. 2245 // This can only be called on roots of transition trees.
2246 DCHECK(GetBackPointer()->IsUndefined()); 2246 DCHECK_EQ(verbatim, NumberOfOwnDescriptors());
2247 2247
2248 Map* current = this; 2248 Map* current = this;
2249 2249
2250 for (int i = verbatim; i < length; i++) { 2250 for (int i = verbatim; i < length; i++) {
2251 if (!current->HasTransitionArray()) break; 2251 if (!current->HasTransitionArray()) break;
2252 Name* name = descriptors->GetKey(i); 2252 Name* name = descriptors->GetKey(i);
2253 PropertyDetails details = descriptors->GetDetails(i); 2253 PropertyDetails details = descriptors->GetDetails(i);
2254 TransitionArray* transitions = current->transitions(); 2254 TransitionArray* transitions = current->transitions();
2255 int transition = 2255 int transition =
2256 transitions->Search(details.kind(), name, details.attributes()); 2256 transitions->Search(details.kind(), name, details.attributes());
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 } 2485 }
2486 } 2486 }
2487 2487
2488 // Check the state of the root map. 2488 // Check the state of the root map.
2489 Handle<Map> root_map(old_map->FindRootMap(), isolate); 2489 Handle<Map> root_map(old_map->FindRootMap(), isolate);
2490 if (!old_map->EquivalentToForTransition(*root_map)) { 2490 if (!old_map->EquivalentToForTransition(*root_map)) {
2491 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, 2491 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode,
2492 new_kind, new_attributes, 2492 new_kind, new_attributes,
2493 "GenAll_NotEquivalent"); 2493 "GenAll_NotEquivalent");
2494 } 2494 }
2495
2496 ElementsKind from_kind = root_map->elements_kind();
2497 ElementsKind to_kind = old_map->elements_kind();
2498 if (from_kind != to_kind &&
2499 !(IsTransitionableFastElementsKind(from_kind) &&
2500 IsMoreGeneralElementsKindTransition(from_kind, to_kind))) {
2501 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode,
2502 new_kind, new_attributes,
2503 "GenAll_InvalidElementsTransition");
2504 }
2495 int root_nof = root_map->NumberOfOwnDescriptors(); 2505 int root_nof = root_map->NumberOfOwnDescriptors();
2496 if (modify_index >= 0 && modify_index < root_nof) { 2506 if (modify_index >= 0 && modify_index < root_nof) {
2497 PropertyDetails old_details = old_descriptors->GetDetails(modify_index); 2507 PropertyDetails old_details = old_descriptors->GetDetails(modify_index);
2498 if (old_details.kind() != new_kind || 2508 if (old_details.kind() != new_kind ||
2499 old_details.attributes() != new_attributes) { 2509 old_details.attributes() != new_attributes) {
2500 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, 2510 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode,
2501 new_kind, new_attributes, 2511 new_kind, new_attributes,
2502 "GenAll_RootModification1"); 2512 "GenAll_RootModification1");
2503 } 2513 }
2504 if ((old_details.type() != DATA && store_mode == FORCE_FIELD) || 2514 if ((old_details.type() != DATA && store_mode == FORCE_FIELD) ||
2505 (old_details.type() == DATA && 2515 (old_details.type() == DATA &&
2506 (!new_field_type->NowIs(old_descriptors->GetFieldType(modify_index)) || 2516 (!new_field_type->NowIs(old_descriptors->GetFieldType(modify_index)) ||
2507 !new_representation.fits_into(old_details.representation())))) { 2517 !new_representation.fits_into(old_details.representation())))) {
2508 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, 2518 return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode,
2509 new_kind, new_attributes, 2519 new_kind, new_attributes,
2510 "GenAll_RootModification2"); 2520 "GenAll_RootModification2");
2511 } 2521 }
2512 } 2522 }
2513 2523
2524 // From here on, use the map with correct elements kind as root map.
2525 if (from_kind != to_kind) {
2526 root_map = Map::AsElementsKind(root_map, to_kind);
2527 }
2528
2514 Handle<Map> target_map = root_map; 2529 Handle<Map> target_map = root_map;
2515 for (int i = root_nof; i < old_nof; ++i) { 2530 for (int i = root_nof; i < old_nof; ++i) {
2516 PropertyDetails old_details = old_descriptors->GetDetails(i); 2531 PropertyDetails old_details = old_descriptors->GetDetails(i);
2517 PropertyKind next_kind; 2532 PropertyKind next_kind;
2518 PropertyLocation next_location; 2533 PropertyLocation next_location;
2519 PropertyAttributes next_attributes; 2534 PropertyAttributes next_attributes;
2520 Representation next_representation; 2535 Representation next_representation;
2521 bool property_kind_reconfiguration = false; 2536 bool property_kind_reconfiguration = false;
2522 2537
2523 if (modify_index == i) { 2538 if (modify_index == i) {
(...skipping 7135 matching lines...) Expand 10 before | Expand all | Expand 10 after
9659 // XOR-ing the prototype and constructor directly yields too many zero bits 9674 // XOR-ing the prototype and constructor directly yields too many zero bits
9660 // when the two pointers are close (which is fairly common). 9675 // when the two pointers are close (which is fairly common).
9661 // To avoid this we shift the prototype bits relatively to the constructor. 9676 // To avoid this we shift the prototype bits relatively to the constructor.
9662 hash ^= ObjectAddressForHashing(prototype()) << (32 - kPageSizeBits); 9677 hash ^= ObjectAddressForHashing(prototype()) << (32 - kPageSizeBits);
9663 9678
9664 return hash ^ (hash >> 16) ^ bit_field2(); 9679 return hash ^ (hash >> 16) ^ bit_field2();
9665 } 9680 }
9666 9681
9667 9682
9668 static bool CheckEquivalent(Map* first, Map* second) { 9683 static bool CheckEquivalent(Map* first, Map* second) {
9669 return 9684 return first->constructor() == second->constructor() &&
9670 first->constructor() == second->constructor() && 9685 first->prototype() == second->prototype() &&
9671 first->prototype() == second->prototype() && 9686 first->instance_type() == second->instance_type() &&
9672 first->instance_type() == second->instance_type() && 9687 first->bit_field() == second->bit_field() &&
9673 first->bit_field() == second->bit_field() && 9688 first->is_extensible() == second->is_extensible() &&
9674 first->bit_field2() == second->bit_field2() && 9689 first->has_instance_call_handler() ==
9675 first->has_instance_call_handler() == second->has_instance_call_handler(); 9690 second->has_instance_call_handler();
9676 } 9691 }
9677 9692
9678 9693
9679 bool Map::EquivalentToForTransition(Map* other) { 9694 bool Map::EquivalentToForTransition(Map* other) {
9680 return CheckEquivalent(this, other); 9695 return CheckEquivalent(this, other);
9681 } 9696 }
9682 9697
9683 9698
9684 bool Map::EquivalentToForNormalization(Map* other, 9699 bool Map::EquivalentToForNormalization(Map* other,
9685 PropertyNormalizationMode mode) { 9700 PropertyNormalizationMode mode) {
9686 int properties = mode == CLEAR_INOBJECT_PROPERTIES 9701 int properties = mode == CLEAR_INOBJECT_PROPERTIES
9687 ? 0 : other->inobject_properties(); 9702 ? 0 : other->inobject_properties();
9688 return CheckEquivalent(this, other) && inobject_properties() == properties; 9703 return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() &&
9704 inobject_properties() == properties;
9689 } 9705 }
9690 9706
9691 9707
9692 void ConstantPoolArray::ConstantPoolIterateBody(ObjectVisitor* v) { 9708 void ConstantPoolArray::ConstantPoolIterateBody(ObjectVisitor* v) {
9693 // Unfortunately the serializer relies on pointers within an object being 9709 // Unfortunately the serializer relies on pointers within an object being
9694 // visited in-order, so we have to iterate both the code and heap pointers in 9710 // visited in-order, so we have to iterate both the code and heap pointers in
9695 // the small section before doing so in the extended section. 9711 // the small section before doing so in the extended section.
9696 for (int s = 0; s <= final_section(); ++s) { 9712 for (int s = 0; s <= final_section(); ++s) {
9697 LayoutSection section = static_cast<LayoutSection>(s); 9713 LayoutSection section = static_cast<LayoutSection>(s);
9698 ConstantPoolArray::Iterator code_iter(this, ConstantPoolArray::CODE_PTR, 9714 ConstantPoolArray::Iterator code_iter(this, ConstantPoolArray::CODE_PTR,
(...skipping 7508 matching lines...) Expand 10 before | Expand all | Expand 10 after
17207 CompilationInfo* info) { 17223 CompilationInfo* info) {
17208 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17224 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17209 handle(cell->dependent_code(), info->isolate()), 17225 handle(cell->dependent_code(), info->isolate()),
17210 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17226 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17211 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17227 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17212 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17228 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17213 cell, info->zone()); 17229 cell, info->zone());
17214 } 17230 }
17215 17231
17216 } } // namespace v8::internal 17232 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698