[csa] Use memcpy to copy FixedArray if allocated in new space.

This improves the performance of copying Smi or Object arrays if
the new array is allocated in new space.

Bug: v8:7980
Change-Id: I8e91a879f603d118b4bb1393e7b8b92f4c0b3696
Reviewed-on: https://chromium-review.googlesource.com/c/1283053
Commit-Queue: Hai Dang <dhai@google.com>
Reviewed-by: Michael Stanton <mvstanton@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56849}
This commit is contained in:
Hai Dang 2018-10-22 10:20:51 +02:00 committed by Commit Bot
parent 4e18f8685b
commit 43bcadd7e6

View File

@ -4187,14 +4187,28 @@ TNode<FixedArray> CodeStubAssembler::ExtractToFixedArray(
Comment("Copy FixedArray new space");
// We use PACKED_ELEMENTS to tell AllocateFixedArray and
// CopyFixedArrayElements that we want a FixedArray.
ElementsKind to_kind = PACKED_ELEMENTS;
Node* to_elements =
const ElementsKind to_kind = PACKED_ELEMENTS;
TNode<FixedArrayBase> to_elements =
AllocateFixedArray(to_kind, capacity, parameter_mode,
AllocationFlag::kNone, var_target_map.value());
var_result.Bind(to_elements);
CopyFixedArrayElements(from_kind, source, to_kind, to_elements, first,
count, capacity, SKIP_WRITE_BARRIER, parameter_mode,
convert_holes, var_holes_converted);
if (convert_holes == HoleConversionMode::kDontConvert &&
!IsDoubleElementsKind(from_kind)) {
// We can use CopyElements (memcpy) because we don't need to replace or
// convert any values. Since {to_elements} is in new-space, CopyElements
// will efficiently use memcpy.
FillFixedArrayWithValue(to_kind, to_elements, count, capacity,
RootIndex::kTheHoleValue, parameter_mode);
CopyElements(to_kind, to_elements, IntPtrConstant(0), CAST(source),
ParameterToIntPtr(first, parameter_mode),
ParameterToIntPtr(count, parameter_mode));
} else {
CopyFixedArrayElements(from_kind, source, to_kind, to_elements, first,
count, capacity, SKIP_WRITE_BARRIER,
parameter_mode, convert_holes,
var_holes_converted);
}
Goto(&done);
if (handle_old_space) {
@ -4231,7 +4245,7 @@ TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedDoubleArrayFillingHoles(
CSA_ASSERT(this, IsFixedDoubleArrayMap(fixed_array_map));
VARIABLE(var_result, MachineRepresentation::kTagged);
ElementsKind kind = PACKED_DOUBLE_ELEMENTS;
const ElementsKind kind = PACKED_DOUBLE_ELEMENTS;
Node* to_elements = AllocateFixedArray(kind, capacity, mode, allocation_flags,
fixed_array_map);
var_result.Bind(to_elements);