Commit 402247f3 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[CSA][cleanup] Remove ParameterMode from ExtractFastJSArray builtin

To do this:
 * Create specialized ParameterToTagged versions of Smi and IntPtT
 * Unify and generalize ExtractFixedArray

Bug: v8:9708, v8:10506
Change-Id: Ic23c6f4bb250076f12d6e8622ebc0b4d4cbeaac8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2202982Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67851}
parent 69f42d40
......@@ -438,7 +438,6 @@ TF_BUILTIN(ArrayPrototypePush, CodeStubAssembler) {
}
TF_BUILTIN(ExtractFastJSArray, ArrayBuiltinsAssembler) {
ParameterMode mode = OptimalParameterMode();
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
TNode<JSArray> array = CAST(Parameter(Descriptor::kSource));
TNode<BInt> begin = SmiToBInt(CAST(Parameter(Descriptor::kBegin)));
......@@ -446,7 +445,7 @@ TF_BUILTIN(ExtractFastJSArray, ArrayBuiltinsAssembler) {
CSA_ASSERT(this, Word32BinaryNot(IsNoElementsProtectorCellInvalid()));
Return(ExtractFastJSArray(context, array, begin, count, mode));
Return(ExtractFastJSArray(context, array, begin, count));
}
TF_BUILTIN(CloneFastJSArray, ArrayBuiltinsAssembler) {
......
......@@ -2950,7 +2950,7 @@ TNode<Smi> CodeStubAssembler::BuildAppendJSArray(ElementsKind kind,
BIND(&pre_bailout);
{
TNode<Smi> length = ParameterToTagged(var_length.value(), mode);
TNode<Smi> length = ParameterToTagged(var_length.value());
var_tagged_length = length;
TNode<Smi> diff = SmiSub(length, LoadFastJSArrayLength(array));
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
......@@ -3728,9 +3728,10 @@ TNode<JSArray> CodeStubAssembler::AllocateJSArray(
return array;
}
TNode<JSArray> CodeStubAssembler::ExtractFastJSArray(
TNode<Context> context, TNode<JSArray> array, Node* begin, Node* count,
ParameterMode mode, Node* capacity, TNode<AllocationSite> allocation_site) {
TNode<JSArray> CodeStubAssembler::ExtractFastJSArray(TNode<Context> context,
TNode<JSArray> array,
TNode<BInt> begin,
TNode<BInt> count) {
TNode<Map> original_array_map = LoadMap(array);
TNode<Int32T> elements_kind = LoadMapElementsKind(original_array_map);
......@@ -3739,11 +3740,11 @@ TNode<JSArray> CodeStubAssembler::ExtractFastJSArray(
TNode<Map> array_map = LoadJSArrayElementsMap(elements_kind, native_context);
TNode<FixedArrayBase> new_elements = ExtractFixedArray(
LoadElements(array), begin, count, capacity,
ExtractFixedArrayFlag::kAllFixedArrays, mode, nullptr, elements_kind);
LoadElements(array), begin, count, base::nullopt,
ExtractFixedArrayFlag::kAllFixedArrays, nullptr, elements_kind);
TNode<JSArray> result = AllocateJSArray(
array_map, new_elements, ParameterToTagged(count, mode), allocation_site);
TNode<JSArray> result =
AllocateJSArray(array_map, new_elements, ParameterToTagged(count), {});
return result;
}
......
......@@ -396,6 +396,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return IntPtrToParameter(ChangeInt32ToIntPtr(value), mode);
}
TNode<Smi> ParameterToTagged(TNode<Smi> value) { return value; }
TNode<Smi> ParameterToTagged(TNode<IntPtrT> value) { return SmiTag(value); }
TNode<Smi> ParameterToTagged(Node* value, ParameterMode mode) {
if (mode != SMI_PARAMETERS) return SmiTag(value);
return UncheckedCast<Smi>(value);
......@@ -1961,7 +1965,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
//
// Allocate and return a JSArray with initialized header fields and its
// uninitialized elements.
// The ParameterMode argument is only used for the capacity parameter.
std::pair<TNode<JSArray>, TNode<FixedArrayBase>>
AllocateUninitializedJSArrayWithElements(
ElementsKind kind, TNode<Map> array_map, TNode<Smi> length,
......@@ -2018,11 +2021,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
HoleConversionMode convert_holes = HoleConversionMode::kDontConvert);
TNode<JSArray> ExtractFastJSArray(TNode<Context> context,
TNode<JSArray> array, Node* begin,
Node* count,
ParameterMode mode = INTPTR_PARAMETERS,
Node* capacity = nullptr,
TNode<AllocationSite> allocation_site = {});
TNode<JSArray> array, TNode<BInt> begin,
TNode<BInt> count);
TNode<FixedArrayBase> AllocateFixedArray(
ElementsKind kind, Node* capacity, ParameterMode mode = INTPTR_PARAMETERS,
......@@ -2295,20 +2295,32 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<FixedArrayBase> ExtractFixedArray(
TNode<FixedArrayBase> source, TNode<Smi> first, TNode<Smi> count,
TNode<Smi> capacity,
base::Optional<TNode<Smi>> capacity,
ExtractFixedArrayFlags extract_flags =
ExtractFixedArrayFlag::kAllFixedArrays) {
return ExtractFixedArray(source, first, count, capacity, extract_flags,
SMI_PARAMETERS);
ExtractFixedArrayFlag::kAllFixedArrays,
TVariable<BoolT>* var_holes_converted = nullptr,
base::Optional<TNode<Int32T>> source_elements_kind = base::nullopt) {
// TODO(solanes): just use capacity when ExtractFixedArray is fully
// converted.
Node* capacity_node = capacity ? static_cast<Node*>(*capacity) : nullptr;
return ExtractFixedArray(source, first, count, capacity_node, extract_flags,
SMI_PARAMETERS, var_holes_converted,
source_elements_kind);
}
TNode<FixedArray> ExtractFixedArray(
TNode<FixedArray> source, TNode<IntPtrT> first, TNode<IntPtrT> count,
TNode<IntPtrT> capacity,
TNode<FixedArrayBase> ExtractFixedArray(
TNode<FixedArrayBase> source, TNode<IntPtrT> first, TNode<IntPtrT> count,
base::Optional<TNode<IntPtrT>> capacity,
ExtractFixedArrayFlags extract_flags =
ExtractFixedArrayFlag::kAllFixedArrays) {
return CAST(ExtractFixedArray(source, first, count, capacity, extract_flags,
INTPTR_PARAMETERS));
ExtractFixedArrayFlag::kAllFixedArrays,
TVariable<BoolT>* var_holes_converted = nullptr,
base::Optional<TNode<Int32T>> source_elements_kind = base::nullopt) {
// TODO(solanes): just use capacity when ExtractFixedArray is fully
// converted.
Node* capacity_node = capacity ? static_cast<Node*>(*capacity) : nullptr;
return ExtractFixedArray(source, first, count, capacity_node, extract_flags,
INTPTR_PARAMETERS, var_holes_converted,
source_elements_kind);
}
// Copy a portion of an existing FixedArray or FixedDoubleArray into a new
......
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