Commit 0b9036dc authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Make Array#find use integers for the index.

The k value passed to NumberAdd was outside the integer range, which
meant it had to choose Double as the only valid representation. The
other array builtins pass the result of CheckBounds here to specifically
force the types into integer range, which allows the representation
selection to pick Word32 instead of Float64 representation.

Drive-by-fix: Pass kind to AccessBuilder::ForJSArrayLength() as well.

Bug: chromium:791045, v8:1956
Change-Id: I357e1ba0dc52be544e631e4d554ab772b9b4c9bb
Reviewed-on: https://chromium-review.googlesource.com/823968Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50084}
parent 98e4b6a1
......@@ -1439,8 +1439,8 @@ Reduction JSCallReducer::ReduceArrayFind(Handle<JSFunction> function,
Node* k = jsgraph()->ZeroConstant();
Node* original_length = effect = graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForJSArrayLength(PACKED_ELEMENTS)),
receiver, effect, control);
simplified()->LoadField(AccessBuilder::ForJSArrayLength(kind)), receiver,
effect, control);
std::vector<Node*> checkpoint_params(
{receiver, fncallback, this_arg, k, original_length});
......@@ -1496,13 +1496,13 @@ Reduction JSCallReducer::ReduceArrayFind(Handle<JSFunction> function,
receiver, effect, control);
}
// Load k-th element from receiver.
Node* element = SafeLoadElement(kind, receiver, control, &effect, &k);
// Increment k for the next iteration.
Node* next_k = checkpoint_params[3] =
graph()->NewNode(simplified()->NumberAdd(), k, jsgraph()->Constant(1));
// Load k-th element from receiver.
Node* element = SafeLoadElement(kind, receiver, control, &effect, &k);
// Replace holes with undefined.
if (IsHoleyElementsKind(kind)) {
element = graph()->NewNode(
......
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