Commit 58881f11 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbofan] Widen fast-path in Array.p.pop/shift

Allow mixing smi/object packed/unpacked maps in A.p.pop/shift.
Beforehand, mixing smi and object maps caused a deopt.

Bug: v8:7205, v8:7340
Change-Id: Ifec021791e98589be4a56fe97d3cc003f0fb6393
Reviewed-on: https://chromium-review.googlesource.com/878121Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50750}
parent 56fe2437
......@@ -3545,7 +3545,7 @@ Reduction JSCallReducer::ReduceArrayPrototypePop(Node* node) {
// once we got the hole NaN mess sorted out in TurboFan/V8.
if (receiver_map->elements_kind() == HOLEY_DOUBLE_ELEMENTS)
return NoChange();
if (!UnionElementsKindUptoPackedness(&kind, receiver_map->elements_kind()))
if (!UnionElementsKindUptoSize(&kind, receiver_map->elements_kind()))
return NoChange();
}
......@@ -3661,7 +3661,7 @@ Reduction JSCallReducer::ReduceArrayPrototypeShift(Node* node) {
// once we got the hole NaN mess sorted out in TurboFan/V8.
if (receiver_map->elements_kind() == HOLEY_DOUBLE_ELEMENTS)
return NoChange();
if (!UnionElementsKindUptoPackedness(&kind, receiver_map->elements_kind()))
if (!UnionElementsKindUptoSize(&kind, receiver_map->elements_kind()))
return NoChange();
}
......
......@@ -229,6 +229,41 @@ inline bool UnionElementsKindUptoPackedness(ElementsKind* a_out,
return false;
}
inline bool UnionElementsKindUptoSize(ElementsKind* a_out, ElementsKind b) {
// Assert that the union of two ElementKinds can be computed via std::max.
static_assert(PACKED_SMI_ELEMENTS < HOLEY_SMI_ELEMENTS,
"ElementsKind union not computable via std::max.");
static_assert(HOLEY_SMI_ELEMENTS < PACKED_ELEMENTS,
"ElementsKind union not computable via std::max.");
static_assert(PACKED_ELEMENTS < HOLEY_ELEMENTS,
"ElementsKind union not computable via std::max.");
static_assert(PACKED_DOUBLE_ELEMENTS < HOLEY_DOUBLE_ELEMENTS,
"ElementsKind union not computable via std::max.");
ElementsKind a = *a_out;
switch (a) {
case HOLEY_SMI_ELEMENTS:
case PACKED_SMI_ELEMENTS:
case PACKED_ELEMENTS:
case HOLEY_ELEMENTS:
if (b == PACKED_ELEMENTS || b == HOLEY_ELEMENTS ||
b == PACKED_SMI_ELEMENTS || b == HOLEY_SMI_ELEMENTS) {
*a_out = std::max(a, b);
return true;
}
break;
case PACKED_DOUBLE_ELEMENTS:
case HOLEY_DOUBLE_ELEMENTS:
if (b == PACKED_DOUBLE_ELEMENTS || b == HOLEY_DOUBLE_ELEMENTS) {
*a_out = std::max(a, b);
return true;
}
break;
default:
break;
}
return false;
}
inline ElementsKind FastSmiToObjectElementsKind(ElementsKind from_kind) {
DCHECK(IsSmiElementsKind(from_kind));
return (from_kind == PACKED_SMI_ELEMENTS) ? PACKED_ELEMENTS : HOLEY_ELEMENTS;
......
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