[elements] Rename IsHoleyElementsKind to IsHoleyOrDictionaryElementsKind

`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 <ishell@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46367}
This commit is contained in:
Mathias Bynens 2017-06-30 18:28:26 +02:00 committed by Commit Bot
parent 951ab5c7b1
commit 2bee643d8f
9 changed files with 24 additions and 25 deletions

View File

@ -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);

View File

@ -513,9 +513,9 @@ namespace {
Maybe<ElementsKind> 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);

View File

@ -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(

View File

@ -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> 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)) {

View File

@ -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;
}

View File

@ -585,7 +585,7 @@ class ElementsAccessorBase : public ElementsAccessor {
}
static void TryTransitionResultArrayToPacked(Handle<JSArray> array) {
if (!IsHoleyElementsKind(kind())) return;
if (!IsHoleyOrDictionaryElementsKind(kind())) return;
Handle<FixedArrayBase> 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<FixedArrayBase> 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<Map> 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<Subclass, KindTraits> {
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, KindTraits> {
}
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;

View File

@ -1398,7 +1398,7 @@ Handle<Object> KeyedLoadIC::LoadElementHandler(Handle<Map> 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);

View File

@ -208,7 +208,7 @@ void LookupIterator::PrepareForDataProperty(Handle<Object> 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) {

View File

@ -5002,7 +5002,7 @@ Handle<Map> Map::TransitionElementsTo(Handle<Map> 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<bool> JSObject::AddDataElement(Handle<JSObject> 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<AllocationSite> 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<AllocationSite> 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)) {