Commit 63ce4ba4 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Reland "Use CopyElements (which uses memcpy) to copy FixedDoubleArray."

This is a reland of fac6f63e, after
adding initialization of unused element slots.

Original change's description:
> Use CopyElements (which uses memcpy) to copy FixedDoubleArray.
>
> This improves the performance of ExtractFixedArray and
> CloneFastJSArray for double arrays, which in turn improve the
> performance of cloning double arrays with slice() or spreading.
>
> This, however, does not improve performance of spreading holey
> double arrays, because spreading needs extra work to convert
> holes to undefined.
>
> Bug: v8:7980
> Change-Id: Ib8aed74abbb0b06982a3b754e134fa415cb7de2d
> Reviewed-on: https://chromium-review.googlesource.com/c/1280308
> Reviewed-by: Michael Stanton <mvstanton@chromium.org>
> Reviewed-by: Georg Neis <neis@chromium.org>
> Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
> Commit-Queue: Hai Dang <dhai@google.com>
> Cr-Commit-Position: refs/heads/master@{#56680}

Bug: v8:7980
Change-Id: I899af60c061b9cd6eb619c247c5fc515b92e9fd7
Reviewed-on: https://chromium-review.googlesource.com/c/1382735
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58333}
parent dde5e3a1
......@@ -4448,11 +4448,14 @@ TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedArray(
// the target are FixedDoubleArray. That it is PACKED or HOLEY does not
// matter.
ElementsKind kind = PACKED_DOUBLE_ELEMENTS;
Node* to_elements = AllocateFixedArray(kind, capacity, parameter_mode,
allocation_flags, source_map);
TNode<FixedArrayBase> to_elements = AllocateFixedArray(
kind, capacity, parameter_mode, allocation_flags, source_map);
FillFixedArrayWithValue(kind, to_elements, count, capacity,
RootIndex::kTheHoleValue, parameter_mode);
CopyElements(kind, to_elements, IntPtrConstant(0), CAST(source),
ParameterToIntPtr(first, parameter_mode),
ParameterToIntPtr(count, parameter_mode));
var_result.Bind(to_elements);
CopyFixedArrayElements(kind, source, kind, to_elements, first, count,
capacity, SKIP_WRITE_BARRIER, parameter_mode);
}
Goto(&done);
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
{
const x = [42];
x.splice(0, 0, 23);
assertEquals([23, 42], x);
x.length++;
assertEquals([23, 42, ,], x);
assertFalse(x.hasOwnProperty(2));
}
{
const x = [4.2];
x.splice(0, 0, 23);
assertEquals([23, 4.2], x);
x.length++;
assertEquals([23, 4.2, ,], x);
assertFalse(x.hasOwnProperty(2));
}
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