Commit bb10b70b authored by Hai Dang's avatar Hai Dang Committed by Commit Bot

Generalize ExtractFixedArray's branch for Smis or Objects.

This CL extracts the branch into a new function. Previously, the branch
is only used to copy a FixedArray to a new FixedArray. The new function
generalizes this to allow copying from a FixedDoubleArray to a
FixedArray also. This function will be useful in a follow-up CL to copy
a FixedDoubleArray with holes into a FixedArray where holes are replaced
by undefined.

Bug: chromium:881273, v8:7980

Change-Id: I8a0e5f933fc152a12d67810f4cbcfdce094d44af
Reviewed-on: https://chromium-review.googlesource.com/1230913
Commit-Queue: Hai Dang <dhai@google.com>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56101}
parent dbfd6250
This diff is collapsed.
......@@ -1554,8 +1554,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
typedef base::Flags<ExtractFixedArrayFlag> ExtractFixedArrayFlags;
// Copy a portion of an existing FixedArray or FixedDoubleArray into a new
// FixedArray, including special appropriate handling for empty arrays and COW
// arrays.
// array, including special appropriate handling for empty arrays and COW
// arrays. The result array will be of the same type as the original array.
//
// * |source| is either a FixedArray or FixedDoubleArray from which to copy
// elements.
......@@ -1591,6 +1591,33 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
SMI_PARAMETERS);
}
// Copy a portion of an existing FixedArray or FixedDoubleArray into a new
// FixedArray, including special appropriate handling for COW arrays.
// * |source| is either a FixedArray or FixedDoubleArray from which to copy
// elements. |source| is assumed to be non-empty.
// * |first| is the starting element index to copy from.
// * |count| is the number of elements to copy out of the source array
// starting from and including the element indexed by |start|.
// * |capacity| determines the size of the allocated result array, with
// |capacity| >= |count|.
// * |source_map| is the map of the |source|.
// * |from_kind| is the elements kind that is consistent with |source| being
// a FixedArray or FixedDoubleArray. This function only cares about double vs.
// non-double, so as to distinguish FixedDoubleArray vs. FixedArray. It does
// not care about holeyness. For example, when |source| is a FixedArray,
// PACKED/HOLEY_ELEMENTS can be used, but not PACKED_DOUBLE_ELEMENTS.
// * The function uses |allocation_flags| and |extract_flags| to decide how to
// allocate the result FixedArray.
// * |parameter_mode| determines the parameter mode of |first|, |count| and
// |capacity|.
TNode<FixedArray> ExtractToFixedArray(
Node* source, Node* first, Node* count, Node* capacity, Node* source_map,
ElementsKind from_kind = PACKED_ELEMENTS,
AllocationFlags allocation_flags = AllocationFlag::kNone,
ExtractFixedArrayFlags extract_flags =
ExtractFixedArrayFlag::kAllFixedArrays,
ParameterMode parameter_mode = INTPTR_PARAMETERS);
// Copy the entire contents of a FixedArray or FixedDoubleArray to a new
// array, including special appropriate handling for empty arrays and COW
// arrays.
......
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