From 2bee643d8fd6917e6306d96019e23822129be13c Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Fri, 30 Jun 2017 18:28:26 +0200 Subject: [PATCH] [elements] Rename IsHoleyElementsKind to IsHoleyOrDictionaryElementsKind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `IsHoleyElementsKind` doesn’t just check for holeyness — it checks for dictionary elements as well. Its name should reflect that. This patch renames `IsHoleyElementsKind` to `IsHoleyOrDictionaryElementsKind`, which makes it possible to rename `IsFastHoleyElementsKind` to `IsHoleyElementsKind` in a future patch. R=jkummerow@chromium.org, cbruni@chromium.org BUG=v8:6548 Change-Id: Id799fe396442e9810426145359254d60990f8492 Reviewed-on: https://chromium-review.googlesource.com/558344 Reviewed-by: Igor Sheludko Reviewed-by: Tobias Tebbi Commit-Queue: Mathias Bynens Cr-Commit-Position: refs/heads/master@{#46367} --- src/code-stub-assembler.cc | 2 +- src/compiler/access-info.cc | 4 ++-- src/compiler/js-create-lowering.cc | 2 +- src/compiler/js-native-context-specialization.cc | 6 +++--- src/elements-kind.h | 6 +----- src/elements.cc | 16 +++++++++------- src/ic/ic.cc | 2 +- src/lookup.cc | 2 +- src/objects.cc | 9 +++++---- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc index 550dbd7a89..08f09f8152 100644 --- a/src/code-stub-assembler.cc +++ b/src/code-stub-assembler.cc @@ -6625,7 +6625,7 @@ Node* CodeStubAssembler::CheckForCapacityGrow(Node* object, Node* elements, Label grow_case(this), no_grow_case(this), done(this); Node* condition; - if (IsHoleyElementsKind(kind)) { + if (IsHoleyOrDictionaryElementsKind(kind)) { condition = UintPtrGreaterThanOrEqual(key, length); } else { condition = WordEqual(key, length); diff --git a/src/compiler/access-info.cc b/src/compiler/access-info.cc index e70635f782..eb7b12dab9 100644 --- a/src/compiler/access-info.cc +++ b/src/compiler/access-info.cc @@ -513,9 +513,9 @@ namespace { Maybe GeneralizeElementsKind(ElementsKind this_kind, ElementsKind that_kind) { - if (IsHoleyElementsKind(this_kind)) { + if (IsHoleyOrDictionaryElementsKind(this_kind)) { that_kind = GetHoleyElementsKind(that_kind); - } else if (IsHoleyElementsKind(that_kind)) { + } else if (IsHoleyOrDictionaryElementsKind(that_kind)) { this_kind = GetHoleyElementsKind(this_kind); } if (this_kind == that_kind) return Just(this_kind); diff --git a/src/compiler/js-create-lowering.cc b/src/compiler/js-create-lowering.cc index 1dd8e4ef84..5114bad7ae 100644 --- a/src/compiler/js-create-lowering.cc +++ b/src/compiler/js-create-lowering.cc @@ -761,7 +761,7 @@ Reduction JSCreateLowering::ReduceNewArrayToStubCall( AllocationSite::ShouldTrack(elements_kind) ? DISABLE_ALLOCATION_SITES : DONT_OVERRIDE; - if (IsHoleyElementsKind(elements_kind)) { + if (IsHoleyOrDictionaryElementsKind(elements_kind)) { ArraySingleArgumentConstructorStub stub(isolate(), elements_kind, override_mode); CallDescriptor* desc = Linkage::GetStubCallDescriptor( diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc index 3cb8a52ded..e668c3a2a1 100644 --- a/src/compiler/js-native-context-specialization.cc +++ b/src/compiler/js-native-context-specialization.cc @@ -1076,7 +1076,7 @@ Reduction JSNativeContextSpecialization::ReduceElementAccess( // store is either holey, or we have a potentially growing store, // then we need to check that all prototypes have stable maps with // fast elements (and we need to guard against changes to that below). - if (IsHoleyElementsKind(receiver_map->elements_kind()) || + if (IsHoleyOrDictionaryElementsKind(receiver_map->elements_kind()) || IsGrowStoreMode(store_mode)) { // Make sure all prototypes are stable and have fast elements. for (Handle map = receiver_map;;) { @@ -2126,7 +2126,7 @@ JSNativeContextSpecialization::BuildElementAccess( if (access_mode == AccessMode::kLoad) { // Compute the real element access type, which includes the hole in case // of holey backing stores. - if (IsHoleyElementsKind(elements_kind)) { + if (IsHoleyOrDictionaryElementsKind(elements_kind)) { element_access.type = Type::Union(element_type, Type::Hole(), graph()->zone()); } @@ -2190,7 +2190,7 @@ JSNativeContextSpecialization::BuildElementAccess( if (receiver_is_jsarray) { flags |= GrowFastElementsFlag::kArrayObject; } - if (IsHoleyElementsKind(elements_kind)) { + if (IsHoleyOrDictionaryElementsKind(elements_kind)) { flags |= GrowFastElementsFlag::kHoleyElements; } if (IsFastDoubleElementsKind(elements_kind)) { diff --git a/src/elements-kind.h b/src/elements-kind.h index af32045822..fc4c491dd0 100644 --- a/src/elements-kind.h +++ b/src/elements-kind.h @@ -101,19 +101,16 @@ inline bool IsFixedTypedArrayElementsKind(ElementsKind kind) { kind <= LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND; } - inline bool IsTerminalElementsKind(ElementsKind kind) { return kind == TERMINAL_FAST_ELEMENTS_KIND || IsFixedTypedArrayElementsKind(kind); } - inline bool IsFastElementsKind(ElementsKind kind) { STATIC_ASSERT(FIRST_FAST_ELEMENTS_KIND == 0); return kind <= HOLEY_DOUBLE_ELEMENTS; } - inline bool IsTransitionElementsKind(ElementsKind kind) { return IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind) || kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS || @@ -161,8 +158,7 @@ inline bool IsFastHoleyElementsKind(ElementsKind kind) { kind == HOLEY_ELEMENTS; } - -inline bool IsHoleyElementsKind(ElementsKind kind) { +inline bool IsHoleyOrDictionaryElementsKind(ElementsKind kind) { return IsFastHoleyElementsKind(kind) || kind == DICTIONARY_ELEMENTS; } diff --git a/src/elements.cc b/src/elements.cc index 130076aab0..2ad12dbf90 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -585,7 +585,7 @@ class ElementsAccessorBase : public ElementsAccessor { } static void TryTransitionResultArrayToPacked(Handle array) { - if (!IsHoleyElementsKind(kind())) return; + if (!IsHoleyOrDictionaryElementsKind(kind())) return; Handle backing_store(array->elements()); int length = Smi::cast(array->length())->value(); if (!Subclass::IsPackedImpl(*array, *backing_store, 0, length)) { @@ -921,7 +921,8 @@ class ElementsAccessorBase : public ElementsAccessor { Handle elements = ConvertElementsWithCapacity(object, old_elements, from_kind, capacity); - if (IsHoleyElementsKind(from_kind)) to_kind = GetHoleyElementsKind(to_kind); + if (IsHoleyOrDictionaryElementsKind(from_kind)) + to_kind = GetHoleyElementsKind(to_kind); Handle new_map = JSObject::GetElementsTransitionMap(object, to_kind); JSObject::SetMapAndElements(object, new_map, elements); @@ -1158,7 +1159,7 @@ class ElementsAccessorBase : public ElementsAccessor { // store size as a last emergency measure if we cannot allocate the big // array. if (!raw_array.ToHandle(&combined_keys)) { - if (IsHoleyElementsKind(kind())) { + if (IsHoleyOrDictionaryElementsKind(kind())) { // If we overestimate the result list size we might end up in the // large-object space which doesn't free memory on shrinking the list. // Hence we try to estimate the final size for holey backing stores more @@ -1197,7 +1198,8 @@ class ElementsAccessorBase : public ElementsAccessor { // For holey elements and arguments we might have to shrink the collected // keys since the estimates might be off. - if (IsHoleyElementsKind(kind()) || IsSloppyArgumentsElementsKind(kind())) { + if (IsHoleyOrDictionaryElementsKind(kind()) || + IsSloppyArgumentsElementsKind(kind())) { // Shrink combined_keys to the final size. int final_size = nof_indices + nof_property_keys; DCHECK_LE(final_size, combined_keys->length()); @@ -1287,7 +1289,7 @@ class ElementsAccessorBase : public ElementsAccessor { FixedArrayBase* backing_store, uint32_t index, PropertyFilter filter) { uint32_t length = Subclass::GetMaxIndex(holder, backing_store); - if (IsHoleyElementsKind(kind())) { + if (IsHoleyOrDictionaryElementsKind(kind())) { return index < length && !BackingStore::cast(backing_store) ->is_the_hole(isolate, index) @@ -1826,7 +1828,7 @@ class FastElementsAccessor : public ElementsAccessorBase { int j = 0; int max_number_key = -1; for (int i = 0; j < capacity; i++) { - if (IsHoleyElementsKind(kind)) { + if (IsHoleyOrDictionaryElementsKind(kind)) { if (BackingStore::cast(*store)->is_the_hole(isolate, i)) continue; } max_number_key = i; @@ -2423,7 +2425,7 @@ class FastElementsAccessor : public ElementsAccessorBase { } Subclass::SetLengthImpl(isolate, receiver, new_length, backing_store); - if (IsHoleyElementsKind(kind) && result->IsTheHole(isolate)) { + if (IsHoleyOrDictionaryElementsKind(kind) && result->IsTheHole(isolate)) { return isolate->factory()->undefined_value(); } return result; diff --git a/src/ic/ic.cc b/src/ic/ic.cc index 7dd98a32f2..a1c4ebfb31 100644 --- a/src/ic/ic.cc +++ b/src/ic/ic.cc @@ -1398,7 +1398,7 @@ Handle KeyedLoadIC::LoadElementHandler(Handle receiver_map) { } DCHECK(IsFastElementsKind(elements_kind) || IsFixedTypedArrayElementsKind(elements_kind)); - // TODO(jkummerow): Use IsHoleyElementsKind(elements_kind). + // TODO(jkummerow): Use IsHoleyOrDictionaryElementsKind(elements_kind). bool convert_hole_to_undefined = is_js_array && elements_kind == HOLEY_ELEMENTS && *receiver_map == isolate()->get_initial_js_array_map(elements_kind); diff --git a/src/lookup.cc b/src/lookup.cc index b5bf5ad861..0af418014e 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -208,7 +208,7 @@ void LookupIterator::PrepareForDataProperty(Handle value) { if (IsElement()) { ElementsKind kind = holder->GetElementsKind(); ElementsKind to = value->OptimalElementsKind(); - if (IsHoleyElementsKind(kind)) to = GetHoleyElementsKind(to); + if (IsHoleyOrDictionaryElementsKind(kind)) to = GetHoleyElementsKind(to); to = GetMoreGeneralElementsKind(kind, to); if (kind != to) { diff --git a/src/objects.cc b/src/objects.cc index 234a51def3..4c725a42e0 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -5002,7 +5002,7 @@ Handle Map::TransitionElementsTo(Handle map, DCHECK(!map->IsUndefined(isolate)); // Check if we can go back in the elements kind transition chain. - if (IsHoleyElementsKind(from_kind) && + if (IsHoleyOrDictionaryElementsKind(from_kind) && to_kind == GetPackedElementsKind(from_kind) && map->GetBackPointer()->IsMap() && Map::cast(map->GetBackPointer())->elements_kind() == to_kind) { @@ -15211,7 +15211,8 @@ Maybe JSObject::AddDataElement(Handle object, uint32_t index, } ElementsKind to = value->OptimalElementsKind(); - if (IsHoleyElementsKind(kind) || !object->IsJSArray() || index > old_length) { + if (IsHoleyOrDictionaryElementsKind(kind) || !object->IsJSArray() || + index > old_length) { to = GetHoleyElementsKind(to); kind = GetHoleyElementsKind(kind); } @@ -15280,7 +15281,7 @@ bool AllocationSite::DigestTransitionFeedback(Handle site, handle(JSArray::cast(site->transition_info())); ElementsKind kind = transition_info->GetElementsKind(); // if kind is holey ensure that to_kind is as well. - if (IsHoleyElementsKind(kind)) { + if (IsHoleyOrDictionaryElementsKind(kind)) { to_kind = GetHoleyElementsKind(to_kind); } if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { @@ -15310,7 +15311,7 @@ bool AllocationSite::DigestTransitionFeedback(Handle site, } else { ElementsKind kind = site->GetElementsKind(); // if kind is holey ensure that to_kind is as well. - if (IsHoleyElementsKind(kind)) { + if (IsHoleyOrDictionaryElementsKind(kind)) { to_kind = GetHoleyElementsKind(to_kind); } if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {