Commit 19b69504 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[elements] Use IsHoleyElementsKind if possible

Bug: v8:6922
Change-Id: I641f654f0548c2da24cdea3ffd275461ae8ce9b0
Reviewed-on: https://chromium-review.googlesource.com/1172776Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55098}
parent 9ae3e619
......@@ -130,29 +130,27 @@ static inline bool IsFastTransitionTarget(ElementsKind elements_kind) {
bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind,
ElementsKind to_kind) {
if (IsFastElementsKind(from_kind) && IsFastTransitionTarget(to_kind)) {
DCHECK(!IsFixedTypedArrayElementsKind(from_kind));
DCHECK(!IsFixedTypedArrayElementsKind(to_kind));
switch (from_kind) {
case PACKED_SMI_ELEMENTS:
return to_kind != PACKED_SMI_ELEMENTS;
case HOLEY_SMI_ELEMENTS:
return to_kind != PACKED_SMI_ELEMENTS && to_kind != HOLEY_SMI_ELEMENTS;
case PACKED_DOUBLE_ELEMENTS:
return to_kind != PACKED_SMI_ELEMENTS &&
to_kind != HOLEY_SMI_ELEMENTS &&
to_kind != PACKED_DOUBLE_ELEMENTS;
case HOLEY_DOUBLE_ELEMENTS:
return to_kind == PACKED_ELEMENTS || to_kind == HOLEY_ELEMENTS;
case PACKED_ELEMENTS:
return to_kind == HOLEY_ELEMENTS;
case HOLEY_ELEMENTS:
return false;
default:
return false;
}
if (!IsFastElementsKind(from_kind)) return false;
if (!IsFastTransitionTarget(to_kind)) return false;
DCHECK(!IsFixedTypedArrayElementsKind(from_kind));
DCHECK(!IsFixedTypedArrayElementsKind(to_kind));
switch (from_kind) {
case PACKED_SMI_ELEMENTS:
return to_kind != PACKED_SMI_ELEMENTS;
case HOLEY_SMI_ELEMENTS:
return to_kind != PACKED_SMI_ELEMENTS && to_kind != HOLEY_SMI_ELEMENTS;
case PACKED_DOUBLE_ELEMENTS:
return to_kind != PACKED_SMI_ELEMENTS && to_kind != HOLEY_SMI_ELEMENTS &&
to_kind != PACKED_DOUBLE_ELEMENTS;
case HOLEY_DOUBLE_ELEMENTS:
return to_kind == PACKED_ELEMENTS || to_kind == HOLEY_ELEMENTS;
case PACKED_ELEMENTS:
return to_kind == HOLEY_ELEMENTS;
case HOLEY_ELEMENTS:
return false;
default:
return false;
}
return false;
}
bool UnionElementsKindUptoSize(ElementsKind* a_out, ElementsKind b) {
......
......@@ -602,7 +602,7 @@ class ElementsAccessorBase : public InternalElementsAccessor {
}
static void TryTransitionResultArrayToPacked(Handle<JSArray> array) {
if (!IsHoleyOrDictionaryElementsKind(kind())) return;
if (!IsHoleyElementsKind(kind())) return;
Handle<FixedArrayBase> backing_store(array->elements(),
array->GetIsolate());
int length = Smi::ToInt(array->length());
......@@ -937,7 +937,7 @@ class ElementsAccessorBase : public InternalElementsAccessor {
Handle<FixedArrayBase> elements =
ConvertElementsWithCapacity(object, old_elements, from_kind, capacity);
if (IsHoleyOrDictionaryElementsKind(from_kind)) {
if (IsHoleyElementsKind(from_kind)) {
to_kind = GetHoleyElementsKind(to_kind);
}
Handle<Map> new_map = JSObject::GetElementsTransitionMap(object, to_kind);
......
......@@ -398,7 +398,7 @@ void LookupIterator::PrepareForDataProperty(Handle<Object> value) {
if (IsElement()) {
ElementsKind kind = holder_obj->GetElementsKind();
ElementsKind to = value->OptimalElementsKind();
if (IsHoleyOrDictionaryElementsKind(kind)) to = GetHoleyElementsKind(to);
if (IsHoleyElementsKind(kind)) to = GetHoleyElementsKind(to);
to = GetMoreGeneralElementsKind(kind, to);
if (kind != to) {
......
......@@ -5656,7 +5656,7 @@ Handle<Map> Map::TransitionElementsTo(Isolate* isolate, Handle<Map> map,
DCHECK(!map->IsUndefined(isolate));
// Check if we can go back in the elements kind transition chain.
if (IsHoleyOrDictionaryElementsKind(from_kind) &&
if (IsHoleyElementsKind(from_kind) &&
to_kind == GetPackedElementsKind(from_kind) &&
map->GetBackPointer()->IsMap() &&
Map::cast(map->GetBackPointer())->elements_kind() == to_kind) {
......@@ -15724,8 +15724,7 @@ void JSObject::AddDataElement(Handle<JSObject> object, uint32_t index,
}
ElementsKind to = value->OptimalElementsKind();
if (IsHoleyOrDictionaryElementsKind(kind) || !object->IsJSArray() ||
index > old_length) {
if (IsHoleyElementsKind(kind) || !object->IsJSArray() || index > old_length) {
to = GetHoleyElementsKind(to);
kind = GetHoleyElementsKind(kind);
}
......@@ -15789,7 +15788,7 @@ bool AllocationSite::DigestTransitionFeedback(Handle<AllocationSite> site,
Handle<JSArray> boilerplate(JSArray::cast(site->boilerplate()), isolate);
ElementsKind kind = boilerplate->GetElementsKind();
// if kind is holey ensure that to_kind is as well.
if (IsHoleyOrDictionaryElementsKind(kind)) {
if (IsHoleyElementsKind(kind)) {
to_kind = GetHoleyElementsKind(to_kind);
}
if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
......@@ -15817,7 +15816,7 @@ bool AllocationSite::DigestTransitionFeedback(Handle<AllocationSite> site,
// The AllocationSite is for a constructed Array.
ElementsKind kind = site->GetElementsKind();
// if kind is holey ensure that to_kind is as well.
if (IsHoleyOrDictionaryElementsKind(kind)) {
if (IsHoleyElementsKind(kind)) {
to_kind = GetHoleyElementsKind(to_kind);
}
if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment