Commit e2ce2e0a authored by peterwmwong's avatar peterwmwong Committed by Commit Bot

[turbofan] Fix Array.p.find handling of holes in double elements

Bug: chromium:791045, v8:1956
Change-Id: I1400fc95b78e0f4771867d136377b14aed5bd4f4
Reviewed-on: https://chromium-review.googlesource.com/819510Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50061}
parent 27da2f8c
......@@ -1400,6 +1400,12 @@ Reduction JSCallReducer::ReduceArrayFind(Handle<JSFunction> function,
if (receiver_maps.size() == 0) return NoChange();
const ElementsKind kind = receiver_maps[0]->elements_kind();
// TODO(pwong): Handle holey double elements kinds.
if (IsDoubleElementsKind(kind) && IsHoleyElementsKind(kind)) {
return NoChange();
}
for (Handle<Map> receiver_map : receiver_maps) {
if (!CanInlineArrayIteratingBuiltin(receiver_map)) return NoChange();
// We can handle different maps, as long as their elements kind are the
......
......@@ -392,3 +392,19 @@
%OptimizeFunctionOnNextCall(withHoles);
assertArrayEquals([1, 2, undefined, 3, 4], withHoles());
})();
(() => {
const a = [1.5, 2.5, , 3.5, 4.5];
function withHoles() {
const callback_values = [];
a.find(v => {
callback_values.push(v);
return false;
});
return callback_values;
}
withHoles();
withHoles();
%OptimizeFunctionOnNextCall(withHoles);
assertArrayEquals([1.5, 2.5, undefined, 3.5, 4.5], withHoles());
})();
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