From 8e53e31eeb2281038ab27542c5593d2e845aa594 Mon Sep 17 00:00:00 2001 From: verwaest Date: Tue, 17 Feb 2015 02:06:52 -0800 Subject: [PATCH] Implement most common usecase for elements kind generalization BUG= Review URL: https://codereview.chromium.org/931083002 Cr-Commit-Position: refs/heads/master@{#26681} --- src/objects.cc | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index 74f8d52..7459ed4 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -2243,7 +2243,7 @@ Map* Map::FindLastMatchMap(int verbatim, DisallowHeapAllocation no_allocation; // This can only be called on roots of transition trees. - DCHECK(GetBackPointer()->IsUndefined()); + DCHECK_EQ(verbatim, NumberOfOwnDescriptors()); Map* current = this; @@ -2482,6 +2482,16 @@ Handle Map::ReconfigureProperty(Handle old_map, int modify_index, new_kind, new_attributes, "GenAll_NotEquivalent"); } + + ElementsKind from_kind = root_map->elements_kind(); + ElementsKind to_kind = old_map->elements_kind(); + if (from_kind != to_kind && + !(IsTransitionableFastElementsKind(from_kind) && + IsMoreGeneralElementsKindTransition(from_kind, to_kind))) { + return CopyGeneralizeAllRepresentations(old_map, modify_index, store_mode, + new_kind, new_attributes, + "GenAll_InvalidElementsTransition"); + } int root_nof = root_map->NumberOfOwnDescriptors(); if (modify_index >= 0 && modify_index < root_nof) { PropertyDetails old_details = old_descriptors->GetDetails(modify_index); @@ -2501,6 +2511,11 @@ Handle Map::ReconfigureProperty(Handle old_map, int modify_index, } } + // From here on, use the map with correct elements kind as root map. + if (from_kind != to_kind) { + root_map = Map::AsElementsKind(root_map, to_kind); + } + Handle target_map = root_map; for (int i = root_nof; i < old_nof; ++i) { PropertyDetails old_details = old_descriptors->GetDetails(i); @@ -9656,13 +9671,13 @@ int Map::Hash() { static bool CheckEquivalent(Map* first, Map* second) { - return - first->constructor() == second->constructor() && - first->prototype() == second->prototype() && - first->instance_type() == second->instance_type() && - first->bit_field() == second->bit_field() && - first->bit_field2() == second->bit_field2() && - first->has_instance_call_handler() == second->has_instance_call_handler(); + return first->constructor() == second->constructor() && + first->prototype() == second->prototype() && + first->instance_type() == second->instance_type() && + first->bit_field() == second->bit_field() && + first->is_extensible() == second->is_extensible() && + first->has_instance_call_handler() == + second->has_instance_call_handler(); } @@ -9675,7 +9690,8 @@ bool Map::EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode) { int properties = mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->inobject_properties(); - return CheckEquivalent(this, other) && inobject_properties() == properties; + return CheckEquivalent(this, other) && bit_field2() == other->bit_field2() && + inobject_properties() == properties; } -- 2.7.4